Andrew Wallo 4 months ago
parent
commit
a72d8e136a

+ 1
- 5
app/Filament/Company/Resources/Purchases/BillResource/Pages/EditBill.php View File

45
 
45
 
46
         $record = parent::handleRecordUpdate($record, $data);
46
         $record = parent::handleRecordUpdate($record, $data);
47
 
47
 
48
-        if (! $record->initialTransaction) {
49
-            $record->createInitialTransaction();
50
-        } else {
51
-            $record->updateInitialTransaction();
52
-        }
48
+        $record->updateInitialTransaction();
53
 
49
 
54
         return $record;
50
         return $record;
55
     }
51
     }

+ 1
- 5
app/Models/Accounting/Bill.php View File

384
 
384
 
385
     public function updateInitialTransaction(): void
385
     public function updateInitialTransaction(): void
386
     {
386
     {
387
-        $transaction = $this->initialTransaction;
388
-
389
-        if ($transaction) {
390
-            $transaction->delete();
391
-        }
387
+        $this->initialTransaction?->delete();
392
 
388
 
393
         $this->createInitialTransaction();
389
         $this->createInitialTransaction();
394
     }
390
     }

+ 1
- 5
app/Models/Accounting/Invoice.php View File

495
 
495
 
496
     public function updateApprovalTransaction(): void
496
     public function updateApprovalTransaction(): void
497
     {
497
     {
498
-        $transaction = $this->approvalTransaction;
499
-
500
-        if ($transaction) {
501
-            $transaction->delete();
502
-        }
498
+        $this->approvalTransaction?->delete();
503
 
499
 
504
         $this->createApprovalTransaction();
500
         $this->createApprovalTransaction();
505
     }
501
     }

+ 1
- 1
app/Observers/BillObserver.php View File

17
 
17
 
18
     public function saving(Bill $bill): void
18
     public function saving(Bill $bill): void
19
     {
19
     {
20
-        if ($bill->isDirty('due_date') && $bill->status === BillStatus::Overdue && ! $bill->shouldBeOverdue()) {
20
+        if ($bill->isDirty('due_date') && $bill->status === BillStatus::Overdue && ! $bill->shouldBeOverdue() && ! $bill->hasPayments()) {
21
             $bill->status = BillStatus::Open;
21
             $bill->status = BillStatus::Open;
22
 
22
 
23
             return;
23
             return;

+ 1
- 1
app/Observers/InvoiceObserver.php View File

16
             return;
16
             return;
17
         }
17
         }
18
 
18
 
19
-        if ($invoice->isDirty('due_date') && $invoice->status === InvoiceStatus::Overdue && ! $invoice->shouldBeOverdue()) {
19
+        if ($invoice->isDirty('due_date') && $invoice->status === InvoiceStatus::Overdue && ! $invoice->shouldBeOverdue() && ! $invoice->hasPayments()) {
20
             $invoice->status = $invoice->hasBeenSent() ? InvoiceStatus::Sent : InvoiceStatus::Unsent;
20
             $invoice->status = $invoice->hasBeenSent() ? InvoiceStatus::Sent : InvoiceStatus::Unsent;
21
 
21
 
22
             return;
22
             return;

Loading…
Cancel
Save