Skip to content

Commit

Permalink
allow edit draft serial number
Browse files Browse the repository at this point in the history
  • Loading branch information
QuentinGab committed Aug 6, 2024
1 parent 3722642 commit 89da32c
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/Invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,18 @@ public static function booted()
});

static::updating(function (Invoice $invoice) {
if ($invoice->isDirty([
'serial_number',
'serial_number_format',
'serial_number_prefix',
'serial_number_serie',
'serial_number_year',
'serial_number_month',
'serial_number_count',
])) {
if (
$invoice->state !== InvoiceState::Draft &&
$invoice->isDirty([
'serial_number',
'serial_number_format',
'serial_number_prefix',
'serial_number_serie',
'serial_number_year',
'serial_number_month',
'serial_number_count',
])
) {
throw new Exception("Serial number details can't be changed after creation", 500);
}

Expand Down

0 comments on commit 89da32c

Please sign in to comment.