! -> Note
$ -> Affected files
+04-Dec-2008 Joe Hunt
+# [0000095] Inbalance double entry on Documents
+$ /gl/includes/db/gl_db_trans.inc
+ /purchasing/includes/db/invoice_db.inc
+ /purchasing/includes/db/supp_payment_db.inc
+ /sales/includes/db/payment_db.inc
+ /sales/includes/db/sales_credit_db.inc
+ /sales/includes/db/sales_invoice_db.inc
+
29-Nov-2008 Joe Hunt
# [0000094] Report does not show items that have 0 qty but have demand qty
$ /reporting/rep302.php
$amount_in_home_currency = round($amount * $rate, user_price_dec());
}
else
- $amount_in_home_currency = $amount;
+ $amount_in_home_currency = round($amount, user_price_dec());
if ($dimension == null || $dimension < 0)
$dimension = 0;
if ($dimension2 == null || $dimension2 < 0)
if ($err_msg == "")
$err_msg = "The GL transaction could not be inserted";
- return db_query($sql, $err_msg);
+ db_query($sql, $err_msg);
+ return $amount_in_home_currency;
}
//--------------------------------------------------------------------------------
return add_gl_trans($type, $trans_id, $date_, $account, $dimension, $dimension2, $memo_,
$amount, null, $person_type_id, $person_id, $err_msg);
else
- return null;
+ return 0;
}
//--------------------------------------------------------------------------------
include_once($path_to_root . "/includes/session.inc");
-page(_("View Work Order Production"), true);
+$js = "";
+if ($use_popup_windows)
+ $js .= get_js_open_window(900, 500);
+page(_("View Work Order Production"), true, false, "", $js);
include_once($path_to_root . "/includes/date_functions.inc");
include_once($path_to_root . "/includes/manufacturing.inc");
/* Now the control account */
$supplier_accounts = get_supplier_accounts($supp_trans->supplier_id);
- add_gl_trans_supplier($trans_type, $invoice_id, $date_, $supplier_accounts["payable_account"], 0, 0,
- -($invoice_items_total + $tax_total + $supp_trans->ov_discount),
- $supp_trans->supplier_id,
- "The general ledger transaction for the control total could not be added");
/*Loop through the GL Entries and create a debit posting for each of the accounts entered */
between the std cost and the currency cost charged as converted at the ex rate of of the invoice is written off
to the purchase price variance account applicable to the item being invoiced.
*/
-
+ $total = 0;
foreach ($supp_trans->gl_codes as $entered_gl_code)
{
$entered_gl_code->amount = -$entered_gl_code->amount;
$memo_ = $entered_gl_code->memo_;
- add_gl_trans_supplier($trans_type, $invoice_id, $date_, $entered_gl_code->gl_code,
+ $total += add_gl_trans_supplier($trans_type, $invoice_id, $date_, $entered_gl_code->gl_code,
$entered_gl_code->gl_dim, $entered_gl_code->gl_dim2, $entered_gl_code->amount, $supp_trans->supplier_id);
add_supp_invoice_gl_item($trans_type, $invoice_id, $entered_gl_code->gl_code,
$line_tax = $entered_grn->full_charge_price($supp_trans->tax_group_id) - $line_taxfree;
$stock_gl_code = get_stock_gl_code($entered_grn->item_code);
- add_gl_trans_supplier($trans_type, $invoice_id, $date_, $stock_gl_code["inventory_account"],
+ $total += add_gl_trans_supplier($trans_type, $invoice_id, $date_, $stock_gl_code["inventory_account"],
$stock_gl_code['dimension_id'], $stock_gl_code['dimension2_id'],
$entered_grn->this_quantity_inv * $line_taxfree, $supp_trans->supplier_id);
// -------------- if price changed since po received. 16 Aug 2008 Joe Hunt
add_supp_invoice_tax_item($trans_type, $invoice_id, $taxitem['tax_type_id'],
$taxitem['rate'], 0, $taxitem['Value']);
- add_gl_trans_supplier($trans_type, $invoice_id, $date_,
+ $total += add_gl_trans_supplier($trans_type, $invoice_id, $date_,
$taxitem['purchasing_gl_code'], 0, 0, $taxitem['Value'],
$supp_trans->supplier_id,
"A general ledger transaction for the tax amount could not be added");
}
}
+ add_gl_trans($trans_type, $invoice_id, $date_, $supplier_accounts["payable_account"], 0, 0, "",
+ -$total, null, payment_person_types::supplier(), $supp_trans->supplier_id,
+ "The general ledger transaction for the control total could not be added");
add_comments($trans_type, $invoice_id, $date_, $supp_trans->Comments);
references::save_last($supp_trans->reference, $trans_type);
}
else
{
- $supp_amount = $amount / $rate;
- $supp_discount = $discount / $rate;
+ $supp_amount = round($amount / $rate, user_price_dec());
+ $supp_discount = round($discount / $rate, user_price_dec());
}
$supplier_accounts = get_supplier_accounts($supplier_id);
- add_gl_trans_supplier($trans_type, $payment_id, $date_, $supplier_accounts["payable_account"], 0, 0,
- $supp_amount + $supp_discount, $supplier_id, "", $rate);
-
+ $total = 0;
// Now credit discount received account with discounts
if ($supp_discount != 0)
{
- add_gl_trans_supplier($trans_type, $payment_id, $date_, $supplier_accounts["payment_discount_account"], 0, 0,
+ $total += add_gl_trans_supplier($trans_type, $payment_id, $date_, $supplier_accounts["payment_discount_account"], 0, 0,
-$supp_discount, $supplier_id, "", $rate);
}
if ($supp_amount != 0)
{
- add_gl_trans_supplier($trans_type, $payment_id, $date_, $bank_account, 0, 0,
+ $total += add_gl_trans_supplier($trans_type, $payment_id, $date_, $bank_account, 0, 0,
-$supp_amount, $supplier_id, "", $rate);
}
+ add_gl_trans($trans_type, $payment_id, $date_, $supplier_accounts["payable_account"], 0, 0, "",
+ -$total, null, payment_person_types::supplier(), $supplier_id);
/*now enter the bank_trans entry */
add_bank_trans($trans_type, $payment_id, $bank_account, $ref,
$date_, $payment_type, -($amount), payment_person_types::supplier(),
void_gl_trans(12, $trans_no, true);
void_cust_allocations(12, $trans_no, $date_);
}
-
+ $total = 0;
/* Bank account entry first */
- add_gl_trans_customer(12, $payment_no, $date_,
+ $total += add_gl_trans_customer(12, $payment_no, $date_,
$bank_account, 0, 0, $amount, $customer_id,
"Cannot insert a GL transaction for the bank account debit", $rate);
$discount_account = $company_record["default_prompt_payment_act"];
}
- if (($discount + $amount) != 0) {
- /* Now Credit Debtors account with receipts + discounts */
- add_gl_trans_customer(12, $payment_no, $date_,
- $debtors_account, 0, 0, -($discount + $amount), $customer_id,
- "Cannot insert a GL transaction for the debtors account credit", $rate);
- }
-
if ($discount != 0) {
/* Now Debit discount account with discounts allowed*/
- add_gl_trans_customer(12, $payment_no, $date_,
+ $total += add_gl_trans_customer(12, $payment_no, $date_,
$discount_account, 0, 0, $discount, $customer_id,
"Cannot insert a GL transaction for the payment discount debit", $rate);
}
+ if (($discount + $amount) != 0) {
+ /* Now Credit Debtors account with receipts + discounts */
+ add_gl_trans(12, $payment_no, $date_, $debtors_account, 0, 0, "",
+ -$total, null, payment_person_types::customer(), $customer_id,
+ "Cannot insert a GL transaction for the debtors account credit");
+ }
+
/*now enter the bank_trans entry */
add_bank_trans(12, $payment_no, $bank_account, $ref,
$date_, $receipt_type, $amount, payment_person_types::customer(), $customer_id,
}
}
-
+ $total = 0;
foreach ($credit_note->line_items as $credit_line) {
if ($credit_invoice && $credit_line->qty_dispatched!=$credit_line->qty_old ) {
add_credit_movements_item($credit_note, $credit_line,
$credit_type, $line_taxfree_price+$line_tax, $credit_invoice);
- add_gl_trans_credit_costs($credit_note, $credit_line, $credit_no,
+ $total += add_gl_trans_credit_costs($credit_note, $credit_line, $credit_no,
$credit_date, $credit_type, $write_off_acc, $branch_data);
} /*end of credit_line loop */
- /*Post credit note transaction to GL credit debtors,
- debit freight re-charged and debit sales */
-
- if (($credit_note_total + $credit_note->freight_cost) != 0) {
-
- add_gl_trans_customer(11, $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");
- }
if ($credit_note->freight_cost !=0) {
- add_gl_trans_customer(11, $credit_no, $credit_date, $company_data["freight_act"], 0, 0,
+ $total += add_gl_trans_customer(11, $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");
}
add_customer_trans_tax_detail_item(11, $credit_no, $taxitem['tax_type_id'],
$taxitem['rate'], $credit_note->tax_included, $taxitem['Value']);
- add_gl_trans_customer(11, $credit_no, $credit_date, $taxitem['sales_gl_code'], 0, 0,
+ $total += add_gl_trans_customer(11, $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");
}
}
+ /*Post credit note transaction to GL credit debtors,
+ debit freight re-charged and debit sales */
+
+ if (($credit_note_total + $credit_note->freight_cost) != 0) {
+
+ add_gl_trans(11, $credit_no, $credit_date, $branch_data["receivables_account"], 0, 0, "",
+ -$total, null, payment_person_types::customer(), $credit_note->customer_id,
+ "The total debtor GL posting for the credit note could not be inserted");
+ }
add_comments(11, $credit_no, $credit_date, $credit_note->Comments);
if ($trans_no == 0) {
$dim = ($customer['dimension_id'] != 0 ? $customer["dimension_id"] : $stock_gl_codes["dimension_id"]);
$dim2 = ($customer['dimension2_id'] != 0 ? $customer["dimension2_id"] : $stock_gl_codes["dimension2_id"]);
+ $total = 0;
/* insert gl_trans to credit stock and debit cost of sales at standard cost*/
$standard_cost = get_standard_cost($order_line->stock_id);
if ($standard_cost != 0) {
/*first the cost of sales entry*/
- add_gl_trans_std_cost(11, $credit_no, $date_, $stock_gl_codes["cogs_account"],
+ $total += add_gl_trans_std_cost(11, $credit_no, $date_, $stock_gl_codes["cogs_account"],
$dim, $dim2, "", -($standard_cost * $order_line->qty_dispatched),
payment_person_types::customer(), $order->customer_id,
"The cost of sales GL posting could not be inserted");
$stock_entry_account = $stock_gl_code["inventory_account"];
}
- add_gl_trans_std_cost(11, $credit_no, $date_, $stock_entry_account, 0, 0,
+ $total += add_gl_trans_std_cost(11, $credit_no, $date_, $stock_entry_account, 0, 0,
"", ($standard_cost * $order_line->qty_dispatched),
payment_person_types::customer(), $order->customer_id,
"The stock side (or write off) of the cost of sales GL posting could not be inserted");
$sales_account = $branch_data['sales_account'];
else
$sales_account = $stock_gl_codes['sales_account'];
- add_gl_trans_customer(11, $credit_no, $date_, $sales_account, $dim, $dim2,
+ $total += add_gl_trans_customer(11, $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");
if ($order_line->discount_percent != 0) {
- add_gl_trans_customer(11, $credit_no, $date_, $branch_data["sales_discount_account"],
+ $total += add_gl_trans_customer(11, $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");
} /*end of if discount !=0 */
} /*if line_price!=0 */
+ return $total;
}
?>
\ No newline at end of file
void_cust_allocations(10, $invoice_no); // ?
void_customer_trans_tax_details(10, $invoice_no);
}
-
+ $total = 0;
foreach ($invoice->line_items as $invoice_line) {
$line_taxfree_price = get_tax_free_price_for_item($invoice_line->stock_id,
// else take the Item Dimension (if any)
$dim = ($customer['dimension_id'] != 0 ? $customer["dimension_id"] : $stock_gl_code["dimension_id"]);
$dim2 = ($customer['dimension2_id'] != 0 ? $customer["dimension2_id"] : $stock_gl_code["dimension2_id"]);
- add_gl_trans_customer(10, $invoice_no, $date_, $sales_account, $dim, $dim2,
+ $total += add_gl_trans_customer(10, $invoice_no, $date_, $sales_account, $dim, $dim2,
(-$line_taxfree_price * $invoice_line->qty_dispatched),
$invoice->customer_id, "The sales price GL posting could not be inserted");
if ($invoice_line->discount_percent != 0) {
- add_gl_trans_customer(10, $invoice_no, $date_,
+ $total += add_gl_trans_customer(10, $invoice_no, $date_,
$branch_data["sales_discount_account"], $dim, $dim2,
($line_taxfree_price * $invoice_line->qty_dispatched * $invoice_line->discount_percent),
$invoice->customer_id, "The sales discount GL posting could not be inserted");
} /*quantity dispatched is more than 0 */
} /*end of delivery_line loop */
- /*Post debtors transaction to GL debit debtors, credit freight re-charged and credit sales */
- if (($items_total + $charge_shipping) != 0) {
- add_gl_trans_customer(10, $invoice_no, $date_, $branch_data["receivables_account"], 0, 0,
- ($items_total + $charge_shipping + $items_added_tax + $freight_added_tax),
- $invoice->customer_id, "The total debtor GL posting could not be inserted");
- }
if ($charge_shipping != 0) {
- add_gl_trans_customer(10, $invoice_no, $date_, $company_data["freight_act"], 0, 0,
+ $total += add_gl_trans_customer(10, $invoice_no, $date_, $company_data["freight_act"], 0, 0,
-$invoice->get_tax_free_shipping(), $invoice->customer_id,
"The freight GL posting could not be inserted");
}
add_customer_trans_tax_detail_item(10, $invoice_no, $taxitem['tax_type_id'],
$taxitem['rate'], $invoice->tax_included, $taxitem['Value']);
- add_gl_trans_customer(10, $invoice_no, $date_, $taxitem['sales_gl_code'], 0, 0,
+ $total += add_gl_trans_customer(10, $invoice_no, $date_, $taxitem['sales_gl_code'], 0, 0,
(-$taxitem['Value']), $invoice->customer_id,
"A tax GL posting could not be inserted");
}
}
+ /*Post debtors transaction to GL debit debtors, credit freight re-charged and credit sales */
+ if (($items_total + $charge_shipping) != 0) {
+ add_gl_trans(10, $invoice_no, $date_, $branch_data["receivables_account"], 0, 0, "",
+ -$total, null, payment_person_types::customer(), $invoice->customer_id,
+ "The total debtor GL posting could not be inserted");
+ }
add_comments(10, $invoice_no, $date_, $invoice->Comments);
if ($trans_no == 0) {