- if (!$inv->tax_included) {
- $taxes = $inv->get_taxes($inv->tax_group_id, 0, false, $inv->tax_algorithm);
- foreach( $taxes as $taxitem) {
- $total += $taxitem['Value'];
- }
- }
-
- $inv_no = add_supp_invoice($inv);
- // 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)
-
- unset($_SESSION['PO']);
- meta_forward($_SERVER['PHP_SELF'], "AddedPI=$inv_no");
- }
- else { // order modification
-