Clean up of Apply Number class for payments

This commit is contained in:
David Bomba 2023-06-08 17:11:19 +10:00
parent 9e604e81f6
commit 897f170307
2 changed files with 5 additions and 10 deletions

View File

@ -98,11 +98,10 @@ class PaymentMigrationRepository extends BaseRepository
}
$payment->deleted_at = $data['deleted_at'] ?: null;
$payment->save();
if ($payment->currency_id == 0) {
$payment->currency_id = $payment->company->settings->currency_id;
$payment->save();
}
/*Ensure payment number generated*/
@ -110,6 +109,8 @@ class PaymentMigrationRepository extends BaseRepository
$payment->number = $payment->client->getNextPaymentNumber($payment->client, $payment);
}
$payment->save();
$invoice_totals = 0;
$credit_totals = 0;
$invoices = false;

View File

@ -20,15 +20,10 @@ class ApplyNumber extends AbstractService
{
use GeneratesCounter;
private $payment;
private bool $completed = true;
public function __construct(Payment $payment)
public function __construct(private Payment $payment)
{
$this->client = $payment->client;
$this->payment = $payment;
}
public function run()
@ -38,7 +33,6 @@ class ApplyNumber extends AbstractService
}
$this->trySaving();
// $this->payment->number = $this->getNextPaymentNumber($this->client, $this->payment);
return $this->payment;
}
@ -49,7 +43,7 @@ class ApplyNumber extends AbstractService
do {
try {
$this->payment->number = $this->getNextPaymentNumber($this->client, $this->payment);
$this->payment->number = $this->getNextPaymentNumber($this->payment->client, $this->payment);
$this->payment->saveQuietly();
$this->completed = false;