本文整理汇总了PHP中vatr函数的典型用法代码示例。如果您正苦于以下问题:PHP vatr函数的具体用法?PHP vatr怎么用?PHP vatr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了vatr函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: cwrite
//.........这里部分代码省略.........
$sql = "INSERT INTO cubit.nons_inv_items (invid, qty, description,\r\n\t\t\tdiv, amt, unitcost, vatex, accid, asset_id)\r\n\t\tVALUES ('{$invid}', '{$item_data['qty']}',\r\n\t\t\t'{$item_data['description']}', '{$item_data['div']}', '{$item_data['amt']}',\r\n\t\t\t'{$item_data['amt']}', '2', '{$item_data['accid']}', '{$item_data['asset_id']}')";
db_exec($sql) or errDie("Unable to add non stock items.");
$sql = "UPDATE hire.assets_hired SET return_time=CURRENT_TIMESTAMP,\r\n\t\t\t\t\tinv_invnum='{$real_invid}', value='{$item_data['amt']}'\r\n\t\t\t\tWHERE item_id='{$item_data['item_id']}'";
db_exec($sql) or errDie("Unable to record asset return time.");
}
// Add the delivery discount to the total revenue
if ($inv["delivery"]) {
$discount = $inv["delivery"] / 100 * $traddisc;
$sql = "INSERT INTO hire.revenue (discount)\r\n\t\t\t\tVALUES ('{$discount}')";
db_exec($sql) or errDie("Unable to update revenue");
}
$cc = "<script> CostCenter('dt', 'Sales', '{$inv['odate']}', 'Non Stock Invoice No.{$real_invid}', '" . ($TOTAL - $VAT) . "', ''); </script>";
db_conn('cubit');
$Sl = "SELECT * FROM settings WHERE constant='SALES'";
$Ri = db_exec($Sl) or errDie("Unable to get settings.");
$data = pg_fetch_array($Ri);
if ($data['value'] == "Yes") {
$sp = "<tr><td><b>Sales Person:</b> {$inv['salespn']}</td></tr>";
} else {
$sp = "";
}
if ($inv['chrgvat'] == "yes") {
$inv['chrgvat'] = "Inclusive";
} elseif ($inv['chrgvat'] == "no") {
$inv['chrgvat'] = "Exclusive";
} else {
$inv['chrgvat'] = "No vat";
}
if ($inv["remarks"] == "") {
db_conn("cubit");
$sql = "SELECT value FROM settings WHERE constant='DEFAULT_COMMENTS'";
$commRslt = db_exec($sql) or errDie("Unable to retrieve the default comments from Cubit.");
$inv["remarks"] = pg_fetch_result($commRslt, 0);
}
if (!isset($showvat)) {
$showvat = TRUE;
}
if ($showvat == TRUE) {
$vat14 = AT14;
} else {
$vat14 = "";
}
// Retrieve the company information
db_conn("cubit");
$sql = "SELECT * FROM compinfo";
$comp_rslt = db_exec($sql) or errDie("Unable to retrieve company information from Cubit.");
$comp_data = pg_fetch_array($comp_rslt);
// Retrieve the banking information
db_conn("cubit");
$sql = "SELECT * FROM bankacct WHERE bankid='2' AND div='" . USER_DIV . "'";
$bank_rslt = db_exec($sql) or errDie("Unable to retrieve bank information from Cubit.");
$bank_data = pg_fetch_array($bank_rslt);
$table_borders = "\r\n\t\tborder-top: 2px solid #000000;\r\n\t\tborder-left: 2px solid #000000;\r\n\t\tborder-right: 2px solid #000000;\r\n\t\tborder-bottom: none;\r\n\t";
// $nolr_borders = "
// border-top: 2px solid #000;
// border-left: none;
// border-right: none;
// border-bottom: none;
// ";
$sql = "UPDATE hire.hire_invoices SET done='y', delivery='0.00'\r\n\t\t\tWHERE invnum='" . getHirenum($inv["hire_invid"]) . "'";
db_exec($sql) or errDie("Unable to update invoices.");
vatr($vd['id'], $td, "OUTPUT", $vd['code'], $refnum, "Non-Stock Sales, invoice No.{$real_invid}", $TOTAL, $inv["vat"]);
$details = "";
$SUBTOT = sprint($totamt);
for ($i = 0; $i <= $page; $i++) {
if ($monthly) {
$monthly_out = "\r\n\t\t\t<tr>\r\n\t\t\t\t<td style='border-right: 2px solid #000'>Invoiced to date " . date("d-m-Y") . "</td>\r\n\t\t\t</tr>";
} else {
$monthly_out = "";
}
// new page?
if ($i > 1) {
$details .= "<br style='page-break-after:always;'>";
}
$products_out = "";
foreach ($products[$i] as $string) {
$products_out .= $string;
}
$details .= "<center>\r\n\t\t<table cellpadding='0' cellspacing='0' width='85%' style='{$table_borders}'>\r\n\t\t\t<tr><td>\r\n\t\t\t<table border='0' cellpadding='2' cellspacing='2' width='100%'>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td align='left' rowspan='2'><img src='../compinfo/getimg.php' width='230' height='47'></td>\r\n\t\t\t\t\t<td align='left' rowspan='2'><font size='5'><b>" . COMP_NAME . "</b></font></td>\r\n\t\t\t\t\t<td align='right'><font size='5'><b>Tax Invoice</b></font></td>\r\n\t\t\t\t</tr>\r\n\t\t\t</table>\r\n\t\t\t</td></tr>\r\n\t\t</table>\r\n\r\n\t\t<table cellpadding='0' cellspacing='0' width='85%' style='{$table_borders}'>\r\n\t\t\t<tr><td valign='top'>\r\n\t\t\t<table cellpadding='2' cellspacing='0' border='0' width='100%'>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td style='border-right: 2px solid #000'>{$comp_data['addr1']} </td>\r\n\t\t\t\t\t<td style='border-right: 2px solid #000'>{$comp_data['paddr1']} </td>\r\n\t\t\t\t</tr>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td style='border-right: 2px solid #000'>{$comp_data['addr2']} </td>\r\n\t\t\t\t\t<td style='border-right: 2px solid #000'>{$comp_data['paddr2']} </td>\r\n\t\t\t\t</tr>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td style='border-right: 2px solid #000'>{$comp_data['addr3']} </td>\r\n\t\t\t\t\t<td style='border-right: 2px solid #000'>{$comp_data['paddr3']} </td>\r\n\t\t\t\t</tr>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td style='border-right: 2px solid #000'>{$comp_data['addr4']} </td>\r\n\t\t\t\t\t<td style='border-right: 2px solid #000'>{$comp_data['postcode']} </td>\r\n\t\t\t\t</tr>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td style='border-right: 2px solid #000'><b>REG:</b> {$comp_data['regnum']}</b> </td>\r\n\t\t\t\t\t<td style='border-right: 2px solid #000'><b>{$bank_data['bankname']}</b> </td>\r\n\t\t\t\t</tr>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td style='border-right: 2px solid #000'><b>VAT REG:</b> {$comp_data['vatnum']} </td>\r\n\t\t\t\t\t<td style='border-right: 2px solid #000'><b>Branch</b> {$bank_data['branchname']} </td>\r\n\t\t\t\t</tr>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td style='border-right: 2px solid #000'><b>Tel:</b> {$comp_data['tel']} </td>\r\n\t\t\t\t\t<td style='border-right: 2px solid #000'><b>Branch Code:</b> {$bank_data['branchcode']} </td>\r\n\t\t\t\t</tr>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td style='border-right: 2px solid #000'><b>Fax:</b> {$comp_data['fax']} </td>\r\n\t\t\t\t\t<td style='border-right: 2px solid #000'><b>Acc Num:</b> {$bank_data['accnum']} </td>\r\n\t\t\t\t</tr>\r\n\t\t\t</table>\r\n\t\t\t</td><td valign='top'>\r\n\t\t\t<table cellpadding='2' cellspacing='0' border='0' width='100%'>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td style='border-right: 2px solid #000'><b>Date</b></td>\r\n\t\t\t\t\t<td><b>Page Number</b></td>\r\n\t\t\t\t</tr>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td style='border-right: 2px solid #000'>{$inv['odate']}</td>\r\n\t\t\t\t\t<td>" . ($i + 1) . "</td>\r\n\t\t\t\t</tr>\r\n\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td style='border-bottom: 2px solid #000; border-right: 2px solid #000'> </td>\r\n\t\t\t\t\t<td style='border-bottom: 2px solid #000'> </td>\r\n\t\t\t\t</tr>\r\n\t\t\t\t<tr><td> </td></tr>\r\n\t\t\t\t<tr><td> </td></tr>\r\n\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td colspan='2'><b>Invoice No:</b> {$real_invid}</td>\r\n\t\t\t\t</tr>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td colspan='2'><b>Hire No:</b> {$hirenum}</td>\r\n\t\t\t\t</tr>\r\n\t\t\t\t{$sp}\r\n\t\t\t</table>\r\n\t\t\t</td></tr>\r\n\t\t</table>\r\n\r\n\t\t<table cellpadding='0' cellspacing='0' width='85%' style='{$table_borders}'>\r\n\t\t\t<tr><td>\r\n\t\t\t<table cellpadding='2' cellspacing='0' border='0' width='100%'>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td align='center'><font size='4'><b>Tax Invoice To:</b></font></td>\r\n\t\t\t\t</tr>\r\n\t\t\t</table>\r\n\t\t\t</td></tr>\r\n\t\t</table>\r\n\r\n\t\t<table cellpadding='0' cellspacing='0' width='85%' style='{$table_borders}'>\r\n\t\t\t<tr><td>\r\n\t\t\t<table cellpadding='2' cellspacing='0' border='0' width='100%'>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td width='33%' style='border-right: 2px solid #000'><b>{$cus['surname']}</b> </td>\r\n\t\t\t\t\t<td width='33%' style='border-right: 2px solid #000'><b>Postal Address</b></td>\r\n\t\t\t\t\t<td width='33%'><b>Delivery Address</td>\r\n\t\t\t\t</tr>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td style='border-right: 2px solid #000'>" . nl2br($cus["addr1"]) . " </td>\r\n\t\t\t\t\t<td style='border-right: 2px solid #000'>" . nl2br($cus["paddr1"]) . " </td>\r\n\t\t\t\t\t<td>" . nl2br($cus["del_addr1"]) . " </td>\r\n\t\t\t\t</tr>\r\n\t\t\t</table>\r\n\t\t\t</td></tr>\r\n\t\t</table>\r\n\r\n\t\t<table cellpadding='0' cellspacing='0' width='85%' style='{$table_borders}'>\r\n\t\t\t<tr><td>\r\n\t\t\t<table cellpadding='2' cellspacing='0' border='0' width='100%'>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td width='33%' style='border-right: 2px solid #000'><b>Customer VAT No:</b> {$inv['cusvatno']}</td>\r\n\t\t\t\t\t<td width='33%'><b>Customer Order No:</b> {$inv['cordno']}</td>\r\n\t\t\t\t</tr>\r\n\t\t\t</table>\r\n\t\t\t</td></tr>\r\n\t\t</table>\r\n\r\n\t\t<table cellpadding='0' cellspacing='0' width='85%' style='{$table_borders}'>\r\n\t\t\t<tr><td>\r\n\t\t\t<table cellpadding='2' cellspacing='0' border='0' width='100%'>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td style='border-bottom: 2px solid #000; border-right: 2px solid #000'><b>Description</b></td>\r\n\t\t\t\t\t<td style='border-bottom: 2px solid #000; border-right: 2px solid #000'><b>Qty</b></td>\r\n\t\t\t\t\t<td style='border-bottom: 2px solid #000; border-right: 2px solid #000'><b>No of Days</b></td>\r\n\t\t\t\t\t<td style='border-bottom: 2px solid #000; border-right: 2px solid #000'><b>Rate</b></td>\r\n\t\t\t\t\t<td style='border-bottom: 2px solid #000;' align='right'><b>Amount</b></td>\r\n\t\t\t\t</tr>\r\n\t\t\t\t{$products_out}\r\n\t\t\t</table>\r\n\t\t\t</td></tr>\r\n\t\t</table>\r\n\r\n\t\t<table cellpadding='0' cellspacing='0' width='85%' style='{$table_borders}'>\r\n\t\t\t<tr><td>\r\n\t\t\t<table cellpadding='2' cellspacing='0' border='0' width='100%'>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td><i>VAT Exempt Indicator: #</i></td>\r\n\t\t\t\t</tr>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td>{$inv['remarks']}</td>\r\n\t\t\t\t</tr>\r\n\t\t\t</table>\r\n\t\t</table>\r\n\r\n\t\t<table cellpadding='0' cellspacing='0' width='85%' style='border: 2px solid #000000'>\r\n\t\t\t<tr><td>\r\n\t\t\t<table cellpadding='2' cellspacing='0' border='0' width='100%'>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td style='border-right: 2px solid #000'><b>Terms:</b> {$inv['terms']} days</b></td>\r\n\t\t\t\t\t<td><b>Subtotal:</b></td>\r\n\t\t\t\t\t<td><b>" . CUR . "{$SUBTOT}</b></td>\r\n\t\t\t\t</tr>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td style='border-right: 2px solid #000'> </td>\r\n\t\t\t\t\t<td><b>Delivery</b></td>\r\n\t\t\t\t\t<td><b>" . CUR . "{$inv['delivery']}</b></td>\r\n\t\t\t\t</tr>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td style='border-right: 2px solid #000'> </td>\r\n\t\t\t\t\t<td><b>Discount</b></td>\r\n\t\t\t\t\t<td><b>" . CUR . "{$inv['discount']}</b></td>\r\n\t\t\t\t</tr>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td style='border-right: 2px solid #000'> </td>\r\n\t\t\t\t\t<td><b>VAT {$vat14}:</b></td>\r\n\t\t\t\t\t<td><b>" . CUR . "{$inv['vat']}</b></td>\r\n\t\t\t\t</tr>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td style='border-right: 2px solid #000'><b>Received in good order by:</b>_____________________</td>\r\n\t\t\t\t\t<td><b>Total Incl VAT:</b></td>\r\n\t\t\t\t\t<td><b>" . CUR . "{$inv['total']}</b></td>\r\n\t\t\t\t</tr>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td style='border-right: 2px solid #000'> </td>\r\n\t\t\t\t<tr>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td style='border-right: 2px solid #000'><b>Date:</b>_____________________</td>\r\n\t\t\t\t</tr>\r\n\t\t\t\t{$monthly_out}\r\n\t\t\t</table>\r\n\t\t</table>\r\n\t\t";
}
$amt = $pcash + $pcheque + $pcc;
$_POST["amt"] = $amt;
$_POST["date"] = $inv["odate"];
recvpayment_write();
$sql = "UPDATE cubit.nons_invoices SET cash='{$pcash}' WHERE invid='{$inv['invid']}'";
db_exec($sql) or errDie("Unable to update cash value.");
pglib_transaction("COMMIT");
// Retrieve the template settings from Cubit
db_conn("cubit");
$sql = "SELECT filename FROM template_settings WHERE template='invoices'";
$tsRslt = db_exec($sql) or errDie("Unable to retrieve template settings from Cubit.");
$template = pg_fetch_result($tsRslt, 0);
if ($template == "invoice-print.php") {
$OUTPUT = "<script> CostCenter('dt', 'Sales', '{$inv['odate']}', 'Non Stock Invoice No.{$real_invid}', '" . ($TOTAL - $VAT) . "', '');</script>\r\n\t\t\t{$details}";
require "../tmpl-print.php";
} else {
$OUTPUT = "<script> CostCenter('dt', 'Sales', '{$inv['odate']}', 'Non Stock Invoice No.{$real_invid}', '" . ($TOTAL - $VAT) . "', '');\r\n\t\tmove (\"../{$template}?invid={$inv['invid']}&type=nons\");\r\n\t\t</script>";
require "template.php";
}
}
开发者ID:andrecoetzee,项目名称:accounting-123.com,代码行数:101,代码来源:hire-nons-invoice-print.php
示例2: write
function write($_POST)
{
# Get vars
extract($_POST);
# validate input
require_lib("validate");
$v = new validate();
foreach ($bank as $key => $value) {
$v->isOk($batchid[$key], "num", 1, 10, "Invalid Batch ID.[{$key}]");
$v->isOk($ctaccid[$key], "num", 1, 50, "Invalid Account to be Credited.[{$key}]");
$v->isOk($dtaccid[$key], "num", 1, 50, "Invalid Account to be Debited.[{$key}]");
$v->isOk($refnum[$key], "num", 1, 10, "Invalid Reference number.[{$key}]");
$v->isOk($amount[$key], "float", 1, 20, "Invalid Amount.[{$key}]");
$v->isOk($descript[$key], "string", 0, 255, "Invalid Details.[{$key}]");
$datea = explode("-", $date[$key]);
if (count($datea) == 3) {
if (!checkdate($datea[1], $datea[2], $datea[0])) {
$v->isOk($date[$key], "num", 1, 1, "Invalid date.");
}
} else {
$v->isOk($date[$key], "num", 1, 1, "Invalid date.");
}
}
# display errors, if any
if ($v->isError()) {
$write = "";
$errors = $v->getErrors();
foreach ($errors as $e) {
$write .= "<li class='err'>" . $e["msg"] . "</li>";
}
$write .= "<p><input type='button' onClick='JavaScript:history.back();' value='« Correct submission'>";
return $write;
}
foreach ($bank as $key => $value) {
// Accounts details
$dtaccRs = get("core", "accname, topacc, accnum", "accounts", "accid", $dtaccid[$key]);
$dtacc[$key] = pg_fetch_array($dtaccRs);
$ctaccRs = get("core", "accname, topacc, accnum", "accounts", "accid", $ctaccid[$key]);
$ctacc[$key] = pg_fetch_array($ctaccRs);
}
// Start layout
$write = "\n\t\t\t\t<center>\n\t\t\t\t<h3>Journal transactions have been recorded</h3>\n\t\t\t\t<table " . TMPL_tblDflts . ">\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<th>Date</th>\n\t\t\t\t\t\t<th>Ref num</th>\n\t\t\t\t\t\t<th>Debit</th>\n\t\t\t\t\t\t<th>Credit</th>\n\t\t\t\t\t\t<th>Amount</th>\n\t\t\t\t\t\t<th>Description</th>\n\t\t\t\t\t\t<th>VAT Amount</th>\n\t\t\t\t\t\t<th>Total Transaction Amount</th>\n\t\t\t\t\t</tr>";
$cc = "";
foreach ($bank as $key => $value) {
$write .= "\n\t\t\t\t\t\t<tr bgcolor=" . bgcolorg() . ">\n\t\t\t\t\t\t\t<td>{$date[$key]}</td>\n\t\t\t\t\t\t\t<td>{$refnum[$key]}</td>\n\t\t\t\t\t\t\t<td valign='center'>" . $dtacc[$key]['topacc'] . "/" . $dtacc[$key]['accnum'] . " " . $dtacc[$key]['accname'] . "</td>\n\t\t\t\t\t\t\t<td valign='center'>" . $ctacc[$key]['topacc'] . "/" . $ctacc[$key]['accnum'] . " " . $ctacc[$key]['accname'] . "</td>\n\t\t\t\t\t\t\t<td>" . CUR . " {$amount[$key]}</td>\n\t\t\t\t\t\t\t<td>{$descript[$key]}</td>";
if (isset($chrgvat[$value])) {
$datea = explode("-", $date[$key]);
$cdate = "{$datea['2']}-{$datea['1']}-{$datea['0']}";
$vataccRs = get("core", "*", "accounts", "accid", $vataccid[$value]);
$vatacc = pg_fetch_array($vataccRs);
$vataccRs = get("core", "*", "accounts", "accid", $vatdedacc[$value]);
$vdedacc = pg_fetch_array($vataccRs);
//$VATP = TAX_VAT;
db_conn('cubit');
$Sl = "SELECT * FROM vatcodes WHERE id='{$vatcodes[$key]}'";
$Ri = db_exec($Sl);
$vd = pg_fetch_array($Ri);
$VATP = $vd['vat_amount'];
# if vat must be charged
if ($vatinc[$value] == "no") {
$vatamt[$value] = sprint($VATP / 100 * $amount[$key]);
$amt[$key] = sprint($amount[$key]);
$totamt = sprint($amount[$key] + $vatamt[$value]);
} else {
$vatamt[$value] = sprint($amount[$key] / ($VATP + 100) * $VATP);
$amt[$key] = sprint($amount[$key] - $vatamt[$value]);
$totamt = sprint($amount[$key]);
}
# Check VAt Deductable account
if ($vatdedacc[$value] == $dtaccid[$key]) {
db_connect();
$Sl = "SELECT * FROM vatcodes WHERE id='{$vatcodes[$key]}'";
$Ri = db_exec($Sl);
if (pg_num_rows($Ri) < 1) {
return "Please select the vatcode";
}
$vd = pg_fetch_array($Ri);
vatr($vd['id'], $date[$key], "INPUT", $vd['code'], $refnum[$key], "{$descript[$key]} VAT", -$totamt, -$vatamt[$value]);
writetrans($vataccid[$value], $ctaccid[$key], $date[$key], $refnum[$key], $vatamt[$value], $descript[$key] . " VAT");
writetrans($dtaccid[$key], $ctaccid[$key], $date[$key], $refnum[$key], $amt[$key], $descript[$key]);
} elseif ($vatdedacc[$value] == $ctaccid[$key]) {
db_connect();
$Sl = "SELECT * FROM vatcodes WHERE id='{$vatcodes[$key]}'";
$Ri = db_exec($Sl);
if (pg_num_rows($Ri) < 1) {
return "Please select the vatcode";
}
$vd = pg_fetch_array($Ri);
vatr($vd['id'], $date[$key], "OUTPUT", $vd['code'], $refnum[$key], "{$descript[$key]} VAT", $totamt, $vatamt[$value]);
writetrans($dtaccid[$key], $vataccid[$value], $date[$key], $refnum[$key], $vatamt[$value], $descript[$key] . " VAT");
writetrans($dtaccid[$key], $ctaccid[$key], $date[$key], $refnum[$key], $amt[$key], $descript[$key]);
}
$write .= "\n\t\t\t\t\t\t\t<td align='right'>" . CUR . " {$vatamt[$value]}</td>\n\t\t\t\t\t\t\t<td align='right'>" . CUR . " {$totamt}</td>";
} else {
$totamt[$key] = sprint($amount[$key]);
# Write normal transaction
writetrans($dtaccid[$key], $ctaccid[$key], $date[$key], $refnum[$key], $totamt[$key], $descript[$key]);
$write .= "<td>0</td><td>" . CUR . " {$totamt[$key]}</td>";
}
$write .= "</tr>";
//.........这里部分代码省略.........
开发者ID:kumarsivarajan,项目名称:accounting-123,代码行数:101,代码来源:batch-procs.php
示例3: write
//.........这里部分代码省略.........
$group_id = pg_fetch_result($group_rslt, 0);
$discount = $inv["discount"] / $item_count;
$amt = $item_data["amt"];
// Update royalty report and detail report
$sql = "\r\n\t\t\tINSERT INTO hire.revenue (\r\n\t\t\t\tgroup_id, asset_id, total, discount, credit\r\n\t\t\t) VALUES (\r\n\t\t\t\t'{$group_id}', '{$item_data['asset_id']}', '-{$amt}', '-{$discount}', '1'\r\n\t\t\t)";
db_exec($sql) or errDie("Unable to update revenue.");
$i++;
}
$blank_lines = 25;
foreach ($products as $key => $val) {
$bl = $blank_lines - count($products[$key]);
for ($i = 0; $i <= $bl; $i++) {
$products[$key][] = "\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td style='border-right: 2px solid #000'> </td>\r\n\t\t\t\t\t<td style='border-right: 2px solid #000'> </td>\r\n\t\t\t\t\t<td style='border-right: 2px solid #000'> </td>\r\n\t\t\t\t\t<td> </td>\r\n\t\t\t\t</tr>";
}
}
// Retrieve customer debt account
$sql = "\r\n\t\tSELECT debtacc FROM exten.departments \r\n\t\t\tLEFT JOIN cubit.customers ON departments.deptid=customers.deptid\r\n\t\tWHERE cusnum='{$inv['cusid']}'";
$dept_rslt = db_exec($sql) or errDie("Unable to retrieve departments.");
$debtacc = pg_fetch_result($dept_rslt, 0);
$hireacc = $inv["accid"];
$vatacc = gethook("accnum", "salesacc", "name", "VAT", "vat");
$refnum = getrefnum();
writetrans($hireacc, $debtacc, $sndate, $refnum, $inv["subtot"], "Non-Stock Invoice No. {$inv['invnum']} Credit Note No. {$noteid} Customer\r\n\t\t{$inv['cusname']}");
if ($inv["vat"] != 0) {
writetrans($vatacc, $debtacc, $sndate, $refnum, $inv["vat"], "Non-Stock Invoice No. {$inv['invnum']} Credit Note No. {$noteid} VAT.\r\n\t\tCustomer {$inv['cusname']}");
}
// Record on the statement
$sql = "\r\n\t\tINSERT INTO cubit.stmnt (\r\n\t\t\tcusnum, invid, amount, date, type, \r\n\t\t\tdiv\r\n\t\t) VALUES (\r\n\t\t\t'{$inv['cusid']}', '{$noteid}', '-{$TOTAL}', '{$sndate}', 'Non-Stock Credit Note, for invoice {$inv['invnum']}', \r\n\t\t\t'" . USER_DIV . "'\r\n\t\t)";
db_exec($sql) or errDie("Unable to insert to customer statement.");
// Update the customer (Make the balance less)
$sql = "UPDATE cubit.customers SET balance=(balance-'{$TOTAL}') WHERE cusnum='{$inv['cusid']}'";
db_exec($sql) or errDie("Unable to update customer balance.");
// Update the customer (Make the balance less)
$sql = "UPDATE cubit.open_stmnt SET balance=(balance-'{$TOTAL}') WHERE cusnum='{$inv['cusid']}'";
db_exec($sql) or errDie("Unable to update customer balance.");
// Create ledger record
custledger($inv["cusid"], $hireacc, $sndate, $noteid, "Non-Stock Credit Note {$noteid}", $TOTAL, "c");
custCT($inv["total"], $inv["cusid"], $inv["odate"]);
// Update non-stock invoice
$sql = "UPDATE cubit.nons_invoices SET balance=(balance-'{$TOTAL}') WHERE invid='{$invid}'";
db_exec($sql) or errDie("Unable to update non-stock invoice.");
$sql = "\r\n\t\tINSERT INTO cubit.salesrec (\r\n\t\t\tedate, invid, invnum, debtacc, vat, total, typ, div\r\n\t\t) VALUES (\r\n\t\t\t'{$sndate}', '{$noteid}', '{$notenum}', '0', '{$inv['vat']}', '{$TOTAL}', 'nnon', '" . USER_DIV . "'\r\n\t\t)";
db_exec($sql) or errDie("Unable to record in sales.");
$sql = "\r\n\t\tINSERT INTO cubit.sj (\r\n\t\t\tcid, name, des, date, \r\n\t\t\texl, vat, inc, div\r\n\t\t) VALUES (\r\n\t\t\t'{$inv['cusid']}', '{$inv['cusname']}', 'Credit Note: {$noteid} Invoice {$inv['invnum']}', '{$sndate}', \r\n\t\t\t'-" . ($TOTAL - $inv["vat"]) . "', '{$inv['vat']}', '" . -sprint($TOTAL) . "', '" . USER_DIV . "'\r\n\t\t)";
db_exec($sql) or errDie("Unable to record in sj.");
$sql = "UPDATE cubit.nons_invoices SET accepted='note' WHERE invid='{$invid}'";
db_exec($sql) or errDie("Unable to update invoice.");
com_invoice($inv["salespn"], -($TOTAL - $inv["vat"]), 0, $inv["invnum"], $sndate);
$cc = "\r\n\t\t<script>\r\n\t\t\tCostCenter('ct', 'Credit Note', '{$sndate}',\r\n\t\t\t'Non Stock Credit Note No.{$noteid}', '" . ($TOTAL - $inv["vat"]) . "', '');\r\n\t </script>";
// Reverse the amounts on the coastal reports -----------------------------
$sql = "UPDATE hire.assets_hired SET value=0 WHERE invid='{$inv['hire_invid']}'";
db_exec($sql) or errDie("Unable to update asset hired records.");
// Vat
$sql = "SELECT id FROM cubit.vatcodes WHERE code='01'";
$vd_rslt = db_exec($sql) or errDie("Unable to retrieve vatcodes.");
$vd_id = pg_fetch_result($vd_rslt, 0);
vatr($vd_id, $sndate, "OUTPUT", "01", $refnum, "Non-Stock Sales, invoice No.{$inv['invnum']}", $TOTAL, $inv["vat"]);
if (!isset($showvat)) {
$showvat = TRUE;
}
if ($showvat == TRUE) {
$vat14 = AT14;
} else {
$vat14 = "";
}
// Retrieve the company information
db_conn("cubit");
$sql = "SELECT * FROM compinfo";
$comp_rslt = db_exec($sql) or errDie("Unable to retrieve company.");
$comp_data = pg_fetch_array($comp_rslt);
// Retrieve the banking information
$sql = "SELECT * FROM bankacct WHERE bankid='2' AND div='" . USER_DIV . "'";
$bank_rslt = db_exec($sql) or errDie("Unable to retrieve bank.");
$bank_data = pg_fetch_array($bank_rslt);
// Retrieve customer information
$sql = "SELECT * FROM customers WHERE cusnum='{$inv['cusid']}'";
$cust_rslt = db_exec($sql) or errDie("Unable to retrieve customer.");
$cust_data = pg_fetch_array($cust_rslt);
if ($inv['cusid'] == "0") {
$cust_data['surname'] = $inv['cusname'];
$cust_data['addr1'] = $inv['cusaddr'];
$cust_data['paddr1'] = $inv['cusaddr'];
}
$table_borders = "\r\n\t\tborder-top: 2px solid #000000;\r\n\t\tborder-left: 2px solid #000000;\r\n\t\tborder-right: 2px solid #000000;\r\n\t\tborder-bottom: none;";
$details = "";
for ($i = 0; $i <= $page; $i++) {
// new page?
if ($i > 1) {
$details .= "<br style='page-break-after:always;'>";
}
$products_out = "";
foreach ($products[$i] as $string) {
$products_out .= $string;
}
$details .= "\r\n\t\t\t<center>\r\n\t\t\t<table cellpadding='0' cellspacing='0' width='85%' style='{$table_borders}'>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td>\r\n\t\t\t\t\t\t<table border='0' cellpadding='2' cellspacing='2' width='100%'>\r\n\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t<td align='left' rowspan='2'><img src='../compinfo/getimg.php' width='230' height='47'></td>\r\n\t\t\t\t\t\t\t\t<td align='left' rowspan='2'><font size='5'><b>" . COMP_NAME . "</b></font></td>\r\n\t\t\t\t\t\t\t\t<td align='right'><font size='5'><b>Tax Credit Note</b></font></td>\r\n\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t</table>\r\n\t\t\t\t\t</td>\r\n\t\t\t\t</tr>\r\n\t\t\t</table>\r\n\r\n\t\t\t<table cellpadding='0' cellspacing='0' width='85%' style='{$table_borders}'>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td valign='top'>\r\n\t\t\t\t\t\t<table cellpadding='2' cellspacing='0' border='0' width='100%'>\r\n\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t<td style='border-right: 2px solid #000'>{$comp_data['addr1']} </td>\r\n\t\t\t\t\t\t\t\t<td style='border-right: 2px solid #000'>{$comp_data['paddr1']} </td>\r\n\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t<td style='border-right: 2px solid #000'>{$comp_data['addr2']} </td>\r\n\t\t\t\t\t\t\t\t<td style='border-right: 2px solid #000'>{$comp_data['paddr2']} </td>\r\n\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t<td style='border-right: 2px solid #000'>{$comp_data['addr3']} </td>\r\n\t\t\t\t\t\t\t\t<td style='border-right: 2px solid #000'>{$comp_data['paddr3']} </td>\r\n\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t<td style='border-right: 2px solid #000'>{$comp_data['addr4']} </td>\r\n\t\t\t\t\t\t\t\t<td style='border-right: 2px solid #000'>{$comp_data['postcode']} </td>\r\n\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t<td style='border-right: 2px solid #000'><b>REG:</b> {$comp_data['regnum']}</b> </td>\r\n\t\t\t\t\t\t\t\t<td style='border-right: 2px solid #000'><b>{$bank_data['bankname']}</b> </td>\r\n\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t<td style='border-right: 2px solid #000'><b>VAT REG:</b> {$comp_data['vatnum']} </td>\r\n\t\t\t\t\t\t\t\t<td style='border-right: 2px solid #000'><b>Branch</b> {$bank_data['branchname']} </td>\r\n\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t<td style='border-right: 2px solid #000'><b>Tel:</b> {$comp_data['tel']} </td>\r\n\t\t\t\t\t\t\t\t<td style='border-right: 2px solid #000'><b>Branch Code:</b> {$bank_data['branchcode']} </td>\r\n\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t<td style='border-right: 2px solid #000'><b>Fax:</b> {$comp_data['fax']} </td>\r\n\t\t\t\t\t\t\t\t<td style='border-right: 2px solid #000'><b>Acc Num:</b> {$bank_data['accnum']} </td>\r\n\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t</table>\r\n\t\t\t\t\t</td>\r\n\t\t\t\t\t<td valign='top'>\r\n\t\t\t\t\t\t<table cellpadding='2' cellspacing='0' border='0' width='100%'>\r\n\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t<td style='border-right: 2px solid #000'><b>Date</b></td>\r\n\t\t\t\t\t\t\t\t<td><b>Page Number</b></td>\r\n\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t<td style='border-right: 2px solid #000'>{$inv['odate']}</td>\r\n\t\t\t\t\t\t\t\t<td>" . ($i + 1) . "</td>\r\n\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t<td style='border-bottom: 2px solid #000; border-right: 2px solid #000'> </td>\r\n\t\t\t\t\t\t\t\t<td style='border-bottom: 2px solid #000'> </td>\r\n\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t<tr><td> </td></tr>\r\n\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t<td colspan='2'><b>Credit Note No:</b> {$noteid}</td>\r\n\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t<td colspan='2'><b>Invoice No:</b> {$inv['invnum']}</td>\r\n\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t<td colspan='2'><b>Proforma Inv No:</b> {$inv['docref']}</td>\r\n\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t</table>\r\n\t\t\t\t\t</td>\r\n\t\t\t\t</tr>\r\n\t\t\t</table>\r\n\r\n\t\t\t<table cellpadding='0' cellspacing='0' width='85%' style='{$table_borders}'>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td>\r\n\t\t\t\t\t\t<table cellpadding='2' cellspacing='0' border='0' width='100%'>\r\n\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t<td align='center'><font size='4'><b>Credit Note To:</b></font></td>\r\n\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t</table>\r\n\t\t\t\t\t</td>\r\n\t\t\t\t</tr>\r\n\t\t\t</table>\r\n\r\n\t\t\t<table cellpadding='0' cellspacing='0' width='85%' style='{$table_borders}'>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td>\r\n\t\t\t\t\t\t<table cellpadding='2' cellspacing='0' border='0' width='100%'>\r\n\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t<td width='33%' style='border-right: 2px solid #000'><b>{$cust_data['surname']}</b></td>\r\n\t\t\t\t\t\t\t\t<td width='33%' style='border-right: 2px solid #000'><b>Postal Address</b></td>\r\n\t\t\t\t\t\t\t\t<td width='33%'><b>Delivery Address</td>\r\n\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t<td style='border-right: 2px solid #000'>" . nl2br($cust_data["addr1"]) . "</td>\r\n\t\t\t\t\t\t\t\t<td style='border-right: 2px solid #000'>" . nl2br($cust_data["paddr1"]) . "</td>\r\n\t\t\t\t\t\t\t\t<td> </td>\r\n\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t</table>\r\n\t\t\t\t\t</td>\r\n\t\t\t\t</tr>\r\n\t\t\t</table>\r\n\r\n\t\t\t<table cellpadding='0' cellspacing='0' width='85%' style='{$table_borders}'>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td>\r\n\t\t\t\t\t\t<table cellpadding='2' cellspacing='0' border='0' width='100%'>\r\n\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t<td width='33%' style='border-right: 2px solid #000'><b>Customer VAT No:</b> {$inv['cusvatno']}</td>\r\n\t\t\t\t\t\t\t\t<td width='33%'><b>Customer Order No:</b> {$inv['cordno']}</td>\r\n\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t</table>\r\n\t\t\t\t\t</td>\r\n\t\t\t\t</tr>\r\n\t\t\t</table>\r\n\r\n\t\t\t<table cellpadding='0' cellspacing='0' width='85%' style='{$table_borders}'>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td>\r\n\t\t\t\t\t\t<table cellpadding='2' cellspacing='0' border='0' width='100%'>\r\n\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t<td style='border-bottom: 2px solid #000; border-right: 2px solid #000'><b>Description</b></td>\r\n\t\t\t\t\t\t\t\t<td style='border-bottom: 2px solid #000; border-right: 2px solid #000'><b>Qty</b></td>\r\n\t\t\t\t\t\t\t\t<td style='border-bottom: 2px solid #000; border-right: 2px solid #000' align='right'><b>Unit Price</b></td>\r\n\t\t\t\t\t\t\t\t<td style='border-bottom: 2px solid #000;' align='right'><b>Amount</b></td>\r\n\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t{$products_out}\r\n\t\t\t\t\t\t</table>\r\n\t\t\t\t\t</td>\r\n\t\t\t\t</tr>\r\n\t\t\t</table>\r\n\r\n\t\t\t<table cellpadding='0' cellspacing='0' width='85%' style='{$table_borders}'>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td>\r\n\t\t\t\t\t\t<table cellpadding='2' cellspacing='0' border='0' width='100%'>\r\n\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t<td><i>VAT Exempt Indicator: #</i></td>\r\n\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t<td>{$remarks}</td>\r\n\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t</table>\r\n\t\t\t\t\t</td>\r\n\t\t\t\t</tr>\r\n\t\t\t</table>\r\n\r\n\t\t\t<table cellpadding='0' cellspacing='0' width='85%' style='border: 2px solid #000000'>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td>\r\n\t\t\t\t\t\t<table cellpadding='2' cellspacing='0' border='0' width='100%'>\r\n\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t<td style='border-right: 2px solid #000'><b>Terms:</b> {$inv['terms']} days</b></td>\r\n\t\t\t\t\t\t\t\t<td><b>Trade Discount:</b></td>\r\n\t\t\t\t\t\t\t\t<td nowrap><b>" . CUR . " {$inv['discount']}</b></td>\r\n\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t<td style='border-right: 2px solid #000'> </td>\r\n\t\t\t\t\t\t\t\t<td><b>Subtotal:</b></td>\r\n\t\t\t\t\t\t\t\t<td nowrap><b>" . CUR . " {$inv['subtot']}</b></td>\r\n\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t<td style='border-right: 2px solid #000'><b>Received in good order by:</b>_____________________</td>\r\n\t\t\t\t\t\t\t\t<td><b>VAT {$vat14}:</b></td>\r\n\t\t\t\t\t\t\t\t<td nowrap><b>" . CUR . " {$inv['vat']}</b></td>\r\n\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t<td style='border-right: 2px solid #000'> </td>\r\n\t\t\t\t\t\t\t\t<td><b>Total Incl VAT:</b></td>\r\n\t\t\t\t\t\t\t\t<td nowrap><b>" . CUR . " " . sprint($TOTAL) . "</b></td>\r\n\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t<td style='border-right: 2px solid #000'><b>Date:</b>_____________________</td>\r\n\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t</table>\r\n\t\t\t\t\t</td>\r\n\t\t\t\t</tr>\r\n\t\t\t</table>";
}
pglib_transaction("COMMIT");
$OUTPUT = $details;
require "../tmpl-print.php";
}
开发者ID:andrecoetzee,项目名称:accounting-123.com,代码行数:101,代码来源:hire-invoice-note.php
示例4: write
//.........这里部分代码省略.........
/* --- Start Products Display --- */
$tot_post = 0;
# Products layout
$products = "";
$resub = 0;
$revat = 0;
foreach ($ids as $key => $id) {
db_conn($prd);
$sql = "SELECT * FROM nons_pur_items WHERE purid = '{$purid}' AND id = '{$id}' AND div = '" . USER_DIV . "'";
$stkdRslt = db_exec($sql);
$stkd = pg_fetch_array($stkdRslt);
$stkacc = $stkd['accid'];
# keep records for transactions
$sql = "UPDATE nons_pur_items SET rqty = (rqty + '{$qtys[$key]}') WHERE id = '{$stkd['id']}'";
$sRslt = db_exec($sql);
# Calculate cost amount bought
$amt[$key] = $qtys[$key] * $unitcost[$key];
/* delivery charge */
# Calculate percentage from subtotal
$perc[$key] = $amt[$key] / $SUBTOTAL * 100;
# Get percentage from shipping charges
$shipc[$key] = $perc[$key] / 100 * $shipchrg;
# add delivery charges
$amt[$key] += $shipc[$key];
/* end delivery charge */
# the subtotal + delivery charges
$resub += $amt[$key];
# calculate vat
$svat[$key] = svat($amt[$key], $stkd['amt'], $stkd['svat']);
db_conn('cubit');
$Sl = "SELECT * FROM vatcodes WHERE id='{$stkd['vatcode']}'";
$Ri = db_exec($Sl) or errDie("Unable to get data.");
$vd = pg_fetch_array($Ri);
vatr($vd['id'], $td, "INPUT", $vd['code'], $refnum, "VAT for Non-Stock purchase No. {$inv['purnum']} returned", $amt[$key], $svat[$key]);
# received vat
$revat += $svat[$key];
# make amount vat free
// if($inv['vatinc'] == "yes"){
// $amt[$key] = ($amt[$key] - $svat[$key]);
// }
$amts[$key] = $stkd['unitcost'] * $qtys[$key];
$nv = sprint($stkd['svat'] / $stkd['qty'] * $qtys[$key]);
if ($inv['vatinc'] != "no") {
$aev = $amts[$key] - $nv;
} else {
$aev = $amts[$key];
}
$stkd['accid'] += 0;
db_conn('cubit');
$sql = "\n\t\t\tINSERT INTO nons_pur_itemsn (\n\t\t\t\tnoteid, qty, description, amt, unitcost, svat, div, \n\t\t\t\tcod, des, ddate, accid\n\t\t\t) VALUES (\n\t\t\t\t'{$noteid}', '{$qtys[$key]}', '{$stkd['des']}', '{$amts[$key]}', '{$stkd['unitcost']}', '{$stkd['svat']}', '" . USER_DIV . "', \n\t\t\t\t'{$stkd['cod']}', '{$stkd['des']}', '{$stkd['ddate']}', '{$stkd['accid']}'\n\t\t\t)";
$stkdRslt = db_exec($sql) or errDie("Unable to insert note items.");
if ($inv['ctyp'] == 'ac') {
$dept['credacc'] = $inv['mpurid'];
}
//$sql = "INSERT INTO nons_pur_itemsn(noteid, cod, des, qty, unitcost, amt, svat, ddate, accid, div) VALUES('$nid', '$stktc[cod]', '$stktc[des]', '$qtys[$key]', '$stktc[unitcost]', '$stktc[amt]', '$stktc[svat]', '$stktc[ddate]', '$stktc[accid]', '".USER_DIV."')";
if ($inv['spurprd'] == 0) {
$tot_post += $aev;
writetrans($dept['credacc'], $stkacc, $td, $refnum, $aev, "Non-Stock purchase No. {$inv['purnum']} returned, Supplier {$inv['supplier']}.");
}
}
$supacc = $dept['credacc'];
$tot_post = 0;
$pur = $inv;
if ($inv['spurprd'] > 0) {
$retot = $TOTAL;
$vatamt = $VAT;
开发者ID:andrecoetzee,项目名称:accounting-123.com,代码行数:67,代码来源:nons-purch-return.php
示例5: write
function write($_POST)
{
extract($_POST);
if (isset($back)) {
unset($_POST["back"]);
return enter($_POST);
}
# CHECK IF THIS DATE IS IN THE BLOCKED RANGE
$blocked_date_from = getCSetting("BLOCKED_FROM");
$blocked_date_to = getCSetting("BLOCKED_TO");
# validate input
require_lib("validate");
$v = new validate();
$v->isOk($bankid, "num", 1, 20, "Invalid Bank ID.");
foreach ($amount as $key => $value) {
# check all vars
$v->isOk($to[$key], "string", 1, 255, "Invalid receipient/depositor.");
$v->isOk($trantype[$key], "string", 1, 20, "Invalid transaction type.");
$v->isOk($descript[$key], "string", 0, 255, "Invalid description.");
$v->isOk($ref[$key], "string", 0, 255, "Invalid reference <b>[{$key}]</b>.");
$v->isOk($cheqnum[$key], "num", 0, 20, "Invalid cheque number <b>[{$key}]</b>.");
$v->isOk($amount[$key], "float", 1, 8, "Invalid amount <b>[{$key}]</b>.");
$v->isOk($accinv[$key], "num", 1, 20, "Invalid account involved <b>[{$key}]</b>.");
$v->isOk($date[$key], "date", 1, 15, "Invalid date <b>[{$key}]</b>.");
if (strtotime($date[$key]) >= strtotime($blocked_date_from) and strtotime($date[$key]) <= strtotime($blocked_date_to) and !user_is_admin(USER_ID)) {
return "<li class='err'>Period Range Is Blocked. Only an administrator can process entries within this period.</li>";
}
}
# display errors, if any
if ($v->isError()) {
$confirm = "";
$errors = $v->getErrors();
foreach ($errors as $e) {
$confirm .= "<li class='err'>" . $e["msg"] . "</li>";
}
$confirm .= "<p><input type='button' onClick='JavaScript:history.back();' value='« Correct submission'>";
return $confirm;
}
# Processes
db_connect();
# Begin Transaction
pglib_transaction("BEGIN");
# Some info
$bankacc = getbankaccid($bankid);
$vatacc = gethook("accnum", "salesacc", "name", "VAT");
foreach ($amount as $key => $amt) {
$totamt = $amount[$key];
if ($chrgvat[$key] == "exc") {
$totamt += $vat[$key];
} elseif ($chrgvat[$key] == "inc") {
$amount[$key] -= $vat[$key];
} else {
$vat[$key] = "No VAT";
}
if ($cheqnum[$key] == '') {
$cheqnum[$key] = 0;
}
if (!isset($batch)) {
$refnum = getrefnum();
if (strtolower($trantype[$key]) == 'deposit') {
$vatacc = gethook("accnum", "salesacc", "name", "VAT", "1");
writetrans($bankacc, $accinv[$key], $date[$key], $refnum, $amount[$key], $descript[$key]);
if ($vat[$key] != 0) {
# DT(Bank), CT(VAT)
$vat[$key] += 0;
writetrans($bankacc, $vatacc, $date[$key], $refnum, $vat[$key], $descript[$key] . " VAT");
db_conn('cubit');
$Sl = "SELECT * FROM vatcodes WHERE id='{$vatcode[$key]}'";
$Rt = db_exec($Sl) or errDie("Unable to get data.");
$vd = pg_fetch_array($Rt);
vatr($vatcode[$key], $date[$key], "OUTPUT", $vd['code'], $refnum, $descript[$key] . " VAT", $totamt, $vat[$key]);
}
} else {
$vatacc = gethook("accnum", "salesacc", "name", "VAT");
writetrans($accinv[$key], $bankacc, $date[$key], $refnum, $amount[$key], $descript[$key]);
if ($vat[$key] != 0) {
# DT(Bank), CT(VAT)
$vat[$key] += 0;
writetrans($vatacc, $bankacc, $date[$key], $refnum, $vat[$key], $descript[$key] . " VAT");
db_conn('cubit');
$Sl = "SELECT * FROM vatcodes WHERE id='{$vatcode[$key]}'";
$Rt = db_exec($Sl) or errDie("Unable to get data.");
$vd = pg_fetch_array($Rt);
vatr($vatcode[$key], $date[$key], "INPUT", $vd['code'], $refnum, $descript[$key] . " VAT", -$totamt, -$vat[$key]);
}
}
$vat[$key] += 0;
db_connect();
$sql = "\n\t\t\t\tINSERT INTO cashbook (\n\t\t\t\t\tbankid, trantype, date, name, descript, cheqnum, \n\t\t\t\t\tamount, banked, accinv, div,chrgvat,vat,reference\n\t\t\t\t) VALUES (\n\t\t\t\t\t'{$bankid}', lower('{$trantype[$key]}'), '{$date[$key]}', '{$to[$key]}', '{$descript[$key]}', '{$cheqnum[$key]}', \n\t\t\t\t\t'{$totamt}', 'no', '{$accinv[$key]}', '" . USER_DIV . "','{$chrgvat[$key]}', '{$vat[$key]}','{$ref[$key]}'\n\t\t\t\t)";
$Rslt = db_exec($sql) or errDie("Unable to add bank payment to database.", SELF);
} else {
db_connect();
$vat[$key] += 0;
$sql = "\n\t\t\t\tINSERT INTO batch_cashbook (\n\t\t\t\t\tbankid, trantype, date, name, descript, cheqnum, \n\t\t\t\t\tamount, banked, accinv, div, chrgvat, vat, vatcode, \n\t\t\t\t\treference\n\t\t\t\t) VALUES (\n\t\t\t\t\t'{$bankid}', lower('{$trantype[$key]}'), '{$date[$key]}', '{$to[$key]}', '{$descript[$key]}', '{$cheqnum[$key]}', \n\t\t\t\t\t'{$totamt}', 'no', '{$accinv[$key]}', '" . USER_DIV . "','{$chrgvat[$key]}','{$vat[$key]}','{$vatcode[$key]}', \n\t\t\t\t\t'{$ref[$key]}'\n\t\t\t\t)";
$Rslt = db_exec($sql) or errDie("Unable to add bank payment to database.", SELF);
}
}
# Get bank details
$bankAccRslt = get("cubit", "*", "bankacct", "bankid", $bankid);
$bankacc = pg_fetch_array($bankAccRslt);
//.........这里部分代码省略.........
开发者ID:kumarsivarajan,项目名称:accounting-123,代码行数:101,代码来源:bank-stmnt.php
示例6: write
//.........这里部分代码省略.........
$xi['vatcode'] += 0;
$xi['account'] += 0;
$xi['del'] += 0;
$cols = grp(m("invid", $x["invid"]), m("whid", $xi["whid"]), m("stkid", $xi["stkid"]), m("qty", $xi["qty"]), m("unitcost", $xi["unitcost"]), m("amt", $xi["amt"]), m("disc", $xi["disc"]), m("discp", $xi["discp"]), m("vatcode", $xi["vatcode"]), m("account", $xi["account"]), m("description", $xi["description"]), m("del", $xi["del"]), m("noted", $xi["noted"]), m("serno", $xi["serno"]), m("div", USER_DIV));
$dbobj->setTable("inv_items", $prd);
$dbobj->setOpt($cols);
$dbobj->run();
$dbobj->free();
}
/* remove invoice from cubit schema */
$dbobj = new dbDelete("invoices", "cubit", wgrp(m("invid", $x["invid"]), m("div", USER_DIV)));
$dbobj->run();
$dbobj->setTable("inv_items", "cubit");
$dbobj->run();
}
/* start moving invoices */
// move invoices that are fully paid
$sql = "SELECT * FROM cubit.invoices WHERE balance=0 AND printed = 'y' AND done = 'y' AND div = '" . USER_DIV . "'";
$invbRslt = db_exec($sql) or errDie("Unable to update Invoice information in Cubit.", SELF);
while ($x = pg_fetch_array($invbRslt)) {
if (($prd = $x['prd']) == "0") {
$prd = PRD_DB;
}
// move invoice
$cols = grp(m("invid", $x["invid"]), m("invnum", $x["invnum"]), m("deptid", $x["deptid"]), m("cusnum", $x["cusnum"]), m("deptname", $x["deptname"]), m("cusacc", $x["cusacc"]), m("cusname", $x["cusname"]), m("surname", $x["surname"]), m("cusaddr", $x["cusaddr"]), m("cusvatno", $x["cusvatno"]), m("cordno", $x["cordno"]), m("ordno", $x["ordno"]), m("chrgvat", $x["chrgvat"]), m("terms", $x["terms"]), m("traddisc", $x["traddisc"]), m("salespn", $x["salespn"]), m("odate", $x["odate"]), m("delchrg", $x["delchrg"]), m("subtot", $x["subtot"]), m("vat", $x["vat"]), m("total", $x["total"]), m("age", $x["age"]), m("comm", $x["comm"]), m("discount", $x["discount"]), m("delivery", $x["delivery"]), m("docref", $x["docref"]), m("prd", $x["prd"]), m("delvat", $x["delvat"]), m("balance", 0), m("printed", "y"), m("done", "y"), m("username", USER_NAME), m("div", USER_DIV));
$dbobj = new dbUpdate("invoices", $prd, $cols);
$dbobj->run(DB_INSERT);
$dbobj->free();
// record movement
$cols = grp(m("invtype", "inv"), m("invnum", $x["invnum"]), m("prd", $x["prd"]), m("docref", $x["docref"]), m("div", USER_DIV));
$dbobj->setTable("movinv", "cubit");
$dbobj->setOpt($cols);
$dbobj->run();
$dbobj->free();
// move invoice items
$inv_items = new dbSelect("inv_items", "cubit", grp(m("where", wgrp(m("invid", $x["invid"]), m("div", USER_DIV)))));
$inv_items->run();
while ($xi = $inv_items->fetch_array()) {
$xi['vatcode'] += 0;
$xi['account'] += 0;
$xi['del'] += 0;
$cols = grp(m("invid", $x["invid"]), m("whid", $xi["whid"]), m("stkid", $xi["stkid"]
|
请发表评论