mirror of https://github.com/itflow-org/itflow
Remove Credit once Applied, also get total credits applied
This commit is contained in:
parent
0db6853fde
commit
4d71eb5de0
|
|
@ -908,13 +908,17 @@ if (isset($_POST['apply_credit'])) {
|
||||||
$invoice_prefix = getFieldByID('invoices',$invoice_id,'invoice_prefix');
|
$invoice_prefix = getFieldByID('invoices',$invoice_id,'invoice_prefix');
|
||||||
$invoice_number = getFieldByID('invoices',$invoice_id,'invoice_number');
|
$invoice_number = getFieldByID('invoices',$invoice_id,'invoice_number');
|
||||||
$invoice_status = getFieldByID('invoices',$invoice_id,'invoice_status');
|
$invoice_status = getFieldByID('invoices',$invoice_id,'invoice_status');
|
||||||
|
$invoice_credit_amount = floatval(getFieldByID('invoices',$invoice_id,'invoice_credit_amount'));
|
||||||
|
$total_credit_amount = $invoice_credit_amount + $amount;
|
||||||
|
|
||||||
//Check to see if amount entered is greater than the balance of the invoice
|
//Check to see if amount entered is greater than the balance of the invoice
|
||||||
if ($amount > $invoice_balance) {
|
if ($amount > $invoice_balance) {
|
||||||
$_SESSION['alert_message'] = "Credit is more than the balance";
|
$_SESSION['alert_message'] = "Credit is more than the balance";
|
||||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||||
} else {
|
} else {
|
||||||
mysqli_query($mysqli,"UPDATE invoices SET invoice_credit_amount = $amount WHERE invoice_id = $invoice_id");
|
mysqli_query($mysqli,"UPDATE invoices SET invoice_credit_amount = $total_credit_amount WHERE invoice_id = $invoice_id");
|
||||||
|
// Remove Amounted Credit
|
||||||
|
mysqli_query($mysqli,"INSERT INTO credits SET credit_amount = -$amount, credit_created_by = $session_user_id, credit_client_id = $client_id");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
//Add up all the payments for the invoice and get the total amount paid to the invoice
|
//Add up all the payments for the invoice and get the total amount paid to the invoice
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue