Added Gateway Fee to the Guest View Invoice and minor fix for ticket counter per Pull Request #866 also added stripe flat and percent config vars to guest view invoice. Note We do not need to merge Pull #866 as all changes nessessary have been implented manually

This commit is contained in:
johnnyq 2024-01-28 15:55:05 -05:00
parent 5afacf78cf
commit f8dc67fbf9
3 changed files with 26 additions and 19 deletions

View File

@ -80,6 +80,8 @@ if (!empty($company_logo)) {
$company_locale = nullable_htmlentities($row['company_locale']); $company_locale = nullable_htmlentities($row['company_locale']);
$config_invoice_footer = nullable_htmlentities($row['config_invoice_footer']); $config_invoice_footer = nullable_htmlentities($row['config_invoice_footer']);
$config_stripe_enable = intval($row['config_stripe_enable']); $config_stripe_enable = intval($row['config_stripe_enable']);
$config_stripe_percentage_fee = floatval($row['config_stripe_percentage_fee']);
$config_stripe_flat_fee = floatval($row['config_stripe_flat_fee']);
$config_stripe_client_pays_fees = intval($row['config_stripe_client_pays_fees']); $config_stripe_client_pays_fees = intval($row['config_stripe_client_pays_fees']);
//Set Currency Format //Set Currency Format
@ -109,16 +111,15 @@ $sql_amount_paid = mysqli_query($mysqli, "SELECT SUM(payment_amount) AS amount_p
$row = mysqli_fetch_array($sql_amount_paid); $row = mysqli_fetch_array($sql_amount_paid);
$amount_paid = floatval($row['amount_paid']); $amount_paid = floatval($row['amount_paid']);
$balance = $invoice_amount - $amount_paid;
// Check config to see if client pays fees is enabled // Check config to see if client pays fees is enabled
if ($config_stripe_client_pays_fees == 1) { if ($config_stripe_client_pays_fees == 1) {
$percentage_fee = 0.029; // Calculate the amount to charge the client
$flat_fee = 0.30; $balance_to_pay = ($balance + $config_stripe_flat_fee) / (1 - $coinfig_stripe_percentage_fee);
// Calculate the amount to charge the client $stripe_fee = $balance_to_pay - $balance;
$balance_to_pay = ($balance + $flat_fee) / (1 - $percentage_fee); } else {
$stripe_fee = $balance_to_pay - $balance; $gateway_fee = 0;
} $balance = $invoice_amount - $amount_paid;
}
//check to see if overdue //check to see if overdue
$invoice_color = $invoice_badge_color; // Default $invoice_color = $invoice_badge_color; // Default
@ -297,7 +298,19 @@ $sql_invoice_items = mysqli_query($mysqli, "SELECT * FROM invoice_items WHERE it
<td><div class="text-success">Paid</div></td> <td><div class="text-success">Paid</div></td>
<td class="text-right text-success"><?php echo numfmt_format_currency($currency_format, $amount_paid, $invoice_currency_code); ?></td> <td class="text-right text-success"><?php echo numfmt_format_currency($currency_format, $amount_paid, $invoice_currency_code); ?></td>
</tr> </tr>
<?php } ?> <?php
}
if (isset($gateway_fee)) {
?>
<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"> <tr class="border-bottom">
<td><strong>Balance</strong></td> <td><strong>Balance</strong></td>
<td class="text-right"><strong><?php echo numfmt_format_currency($currency_format, $balance, $invoice_currency_code); ?></strong></td> <td class="text-right"><strong><?php echo numfmt_format_currency($currency_format, $balance, $invoice_currency_code); ?></strong></td>

View File

@ -103,7 +103,6 @@
document.getElementById("startStopTimer").innerText = "Start"; document.getElementById("startStopTimer").innerText = "Start";
} }
function handleInputFocus() { function handleInputFocus() {
if (!isPaused) { if (!isPaused) {
pauseTimer(); pauseTimer();
@ -126,7 +125,6 @@
} }
} }
function updateRunningTicketsCount() { function updateRunningTicketsCount() {
let runningTickets = parseInt(document.getElementById('runningTicketsCount').innerText, 10); let runningTickets = parseInt(document.getElementById('runningTicketsCount').innerText, 10);
@ -136,31 +134,27 @@
runningTickets = Math.max(0, runningTickets - 1); runningTickets = Math.max(0, runningTickets - 1);
} }
document.getElementById('runningTicketsCount').innerText = runningTickets.toString(); document.getElementById('runningTicketsCount').innerText = runningTickets.toString();
} }
// Function to check status and pause timer // Function to check status and pause timer
function checkStatusAndPauseTimer() { function checkStatusAndPauseTimer() {
var status = document.querySelector('select[name="status"]').value; var status = document.querySelector('select[name="status"]').value;
if (status.includes("Pending")) { if (status.includes("Pending") || status.includes("Close")) {
pauseTimer(); pauseTimer();
} }
} }
document.getElementById("hours").addEventListener('change', updateTimeFromInput); document.getElementById("hours").addEventListener('change', updateTimeFromInput);
document.getElementById("minutes").addEventListener('change', updateTimeFromInput); document.getElementById("minutes").addEventListener('change', updateTimeFromInput);
document.getElementById("seconds").addEventListener('change', updateTimeFromInput); document.getElementById("seconds").addEventListener('change', updateTimeFromInput);
document.getElementById("hours").addEventListener('focus', handleInputFocus); document.getElementById("hours").addEventListener('focus', handleInputFocus);
document.getElementById("minutes").addEventListener('focus', handleInputFocus); document.getElementById("minutes").addEventListener('focus', handleInputFocus);
document.getElementById("seconds").addEventListener('focus', handleInputFocus); document.getElementById("seconds").addEventListener('focus', handleInputFocus);
document.querySelector('select[name="status"]').addEventListener('change', checkStatusAndPauseTimer); document.querySelector('select[name="status"]').addEventListener('change', checkStatusAndPauseTimer);
document.getElementById("startStopTimer").addEventListener('click', function() { document.getElementById("startStopTimer").addEventListener('click', function() {
if (timerInterval === null) { if (timerInterval === null) {
startTimer(); startTimer();

View File

@ -24,7 +24,7 @@ require_once "inc_all_settings.php";
<div class="<?php if ($config_stripe_enable == 0) { echo "d-none"; } ?>"> <div class="<?php if ($config_stripe_enable == 0) { echo "d-none"; } ?>">
<div class="form-group"> <div class="form-group">
<label>Publishable</label> <label>Publishable key</label>
<div class="input-group"> <div class="input-group">
<div class="input-group-prepend"> <div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-eye"></i></span> <span class="input-group-text"><i class="fa fa-fw fa-eye"></i></span>
@ -34,7 +34,7 @@ require_once "inc_all_settings.php";
</div> </div>
<div class="form-group"> <div class="form-group">
<label>Secret</label> <label>Secret key</label>
<div class="input-group"> <div class="input-group">
<div class="input-group-prepend"> <div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-lock"></i></span> <span class="input-group-text"><i class="fa fa-fw fa-lock"></i></span>