}
// do the source account postings
- add_gl_trans($trans_type, $trans_no, $date_, $bank_gl_account, 0, 0, $memo_,
+ add_gl_trans($trans_type, $trans_no, $date_, $bank_gl_account, $gl_item->dimension_id, $gl_item->dimension2_id, $memo_,
-$total, null, $person_type_id, $person_id);
if ($do_exchange_variance)
$trans_no = $supp_trans->trans_no;
$trans_type = $supp_trans->trans_type;
$supplier = get_supplier($supp_trans->supplier_id);
+ $dim = !empty($supp_trans->dimension) ? $supp_trans->dimension :
+ ($supplier['dimension_id'] ? $supplier['dimension_id'] : 0);
+ $dim2 = !empty($supp_trans->dimension2) ? $supp_trans->dimension2 :
+ ($supplier['dimension2_id'] ? $supplier['dimension2_id'] : 0);
begin_transaction();
hook_db_prewrite($supp_trans, $trans_type);
if ($trans_type == ST_SUPPCREDIT)
$taxitem['Value'] = -$taxitem['Value'];
$total += add_gl_trans_supplier($trans_type, $invoice_id, $date_,
- $taxitem['purchasing_gl_code'], 0, 0, $taxitem['Value'],
+ $taxitem['purchasing_gl_code'], $dim, $dim2, $taxitem['Value'],
$supp_trans->supplier_id,
"A general ledger transaction for the tax amount could not be added");
}
$net_diff = -$net_diff;
/* Now the AP account */
- $total += add_gl_trans_supplier($trans_type, $invoice_id, $date_, $supplier["payable_account"], 0, 0,
+ $total += add_gl_trans_supplier($trans_type, $invoice_id, $date_, $supplier["payable_account"], $dim, $dim2,
-($invoice_items_total + $item_added_tax + $supp_trans->ov_discount),
$supp_trans->supplier_id,
"The general ledger transaction for the control total could not be added");
See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
***********************************************************************/
function write_supp_payment($trans_no, $supplier_id, $bank_account,
- $date_, $ref, $supp_amount, $supp_discount, $memo_, $bank_charge=0, $bank_amount=0)
+ $date_, $ref, $supp_amount, $supp_discount, $memo_, $bank_charge=0, $bank_amount=0, $dimension=0, $dimension2=0)
{
global $Refs;
begin_transaction();
- $args = func_get_args(); while (count($args) < 10) $args[] = 0;
+ $args = func_get_args(); while (count($args) < 12) $args[] = 0;
$args = (object)array_combine(array('trans_no', 'supplier_id', 'bank_account', 'date_',
- 'ref', 'bank_amount', 'supp_amount', 'supp_discount', 'memo_', 'bank_charge'), $args);
+ 'ref', 'supp_amount', 'supp_discount', 'memo_', 'bank_charge', 'bank_amount', 'dimension', 'dimension2'), $args);
$args->trans_no = 0;
hook_db_prewrite( $args, ST_SUPPAYMENT);
$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,
+ $total += add_gl_trans_supplier(ST_SUPPAYMENT, $payment_id, $date_, $supplier_accounts["payable_account"], $dimension, $dimension2,
$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,
+ $total += add_gl_trans_supplier(ST_SUPPAYMENT, $payment_id, $date_, $supplier_accounts["payment_discount_account"], $dimension, $dimension2,
-$supp_discount, $supplier_id, "", $rate);
}
if ($bank_charge != 0)
{
$charge_act = get_company_pref('bank_charge_act');
- $total += add_gl_trans(ST_SUPPAYMENT, $payment_id, $date_, $charge_act, 0, 0, '',
+ $total += add_gl_trans(ST_SUPPAYMENT, $payment_id, $date_, $charge_act, $dimension, $dimension2, '',
$bank_charge, $bank['bank_curr_code']);
}
- $total += add_gl_trans(ST_SUPPAYMENT, $payment_id, $date_, $bank['account_code'], 0, 0, '',
+ $total += add_gl_trans(ST_SUPPAYMENT, $payment_id, $date_, $bank['account_code'], $dimension, $dimension2, '',
-($bank_amount + $bank_charge), $bank['bank_curr_code'], PT_SUPPLIER, $supplier_id);
/*Post a balance post if $total != 0 due to variance in AP and bank posted values*/
if ($total != 0)
{
$variance_act = get_company_pref('exchange_diff_act');
- add_gl_trans(ST_SUPPAYMENT, $payment_id, $date_, $variance_act, 0, 0, '',
+ add_gl_trans(ST_SUPPAYMENT, $payment_id, $date_, $variance_act, $dimension, $dimension2, '',
-$total, null, PT_SUPPLIER, $supplier_id);
}
if ($cart->cash_account) {
$pmt_no = write_supp_payment(0, $inv->supplier_id, $cart->cash_account, $inv->tran_date, $Refs->get_next(ST_SUPPAYMENT, null, $inv->tran_date),
- $total, 0, _('Payment for:').$inv->supp_reference .' ('.$type_shortcuts[ST_SUPPINVOICE].$inv_no.')');
+ $total, 0, _('Payment for:').$inv->supp_reference .' ('.$type_shortcuts[ST_SUPPINVOICE].$inv_no.')' . ' ' . $cart->Comments, $cart->dimension, $cart->dimension2);
add_supp_allocation($total, ST_SUPPAYMENT, $pmt_no, ST_SUPPINVOICE, $inv_no, $inv->supplier_id, $inv->tran_date);
update_supp_trans_allocation(ST_SUPPINVOICE, $inv_no, $inv->supplier_id);
update_supp_trans_allocation(ST_SUPPAYMENT, $pmt_no, $inv->supplier_id);
{
$payment_id = write_supp_payment(0, $_POST['supplier_id'], $_POST['bank_account'],
$_POST['DatePaid'], $_POST['ref'], input_num('amount'), input_num('discount'), $_POST['memo_'],
- input_num('charge'), input_num('bank_amount', input_num('amount')));
+ input_num('charge'), input_num('bank_amount', input_num('amount')), $_POST['dimension_id'], $_POST['dimension2_id']);
new_doc_date($_POST['DatePaid']);
$_SESSION['alloc']->trans_no = $payment_id;
amount_row(_("Bank Charge:"), 'charge', null, '', $bank_currency);
+ $row = get_supplier($_POST['supplier_id']);
+ $_POST['dimension_id'] = $row['dimension_id'];
+ $_POST['dimension2_id'] = $row['dimension2_id'];
+ $dim = get_company_pref('use_dimension');
+ if ($dim > 0)
+ dimensions_list_row(_("Dimension").":", 'dimension_id',
+ null, true, ' ', false, 1, false);
+ else
+ hidden('dimension_id', 0);
+ if ($dim > 1)
+ dimensions_list_row(_("Dimension")." 2:", 'dimension2_id',
+ null, true, ' ', false, 2, false);
+ else
+ hidden('dimension2_id', 0);
end_outer_table(1);
//Chaitanya : 13-OCT-2011 - To support Edit feature
$payment_no = write_customer_payment($_SESSION['alloc']->trans_no, $_POST['customer_id'], $_POST['BranchID'],
$_POST['bank_account'], $_POST['DateBanked'], $_POST['ref'],
- input_num('amount'), input_num('discount'), $_POST['memo_'], 0, input_num('charge'), input_num('bank_amount', input_num('amount')));
+ input_num('amount'), input_num('discount'), $_POST['memo_'], 0, input_num('charge'), input_num('bank_amount', input_num('amount')), $_POST['dimension_id'], $_POST['dimension2_id']);
$_SESSION['alloc']->trans_no = $payment_no;
$_SESSION['alloc']->date_ = $_POST['DateBanked'];
amount_row(_("Bank Charge:"), 'charge', null, '', $bank_currency);
+$row = get_customer($_POST['customer_id']);
+$_POST['dimension_id'] = $row['dimension_id'];
+$_POST['dimension2_id'] = $row['dimension2_id'];
+$dim = get_company_pref('use_dimension');
+if ($dim > 0)
+ dimensions_list_row(_("Dimension").":", 'dimension_id',
+ null, true, ' ', false, 1, false);
+else
+ hidden('dimension_id', 0);
+if ($dim > 1)
+ dimensions_list_row(_("Dimension")." 2:", 'dimension2_id',
+ null, true, ' ', false, 2, false);
+else
+ hidden('dimension2_id', 0);
+
end_outer_table(1);
div_start('alloc_tbl');
$charge - in bank currency
*/
function write_customer_payment($trans_no, $customer_id, $branch_id, $bank_account,
- $date_, $ref, $amount, $discount, $memo_, $rate=0, $charge=0, $bank_amount=0)
+ $date_, $ref, $amount, $discount, $memo_, $rate=0, $charge=0, $bank_amount=0, $dim1=0, $dim2=0)
{
global $Refs;
begin_transaction();
- $args = func_get_args(); while (count($args) < 12) $args[] = 0;
+ $args = func_get_args(); while (count($args) < 14) $args[] = 0;
$args = (object)array_combine(array('trans_no', 'customer_id', 'branch_id', 'bank_account',
- 'date_', 'ref', 'amount', 'discount', 'memo_','rate','charge', 'bank_amount'), $args);
+ 'date_', 'ref', 'amount', 'discount', 'memo_','rate','charge', 'bank_amount', 'dim1', 'dim2'), $args);
hook_db_prewrite($args, ST_CUSTPAYMENT);
$company_record = get_company_prefs();
/* Bank account entry first */
$total += add_gl_trans(ST_CUSTPAYMENT, $payment_no, $date_,
- $bank_gl_account, 0, 0, '', ($bank_amount - $charge), $bank['bank_curr_code'], PT_CUSTOMER, $customer_id);
+ $bank_gl_account, $dim1, $dim2, '', ($bank_amount - $charge), $bank['bank_curr_code'], PT_CUSTOMER, $customer_id);
if ($branch_id != ANY_NUMERIC) {
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,
+ $debtors_account, $dim1, $dim2, -($discount + $amount), $customer_id,
"Cannot insert a GL transaction for the debtors account credit");
}
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,
+ $discount_account, $dim1, $dim2, $discount, $customer_id,
"Cannot insert a GL transaction for the payment discount debit");
}
if ($charge != 0) {
/* Now Debit bank charge account with charges */
$charge_act = get_bank_charge_account($bank_account);
- $total += add_gl_trans(ST_CUSTPAYMENT, $payment_no, $date_, $charge_act, 0, 0, '',
+ $total += add_gl_trans(ST_CUSTPAYMENT, $payment_no, $date_, $charge_act, $dim1, $dim2, '',
$charge, $bank['bank_curr_code'], PT_CUSTOMER, $customer_id);
}
if ($total != 0)
{
$variance_act = get_company_pref('exchange_diff_act');
- add_gl_trans(ST_CUSTPAYMENT, $payment_no, $date_, $variance_act, 0, 0, '',
+ add_gl_trans(ST_CUSTPAYMENT, $payment_no, $date_, $variance_act, $dim1, $dim2, '',
-$total, null, PT_CUSTOMER, $customer_id);
}
if (($credit_note_total + $credit_note->freight_cost) != 0) {
- $total += add_gl_trans_customer(ST_CUSTCREDIT, $credit_no, $credit_date, $branch_data["receivables_account"], 0, 0,
+ $total += add_gl_trans_customer(ST_CUSTCREDIT, $credit_no, $credit_date, $branch_data["receivables_account"], $credit_note->dimension_id, $credit_note->dimension2_id,
-($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");
}
if ($credit_note->freight_cost != 0) {
- $total += add_gl_trans_customer(ST_CUSTCREDIT, $credit_no, $credit_date, $company_data["freight_act"], 0, 0,
+ $total += add_gl_trans_customer(ST_CUSTCREDIT, $credit_no, $credit_date, $company_data["freight_act"], $credit_note->dimension_id, $credit_note->dimension2_id,
$credit_note->get_tax_free_shipping(), $credit_note->customer_id,
"The freight GL posting for this credit note could not be inserted");
}
$taxitem['rate'], $credit_note->tax_included, $taxitem['Value'],
$taxitem['Net'], $ex_rate,
$credit_note->document_date, $credit_note->reference, TR_OUTPUT);
-
- $total += add_gl_trans_customer(ST_CUSTCREDIT, $credit_no, $credit_date, $taxitem['sales_gl_code'], 0, 0,
+ // sales_gl_code is not set for taxexempt
+ if (isset($taxitem['sales_gl_code']))
+ $total += add_gl_trans_customer(ST_CUSTCREDIT, $credit_no, $credit_date, $taxitem['sales_gl_code'], $credit_note->dimension_id, $credit_note->dimension2_id,
$taxitem['Value'], $credit_note->customer_id,
"A tax GL posting for this credit note could not be inserted");
}
} /*end of delivery_line loop */
if (($items_total + $charge_shipping) != 0) {
- $total += add_gl_trans_customer(ST_SALESINVOICE, $invoice_no, $date_, $branch_data["receivables_account"], 0, 0,
+ $total += add_gl_trans_customer(ST_SALESINVOICE, $invoice_no, $date_, $branch_data["receivables_account"], $invoice->dimension_id, $invoice->dimension2_id,
($items_total + $charge_shipping + $items_added_tax + $freight_added_tax)*$prepaid_factor,
$invoice->customer_id, "The total debtor GL posting could not be inserted");
}
$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,
+ $total += add_gl_trans_customer(ST_SALESINVOICE, $invoice_no, $date_, $company_data["freight_act"], $invoice->dimension_id, $invoice->dimension2_id,
-$invoice->get_tax_free_shipping()*$prepaid_factor, $invoice->customer_id,
"The freight GL posting could not be inserted");
}
$taxitem['rate'], $invoice->tax_included, $prepaid_factor*$taxitem['Value'],
$taxitem['Net'], $ex_rate, $date_, $invoice->reference, TR_OUTPUT);
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,
+ $total += add_gl_trans_customer(ST_SALESINVOICE, $invoice_no, $date_, $taxitem['sales_gl_code'], $invoice->dimension_id, $invoice->dimension2_id,
(-$taxitem['Value'])*$prepaid_factor, $invoice->customer_id,
"A tax GL posting could not be inserted");
}
// extend invoice entry page with final amount after discount
// and change line below.
$discount = 0; // $invoice->cash_discount*$amount;
+ $payment_info = $invoice->pos['pos_name'].' #'.$invoice_no;
+ if (!empty($invoice->payment_info))
+ $payment_info .= ' ' . $invoice->payment_info;
$pmtno = write_customer_payment(0, $invoice->customer_id,
$invoice->Branch, $invoice->pos['pos_account'], $date_,
$Refs->get_next(ST_CUSTPAYMENT, null, array('customer' => $invoice->customer_id,
'branch' => $invoice->Branch, 'date' => $date_)),
- $amount-$discount, $discount,
- $invoice->pos['pos_name'].' #'.$invoice_no);
+ $amount-$discount, $discount, $payment_info,
+ 0,0,0,$invoice->dimension_id, $invoice->dimension2_id);
add_cust_allocation($amount, ST_CUSTPAYMENT, $pmtno, ST_SALESINVOICE, $invoice_no, $invoice->customer_id, $date_);
update_debtor_trans_allocation(ST_SALESINVOICE, $invoice_no, $invoice->customer_id);