mirror of https://github.com/itflow-org/itflow
Removed Gateway Fee from the baance of Guest View Invoice and displayed it on the Pay Online button, as the client can pay other ways if they decide to not pay online if Client Pays Fees is enabled
This commit is contained in:
parent
1bbb4426f6
commit
28e7a6b195
|
|
@ -86,10 +86,9 @@ if (isset($_GET['invoice_id'], $_GET['url_key']) && !isset($_GET['payment_intent
|
|||
|
||||
if ($config_stripe_client_pays_fees == 1) {
|
||||
$balance_before_fees = $balance_to_pay;
|
||||
// Calculate the amount to charge the client
|
||||
$balance_to_pay = ($balance_to_pay + $config_stripe_flat_fee) / (1 - $config_stripe_percentage_fee);
|
||||
// Calculate the fee amount
|
||||
$gateway_fee = round($balance_to_pay - $balance_before_fees, 2);
|
||||
// Calculate the Gateway fee
|
||||
$gateway_fee = round($balance_to_pay * $config_stripe_percentage_fee + $config_stripe_flat_fee, 2);
|
||||
$balance_to_pay = $balance_to_pay + $gateway_fee;
|
||||
}
|
||||
|
||||
//Round balance to pay to 2 decimal places
|
||||
|
|
@ -277,17 +276,19 @@ if (isset($_GET['invoice_id'], $_GET['url_key']) && !isset($_GET['payment_intent
|
|||
|
||||
// Check config to see if client pays fees is enabled or if should expense it
|
||||
if ($config_stripe_client_pays_fees == 1) {
|
||||
// Calculate gateway expense fee
|
||||
$gateway_fee = round($balance_to_pay * $config_stripe_percentage_fee + $config_stripe_flat_fee, 2);
|
||||
// Calculate the amount to charge the client
|
||||
$balance_to_pay = ($balance_to_pay + $config_stripe_flat_fee) / (1 - $config_stripe_percentage_fee);
|
||||
$balance_to_pay = $balance_to_pay + $gateway_fee;
|
||||
}
|
||||
|
||||
// Check to see if Expense Fields are configured and client pays fee is off then create expense
|
||||
if ($config_stripe_client_pays_fees == 0 && $config_stripe_expense_vendor > 0 && $config_stripe_expense_category > 0) {
|
||||
// Calculate gateway expense fee
|
||||
$gateway_expense_fee = round($balance_to_pay * $config_stripe_percentage_fee + $config_stripe_flat_fee, 2);
|
||||
$gateway_fee = round($balance_to_pay * $config_stripe_percentage_fee + $config_stripe_flat_fee, 2);
|
||||
|
||||
// Add Expense
|
||||
mysqli_query($mysqli,"INSERT INTO expenses SET expense_date = '$pi_date', expense_amount = $gateway_expense_fee, expense_currency_code = '$invoice_currency_code', expense_account_id = $config_stripe_account, expense_vendor_id = $config_stripe_expense_vendor, expense_client_id = $client_id, expense_category_id = $config_stripe_expense_category, expense_description = 'Stripe Transaction for Invoice $invoice_prefix$invoice_number In the Amount of $balance_to_pay', expense_reference = 'Stripe - $pi_id'");
|
||||
mysqli_query($mysqli,"INSERT INTO expenses SET expense_date = '$pi_date', expense_amount = $gateway_fee, expense_currency_code = '$invoice_currency_code', expense_account_id = $config_stripe_account, expense_vendor_id = $config_stripe_expense_vendor, expense_client_id = $client_id, expense_category_id = $config_stripe_expense_category, expense_description = 'Stripe Transaction for Invoice $invoice_prefix$invoice_number In the Amount of $balance_to_pay', expense_reference = 'Stripe - $pi_id'");
|
||||
}
|
||||
|
||||
// Round balance to pay to 2 decimal places
|
||||
|
|
|
|||
|
|
@ -114,24 +114,8 @@ $amount_paid = floatval($row['amount_paid']);
|
|||
// Calculate the balance owed
|
||||
$balance = $invoice_amount - $amount_paid;
|
||||
|
||||
// Check for overpayment or exact payment (amount paid is equal to or exceeds invoice amount)
|
||||
if ($balance <= 0) {
|
||||
// Invoice is fully paid (either exact payment or overpayment)
|
||||
$gateway_fee = 0; // Zero out the gateway fee
|
||||
$amount_paid = $invoice_amount; // Adjust amount paid to equal invoice amount
|
||||
$balance = 0; // Balance is zero since invoice is fully paid
|
||||
} else {
|
||||
// If invoice is not fully paid
|
||||
// Check if client is responsible for paying Stripe fees
|
||||
if ($config_stripe_client_pays_fees == 1) {
|
||||
// Calculate the total amount to charge the client, including Stripe fees
|
||||
$balance_to_pay = ($balance + $config_stripe_flat_fee) / (1 - $config_stripe_percentage_fee);
|
||||
$gateway_fee = $balance_to_pay - $balance; // Calculate gateway fee based on Stripe fees
|
||||
} else {
|
||||
// If client is not responsible for Stripe fees, gateway fee remains zero
|
||||
$gateway_fee = 0;
|
||||
}
|
||||
}
|
||||
// Calculate Gateway Fee
|
||||
$gateway_fee = round($balance * $config_stripe_percentage_fee + $config_stripe_flat_fee, 2);
|
||||
|
||||
//check to see if overdue
|
||||
$invoice_color = $invoice_badge_color; // Default
|
||||
|
|
@ -155,7 +139,7 @@ $sql_invoice_items = mysqli_query($mysqli, "SELECT * FROM invoice_items WHERE it
|
|||
<a class="btn btn-primary" href="#" onclick="pdfMake.createPdf(docDefinition).download('<?php echo strtoAZaz09(html_entity_decode("$invoice_date-$company_name-Invoice-$invoice_prefix$invoice_number")); ?>');"><i class="fa fa-fw fa-download mr-2"></i>Download</a>
|
||||
<?php
|
||||
if ($invoice_status !== "Paid" && $invoice_status !== "Cancelled" && $invoice_status !== "Draft" && $config_stripe_enable == 1) { ?>
|
||||
<a class="btn btn-success" href="guest_pay_invoice_stripe.php?invoice_id=<?php echo $invoice_id; ?>&url_key=<?php echo $url_key; ?>"><i class="fa fa-fw fa-credit-card mr-2"></i>Pay Online</a>
|
||||
<a class="btn btn-success" href="guest_pay_invoice_stripe.php?invoice_id=<?php echo $invoice_id; ?>&url_key=<?php echo $url_key; ?>"><i class="fa fa-fw fa-credit-card mr-2"></i>Pay Online <?php if($config_stripe_client_pays_fees == 1) { echo "(Gateway Fee: " . numfmt_format_currency($currency_format, $gateway_fee, $invoice_currency_code) . ")"; } ?></a>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -312,16 +296,6 @@ $sql_invoice_items = mysqli_query($mysqli, "SELECT * FROM invoice_items WHERE it
|
|||
</tr>
|
||||
<?php
|
||||
}
|
||||
|
||||
if ($gateway_fee > 0) {
|
||||
?>
|
||||
|
||||
<tr class=border-bottom>
|
||||
<td><div class="text-success">Gateway Fee</div></td>
|
||||
<td class="text-right text-success"><?php echo numfmt_format_currency($currency_format, $gateway_fee, $invoice_currency_code); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<tr class="border-bottom">
|
||||
<td><strong>Balance</strong></td>
|
||||
|
|
|
|||
Loading…
Reference in New Issue