Fix Expense being off for Payment Gateway Fee

This commit is contained in:
johnnyq 2024-01-31 21:33:37 -05:00
parent 96ff92d070
commit 1bbb4426f6
1 changed files with 2 additions and 5 deletions

View File

@ -283,11 +283,8 @@ if (isset($_GET['invoice_id'], $_GET['url_key']) && !isset($_GET['payment_intent
// 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) {
$balance_before_fees = $balance_to_pay;
// Calculate the amount to charge the client
$balance_to_not_pay = ($balance_to_pay + $config_stripe_flat_fee) / (1 - $config_stripe_percentage_fee);
// Calculate the fee amount
$gateway_expense_fee = round($balance_to_not_pay - $balance_before_fees, 2);
// Calculate gateway expense fee
$gateway_expense_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'");