- commit_transaction(); // save PO+GRN+PI
- // FIXME payment for cash terms. (Needs cash account selection)
+ // presume supplier data need correction
+ if ($inv->stored_algorithm != $inv->tax_algorithm)
+ update_supp_tax_algorithm($inv->supplier_id, $inv->tax_algorithm);
+
+ if (get_post('cash_account')) {
+
+ $pmt_no = add_supp_payment($inv->supplier_id, $inv->tran_date, get_post('cash_account'),
+ $total, 0, $Refs->get_next(ST_SUPPAYMENT),
+ _('Payment for:').$inv->supp_reference .' ('.$type_shortcuts[ST_SUPPINVOICE].$inv_no.')');
+ add_supp_allocation($total, ST_SUPPAYMENT, $pmt_no, ST_SUPPINVOICE, $inv_no, $inv->tran_date);
+ update_supp_trans_allocation(ST_SUPPINVOICE, $inv_no, $total);
+ update_supp_trans_allocation(ST_SUPPAYMENT, $pmt_no, $total);
+
+ }
+
+ commit_transaction(); // save PO+GRN+PI(+SP)
+