mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Fixes for calcuting gateway fees and for removing unpaid gateway fees appropriately
This commit is contained in:
parent
965b7691fd
commit
8b48f26c79
@ -95,6 +95,7 @@ class InvoiceController extends Controller
|
||||
}
|
||||
|
||||
$invoices->map(function ($invoice) {
|
||||
$invoice->service()->removeUnpaidGatewayFees()->save();
|
||||
$invoice->balance = Number::formatValue($invoice->balance, $invoice->client->currency());
|
||||
$invoice->partial = Number::formatValue($invoice->partial, $invoice->client->currency());
|
||||
|
||||
|
@ -163,19 +163,29 @@ class PaymentController extends Controller
|
||||
|
||||
$first_invoice = $invoices->first();
|
||||
|
||||
$fee_totals = round($gateway->calcGatewayFee($invoice_totals, true), $first_invoice->client->currency()->precision);
|
||||
$starting_invoice_amount = $first_invoice->amount;
|
||||
|
||||
if (!$first_invoice->uses_inclusive_taxes) {
|
||||
$fee_tax = 0;
|
||||
$fee_tax += round(($first_invoice->tax_rate1 / 100) * $fee_totals, $first_invoice->client->currency()->precision);
|
||||
$fee_tax += round(($first_invoice->tax_rate2 / 100) * $fee_totals, $first_invoice->client->currency()->precision);
|
||||
$fee_tax += round(($first_invoice->tax_rate3 / 100) * $fee_totals, $first_invoice->client->currency()->precision);
|
||||
// $fee_totals = round($gateway->calcGatewayFee($invoice_totals, true), $first_invoice->client->currency()->precision);
|
||||
|
||||
$fee_totals += $fee_tax;
|
||||
}
|
||||
// if (!$first_invoice->uses_inclusive_taxes) {
|
||||
// $fee_tax = 0;
|
||||
// $fee_tax += round(($first_invoice->tax_rate1 / 100) * $fee_totals, $first_invoice->client->currency()->precision);
|
||||
// $fee_tax += round(($first_invoice->tax_rate2 / 100) * $fee_totals, $first_invoice->client->currency()->precision);
|
||||
// $fee_tax += round(($first_invoice->tax_rate3 / 100) * $fee_totals, $first_invoice->client->currency()->precision);
|
||||
|
||||
// $fee_totals += $fee_tax;
|
||||
// }
|
||||
|
||||
$first_invoice->service()->addGatewayFee($gateway, $invoice_totals)->save();
|
||||
|
||||
/**
|
||||
*
|
||||
* The best way to determine the exact gateway fee is to not calculate it in isolation (due to rounding)
|
||||
* but to simply add it as a line item, and then subtract the starting and finishing amounts of
|
||||
* the invoice.
|
||||
*/
|
||||
$fee_totals = $first_invoice->amount - $starting_invoice_amount;
|
||||
|
||||
$payment_hash = new PaymentHash;
|
||||
$payment_hash->hash = Str::random(128);
|
||||
$payment_hash->data = $payable_invoices;
|
||||
|
Loading…
x
Reference in New Issue
Block a user