diff --git a/app/Console/Commands/CreateSingleAccount.php b/app/Console/Commands/CreateSingleAccount.php index ee489b53d7b7..fba9fcb378cf 100644 --- a/app/Console/Commands/CreateSingleAccount.php +++ b/app/Console/Commands/CreateSingleAccount.php @@ -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(); diff --git a/app/Helpers/Invoice/InvoiceSum.php b/app/Helpers/Invoice/InvoiceSum.php index cde944a98828..561f9480a1cc 100644 --- a/app/Helpers/Invoice/InvoiceSum.php +++ b/app/Helpers/Invoice/InvoiceSum.php @@ -287,4 +287,6 @@ class InvoiceSum { return $this->getTotalTaxes(); } + + } diff --git a/app/Helpers/Invoice/InvoiceSumInclusive.php b/app/Helpers/Invoice/InvoiceSumInclusive.php index 924fb7098e36..b84d4090935b 100644 --- a/app/Helpers/Invoice/InvoiceSumInclusive.php +++ b/app/Helpers/Invoice/InvoiceSumInclusive.php @@ -301,4 +301,5 @@ class InvoiceSumInclusive { return $this->getTotalTaxes(); } + } diff --git a/app/Models/CompanyGateway.php b/app/Models/CompanyGateway.php index 6ebf2371e213..d569f26b96b1 100644 --- a/app/Models/CompanyGateway.php +++ b/app/Models/CompanyGateway.php @@ -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}"); } } diff --git a/app/Services/Invoice/AddGatewayFee.php b/app/Services/Invoice/AddGatewayFee.php index 18e3937aac1e..bc88092d3048 100644 --- a/app/Services/Invoice/AddGatewayFee.php +++ b/app/Services/Invoice/AddGatewayFee.php @@ -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) { diff --git a/app/Services/Invoice/InvoiceService.php b/app/Services/Invoice/InvoiceService.php index 51a98d161675..d814e382f7e8 100644 --- a/app/Services/Invoice/InvoiceService.php +++ b/app/Services/Invoice/InvoiceService.php @@ -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(); diff --git a/app/Services/Payment/PaymentService.php b/app/Services/Payment/PaymentService.php index 5f253b09ff50..764b465eea41 100644 --- a/app/Services/Payment/PaymentService.php +++ b/app/Services/Payment/PaymentService.php @@ -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 diff --git a/database/migrations/2020_09_27_215800_update_gateway_table_visible_column.php b/database/migrations/2020_09_27_215800_update_gateway_table_visible_column.php index c870ead51551..c5b029f921f8 100644 --- a/database/migrations/2020_09_27_215800_update_gateway_table_visible_column.php +++ b/database/migrations/2020_09_27_215800_update_gateway_table_visible_column.php @@ -31,7 +31,6 @@ class UpdateGatewayTableVisibleColumn extends Migration }); - Schema::table('expenses', function ($t){ $t->renameColumn('invoice_category_id', 'category_id'); });