diff --git a/app/Services/Invoice/ApplyNumber.php b/app/Services/Invoice/ApplyNumber.php index 6520d2d86542..7bb10ec8e887 100644 --- a/app/Services/Invoice/ApplyNumber.php +++ b/app/Services/Invoice/ApplyNumber.php @@ -36,6 +36,7 @@ class ApplyNumber extends AbstractService public function run() { + if ($this->invoice->number != '') { return $this->invoice; } @@ -45,7 +46,7 @@ class ApplyNumber extends AbstractService $this->trySaving(); break; case 'when_sent': - if ($this->invoice->status_id == Invoice::STATUS_SENT) { + if ($this->invoice->status_id >= Invoice::STATUS_SENT) { $this->trySaving(); } break; diff --git a/app/Services/Payment/UpdateInvoicePayment.php b/app/Services/Payment/UpdateInvoicePayment.php index 4fc84e33b489..5035b4cb2a71 100644 --- a/app/Services/Payment/UpdateInvoicePayment.php +++ b/app/Services/Payment/UpdateInvoicePayment.php @@ -85,7 +85,11 @@ class UpdateInvoicePayment if($invoice->is_proforma) { - $invoice->number = ''; + + if(strlen($invoice->number) > 1 && str_starts_with($invoice->number,"####")) + $invoice->number = ''; + + $invoice->is_proforma = false; $invoice->service() diff --git a/app/Services/Subscription/SubscriptionService.php b/app/Services/Subscription/SubscriptionService.php index c9862683f843..e2c0e9f56383 100644 --- a/app/Services/Subscription/SubscriptionService.php +++ b/app/Services/Subscription/SubscriptionService.php @@ -958,7 +958,7 @@ class SubscriptionService $invoice->subscription_id = $this->subscription->id; $invoice->client_id = $client_id; $invoice->is_proforma = true; - $invoice->number = ctrans('texts.subscription') . "_" . now()->format('Y-m-d') . "_" . rand(0,100000); + $invoice->number = "####" . ctrans('texts.subscription') . "_" . now()->format('Y-m-d') . "_" . rand(0,100000); $line_items = $bundle->map(function ($item){ $line_item = new InvoiceItem;