Supplier Credit Note: invalid reference number selected for credit against invoice - fixed
return $diff;
}
//----------------------------------------------------------------------------------------
-
function add_supp_invoice(&$supp_trans)
{
global $Refs;
foreach ($taxes as $n => $taxitem)
$item_added_tax += isset($taxitem['Override']) ? $taxitem['Override'] : round2($taxitem['Value'], user_price_dec());
}
-
if ($trans_type == ST_SUPPCREDIT)
{
// let's negate everything because it's a credit note
$details_row["description"],
$details_row['qty_recd'],
$details_row['quantity_inv'],
- $details_row["quantity"], 0, $details_row["FullUnitPrice"],
+ ($trans_type == ST_SUPPCREDIT ? -1 : 1) * $details_row["quantity"], 0, $details_row["FullUnitPrice"], // SUPPCREDIT quantities are stored negative in database
0, 0);
}
else
$result = db_query($sql,"calculate the allocation");
$myrow = db_fetch_row($result);
- return $myrow[0];
+ return $myrow ? $myrow[0] : 0;
}
//----------------------------------------------------------------------------------------
$_SESSION['supp_trans']->trans_type = ST_SUPPCREDIT;
$_SESSION['supp_trans']->trans_no = 0;
$_SESSION['supp_trans']->supp_reference = '';
+ $_SESSION['supp_trans']->reference = '';
$help_context = "Supplier Credit Note";
$_SESSION['page_title'] = _("Supplier Credit Note");
if (!check_data())
return;
- if (isset($_POST['invoice_no']))
- $invoice_no = add_supp_invoice($_SESSION['supp_trans'], $_POST['invoice_no']);
- else
- $invoice_no = add_supp_invoice($_SESSION['supp_trans']);
+ $invoice_no = add_supp_invoice($_SESSION['supp_trans']);
$_SESSION['supp_trans']->clear_items();
unset($_SESSION['supp_trans']);