Fixes for applying invoice numbers to subscriptions where invoice number is set to When Sent

This commit is contained in:
David Bomba 2023-02-07 22:25:40 +11:00
parent c989aaad87
commit cb47c9d40e
3 changed files with 8 additions and 3 deletions

View File

@ -36,6 +36,7 @@ class ApplyNumber extends AbstractService
public function run() public function run()
{ {
if ($this->invoice->number != '') { if ($this->invoice->number != '') {
return $this->invoice; return $this->invoice;
} }
@ -45,7 +46,7 @@ class ApplyNumber extends AbstractService
$this->trySaving(); $this->trySaving();
break; break;
case 'when_sent': case 'when_sent':
if ($this->invoice->status_id == Invoice::STATUS_SENT) { if ($this->invoice->status_id >= Invoice::STATUS_SENT) {
$this->trySaving(); $this->trySaving();
} }
break; break;

View File

@ -85,7 +85,11 @@ class UpdateInvoicePayment
if($invoice->is_proforma) if($invoice->is_proforma)
{ {
$invoice->number = '';
if(strlen($invoice->number) > 1 && str_starts_with($invoice->number,"####"))
$invoice->number = '';
$invoice->is_proforma = false; $invoice->is_proforma = false;
$invoice->service() $invoice->service()

View File

@ -958,7 +958,7 @@ class SubscriptionService
$invoice->subscription_id = $this->subscription->id; $invoice->subscription_id = $this->subscription->id;
$invoice->client_id = $client_id; $invoice->client_id = $client_id;
$invoice->is_proforma = true; $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_items = $bundle->map(function ($item){
$line_item = new InvoiceItem; $line_item = new InvoiceItem;