From: <dai...@us...> - 2012-02-07 09:12:20
|
Revision: 4884 http://web-erp.svn.sourceforge.net/web-erp/?rev=4884&view=rev Author: daintree Date: 2012-02-07 09:12:13 +0000 (Tue, 07 Feb 2012) Log Message: ----------- added discount to the InsertDebtorReceipt function Modified Paths: -------------- trunk/api/api_debtortransactions.php trunk/api/api_xml-rpc.php Modified: trunk/api/api_debtortransactions.php =================================================================== --- trunk/api/api_debtortransactions.php 2012-02-07 07:27:32 UTC (rev 4883) +++ trunk/api/api_debtortransactions.php 2012-02-07 09:12:13 UTC (rev 4884) @@ -276,6 +276,7 @@ * $Receipt['paymentmethod'] - the payment method of the receipt e.g. cash/EFTPOS/credit card * $Receipt['bankaccount'] - the webERP bank account * $Receipt['reference'] + * $Receipt['discountfx'] */ $Errors = array(); @@ -288,7 +289,8 @@ /*Get Company Defaults */ $ReadCoyResult = api_DB_query("SELECT debtorsact, - gllink_debtors + pytdiscountact, + gllink_debtors FROM companies WHERE coycode=1",$db); @@ -391,12 +393,30 @@ '" . $PeriodNo . "', '". $CompanyRecord['debtorsact'] . "', '" . $Receipt['reference'] . "', - '" . round(-$Receipt['amountfx'] * $FunctionalExRate / $ReceiptExRate,4) . "')"; + '" . round((-$Receipt['amountfx']-$Receipt['discountfx']) * $FunctionalExRate / $ReceiptExRate,4) . "')"; $result = api_DB_query($SQL,$db,'','',true); fputs($fp, "Entered the debtor GL journal with the following SQL: \n" . $SQL . "\n"); - + + if($Receipt['discountfx']!=0){ + $SQL="INSERT INTO gltrans ( type, + typeno, + trandate, + periodno, + account, + narrative, + amount) + VALUES (12, + '" . $ReceiptNo . "', + '" . $Receipt['trandate'] . "', + '" . $PeriodNo . "', + '". $CompanyRecord['pytdiscountact'] . "', + '" . $Receipt['reference'] . "', + '" . round($Receipt['discountfx'] * $FunctionalExRate / $ReceiptExRate,4) . "')"; + + $result = api_DB_query($SQL,$db,'','',true); + } /*and debit bank account with the receipt */ $SQL="INSERT INTO gltrans ( type, typeno, @@ -410,7 +430,7 @@ '" . $ReceiptNo . "', '" . $Receipt['trandate'] . "', '" . $PeriodNo . "', - '". $Receipt['bankaccount'] . "', + '" . $Receipt['bankaccount'] . "', '" . $Receipt['reference'] . "', '" . round($Receipt['amountfx'] * $FunctionalExRate / $ReceiptExRate,4) . "')"; @@ -438,10 +458,11 @@ '" . $PeriodNo . "', '" . $Receipt['reference'] . "', '" . ($ReceiptExRate/$FunctionalExRate) . "', - '" . -$Receipt['amountfx'] . "', + '" . (-$Receipt['amountfx']-$Receipt['discountfx']) . "', '" . $Receipt['paymentmethod'] . "')"; $result = api_DB_query($SQL,$db,'','',true); + fputs($fp, "Entered the debtortrans with the following SQL: \n" . $SQL . "\n"); $SQL = "UPDATE debtorsmaster SET lastpaiddate = '" . $Receipt['trandate'] . "', Modified: trunk/api/api_xml-rpc.php =================================================================== --- trunk/api/api_xml-rpc.php 2012-02-07 07:27:32 UTC (rev 4883) +++ trunk/api/api_xml-rpc.php 2012-02-07 09:12:13 UTC (rev 4884) @@ -1086,7 +1086,7 @@ unset($Parameter); unset($ReturnValue); - $Description = _('Creates a credit note from header details associative array and line items'); + $Description = _('Creates a credit note from header details associative array and line items. This function implements most of a webERP credit note with the exception that it cannot handle serialised or lot/batch controlled items. All the necessary updates and inserts are handled for stock quantities returned, taxes, sales analysis, stock movements, sales and cost of sales journals'); $Parameter[0]['name'] = _('Credit Note Header Details'); $Parameter[0]['description'] = _('An associative array describing the credit note header with the fields debtorno, branchcode, trandate, tpe, fromstkloc, customerref, shipvia'); $Parameter[1]['name'] = _('Credit note line items'); @@ -1118,7 +1118,7 @@ unset($Parameter); unset($ReturnValue); - $Description = _('Inserts a sales invoice into the debtortrans table and does the relevant GL entries'); + $Description = _('Inserts a sales invoice into the debtortrans table and does the relevant GL entries. Note that this function does not do the tax entries, insert stock movements, update the stock quanties, sales analysis data or do any cost of sales gl journals. Caution is advised in using this function. To create a full webERP invoice with all tables updated use the InvoiceSalesOrder function.'); $Parameter[0]['name'] = _('Invoice Details'); $Parameter[0]['description'] = _('An array of index/value items describing the invoice.') ._('The field names can be found ').'<a href="../../Z_DescribeTable.php?table=debtortrans">'._('here ').'</a>' @@ -1157,7 +1157,7 @@ unset($Parameter); unset($ReturnValue); $ReturnValue = _('Return Value Descriptions go here'); - $Description = _('This function is used to insert a new Sales Credit to the webERP database.'); + $Description = _('This function is used to insert a new Sales Credit to the webERP database. Note that this function does not implement a webERP credit note in full and caution is advised in using this function. It does not handle tax at all, it does not add stockmovements, it does not update stock for any quantity returned or update sales analysis. To create a credit note using webERP logic use the CreateCreditNote function'); $Parameter[0]['name'] = _('Credit Details'); $Parameter[0]['description'] = _('An array of index/value items describing the credit. All values must be negative.'); $Parameter[1]['name'] = _('User name'); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |