本文整理汇总了PHP中EnsureGLEntriesBalance函数的典型用法代码示例。如果您正苦于以下问题:PHP EnsureGLEntriesBalance函数的具体用法?PHP EnsureGLEntriesBalance怎么用?PHP EnsureGLEntriesBalance使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了EnsureGLEntriesBalance函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: CreateCreditNote
//.........这里部分代码省略.........
$Result = api_DB_query($SQL, $db, '', '', true);
if ($CompanyRecord['gllink_stock'] == 1 and $StandardCost != 0) {
/*first the cost of sales entry - GL accounts are retrieved using the function GetCOGSGLAccount from includes/GetSalesTransGLCodes.inc */
$SQL = "INSERT INTO gltrans (type,\n\t\t\t\t\t\t\t\t\t\t\ttypeno,\n\t\t\t\t\t\t\t\t\t\t\ttrandate,\n\t\t\t\t\t\t\t\t\t\t\tperiodno,\n\t\t\t\t\t\t\t\t\t\t\taccount,\n\t\t\t\t\t\t\t\t\t\t\tnarrative,\n\t\t\t\t\t\t\t\t\t\t\tamount)\n\t\t\t\t\t\t\t\t\tVALUES (11,\n\t\t\t\t\t\t\t\t\t\t'" . $CreditNoteNo . "',\n\t\t\t\t\t\t\t\t\t\t'" . $Header['trandate'] . "',\n\t\t\t\t\t\t\t\t\t\t'" . $PeriodNo . "',\n\t\t\t\t\t\t\t\t\t\t'" . GetCOGSGLAccount($CN_Header['area'], $CN_Line['stockid'], $Header['tpe'], $db) . "',\n\t\t\t\t\t\t\t\t\t\t'" . $Header['debtorno'] . " - " . $CN_Line['stockid'] . " x " . $CN_Line['qty'] . " @ " . $StandardCost . "',\n\t\t\t\t\t\t\t\t\t\t'" . $StandardCost * $CN_Line['qty'] . "')";
$Result = api_DB_query($SQL, $db, '', '', true);
/*now the stock entry - this is set to the cost act in the case of a fixed asset disposal */
$StockGLCode = GetStockGLCode($CN_Line['stockid'], $db);
$SQL = "INSERT INTO gltrans (type,\n\t\t\t\t\t\t\t\t\t\t\ttypeno,\n\t\t\t\t\t\t\t\t\t\t\ttrandate,\n\t\t\t\t\t\t\t\t\t\t\tperiodno,\n\t\t\t\t\t\t\t\t\t\t\taccount,\n\t\t\t\t\t\t\t\t\t\t\tnarrative,\n\t\t\t\t\t\t\t\t\t\t\tamount)\n\t\t\t\t\t\t\t\t\tVALUES (11,\n\t\t\t\t\t\t\t\t\t\t'" . $CreditNoteNo . "',\n\t\t\t\t\t\t\t\t\t\t'" . $Header['trandate'] . "',\n\t\t\t\t\t\t\t\t\t\t'" . $PeriodNo . "',\n\t\t\t\t\t\t\t\t\t\t'" . $StockGLCode['stockact'] . "',\n\t\t\t\t\t\t\t\t\t\t'" . $Header['debtorno'] . " - " . $CN_Line['stockid'] . " x " . $CN_Line['qty'] . " @ " . $StandardCost . "',\n\t\t\t\t\t\t\t\t\t\t'" . -$StandardCost * $CN_Line['qty'] . "')";
$Result = api_DB_query($SQL, $db, '', '', true);
}
/* end of if GL and stock integrated and standard cost !=0 and not an asset */
if ($CompanyRecord['gllink_debtors'] == 1 and $CN_Line['price'] != 0) {
//Post sales transaction to GL credit sales
$SalesGLAccounts = GetSalesGLAccount($CN_Header['area'], $CN_Line['stockid'], $Header['tpe'], $db);
$SQL = "INSERT INTO gltrans (type,\n\t\t\t\t\t\t\t\t\t\t\ttypeno,\n\t\t\t\t\t\t\t\t\t\t\ttrandate,\n\t\t\t\t\t\t\t\t\t\t\tperiodno,\n\t\t\t\t\t\t\t\t\t\t\taccount,\n\t\t\t\t\t\t\t\t\t\t\tnarrative,\n\t\t\t\t\t\t\t\t\t\t\tamount )\n\t\t\t\t\tVALUES ('11',\n\t\t\t\t\t\t'" . $CreditNoteNo . "',\n\t\t\t\t\t\t'" . $Header['trandate'] . "',\n\t\t\t\t\t\t'" . $PeriodNo . "',\n\t\t\t\t\t\t'" . $SalesGLAccounts['salesglcode'] . "',\n\t\t\t\t\t\t'" . $Header['debtorno'] . " - " . $CN_Line['stockid'] . " x " . $CN_Line['qty'] . " @ " . $CN_Line['price'] . "',\n\t\t\t\t\t\t'" . -$CN_Line['price'] * $CN_Line['qty'] / $CN_Header['rate'] . "'\n\t\t\t\t\t)";
$Result = api_DB_query($SQL, $db, '', '', true);
if ($CN_Line['discountpercent'] != 0) {
$SQL = "INSERT INTO gltrans (type,\n\t\t\t\t\t\t\t\t\t\t\t\ttypeno,\n\t\t\t\t\t\t\t\t\t\t\t\ttrandate,\n\t\t\t\t\t\t\t\t\t\t\t\tperiodno,\n\t\t\t\t\t\t\t\t\t\t\t\taccount,\n\t\t\t\t\t\t\t\t\t\t\t\tnarrative,\n\t\t\t\t\t\t\t\t\t\t\t\tamount)\n\t\t\t\t\t\t\tVALUES (11,\n\t\t\t\t\t\t\t\t'" . $CreditNoteNo . "',\n\t\t\t\t\t\t\t\t'" . $Header['trandate'] . "',\n\t\t\t\t\t\t\t\t'" . $PeriodNo . "',\n\t\t\t\t\t\t\t\t'" . $SalesGLAccounts['discountglcode'] . "',\n\t\t\t\t\t\t\t\t'" . $Header['debtorno'] . " - " . $CN_Line['stockid'] . " @ " . $CN_Line['discountpercent'] * 100 . "%',\n\t\t\t\t\t\t\t\t'" . $CN_Line['price'] * $CN_Line['qty'] * $CN_Line['discountpercent'] / $CN_Header['rate'] . "')";
$Result = DB_query($SQL, $db, '', '', true);
}
/*end of if discount !=0 */
}
/*end of if sales integrated with gl */
$LineCounter++;
//needed for the array of taxes by line
}
/*end of OrderLine loop */
$TotalCreditLocalCurr = ($TotalFXNetCredit + $TotalFXTax) / $CN_Header['rate'];
if ($CompanyRecord['gllink_debtors'] == 1) {
/*Now post the tax to the GL at local currency equivalent */
if ($CompanyRecord['gllink_debtors'] == 1 and $TaxAuthAmount != 0) {
/*Loop through the tax authorities array to post each total to the taxauth glcode */
foreach ($TaxTotals as $Tax) {
$SQL = "INSERT INTO gltrans (type,\n\t\t\t\t\t\t\t\t\t\t\t\ttypeno,\n\t\t\t\t\t\t\t\t\t\t\t\ttrandate,\n\t\t\t\t\t\t\t\t\t\t\t\tperiodno,\n\t\t\t\t\t\t\t\t\t\t\t\taccount,\n\t\t\t\t\t\t\t\t\t\t\t\tnarrative,\n\t\t\t\t\t\t\t\t\t\t\t\tamount )\n\t\t\t\t\t\t\t\t\t\t\tVALUES (11,\n\t\t\t\t\t\t\t\t\t\t\t'" . $CreditNoteNo . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $Header['trandate'] . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $PeriodNo . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $Tax['GLCode'] . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $Header['debtorno'] . "-" . $Tax['TaxAuthDescription'] . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . -$Tax['FXAmount'] / $CN_Header['rate'] . "' )";
$Result = api_DB_query($SQL, $db, '', '', true);
}
}
/*Post debtors transaction to GL credit debtors, and debit sales */
if ($TotalCreditLocalCurr != 0) {
$SQL = "INSERT INTO gltrans (type,\n\t\t\t\t\t\t\t\t\t\t\ttypeno,\n\t\t\t\t\t\t\t\t\t\t\ttrandate,\n\t\t\t\t\t\t\t\t\t\t\tperiodno,\n\t\t\t\t\t\t\t\t\t\t\taccount,\n\t\t\t\t\t\t\t\t\t\t\tnarrative,\n\t\t\t\t\t\t\t\t\t\t\tamount)\n\t\t\t\t\t\t\t\t\tVALUES ('11',\n\t\t\t\t\t\t\t\t\t\t'" . $CreditNoteNo . "',\n\t\t\t\t\t\t\t\t\t\t'" . $Header['trandate'] . "',\n\t\t\t\t\t\t\t\t\t\t'" . $PeriodNo . "',\n\t\t\t\t\t\t\t\t\t\t'" . $CompanyRecord['debtorsact'] . "',\n\t\t\t\t\t\t\t\t\t\t'" . $Header['debtorno'] . "',\n\t\t\t\t\t\t\t\t\t\t'" . $TotalCreditLocalCurr . "')";
$Result = api_DB_query($SQL, $db, '', '', true);
}
EnsureGLEntriesBalance(11, $CreditNoteNo, $db);
}
/*end of if Sales and GL integrated */
/*Now insert the DebtorTrans */
$SQL = "INSERT INTO debtortrans (transno,\n\t\t\t\t\t\t\t\t\t\ttype,\n\t\t\t\t\t\t\t\t\t\tdebtorno,\n\t\t\t\t\t\t\t\t\t\tbranchcode,\n\t\t\t\t\t\t\t\t\t\ttrandate,\n\t\t\t\t\t\t\t\t\t\tinputdate,\n\t\t\t\t\t\t\t\t\t\tprd,\n\t\t\t\t\t\t\t\t\t\treference,\n\t\t\t\t\t\t\t\t\t\ttpe,\n\t\t\t\t\t\t\t\t\t\tovamount,\n\t\t\t\t\t\t\t\t\t\tovgst,\n\t\t\t\t\t\t\t\t\t\trate,\n\t\t\t\t\t\t\t\t\t\tshipvia)\n\t\t\t\t\t\t\t\t\tVALUES (\n\t\t\t\t\t\t\t\t\t\t'" . $CreditNoteNo . "',\n\t\t\t\t\t\t\t\t\t\t11,\n\t\t\t\t\t\t\t\t\t\t'" . $Header['debtorno'] . "',\n\t\t\t\t\t\t\t\t\t\t'" . $Header['branchcode'] . "',\n\t\t\t\t\t\t\t\t\t\t'" . $Header['trandate'] . "',\n\t\t\t\t\t\t\t\t\t\t'" . date('Y-m-d H-i-s') . "',\n\t\t\t\t\t\t\t\t\t\t'" . $PeriodNo . "',\n\t\t\t\t\t\t\t\t\t\t'" . $Header['customerref'] . "',\n\t\t\t\t\t\t\t\t\t\t'" . $Header['tpe'] . "',\n\t\t\t\t\t\t\t\t\t\t'" . $TotalFXNetCredit . "',\n\t\t\t\t\t\t\t\t\t\t'" . $TotalFXTax . "',\n\t\t\t\t\t\t\t\t\t\t'" . $CN_Header['rate'] . "',\n\t\t\t\t\t\t\t\t\t\t'" . $Header['shipvia'] . "')";
$Result = api_DB_query($SQL, $db, '', '', true);
$DebtorTransID = DB_Last_Insert_ID($db, 'debtortrans', 'id');
/*for each Tax - need to insert into debtortranstaxes */
foreach ($TaxTotals as $TaxAuthID => $Tax) {
$SQL = "INSERT INTO debtortranstaxes (debtortransid,\n\t\t\t\t\t\t\t\t\t\t\t\ttaxauthid,\n\t\t\t\t\t\t\t\t\t\t\t\ttaxamount)\n\t\t\t\t\t\t\t\tVALUES ('" . $DebtorTransID . "',\n\t\t\t\t\t\t\t\t\t\t'" . $TaxAuthID . "',\n\t\t\t\t\t\t\t\t\t\t'" . $Tax['FXAmount'] / $CN_Header['rate'] . "')";
$Result = api_DB_query($SQL, $db, '', '', true);
}
#Now figure out if there was an invoice in the same POS transaction to allocate against?
$SQL = "SELECT id,\n\t\t\t\t\tovamount+ovgst AS total,\n\t\t\t\t\talloc\n\t\t\t\tFROM debtortrans\n\t\t\t\tWHERE customerref='" . $Header['customerref'] . "'\n\t\t\t\tAND type=10\n\t\t\t\tAND settled=0";
$Result = api_DB_query($SQL, $db, '', '', true);
$TotalCreditFX = $TotalFXNetCredit + $TotalFXTax;
#Should be negative number
$Allocated = 0;
if (DB_num_rows($Result) > 0) {
while ($InvoiceRow = DB_fetch_array($Result) and $Allocated > $TotalCreditFX) {
if ($InvoiceRow['total'] - $InvoiceRow['alloc'] + $TotalCreditFX - $Allocated > 0) {
/*Then we can allocate all of the (remaining) credit against this invoice */
$AllocateAmount = $InvoiceRow['total'] - $InvoiceRow['alloc'] + $TotalCreditFX - $Allocated;
} elseif ($InvoiceRow['total'] - $InvoiceRow['alloc'] - $Allocated > 0) {
$AllocateAmount = $InvoiceRow['total'] - $InvoiceRow['alloc'] - $Allocated;
} else {
$AllocateAmount = 0;
}
if ($AllocateAmount > 0) {
$SQL = "INSERT INTO\tcustallocns (datealloc,\n\t\t\t\t\t\t\t\t\t\t\t\t\t amt,\n\t\t\t\t\t\t\t\t\t\t\t\t\t transid_allocfrom,\n\t\t\t\t\t\t\t\t\t\t\t\t\t transid_allocto)\n\t\t\t\t\t\t\tVALUES ('" . date('Y-m-d') . "',\n\t\t\t\t\t\t\t\t\t'" . $AllocateAmount . "',\n\t\t\t\t\t\t\t\t\t'" . $DebtorTransID . "',\n\t\t\t\t\t\t\t\t\t'" . $InvoiceRow['id'] . "')";
$InsertAllocResult = api_DB_query($SQL, $db, '', '', true);
}
if (abs($InvoiceRow['total'] - $InvoiceRow['alloc'] - $AllocateAmount) < 0.005) {
$Settled = 1;
} else {
$Settled = 0;
}
$SQL = "UPDATE debtortrans SET alloc = alloc + " . $AllocateAmount . ",\n\t\t\t\t\t\t\t\t\t\t\t\tsettled = '" . $Settled . "'\n\t\t\t\t\t\tWHERE id = '" . $InvoiceRow['id'] . "'";
$UpdateAllocResult = api_DB_query($SQL, $db, '', '', true);
$Allocated -= $AllocateAmount;
}
if (abs($TotalCreditFX - $Allocated) < 0.005) {
$Settled = 1;
} else {
$Settled = 0;
}
$SQL = "UPDATE debtortrans SET alloc = alloc + " . $Allocated . ",\n\t\t\t\t\t\t\t\t\t\t\t\tsettled = '" . $Settled . "'\n\t\t\t\t\tWHERE id = '" . $DebtorTransID . "'";
$UpdateAllocResult = api_DB_query($SQL, $db, '', '', true);
}
if (sizeof($Errors) == 0) {
$Result = DB_Txn_Commit($db);
$Errors[0] = 0;
$Errors[1] = $CreditNoteNo;
} else {
$Result = DB_Txn_Rollback($db);
}
return $Errors;
}
示例2: gltrans
}
if ($_SESSION['CreditItems' . $identifier]->FreightCost != 0) {
$SQL = "INSERT INTO gltrans (type,\n\t\t\t\t\t\t\t\t\t\ttypeno,\n\t\t\t\t\t\t\t\t\t\ttrandate,\n\t\t\t\t\t\t\t\t\t\tperiodno,\n\t\t\t\t\t\t\t\t\t\taccount,\n\t\t\t\t\t\t\t\t\t\tnarrative,\n\t\t\t\t\t\t\t\t\t\tamount)\n\t\t\t\t\t\t\tVALUES (11,\n\t\t\t\t\t\t\t\t'" . $CreditNo . "',\n\t\t\t\t\t\t\t\t'" . $SQLCreditDate . "',\n\t\t\t\t\t\t\t\t'" . $PeriodNo . "',\n\t\t\t\t\t\t\t\t'" . $_SESSION['CompanyRecord']['freightact'] . "',\n\t\t\t\t\t\t\t\t'" . $_SESSION['CreditItems' . $identifier]->DebtorNo . "',\n\t\t\t\t\t\t\t\t'" . $_SESSION['CreditItems' . $identifier]->FreightCost / $_SESSION['CurrencyRate'] . "')";
$ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The freight GL posting for this credit note could not be inserted because');
$DbgMsg = _('The following SQL to insert the GLTrans record was used');
$Result = DB_query($SQL, $ErrMsg, $DbgMsg, true);
}
foreach ($TaxTotals as $TaxAuthID => $TaxAmount) {
if ($TaxAmount != 0) {
$SQL = "INSERT INTO gltrans (type,\n\t\t\t\t\t\t\t\t\t\t\ttypeno,\n\t\t\t\t\t\t\t\t\t\t\ttrandate,\n\t\t\t\t\t\t\t\t\t\t\tperiodno,\n\t\t\t\t\t\t\t\t\t\t\taccount,\n\t\t\t\t\t\t\t\t\t\t\tnarrative,\n\t\t\t\t\t\t\t\t\t\t\tamount )\n\t\t\t\t\t\t\t\t\t\tVALUES (11,\n\t\t\t\t\t\t\t\t\t\t\t'" . $CreditNo . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $SQLCreditDate . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $PeriodNo . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $TaxGLCodes[$TaxAuthID] . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $_SESSION['CreditItems' . $identifier]->DebtorNo . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $TaxAmount / $_SESSION['CurrencyRate'] . "')";
$ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The tax GL posting could not be inserted because');
$DbgMsg = _('The following SQL to insert the GLTrans record was used');
$Result = DB_query($SQL, $ErrMsg, $DbgMsg, true);
}
}
EnsureGLEntriesBalance(11, $CreditNo, $db);
}
/*end of if Sales and GL integrated */
DB_Txn_Commit();
unset($_SESSION['CreditItems' . $identifier]->LineItems);
unset($_SESSION['CreditItems' . $identifier]);
echo _('Credit Note number') . ' ' . $CreditNo . ' ' . _('processed') . '<br />';
echo '<a target="_blank" href="' . $RootPath . '/PrintCustTrans.php?FromTransNo=' . $CreditNo . '&InvOrCredit=Credit">' . _('Show this Credit Note on screen') . '</a><br />';
if ($_SESSION['InvoicePortraitFormat'] == 0) {
echo '<a href="' . $RootPath . '/PrintCustTrans.php?FromTransNo=' . $CreditNo . '&InvOrCredit=Credit&PrintPDF=True">' . _('Print this Credit Note') . '</a>';
} else {
echo '<a href="' . $RootPath . '/PrintCustTransPortrait.php?FromTransNo=' . $CreditNo . '&InvOrCredit=Credit&PrintPDF=True">' . _('Print this Credit Note') . '</a>';
}
echo '<br /><a href="' . $RootPath . '/SelectCreditItems.php">' . _('Enter Another Credit Note') . '</a>';
}
/*end of process credit note */
示例3: DB_query
$result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
}
// end if discount
}
// end if gl creditors
}
// end if supplier
if ($_SESSION['CompanyRecord']['gllink_creditors'] == 1) {
/* then do the common GLTrans */
if ($_SESSION['PaymentDetail' . $identifier]->Amount != 0) {
/* Bank account entry first */
$SQL = "INSERT INTO gltrans ( type,\n\t\t\t\t\t\t\t\t\t\t\ttypeno,\n\t\t\t\t\t\t\t\t\t\t\ttrandate,\n\t\t\t\t\t\t\t\t\t\t\tperiodno,\n\t\t\t\t\t\t\t\t\t\t\taccount,\n\t\t\t\t\t\t\t\t\t\t\tnarrative,\n\t\t\t\t\t\t\t\t\t\t\tamount)\n\t\t\t\t\t\tVALUES ('" . $TransType . "',\n\t\t\t\t\t\t\t\t'" . $TransNo . "',\n\t\t\t\t\t\t\t\t'" . FormatDateForSQL($_SESSION['PaymentDetail' . $identifier]->DatePaid) . "',\n\t\t\t\t\t\t\t\t'" . $PeriodNo . "',\n\t\t\t\t\t\t\t\t'" . $_SESSION['PaymentDetail' . $identifier]->Account . "',\n\t\t\t\t\t\t\t\t'" . $_SESSION['PaymentDetail' . $identifier]->Narrative . "',\n\t\t\t\t\t\t\t\t'" . -$_SESSION['PaymentDetail' . $identifier]->Amount / $_SESSION['PaymentDetail' . $identifier]->ExRate / $_SESSION['PaymentDetail' . $identifier]->FunctionalExRate . "')";
$ErrMsg = _('Cannot insert a GL transaction for the bank account credit because');
$DbgMsg = _('Cannot insert a GL transaction for the bank account credit using the SQL');
$result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
EnsureGLEntriesBalance($TransType, $TransNo, $db);
}
}
/*now enter the BankTrans entry */
if ($TransType == 22) {
$SQL = "INSERT INTO banktrans (transno,\n\t\t\t\t\t\t\t\t\t\ttype,\n\t\t\t\t\t\t\t\t\t\tbankact,\n\t\t\t\t\t\t\t\t\t\tref,\n\t\t\t\t\t\t\t\t\t\texrate,\n\t\t\t\t\t\t\t\t\t\tfunctionalexrate,\n\t\t\t\t\t\t\t\t\t\ttransdate,\n\t\t\t\t\t\t\t\t\t\tbanktranstype,\n\t\t\t\t\t\t\t\t\t\tamount,\n\t\t\t\t\t\t\t\t\t\tcurrcode)\n\t\t\t\t\t\t\tVALUES ('" . $TransNo . "',\n\t\t\t\t\t\t\t\t\t'" . $TransType . "',\n\t\t\t\t\t\t\t\t\t'" . $_SESSION['PaymentDetail' . $identifier]->Account . "',\n\t\t\t\t\t\t\t\t\t'" . $_SESSION['PaymentDetail' . $identifier]->Narrative . "',\n\t\t\t\t\t\t\t\t\t'" . $_SESSION['PaymentDetail' . $identifier]->ExRate . "',\n\t\t\t\t\t\t\t\t\t'" . $_SESSION['PaymentDetail' . $identifier]->FunctionalExRate . "',\n\t\t\t\t\t\t\t\t\t'" . FormatDateForSQL($_SESSION['PaymentDetail' . $identifier]->DatePaid) . "',\n\t\t\t\t\t\t\t\t\t'" . $_SESSION['PaymentDetail' . $identifier]->Paymenttype . "',\n\t\t\t\t\t\t\t\t\t'" . -$_SESSION['PaymentDetail' . $identifier]->Amount . "',\n\t\t\t\t\t\t\t\t\t'" . $_SESSION['PaymentDetail' . $identifier]->Currency . "'\n\t\t\t\t\t\t\t\t)";
$ErrMsg = _('Cannot insert a bank transaction because');
$DbgMsg = _('Cannot insert a bank transaction using the SQL');
$result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
} else {
foreach ($_SESSION['PaymentDetail' . $identifier]->GLItems as $PaymentItem) {
$SQL = "INSERT INTO banktrans (transno,\n\t\t\t\t\t\t\t\t\t\t\ttype,\n\t\t\t\t\t\t\t\t\t\t\tbankact,\n\t\t\t\t\t\t\t\t\t\t\tref,\n\t\t\t\t\t\t\t\t\t\t\texrate,\n\t\t\t\t\t\t\t\t\t\t\tfunctionalexrate,\n\t\t\t\t\t\t\t\t\t\t\ttransdate,\n\t\t\t\t\t\t\t\t\t\t\tbanktranstype,\n\t\t\t\t\t\t\t\t\t\t\tamount,\n\t\t\t\t\t\t\t\t\t\t\tcurrcode)\n\t\t\t\t\t\tVALUES ('" . $TransNo . "',\n\t\t\t\t\t\t\t\t'" . $TransType . "',\n\t\t\t\t\t\t\t\t'" . $_SESSION['PaymentDetail' . $identifier]->Account . "',\n\t\t\t\t\t\t\t\t'" . $_SESSION['PaymentDetail' . $identifier]->Narrative . "',\n\t\t\t\t\t\t\t\t'" . $_SESSION['PaymentDetail' . $identifier]->ExRate . "',\n\t\t\t\t\t\t\t\t'" . $_SESSION['PaymentDetail' . $identifier]->FunctionalExRate . "',\n\t\t\t\t\t\t\t\t'" . FormatDateForSQL($_SESSION['PaymentDetail' . $identifier]->DatePaid) . "',\n\t\t\t\t\t\t\t\t'" . $_SESSION['PaymentDetail' . $identifier]->Paymenttype . "',\n\t\t\t\t\t\t\t\t'" . -$PaymentItem->Amount . "',\n\t\t\t\t\t\t\t\t'" . $_SESSION['PaymentDetail' . $identifier]->Currency . "' )";
$ErrMsg = _('Cannot insert a bank transaction because');
$DbgMsg = _('Cannot insert a bank transaction using the SQL');
$result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
}
示例4: floatval
$SQL = "UPDATE locstock SET quantity = quantity + " . floatval($_SESSION['Adjustment' . $identifier]->Quantity) . "\n\t\t\t\tWHERE stockid='" . $_SESSION['Adjustment' . $identifier]->StockID . "'\n\t\t\t\tAND loccode='" . $_SESSION['Adjustment' . $identifier]->StockLocation . "'";
$ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The location stock record could not be updated because');
$DbgMsg = _('The following SQL to update the stock record was used');
$Result = DB_query($SQL, $ErrMsg, $DbgMsg, true);
if ($_SESSION['CompanyRecord']['gllink_stock'] == 1 and $_SESSION['Adjustment' . $identifier]->StandardCost > 0) {
$StockGLCodes = GetStockGLCode($_SESSION['Adjustment' . $identifier]->StockID, $db);
$SQL = "INSERT INTO gltrans (type,\n\t\t\t\t\t\t\t\t\t\ttypeno,\n\t\t\t\t\t\t\t\t\t\ttrandate,\n\t\t\t\t\t\t\t\t\t\tperiodno,\n\t\t\t\t\t\t\t\t\t\taccount,\n\t\t\t\t\t\t\t\t\t\tamount,\n\t\t\t\t\t\t\t\t\t\tnarrative,\n\t\t\t\t\t\t\t\t\t\ttag)\n\t\t\t\t\t\t\t\tVALUES (17,\n\t\t\t\t\t\t\t\t\t'" . $AdjustmentNumber . "',\n\t\t\t\t\t\t\t\t\t'" . $SQLAdjustmentDate . "',\n\t\t\t\t\t\t\t\t\t'" . $PeriodNo . "',\n\t\t\t\t\t\t\t\t\t'" . $StockGLCodes['adjglact'] . "',\n\t\t\t\t\t\t\t\t\t'" . round($_SESSION['Adjustment' . $identifier]->StandardCost * -$_SESSION['Adjustment' . $identifier]->Quantity, $_SESSION['CompanyRecord']['decimalplaces']) . "',\n\t\t\t\t\t\t\t\t\t'" . $_SESSION['Adjustment' . $identifier]->StockID . " x " . $_SESSION['Adjustment' . $identifier]->Quantity . " @ " . $_SESSION['Adjustment' . $identifier]->StandardCost . " " . $_SESSION['Adjustment' . $identifier]->Narrative . "',\n\t\t\t\t\t\t\t\t\t'" . $_SESSION['Adjustment' . $identifier]->tag . "')";
$ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The general ledger transaction entries could not be added because');
$DbgMsg = _('The following SQL to insert the GL entries was used');
$Result = DB_query($SQL, $ErrMsg, $DbgMsg, true);
$SQL = "INSERT INTO gltrans (type,\n\t\t\t\t\t\t\t\t\t\ttypeno,\n\t\t\t\t\t\t\t\t\t\ttrandate,\n\t\t\t\t\t\t\t\t\t\tperiodno,\n\t\t\t\t\t\t\t\t\t\taccount,\n\t\t\t\t\t\t\t\t\t\tamount,\n\t\t\t\t\t\t\t\t\t\tnarrative,\n\t\t\t\t\t\t\t\t\t\ttag)\n\t\t\t\t\t\t\t\tVALUES (17,\n\t\t\t\t\t\t\t\t\t'" . $AdjustmentNumber . "',\n\t\t\t\t\t\t\t\t\t'" . $SQLAdjustmentDate . "',\n\t\t\t\t\t\t\t\t\t'" . $PeriodNo . "',\n\t\t\t\t\t\t\t\t\t'" . $StockGLCodes['stockact'] . "',\n\t\t\t\t\t\t\t\t\t'" . round($_SESSION['Adjustment' . $identifier]->StandardCost * $_SESSION['Adjustment' . $identifier]->Quantity, $_SESSION['CompanyRecord']['decimalplaces']) . "',\n\t\t\t\t\t\t\t\t\t'" . $_SESSION['Adjustment' . $identifier]->StockID . ' x ' . $_SESSION['Adjustment' . $identifier]->Quantity . ' @ ' . $_SESSION['Adjustment' . $identifier]->StandardCost . ' ' . $_SESSION['Adjustment' . $identifier]->Narrative . "',\n\t\t\t\t\t\t\t\t\t'" . $_SESSION['Adjustment' . $identifier]->tag . "'\n\t\t\t\t\t\t\t\t\t)";
$Errmsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The general ledger transaction entries could not be added because');
$DbgMsg = _('The following SQL to insert the GL entries was used');
$Result = DB_query($SQL, $ErrMsg, $DbgMsg, true);
}
EnsureGLEntriesBalance(17, $AdjustmentNumber, $db);
$Result = DB_Txn_Commit();
$ConfirmationText = _('A stock adjustment for') . ' ' . $_SESSION['Adjustment' . $identifier]->StockID . ' - ' . $_SESSION['Adjustment' . $identifier]->ItemDescription . ' ' . _('has been created from location') . ' ' . $_SESSION['Adjustment' . $identifier]->StockLocation . ' ' . _('for a quantity of') . ' ' . locale_number_format($_SESSION['Adjustment' . $identifier]->Quantity, $_SESSION['Adjustment' . $identifier]->DecimalPlaces);
prnMsg($ConfirmationText, 'success');
if ($_SESSION['InventoryManagerEmail'] != '') {
$ConfirmationText = $ConfirmationText . ' ' . _('by user') . ' ' . $_SESSION['UserID'] . ' ' . _('at') . ' ' . Date('Y-m-d H:i:s');
$EmailSubject = _('Stock adjustment for') . ' ' . $_SESSION['Adjustment' . $identifier]->StockID;
if ($_SESSION['SmtpSetting'] == 0) {
mail($_SESSION['InventoryManagerEmail'], $EmailSubject, $ConfirmationText);
} else {
include 'includes/htmlMimeMail.php';
$mail = new htmlMimeMail();
$mail->setSubject($EmailSubject);
$mail->setText($ConfirmationText);
$result = SendmailBySmtp($mail, array($_SESSION['InventoryManagerEmail']));
}
示例5: gltrans
$SQL = "INSERT INTO gltrans (\n\t\t\t\t\t\ttype,\n\t\t\t\t\t\ttypeno,\n\t\t\t\t\t\ttrandate,\n\t\t\t\t\t\tperiodno,\n\t\t\t\t\t\taccount,\n\t\t\t\t\t\tnarrative,\n\t\t\t\t\t\tamount\t)\n\t\t\t\tVALUES (\n\t\t\t\t\t10,\n\t\t\t\t\t'" . $InvoiceNo . "',\n\t\t\t\t\t'" . $DefaultDispatchDate . "',\n\t\t\t\t\t'" . $PeriodNo . "',\n\t\t\t\t\t'" . $_SESSION['CompanyRecord']['freightact'] . "',\n\t\t\t\t\t'" . $_SESSION['Items' . $identifier]->DebtorNo . "',\n\t\t\t\t\t'" . -$_SESSION['Items' . $identifier]->FreightCost / $_SESSION['CurrencyRate'] . "')";
$ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The freight GL posting could not be inserted because');
$DbgMsg = _('The following SQL to insert the GLTrans record was used');
$Result = DB_query($SQL, $ErrMsg, $DbgMsg, true);
}
foreach ($TaxTotals as $TaxAuthID => $TaxAmount) {
if ($TaxAmount != 0) {
$SQL = "INSERT INTO gltrans (type,\n\t\t\t\t\t\t\t\t\t\t\ttypeno,\n\t\t\t\t\t\t\t\t\t\t\ttrandate,\n\t\t\t\t\t\t\t\t\t\t\tperiodno,\n\t\t\t\t\t\t\t\t\t\t\taccount,\n\t\t\t\t\t\t\t\t\t\t\tnarrative,\n\t\t\t\t\t\t\t\t\t\t\tamount)\n\t\t\t\t\t\t\t\t\t\tVALUES (\n\t\t\t\t\t\t\t\t\t\t\t10,\n\t\t\t\t\t\t\t\t\t\t\t'" . $InvoiceNo . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $DefaultDispatchDate . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $PeriodNo . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $TaxGLCodes[$TaxAuthID] . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $_SESSION['Items' . $identifier]->DebtorNo . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . -$TaxAmount / $_SESSION['CurrencyRate'] . "')";
$ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The tax GL posting could not be inserted because');
$DbgMsg = _('The following SQL to insert the GLTrans record was used');
$Result = DB_query($SQL, $ErrMsg, $DbgMsg, true);
}
}
}
/*end of if Sales and GL integrated */
EnsureGLEntriesBalance(10, $InvoiceNo, $db);
DB_Txn_Commit();
// *************************************************************************
// E N D O F I N V O I C E S Q L P R O C E S S I N G
// *************************************************************************
unset($_SESSION['Items' . $identifier]->LineItems);
unset($_SESSION['Items' . $identifier]);
unset($_SESSION['ProcessingOrder']);
echo prnMsg(_('Invoice number') . ' ' . $InvoiceNo . ' ' . _('processed'), 'success');
echo '<br /><div class="centre">';
if ($_SESSION['InvoicePortraitFormat'] == 0) {
echo '<img src="' . $RootPath . '/css/' . $Theme . '/images/printer.png" title="' . _('Print') . '" alt="" />' . ' ' . '<a target="_blank" href="' . $RootPath . '/PrintCustTrans.php?FromTransNo=' . $InvoiceNo . '&InvOrCredit=Invoice&PrintPDF=True">' . _('Print this invoice') . ' (' . _('Landscape') . ')</a><br /><br />';
} else {
echo '<img src="' . $RootPath . '/css/' . $Theme . '/images/printer.png" title="' . _('Print') . '" alt="" />' . ' ' . '<a target="_blank" href="' . $RootPath . '/PrintCustTransPortrait.php?FromTransNo=' . $InvoiceNo . '&InvOrCredit=Invoice&PrintPDF=True">' . _('Print this invoice') . ' (' . _('Portrait') . ')</a><br /><br />';
}
echo '<a href="' . $RootPath . '/SelectSalesOrder.php">' . _('Select another order for invoicing') . '</a><br /><br />';
示例6: GetNextTransNo
/*Also if GL is linked to debtors need to process the debit to bank and credit to debtors for the payment */
/*Need to figure out the cross rate between customer currency and bank account currency */
if ($_POST['AmountPaid'] != 0) {
$ReceiptNumber = GetNextTransNo(12, $db);
$SQL = "INSERT INTO gltrans (type,\n\t\t\t\t\t\t\t\t\t\t\ttypeno,\n\t\t\t\t\t\t\t\t\t\t\ttrandate,\n\t\t\t\t\t\t\t\t\t\t\tperiodno,\n\t\t\t\t\t\t\t\t\t\t\taccount,\n\t\t\t\t\t\t\t\t\t\t\tnarrative,\n\t\t\t\t\t\t\t\t\t\t\tamount)\n\t\t\t\t\t\tVALUES (12,\n\t\t\t\t\t\t\t'" . $ReceiptNumber . "',\n\t\t\t\t\t\t\t'" . $DefaultDispatchDate . "',\n\t\t\t\t\t\t\t'" . $PeriodNo . "',\n\t\t\t\t\t\t\t'" . $_POST['BankAccount'] . "',\n\t\t\t\t\t\t\t'" . $_SESSION['Items' . $identifier]->LocationName . ' ' . _('Counter Sale') . ' ' . $InvoiceNo . "',\n\t\t\t\t\t\t\t'" . filter_number_format($_POST['AmountPaid']) / $ExRate . "')";
$DbgMsg = _('The SQL that failed to insert the GL transaction for the bank account debit was');
$ErrMsg = _('Cannot insert a GL transaction for the bank account debit');
$result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
/* Now Credit Debtors account with receipt */
$SQL = "INSERT INTO gltrans ( type,\n\t\t\t\t\t\ttypeno,\n\t\t\t\t\t\ttrandate,\n\t\t\t\t\t\tperiodno,\n\t\t\t\t\t\taccount,\n\t\t\t\t\t\tnarrative,\n\t\t\t\t\t\tamount)\n\t\t\t\tVALUES (12,\n\t\t\t\t\t'" . $ReceiptNumber . "',\n\t\t\t\t\t'" . $DefaultDispatchDate . "',\n\t\t\t\t\t'" . $PeriodNo . "',\n\t\t\t\t\t'" . $_SESSION['CompanyRecord']['debtorsact'] . "',\n\t\t\t\t\t'" . $_SESSION['Items' . $identifier]->LocationName . ' ' . _('Counter Sale') . ' ' . $InvoiceNo . "',\n\t\t\t\t\t'" . -(filter_number_format($_POST['AmountPaid']) / $ExRate) . "')";
$DbgMsg = _('The SQL that failed to insert the GL transaction for the debtors account credit was');
$ErrMsg = _('Cannot insert a GL transaction for the debtors account credit');
$result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
}
//amount paid we not zero
EnsureGLEntriesBalance(12, $ReceiptNumber, $db);
}
/*end of if Sales and GL integrated */
if ($_POST['AmountPaid'] != 0) {
if (!isset($ReceiptNumber)) {
$ReceiptNumber = GetNextTransNo(12, $db);
}
//Now need to add the receipt banktrans record
//First get the account currency that it has been banked into
$result = DB_query("SELECT rate FROM currencies\n\t\t\t\t\t\t\t\tINNER JOIN bankaccounts\n\t\t\t\t\t\t\t\tON currencies.currabrev=bankaccounts.currcode\n\t\t\t\t\t\t\t\tWHERE bankaccounts.accountcode='" . $_POST['BankAccount'] . "'", $db);
$myrow = DB_fetch_row($result);
$BankAccountExRate = $myrow[0];
/*
* Some interesting exchange rate conversion going on here
* Say :
* The business's functional currency is NZD
示例7: _
$DbgMsg = _('The following SQL to insert the GRN Suspense GLTrans record was used');
$Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
}
/* end of if GL and stock integrated and standard cost !=0 */
}
/*Quantity received is != 0 */
}
/*end of OrderLine loop */
if ($_SESSION['PO' . $identifier]->AllLinesReceived() == 1 or $OrderCompleted) {
//all lines on the purchase order are now completed
$StatusComment = date($_SESSION['DefaultDateFormat']) . ' - ' . _('Order Completed on entry of GRN') . '<br />' . $_SESSION['PO' . $identifier]->StatusComments;
$sql = "UPDATE purchorders\n\t\t\t\tSET status='Completed',\n\t\t\t\tstat_comment='" . $StatusComment . "'\n\t\t\t\tWHERE orderno='" . $_SESSION['PO' . $identifier]->OrderNo . "'";
$result = DB_query($sql, $db);
}
if ($_SESSION['PO' . $identifier]->GLLink == 1) {
EnsureGLEntriesBalance(25, $GRN, $db);
}
$Result = DB_Txn_Commit($db);
$PONo = $_SESSION['PO' . $identifier]->OrderNo;
unset($_SESSION['PO' . $identifier]->LineItems);
unset($_SESSION['PO' . $identifier]);
unset($_POST['ProcessGoodsReceived']);
echo '<br />
<div class="centre">
' . prnMsg(_('GRN number') . ' ' . $GRN . ' ' . _('has been processed'), 'success') . '
<br />
<br />
<a href="PDFGrn.php?GRNNo=' . $GRN . '&PONo=' . $PONo . '">' . _('Print this Goods Received Note (GRN)') . '</a>
<br />
<br />
<a href="' . $RootPath . '/PO_SelectOSPurchOrder.php">' . _('Select a different purchase order for receiving goods against') . '</a>
示例8: gltrans
include 'footer.inc';
exit;
}
/*Do the GL trans for the exch diff */
if ($AccumDiffOnExch != 0) {
$SQL = "INSERT INTO gltrans (type,\n\t\t\t\t\t\t\t\t\t\ttypeno,\n\t\t\t\t\t\t\t\t\t\ttrandate,\n\t\t\t\t\t\t\t\t\t\tperiodno,\n\t\t\t\t\t\t\t\t\t\taccount,\n\t\t\t\t\t\t\t\t\t\tnarrative,\n\t\t\t\t\t\t\t\t\t\tamount )\n\t\t\t\t\t\t\t\t\tVALUES (22,\n\t\t\t\t\t\t\t\t\t\t'" . $SuppPaymentNo . "',\n\t\t\t\t\t\t\t\t\t\t'" . FormatDateForSQL($_POST['AmountsDueBy']) . "',\n\t\t\t\t\t\t\t\t\t\t'" . $PeriodNo . "',\n\t\t\t\t\t\t\t\t\t\t'" . $_SESSION['CompanyRecord']['purchasesexchangediffact'] . "',\n\t\t\t\t\t\t\t\t\t\t'" . $SupplierID . ' - ' . $SupplierName . ' ' . _('payment run on') . ' ' . Date($_SESSION['DefaultDateFormat']) . " - " . $PaytReference . "',\n\t\t\t\t\t\t\t\t\t\t'" . -$AccumDiffOnExch . "')";
$ProcessResult = DB_query($SQL, $db, '', '', false, false);
if (DB_error_no($db) != 0) {
$Title = _('Payment Processing - Problem Report');
include 'header.inc';
prnMsg(_('None of the payments will be processed since the general ledger posting for the exchange difference on') . ' ' . $SupplierName . ' ' . _('could not be inserted because') . ' - ' . DB_error_msg($db), 'error');
echo '<br /><a href="' . $RootPath . '/index.php">' . _('Back to the menu') . '</a>';
if ($debug == 1) {
prnMsg(_('The SQL that failed was: ') . '<br />' . $SQL, 'error');
}
$ProcessResult = DB_Txn_Rollback($db);
include 'footer.inc';
exit;
}
}
EnsureGLEntriesBalance(22, $SuppPaymentNo, $db);
}
/*end if GL linked to creditors */
}
$YPos -= 1.5 * $line_height;
$pdf->line($Left_Margin, $YPos + $line_height, $Page_Width - $Right_Margin, $YPos + $line_height);
$YPos -= $line_height;
if ($YPos < $Bottom_Margin + $line_height) {
$PageNumber++;
include 'PDFPaymentRunPageHeader.inc';
}
示例9: gltrans
if ($BatchReceiptsTotal != 0) {
/* Bank account entry first */
$SQL = "INSERT INTO gltrans (type,\n\t\t\t\t\t\t\t\t\t\ttypeno,\n\t\t\t\t\t\t\t\t\t\ttrandate,\n\t\t\t\t\t\t\t\t\t\tperiodno,\n\t\t\t\t\t\t\t\t\t\taccount,\n\t\t\t\t\t\t\t\t\t\tnarrative,\n\t\t\t\t\t\t\t\t\t\tamount)\n\t\t\t\tVALUES (\n\t\t\t\t\t12,\n\t\t\t\t\t'" . $_SESSION['ReceiptBatch']->BatchNo . "',\n\t\t\t\t\t'" . FormatDateForSQL($_SESSION['ReceiptBatch']->DateBanked) . "',\n\t\t\t\t\t'" . $PeriodNo . "',\n\t\t\t\t\t'" . $_SESSION['ReceiptBatch']->Account . "',\n\t\t\t\t\t'" . $_SESSION['ReceiptBatch']->Narrative . "',\n\t\t\t\t\t'" . $BatchReceiptsTotal . "'\n\t\t\t\t)";
$DbgMsg = _('The SQL that failed to insert the GL transaction fro the bank account debit was');
$ErrMsg = _('Cannot insert a GL transaction for the bank account debit');
$result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
}
if ($BatchDiscount != 0) {
/* Now Debit Discount account with discounts allowed*/
$SQL = "INSERT INTO gltrans ( type,\n\t\t\t\t\t\t\t\t\t\ttypeno,\n\t\t\t\t\t\t\t\t\t\ttrandate,\n\t\t\t\t\t\t\t\t\t\tperiodno,\n\t\t\t\t\t\t\t\t\t\taccount,\n\t\t\t\t\t\t\t\t\t\tnarrative,\n\t\t\t\t\t\t\t\t\t\tamount)\n\t\t\t\t\t\tVALUES (\n\t\t\t\t\t\t\t\t12,\n\t\t\t\t\t\t\t\t'" . $_SESSION['ReceiptBatch']->BatchNo . "',\n\t\t\t\t\t\t\t\t'" . FormatDateForSQL($_SESSION['ReceiptBatch']->DateBanked) . "',\n\t\t\t\t\t\t\t\t'" . $PeriodNo . "',\n\t\t\t\t\t\t\t\t'" . $_SESSION['CompanyRecord']['pytdiscountact'] . "',\n\t\t\t\t\t\t\t\t'" . $_SESSION['ReceiptBatch']->Narrative . "',\n\t\t\t\t\t\t\t\t'" . $BatchDiscount . "'\n\t\t\t\t\t\t\t)";
$DbgMsg = _('The SQL that failed to insert the GL transaction for the payment discount debit was');
$ErrMsg = _('Cannot insert a GL transaction for the payment discount debit');
$result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
}
//end if there is some discount
EnsureGLEntriesBalance(12, $_SESSION['ReceiptBatch']->BatchNo, $db);
}
//end if there is GL work to be done - ie config is to link to GL
$ErrMsg = _('Cannot commit the changes');
$DbgMsg = _('The SQL that failed was');
$result = DB_Txn_Commit($db);
echo '<br />';
prnMsg(_('Receipt batch') . ' ' . $_SESSION['ReceiptBatch']->BatchNo . ' ' . _('has been successfully entered into the database'), 'success');
echo '<p class="page_title_text noPrint" ><img src="' . $RootPath . '/css/' . $Theme . '/images/printer.png" title="' . _('Print') . '" alt="" />' . ' ' . '<a href="' . $RootPath . '/PDFBankingSummary.php?BatchNo=' . $_SESSION['ReceiptBatch']->BatchNo . '">' . _('Print PDF Batch Summary') . '</a></p>';
echo '<p class="page_title_text noPrint" ><img src="' . $RootPath . '/css/' . $Theme . '/images/allocation.png" title="' . _('Allocate') . '" alt="" />' . ' ' . '<a href="' . $RootPath . '/CustomerAllocations.php">' . _('Allocate Receipts') . '</a></p>';
echo '<p class="page_title_text noPrint" ><a href="' . $RootPath . '/CustomerReceipt.php?NewReceipt=Yes&Type=Customer">' . _('Enter Receipts') . '</a>
</p>';
unset($_SESSION['ReceiptBatch']);
include 'includes/footer.inc';
exit;
}
示例10: GetNextTransNo
/*Also if GL is linked to debtors need to process the debit to bank and credit to debtors for the payment */
/*Need to figure out the cross rate between customer currency and bank account currency */
if ($_POST['AmountPaid'] != 0) {
$PaymentNumber = GetNextTransNo(12, $db);
$SQL = "INSERT INTO gltrans (type,\r\n\t\t\t\t\t\t\t\t\t\t\ttypeno,\r\n\t\t\t\t\t\t\t\t\t\t\ttrandate,\r\n\t\t\t\t\t\t\t\t\t\t\tperiodno,\r\n\t\t\t\t\t\t\t\t\t\t\taccount,\r\n\t\t\t\t\t\t\t\t\t\t\tnarrative,\r\n\t\t\t\t\t\t\t\t\t\t\tamount)\r\n\t\t\t\t\t\tVALUES (12,\r\n\t\t\t\t\t\t\t'" . $PaymentNumber . "',\r\n\t\t\t\t\t\t\t'" . $ReturnDate . "',\r\n\t\t\t\t\t\t\t'" . $PeriodNo . "',\r\n\t\t\t\t\t\t\t'" . $_POST['BankAccount'] . "',\r\n\t\t\t\t\t\t\t'" . $_SESSION['Items' . $identifier]->LocationName . ' ' . _('Counter Return') . ' ' . $CreditNoteNo . "',\r\n\t\t\t\t\t\t\t'" . -(filter_number_format($_POST['AmountPaid']) / $ExRate) . "')";
$DbgMsg = _('The SQL that failed to insert the GL transaction for the bank account debit was');
$ErrMsg = _('Cannot insert a GL transaction for the bank account debit');
$result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
/* Now Debit Debtors account with negative receipt/payment to customer */
$SQL = "INSERT INTO gltrans ( type,\r\n\t\t\t\t\t\ttypeno,\r\n\t\t\t\t\t\ttrandate,\r\n\t\t\t\t\t\tperiodno,\r\n\t\t\t\t\t\taccount,\r\n\t\t\t\t\t\tnarrative,\r\n\t\t\t\t\t\tamount)\r\n\t\t\t\tVALUES (12,\r\n\t\t\t\t\t'" . $PaymentNumber . "',\r\n\t\t\t\t\t'" . $ReturnDate . "',\r\n\t\t\t\t\t'" . $PeriodNo . "',\r\n\t\t\t\t\t'" . $_SESSION['CompanyRecord']['debtorsact'] . "',\r\n\t\t\t\t\t'" . $_SESSION['Items' . $identifier]->LocationName . ' ' . _('Counter Return') . ' ' . $CreditNoteNo . "',\r\n\t\t\t\t\t'" . filter_number_format($_POST['AmountPaid']) / $ExRate . "')";
$DbgMsg = _('The SQL that failed to insert the GL transaction for the debtors account credit was');
$ErrMsg = _('Cannot insert a GL transaction for the debtors account credit');
$result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
}
//amount paid was not zero
EnsureGLEntriesBalance(12, $PaymentNumber, $db);
}
/*end of if Sales and GL integrated */
if ($_POST['AmountPaid'] != 0) {
if (!isset($PaymentNumber)) {
$PaymentNumber = GetNextTransNo(12, $db);
}
//Now need to add the receipt banktrans record
//First get the account currency that it has been banked into
$result = DB_query("SELECT rate FROM currencies\r\n\t\t\t\t\t\t\t\tINNER JOIN bankaccounts\r\n\t\t\t\t\t\t\t\tON currencies.currabrev=bankaccounts.currcode\r\n\t\t\t\t\t\t\t\tWHERE bankaccounts.accountcode='" . $_POST['BankAccount'] . "'", $db);
$myrow = DB_fetch_row($result);
$BankAccountExRate = $myrow[0];
/*
* Some interesting exchange rate conversion going on here
* Say :
* The business's functional currency is NZD