// $date_ is display date (non-sql)
function add_bank_trans($type, $trans_no, $bank_act, $ref, $date_,
- $amount, $person_type_id, $person_id, $currency="", $err_msg="", $rate=0)
+ $amount, $person_type_id, $person_id, $currency="", $rate=0)
{
$sqlDate = date2sql($date_);
".db_escape($amount_bank).", ".db_escape($person_type_id)
.", ". db_escape($person_id).")";
- if ($err_msg == "")
- $err_msg = "The bank transaction could not be inserted";
-
- db_query($sql, $err_msg);
+ db_query($sql, "The bank transaction could not be inserted");
}
//----------------------------------------------------------------------------------------
add_bank_trans($trans_type, $trans_no, $from_account, $ref,
$date_, -($amount + $charge),
- PT_MISC, $person_id, $currency,
- "Cannot insert a source bank transaction");
+ PT_MISC, $person_id, $currency);
if ($SysPrefs->auto_currency_revaluation())
{
$trans_no1 = get_next_trans_no(ST_JOURNAL);
0, 0, _("Exchange Variance"), -$total);
add_bank_trans($trans_type, $trans_no, $to_account, $ref,
- $date_, $to_amount, PT_MISC, $person_id,
- $to_currency, "Cannot insert a destination bank transaction");
+ $date_, $to_amount, PT_MISC, $person_id);
if ($SysPrefs->auto_currency_revaluation())
{
add_bank_trans($trans_type, $trans_no, $from_account, $ref,
$date_, -$total_amount,
$person_type_id, $person_id,
- $currency,
- "Cannot insert a source bank transaction");
+ $currency);
$total = 0;
foreach ($items->gl_items as $gl_item)
{
{
add_bank_trans($trans_type, $trans_no, $is_bank_to, $ref,
$date_, $gl_item->amount,
- $person_type_id, $person_id, $currency,
- "Cannot insert a destination bank transaction");
+ $person_type_id, $person_id, $currency);
if ($do_exchange_variance)
{
add_exchange_variation($trans_no1, $date_, $is_bank_to, $gl_item->code_id,
// if $currency is not set, then defaults to no conversion
function add_gl_trans($type, $trans_id, $date_, $account, $dimension, $dimension2, $memo_,
- $amount, $currency=null, $person_type_id=null, $person_id=null, $err_msg="", $rate=0)
+ $amount, $currency=null, $person_type_id=null, $person_id=null, $rate=0)
{
global $SysPrefs;
$sql .= ") ";
- if ($err_msg == "")
- $err_msg = "The GL transaction could not be inserted";
-
- db_query($sql, $err_msg);
+ db_query($sql, "The GL transaction could not be inserted");
return $amount_in_home_currency;
}
// $amount is in HOME currency
function add_gl_trans_std_cost($type, $trans_id, $date_, $account, $dimension, $dimension2,
- $memo_, $amount, $person_type_id=null, $person_id=null, $err_msg="")
+ $memo_, $amount, $person_type_id=null, $person_id=null)
{
if ($amount != 0)
return add_gl_trans($type, $trans_id, $date_, $account, $dimension, $dimension2, $memo_,
- $amount, null, $person_type_id, $person_id, $err_msg);
+ $amount, null, $person_type_id, $person_id);
else
return 0;
}
{
error_log(sprintf( _("Rounding error %s encountered for trans_type:%s,trans_no:%s"), $amount, $type, $trans_id));
return add_gl_trans($type, $trans_id, $date_, get_company_pref('exchange_diff_act'), 0, 0, "",
- $amount, null, $person_type_id, $person_id, "The balanced GL transaction could not be inserted");
+ $amount, null, $person_type_id, $person_id);
} else
return 0;
}
$gl->date = $this->tran_date;
$total_gl += add_gl_trans($this->trans_type, $this->order_id, $gl->date, $gl->code_id, $gl->dimension_id, $gl->dimension2_id,
- $gl->reference, $gl->amount, $this->currency, $gl->person_type_id, $gl->person_id, "", $this->rate);
+ $gl->reference, $gl->amount, $this->currency, $gl->person_type_id, $gl->person_id, $this->rate);
// post to first found bank account using given gl acount code.
$is_bank_to = is_bank_account($gl->code_id);
// update bank ledger if used
foreach($bank_trans as $bank_id => $amount)
add_bank_trans($this->trans_type, $this->order_id, $bank_id, $this->reference,
- $this->tran_date, $amount, 0, "", $this->currency,
- "Cannot insert a destination bank transaction");
+ $this->tran_date, $amount, 0, "", $this->currency);
// add AP/AR for journal transaction
if ($this->trans_type == ST_JOURNAL)
if ($is_bank_to)
{
add_bank_trans(ST_JOURNAL, $journal_id, $is_bank_to, "",
- $date, -$amount, PT_WORKORDER, $wo_id, get_company_currency(),
- "Cannot insert a destination bank transaction");
+ $date, -$amount, PT_WORKORDER, $wo_id, get_company_currency());
}
add_journal(ST_JOURNAL, $journal_id, $amount, $date, get_company_currency(), $ref, '', 1, $date, $date);
if ($clearing_act)
$total += add_gl_trans_supplier(ST_SUPPRECEIVE, $grn, $date_, $stock_gl_code["inventory_account"],
$stock_gl_code['dimension_id'], $stock_gl_code['dimension2_id'],
- $order_line->taxfree_charge_value($po), $po->supplier_id, '', 0, $order_line->stock_id);
+ $order_line->taxfree_charge_value($po), $po->supplier_id, 0, $order_line->stock_id);
update_average_material_cost($po->supplier_id, $order_line->stock_id, $order_line->price,
$order_line->quantity, $date_);
}
// store basic transaction info
$invoice_id = write_supp_trans($trans_type, 0, $supp_trans->supplier_id, $supp_trans->tran_date, $supp_trans->due_date,
- $supp_trans->reference, $supp_trans->supp_reference, 0, 0, 0, "", $supp_trans->ex_rate, $supp_trans->tax_included);
+ $supp_trans->reference, $supp_trans->supp_reference, 0, 0, 0, $supp_trans->ex_rate, $supp_trans->tax_included);
if ($trans_no)
move_trans_attachments($trans_type, $trans_no, $invoice_id);
/* Create a supp_trans entry for the supplier payment */
$payment_id = write_supp_trans(ST_SUPPAYMENT, 0, $supplier_id, $date_, $date_,
- $ref, "", -$supp_amount, 0, -$supp_discount, "", $rate);
+ $ref, "", -$supp_amount, 0, -$supp_discount, $rate);
// Now debit creditors account with payment + discount
$total = 0;
$supplier_accounts = get_supplier_accounts($supplier_id);
$total += add_gl_trans_supplier(ST_SUPPAYMENT, $payment_id, $date_, $supplier_accounts["payable_account"], 0, 0,
- $supp_amount + $supp_discount, $supplier_id, "", $rate);
+ $supp_amount + $supp_discount, $supplier_id, $rate);
// Now credit discount received account with discounts
if ($supp_discount != 0)
{
$total += add_gl_trans_supplier(ST_SUPPAYMENT, $payment_id, $date_, $supplier_accounts["payment_discount_account"], 0, 0,
- -$supp_discount, $supplier_id, "", $rate);
+ -$supp_discount, $supplier_id, $rate);
}
if ($bank_charge != 0)
// FIXME - this should be revised for transaction update case.
//
function write_supp_trans($type, $trans_no, $supplier_id, $date_, $due_date, $reference, $supp_reference,
- $amount, $amount_tax, $discount, $err_msg="", $rate=0, $included=0)
+ $amount, $amount_tax, $discount, $rate=0, $included=0)
{
$new = $trans_no==0;
$date = date2sql($date_);
".db_escape($reference).", ".db_escape($supp_reference).", ".db_escape($amount)
.", ".db_escape($amount_tax).", ".db_escape($rate).", ".db_escape($discount).", ".db_escape($included).")";
- if ($err_msg == "")
- $err_msg = "Cannot insert a supplier transaction record";
-
- db_query($sql, $err_msg);
+ db_query($sql, "Cannot insert a supplier transaction record");
add_audit_trail($type, $trans_no, $date_);
return $trans_no;
// $amount is in SUPPLIERS'S currency
function add_gl_trans_supplier($type, $type_no, $date_, $account, $dimension, $dimension2,
- $amount, $supplier_id, $err_msg="", $rate=0, $memo="")
+ $amount, $supplier_id, $rate=0, $memo="")
{
- if ($err_msg == "")
- $err_msg = "The supplier GL transaction could not be inserted";
-
return add_gl_trans($type, $type_no, $date_, $account, $dimension, $dimension2, $memo,
$amount, get_supplier_currency($supplier_id),
- PT_SUPPLIER, $supplier_id, $err_msg, $rate);
+ PT_SUPPLIER, $supplier_id, $rate);
}
//----------------------------------------------------------------------------------------
if (($discount + $amount) != 0) {
/* Now Credit Debtors account with receipts + discounts */
$total += add_gl_trans_customer(ST_CUSTPAYMENT, $payment_no, $date_,
- $debtors_account, 0, 0, -($discount + $amount), $customer_id,
- "Cannot insert a GL transaction for the debtors account credit");
+ $debtors_account, 0, 0, -($discount + $amount), $customer_id);
}
if ($discount != 0) {
/* Now Debit discount account with discounts allowed*/
$total += add_gl_trans_customer(ST_CUSTPAYMENT, $payment_no, $date_,
- $discount_account, 0, 0, $discount, $customer_id,
- "Cannot insert a GL transaction for the payment discount debit");
+ $discount_account, 0, 0, $discount, $customer_id);
}
if ($charge != 0) {
$total += add_gl_trans_customer(ST_CUSTCREDIT, $credit_no, $credit_date, $branch_data["receivables_account"], 0, 0,
-($credit_note_total + $credit_note->freight_cost + $items_added_tax + $freight_added_tax),
- $credit_note->customer_id,
- "The total debtor GL posting for the credit note could not be inserted");
+ $credit_note->customer_id);
}
if ($credit_note->freight_cost != 0) {
$total += add_gl_trans_customer(ST_CUSTCREDIT, $credit_no, $credit_date, $company_data["freight_act"], 0, 0,
- $credit_note->get_tax_free_shipping(), $credit_note->customer_id,
- "The freight GL posting for this credit note could not be inserted");
+ $credit_note->get_tax_free_shipping(), $credit_note->customer_id);
}
foreach ($taxes as $taxitem) {
$credit_note->document_date, $credit_note->reference, TR_OUTPUT, $credit_note->tax_group_id);
$total += add_gl_trans_customer(ST_CUSTCREDIT, $credit_no, $credit_date, $taxitem['sales_gl_code'], 0, 0,
- $taxitem['Value'], $credit_note->customer_id,
- "A tax GL posting for this credit note could not be inserted");
+ $taxitem['Value'], $credit_note->customer_id);
}
}
/*Post a balance post if $total != 0 */
$total += add_gl_trans_std_cost(ST_CUSTCREDIT, $credit_no, $date_, $stock_gl_codes["cogs_account"],
$dim, $dim2, "", -($unit_cost * $order_line->qty_dispatched),
- PT_CUSTOMER, $order->customer_id,
- "The cost of sales GL posting could not be inserted");
+ PT_CUSTOMER, $order->customer_id);
/*now the stock entry*/
if ($credit_type == "WriteOff") {
$total += add_gl_trans_std_cost(ST_CUSTCREDIT, $credit_no, $date_, $stock_entry_account, 0, 0,
"", ($unit_cost * $order_line->qty_dispatched),
- PT_CUSTOMER, $order->customer_id,
- "The stock side (or write off) of the cost of sales GL posting could not be inserted");
+ PT_CUSTOMER, $order->customer_id);
} /* end of if GL and stock integrated and standard cost !=0 */
else
$sales_account = $stock_gl_codes['sales_account'];
$total += add_gl_trans_customer(ST_CUSTCREDIT, $credit_no, $date_, $sales_account, $dim, $dim2,
- ($line_taxfree_price * $order_line->qty_dispatched), $order->customer_id,
- "The credit note GL posting could not be inserted");
+ ($line_taxfree_price * $order_line->qty_dispatched), $order->customer_id);
if ($order_line->discount_percent != 0) {
$total += add_gl_trans_customer(ST_CUSTCREDIT, $credit_no, $date_, $branch_data["sales_discount_account"],
$dim, $dim2, -($line_taxfree_price * $order_line->qty_dispatched * $order_line->discount_percent),
- $order->customer_id,
- "The credit note discount GL posting could not be inserted");
+ $order->customer_id);
} /*end of if discount !=0 */
} /*if line_price!=0 */
$sales_account = ($branch_data['sales_account'] != "" ? $branch_data['sales_account'] : $stock_gl_code['sales_account']);
$total += add_gl_trans_customer(ST_CUSTDELIVERY, $delivery_no, $delivery->document_date, $sales_account, $dim, $dim2,
- -$line_taxfree_price, $delivery->customer_id, "The sales price GL posting could not be inserted");
+ -$line_taxfree_price, $delivery->customer_id);
}
/* insert gl_trans to credit stock and debit cost of sales at standard cost*/
add_gl_trans_std_cost(ST_CUSTDELIVERY, $delivery_no,
$delivery->document_date, $stock_gl_code["adjustment_account"], $dim, $dim2, "",
$fa_depreciation,
- PT_CUSTOMER, $delivery->customer_id,
- "The cost of sales GL posting could not be inserted");
+ PT_CUSTOMER, $delivery->customer_id);
/*then remove asset*/
add_gl_trans_std_cost(ST_CUSTDELIVERY, $delivery_no, $delivery->document_date,
$stock_gl_code["inventory_account"], 0, 0, "",
-$fa_purchase_cost,
- PT_CUSTOMER, $delivery->customer_id,
- "The stock side of the cost of sales GL posting could not be inserted");
+ PT_CUSTOMER, $delivery->customer_id);
/*finally adjust sales account with the remaining*/
add_gl_trans_std_cost(ST_CUSTDELIVERY, $delivery_no, $delivery->document_date,
$stock_gl_code["cogs_account"], 0, 0, "",
($fa_purchase_cost - $fa_depreciation),
- PT_CUSTOMER, $delivery->customer_id,
- "The stock side of the cost of sales GL posting could not be inserted");
+ PT_CUSTOMER, $delivery->customer_id);
}
// Invetory Items
else if ($delivery_line->unit_cost != 0) {
add_gl_trans_std_cost(ST_CUSTDELIVERY, $delivery_no,
$delivery->document_date, $stock_gl_code["cogs_account"], $dim, $dim2, "",
$delivery_line->unit_cost * $delivery_line->qty_dispatched,
- PT_CUSTOMER, $delivery->customer_id,
- "The cost of sales GL posting could not be inserted");
+ PT_CUSTOMER, $delivery->customer_id);
/*now the stock entry*/
add_gl_trans_std_cost(ST_CUSTDELIVERY, $delivery_no, $delivery->document_date,
$stock_gl_code["inventory_account"], 0, 0, "",
(-$delivery_line->unit_cost * $delivery_line->qty_dispatched),
- PT_CUSTOMER, $delivery->customer_id,
- "The stock side of the cost of sales GL posting could not be inserted");
+ PT_CUSTOMER, $delivery->customer_id);
}
} /* end of if GL and stock integrated and standard cost !=0 */
{
$deferred_act = get_company_pref('deferred_income_act');
add_gl_trans_customer(ST_CUSTDELIVERY, $delivery_no, $delivery->document_date, $deferred_act, 0, 0,
- -$total, $delivery->customer_id, "The deferred income GL posting could not be inserted");
+ -$total, $delivery->customer_id);
}
if ($bo_policy == 0) {
$dim2 = ($invoice->dimension2_id != $customer['dimension2_id'] ? $invoice->dimension2_id :
($customer['dimension2_id'] != 0 ? $customer["dimension2_id"] : $stock_gl_code["dimension2_id"]));
$total += add_gl_trans_customer(ST_SALESINVOICE, $invoice_no, $date_, $sales_account, $dim, $dim2,
- -$line_taxfree_price*$prepaid_factor,
- $invoice->customer_id, "The sales price GL posting could not be inserted");
+ -$line_taxfree_price*$prepaid_factor, $invoice->customer_id);
if ($invoice_line->discount_percent != 0) {
$total += add_gl_trans_customer(ST_SALESINVOICE, $invoice_no, $date_,
$branch_data["sales_discount_account"], $dim, $dim2,
- ($line_taxfree_price * $invoice_line->discount_percent)*$prepaid_factor,
- $invoice->customer_id, "The sales discount GL posting could not be inserted");
+ ($line_taxfree_price * $invoice_line->discount_percent)*$prepaid_factor, $invoice->customer_id);
} /*end of if discount !=0 */
}
} /*quantity dispatched is more than 0 */
if (($items_total + $charge_shipping) != 0) {
$total += add_gl_trans_customer(ST_SALESINVOICE, $invoice_no, $date_, $branch_data["receivables_account"], 0, 0,
- ($items_total + $charge_shipping + $items_added_tax + $freight_added_tax)*$prepaid_factor,
- $invoice->customer_id, "The total debtor GL posting could not be inserted");
+ ($items_total + $charge_shipping + $items_added_tax + $freight_added_tax)*$prepaid_factor, $invoice->customer_id);
}
$to_allocate = ($items_total + $charge_shipping + $items_added_tax + $freight_added_tax);
if ($charge_shipping != 0) {
$total += add_gl_trans_customer(ST_SALESINVOICE, $invoice_no, $date_, $company_data["freight_act"], 0, 0,
- -$invoice->get_tax_free_shipping()*$prepaid_factor, $invoice->customer_id,
- "The freight GL posting could not be inserted");
+ -$invoice->get_tax_free_shipping()*$prepaid_factor, $invoice->customer_id);
}
// post all taxes
foreach ($taxes as $taxitem) {
$taxitem['Net'], $ex_rate, $date_, $invoice->reference, TR_OUTPUT, $invoice->tax_group_id);
if (isset($taxitem['sales_gl_code']) && !empty($taxitem['sales_gl_code']) && $taxitem['Value'] != 0)
$total += add_gl_trans_customer(ST_SALESINVOICE, $invoice_no, $date_, $taxitem['sales_gl_code'], 0, 0,
- (-$taxitem['Value'])*$prepaid_factor, $invoice->customer_id,
- "A tax GL posting could not be inserted");
+ (-$taxitem['Value'])*$prepaid_factor, $invoice->customer_id);
}
}
// $amount is in CUSTOMER'S currency
function add_gl_trans_customer($type, $type_no, $date_, $account, $dimension, $dimension2,
- $amount, $customer_id, $err_msg="", $rate=0)
+ $amount, $customer_id, $rate=0)
{
- if ($err_msg == "")
- $err_msg = "The customer GL transaction could not be inserted";
-
return add_gl_trans($type, $type_no, $date_, $account, $dimension, $dimension2, "", $amount,
get_customer_currency($customer_id),
- PT_CUSTOMER, $customer_id, $err_msg, $rate);
+ PT_CUSTOMER, $customer_id, $rate);
}
//----------------------------------------------------------------------------------------