Merge pull request #5718 from turbo124/v5-develop

Fixes for gateway fees less that
This commit is contained in:
David Bomba 2021-05-16 08:19:01 +10:00 committed by GitHub
commit 7005c6ffe8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 4 deletions

View File

@ -309,14 +309,14 @@ class CompanyGateway extends BaseModel
$fees_and_limits = $this->getFeesAndLimits($gateway_type_id);
if (! $fees_and_limits) {
return 0;
return false;
}
$fee = 0;
if ($fees_and_limits->fee_amount) {
$fee += $fees_and_limits->fee_amount;
// info("fee after adding fee amount = {$fee}");
nlog("fee after adding fee amount = {$fee}");
}
if ($fees_and_limits->fee_percent) {
@ -325,7 +325,7 @@ class CompanyGateway extends BaseModel
} else {
$fee += round(($amount * $fees_and_limits->fee_percent / 100), 2);
}
// info("fee after adding fee percent = {$fee}");
nlog("fee after adding fee percent = {$fee}");
}
/* Cap fee if we have to here. */
@ -334,6 +334,7 @@ class CompanyGateway extends BaseModel
}
$pre_tax_fee = $fee;
nlog("fee after adding fee percent = {$fee}");
/**/
if ($include_taxes) {
@ -352,6 +353,7 @@ class CompanyGateway extends BaseModel
// info("fee after adding fee tax 3 = {$fee}");
}
}
nlog("fee after adding fee percent = {$fee}");
return $fee;
}

View File

@ -43,7 +43,7 @@ class AddGatewayFee extends AbstractService
{
$gateway_fee = round($this->company_gateway->calcGatewayFee($this->amount, $this->gateway_type_id, $this->invoice->uses_inclusive_taxes), $this->invoice->client->currency()->precision);
if ((int)$gateway_fee == 0)
if (!$gateway_fee)
return $this->invoice;
// Removes existing stale gateway fees