Working on gateway fee slippage

This commit is contained in:
David Bomba 2020-10-10 21:57:28 +11:00
parent 61646ec55c
commit b6bea31646
8 changed files with 19 additions and 8 deletions

View File

@ -236,7 +236,7 @@ class CreateSingleAccount extends Command
$client->id_number = $this->getNextClientNumber($client);
$settings = $client->settings;
$settings->currency_id = (string) rand(1, 79);
$settings->currency_id = "1";
$client->settings = $settings;
$country = Country::all()->random();

View File

@ -287,4 +287,6 @@ class InvoiceSum
{
return $this->getTotalTaxes();
}
}

View File

@ -301,4 +301,5 @@ class InvoiceSumInclusive
{
return $this->getTotalTaxes();
}
}

View File

@ -286,7 +286,7 @@ class CompanyGateway extends BaseModel
}
if ($fees_and_limits->fee_percent) {
$fee += $amount * $fees_and_limits->fee_percent / 100;
$fee += round(($amount * $fees_and_limits->fee_percent / 100),2);
info("fee after adding fee percent = {$fee}");
}
@ -300,17 +300,17 @@ class CompanyGateway extends BaseModel
/**/
if ($include_taxes) {
if ($fees_and_limits->fee_tax_rate1) {
$fee += $pre_tax_fee * $fees_and_limits->fee_tax_rate1 / 100;
$fee += round(($pre_tax_fee * $fees_and_limits->fee_tax_rate1 / 100),2);
info("fee after adding fee tax 1 = {$fee}");
}
if ($fees_and_limits->fee_tax_rate2) {
$fee += $pre_tax_fee * $fees_and_limits->fee_tax_rate2 / 100;
$fee += round(($pre_tax_fee * $fees_and_limits->fee_tax_rate2 / 100),2);
info("fee after adding fee tax 2 = {$fee}");
}
if ($fees_and_limits->fee_tax_rate3) {
$fee += $pre_tax_fee * $fees_and_limits->fee_tax_rate3 / 100;
$fee += round(($pre_tax_fee * $fees_and_limits->fee_tax_rate3 / 100),2);
info("fee after adding fee tax 3 = {$fee}");
}
}

View File

@ -44,6 +44,9 @@ class AddGatewayFee extends AbstractService
{
$gateway_fee = round($this->company_gateway->calcGatewayFee($this->amount), $this->invoice->client->currency()->precision);
if((int)$gateway_fee == 0)
return;
$this->cleanPendingGatewayFees();
if ($gateway_fee > 0) {

View File

@ -212,6 +212,8 @@ class InvoiceService
public function updateStatus()
{
info("invoice balance = {$this->invoice->balance}");
if((int)$this->invoice->balance == 0)
$this->setStatus(Invoice::STATUS_PAID);
@ -232,7 +234,7 @@ class InvoiceService
return $item;
})->toArray();
$this->invoice = $this->invoice->calc()->getInvoice();
//$this->invoice = $this->invoice->calc()->getInvoice();
$this->deletePdf();

View File

@ -67,12 +67,16 @@ class PaymentService
}
});
$this->payment->ledger()->updatePaymentBalance($this->payment->amount);
$this->payment
->ledger()
->updatePaymentBalance($this->payment->amount);
$client->service()
->updateBalance($this->payment->amount)
->updatePaidToDate($this->payment->amount * -1)
->save();
return $this;
}
public function refundPayment(array $data) :?Payment

View File

@ -31,7 +31,6 @@ class UpdateGatewayTableVisibleColumn extends Migration
});
Schema::table('expenses', function ($t){
$t->renameColumn('invoice_category_id', 'category_id');
});