From: <dai...@us...> - 2012-02-09 09:30:30
|
Revision: 4887 http://web-erp.svn.sourceforge.net/web-erp/?rev=4887&view=rev Author: daintree Date: 2012-02-09 09:30:20 +0000 (Thu, 09 Feb 2012) Log Message: ----------- new function for allocating debtor receipts from POS 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-08 20:10:33 UTC (rev 4886) +++ trunk/api/api_debtortransactions.php 2012-02-09 09:30:20 UTC (rev 4887) @@ -285,8 +285,7 @@ $Errors[0]=NoAuthorisation; return $Errors; } - $fp = fopen( "/root/Web-Server/apidebug/DebugInfo.txt", "w"); - + /*Get Company Defaults */ $ReadCoyResult = api_DB_query("SELECT debtorsact, pytdiscountact, @@ -341,18 +340,12 @@ $ReceiptExRate = $CustCurrRow['rate']/$BankActRow['rate']; $FunctionalExRate = $BankActRow['rate']; -fputs($fp, 'Receipt ex rate = ' . $ReceiptExRate . "\n"); -fputs($fp, 'Functional ex rate = ' . $FunctionalExRate . "\n"); - DB_Txn_Begin($db); $ReceiptNo = GetNextTransNo(12,$db); $PeriodNo = GetCurrentPeriod($db); /*now enter the BankTrans entry */ -fputs($fp, 'Receipt No = ' . $ReceiptNo . "\n"); -fputs($fp, 'Period No = ' . $PeriodNo . "\n"); - $SQL="INSERT INTO banktrans (type, transno, bankact, @@ -376,7 +369,6 @@ $result = api_DB_query($SQL,$db,'','',true); -fputs($fp, "Entered the bank trans with the following SQL: \n" . $SQL . "\n"); if ($CompanyRecord['gllink_debtors']==1) { /* Now Credit Debtors account with receipts */ @@ -396,8 +388,6 @@ '" . 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, @@ -436,8 +426,6 @@ $result = api_DB_query($SQL,$db,'','',true); -fputs($fp, "Entered the bank deposit GL trans with the following SQL: \n" . $SQL . "\n"); - } /* end if GL linked to debtors */ $SQL = "INSERT INTO debtortrans (transno, @@ -463,8 +451,6 @@ $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'] . "', lastpaid='" . $Receipt['amountfx'] ."' WHERE debtorsmaster.debtorno='" . $Receipt['debtorno'] . "'"; @@ -1311,7 +1297,10 @@ function AllocateTrans($AllocDetails, $User, $Password) { - /* AllocDetails is an associative array containing: + /* This function is quite specific and probably not generally useful + * It only attempts to allocate a receipt or credit note sent to invoices that have a customerref equal to the value sent + * + * The first parameter AllocDetails is an associative array containing: * AllocDetails['debtorno'] * AllocDetails['type'] * AllocDetails['transno'] @@ -1338,7 +1327,7 @@ AND transno='" . $AllocDetails['transno'] . "'"; $Result = api_DB_query($SQL,$db); $LeftToAllocRow = DB_fetch_array($Result); - if (DB_num_row($Result)==0){ + if (DB_num_rows($Result)==0){ $Errors[] = NoTransactionToAllocate; } Modified: trunk/api/api_xml-rpc.php =================================================================== --- trunk/api/api_xml-rpc.php 2012-02-08 20:10:33 UTC (rev 4886) +++ trunk/api/api_xml-rpc.php 2012-02-09 09:30:20 UTC (rev 4887) @@ -1057,8 +1057,8 @@ unset($ReturnValue); $Description = _('Creates a customer receipt from the details passed to the method as an associative array'); - $Parameter[0]['name'] = _('Create Customer Receipt'); - $Parameter[0]['description'] = _('An associative array describing the customer receipt with the following fields: debtorno - the customer code, trandate - the date of the receipt in Y-m-d format, amountfx - the amount in FX, paymentmethod - the payment method of the receipt e.g. cash/EFTPOS/credit card, bankaccount - the webERP bank account to use for the transaction, reference - the reference to record against the webERP receipt transaction'); + $Parameter[0]['name'] = _('Receipt Details'); + $Parameter[0]['description'] = _('An associative array describing the customer receipt with the following fields: debtorno - the customer code; trandate - the date of the receipt in Y-m-d format; amountfx - the amount in FX; paymentmethod - the payment method of the receipt e.g. cash/EFTPOS/credit card; bankaccount - the webERP bank account to use for the transaction, reference - the reference to record against the webERP receipt transaction'); $Parameter[1]['name'] = _('User name'); $Parameter[1]['description'] = _('A valid weberp username. This user should have security access to this data.'); $Parameter[2]['name'] = _('User password'); @@ -1086,6 +1086,36 @@ unset($Parameter); unset($ReturnValue); + $Description = _('Allocates a debtor receipt or credit to a debtor invoice. Using the customerref field to match up which invoice to allocate to'); + $Parameter[0]['name'] = _('Allocation Details'); + $Parameter[0]['description'] = _('An associative array describing the customer, the transaction being allocated from, it\'s transaction type 12 for a receipt or 11 for a credit note, the webERP transaction number, the customer ref that is to be searched for in invoices to match to. The fields are: debtorno, type, transno, customerref'); + $Parameter[1]['name'] = _('User name'); + $Parameter[1]['description'] = _('A valid weberp username. This user should have security access to this data.'); + $Parameter[2]['name'] = _('User password'); + $Parameter[2]['description'] = _('The weberp password associated with this user name. '); + $ReturnValue[0] = _('This function returns an array of integers. ') + ._('If the first element is zero then the function was successful.') + ._('Otherwise an array of error codes is returned and no insertion takes place. '); + +/*E*/$AllocateTrans_sig = array(array($xmlrpcStruct,$xmlrpcStruct), +/*x*/ array($xmlrpcStruct,$xmlrpcStruct,$xmlrpcString,$xmlrpcString)); + $AllocateTrans_doc = apiBuildDocHTML( $Description,$Parameter,$ReturnValue ); + + function xmlrpc_AllocateTrans($xmlrpcmsg){ + ob_start('ob_file_callback'); +/*x*/ if ($xmlrpcmsg->getNumParams() == 3) { +/*x*/ $rtn = new xmlrpcresp( php_xmlrpc_encode(AllocateTrans(php_xmlrpc_decode($xmlrpcmsg->getParam( 0 )), $xmlrpcmsg->getParam( 1 )->scalarval( ),$xmlrpcmsg->getParam( 2 )->scalarval( ))) ); +/*x*/ } else { +/*e*/ $rtn = new xmlrpcresp( php_xmlrpc_encode(AllocateTrans(php_xmlrpc_decode($xmlrpcmsg->getParam( 0 )), '', ''))); +/*x*/ } + ob_end_flush(); + return $rtn; + } + + unset($Description); + unset($Parameter); + unset($ReturnValue); + $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'); @@ -3100,6 +3130,10 @@ "function" => "xmlrpc_InsertSalesInvoice", "signature" => $InsertSalesInvoice_sig, "docstring" => $InsertSalesInvoice_doc), + "weberp.xmlrpc_AllocateTrans" => array( + "function" => "xmlrpc_AllocateTrans", + "signature" => $AllocateTrans_sig, + "docstring" => $AllocateTrans_doc), "weberp.xmlrpc_InsertDebtorReceipt" => array( "function" => "xmlrpc_InsertDebtorReceipt", "signature" => $InsertDebtorReceipt_sig, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |