- /* Now the control account */
- $supplier_accounts = get_supplier_accounts($supp_trans->supplier_id);
- $total += add_gl_trans_supplier($trans_type, $invoice_id, $date_, $supplier_accounts["payable_account"], 0, 0,
+
+ /* Now the TAX account */
+ $taxes = $supp_trans->get_taxes($supp_trans->tax_group_id, 0, false);
+ $net_diff = 0;
+
+ foreach ($taxes as $taxitem)
+ {
+ if ($taxitem['Net'] != 0)
+ {
+ if (isset($taxitem['Override'])) {
+ if ($supp_trans->tax_included) { // if tax included, fix net amount to preserve overall line price
+ $net_diff += $taxitem['Override'] - $taxitem['Value'];
+ $taxitem['Net'] += $taxitem['Override'] - $taxitem['Value'];
+ }
+ $taxitem['Value'] = $taxitem['Override'];
+ }
+ add_trans_tax_details($trans_type, $invoice_id,
+ $taxitem['tax_type_id'], $taxitem['rate'], $supp_trans->tax_included, $taxitem['Value'],
+ $taxitem['Net'], $ex_rate, $date_, $supp_trans->supp_reference, TR_INPUT);
+
+ if (isset($taxitem['purchasing_gl_code']))
+ {
+ if ($trans_type == ST_SUPPCREDIT)
+ $taxitem['Value'] = -$taxitem['Value'];
+ $total += add_gl_trans_supplier($trans_type, $invoice_id, $date_,
+ $taxitem['purchasing_gl_code'], $dim, $dim2, $taxitem['Value'],
+ $supp_trans->supplier_id,
+ "A general ledger transaction for the tax amount could not be added");
+ }
+ }
+ }
+ if ($trans_type == ST_SUPPCREDIT)
+ $net_diff = -$net_diff;
+
+ /* Now the AP account */
+ $total += add_gl_trans_supplier($trans_type, $invoice_id, $date_, $supplier["payable_account"], $dim, $dim2,