diff --git a/app/Http/Middleware/ContactRegister.php b/app/Http/Middleware/ContactRegister.php index b2cf964b87a2..60e48d8771c0 100644 --- a/app/Http/Middleware/ContactRegister.php +++ b/app/Http/Middleware/ContactRegister.php @@ -21,6 +21,7 @@ class ContactRegister { $domain_name = $request->getHost(); + /* Hosted */ if (strpos($domain_name, 'invoicing.co') !== false) { $subdomain = explode('.', $domain_name)[0]; @@ -42,6 +43,7 @@ class ContactRegister } } + /* Hosted */ if (Ninja::isHosted()) { $query = [ 'portal_domain' => $request->getSchemeAndHttpHost(), diff --git a/app/Services/Invoice/MarkInvoiceDeleted.php b/app/Services/Invoice/MarkInvoiceDeleted.php index 8990cbfaa597..b7478f920133 100644 --- a/app/Services/Invoice/MarkInvoiceDeleted.php +++ b/app/Services/Invoice/MarkInvoiceDeleted.php @@ -45,8 +45,7 @@ class MarkInvoiceDeleted extends AbstractService ->setAdjustmentAmount() ->deletePaymentables() ->adjustPayments() - ->adjustPaidToDate() - ->adjustBalance() + ->adjustPaidToDateAndBalance() ->adjustLedger(); $transaction = [ @@ -70,21 +69,29 @@ class MarkInvoiceDeleted extends AbstractService return $this; } - private function adjustPaidToDate() + private function adjustPaidToDateAndBalance() { - $client = $this->invoice->client->fresh(); - $client->paid_to_date += $this->adjustment_amount * -1; - $client->save(); - // $this->invoice->client->service()->updatePaidToDate($this->adjustment_amount * -1)->save(); //reduces the paid to date by the payment totals + // $client = $this->invoice->client->fresh(); + // $client->paid_to_date += $this->adjustment_amount * -1; + // $client->balance += $this->balance_adjustment * -1; + // $client->save(); + + // 06-09-2022 + $this->invoice + ->client + ->service() + ->updateBalanceAndPaidToDate($this->balance_adjustment * -1, $this->adjustment_amount * -1) + ->save(); //reduces the paid to date by the payment totals return $this; } + // @deprecated private function adjustBalance() { - $client = $this->invoice->client->fresh(); - $client->balance += $this->balance_adjustment * -1; - $client->save(); + // $client = $this->invoice->client->fresh(); + // $client->balance += $this->balance_adjustment * -1; + // $client->save(); // $this->invoice->client->service()->updateBalance($this->balance_adjustment * -1)->save(); //reduces the client balance by the invoice amount. diff --git a/app/Services/Invoice/MarkPaid.php b/app/Services/Invoice/MarkPaid.php index 2c545556c05e..9f734d17d802 100644 --- a/app/Services/Invoice/MarkPaid.php +++ b/app/Services/Invoice/MarkPaid.php @@ -117,16 +117,12 @@ class MarkPaid extends AbstractService $payment->ledger() ->updatePaymentBalance($this->payable_balance * -1); - // \DB::connection(config('database.default'))->transaction(function () use ($payment) { - - // /* Get the last record for the client and set the current balance*/ - // $client = Client::withTrashed()->where('id', $this->invoice->client_id)->lockForUpdate()->first(); - // $client->paid_to_date += $payment->amount; - // $client->balance -= $payment->amount; - // $client->save(); - // }, 1); - - $this->invoice->client->service()->updateBalanceAndPaidToDate($payment->amount*-1, $payment->amount)->save(); + //06-09-2022 + $this->invoice + ->client + ->service() + ->updateBalanceAndPaidToDate($payment->amount*-1, $payment->amount) + ->save(); $this->invoice = $this->invoice ->service() diff --git a/app/Services/Invoice/MarkSent.php b/app/Services/Invoice/MarkSent.php index fae67eb6540c..07bae6f98659 100644 --- a/app/Services/Invoice/MarkSent.php +++ b/app/Services/Invoice/MarkSent.php @@ -62,16 +62,6 @@ class MarkSent extends AbstractService ->save(); /*Adjust client balance*/ - - // \DB::connection(config('database.default'))->transaction(function () use ($adjustment) { - - // /* Get the last record for the client and set the current balance*/ - // $client = Client::withTrashed()->where('id', $this->client->id)->lockForUpdate()->first(); - // $client->balance += $adjustment; - // $client->save(); - - // }, 1); - $this->invoice->client->service()->updateBalance($adjustment)->save(); $this->invoice->markInvitationsSent(); diff --git a/app/Utils/Traits/Payment/Refundable.php b/app/Utils/Traits/Payment/Refundable.php index c313e1b782a3..7bcbabb98a91 100644 --- a/app/Utils/Traits/Payment/Refundable.php +++ b/app/Utils/Traits/Payment/Refundable.php @@ -28,6 +28,7 @@ trait Refundable /** * Entry point for processing of refunds. * @param array $data + * @deprecated ???? 06-09-2022 * @return Refundable * @throws PaymentRefundFailed */ diff --git a/resources/views/portal/ninja2020/auth/register.blade.php b/resources/views/portal/ninja2020/auth/register.blade.php index 9a8f13540cef..30b94a07629d 100644 --- a/resources/views/portal/ninja2020/auth/register.blade.php +++ b/resources/views/portal/ninja2020/auth/register.blade.php @@ -52,7 +52,7 @@ @elseif($field['key'] === 'country_id') + + + + + + + +