Andrew Wallo hace 4 meses
padre
commit
a72d8e136a

+ 1
- 5
app/Filament/Company/Resources/Purchases/BillResource/Pages/EditBill.php Ver fichero

@@ -45,11 +45,7 @@ class EditBill extends EditRecord
45 45
 
46 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 50
         return $record;
55 51
     }

+ 1
- 5
app/Models/Accounting/Bill.php Ver fichero

@@ -384,11 +384,7 @@ class Bill extends Document
384 384
 
385 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 389
         $this->createInitialTransaction();
394 390
     }

+ 1
- 5
app/Models/Accounting/Invoice.php Ver fichero

@@ -495,11 +495,7 @@ class Invoice extends Document
495 495
 
496 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 500
         $this->createApprovalTransaction();
505 501
     }

+ 1
- 1
app/Observers/BillObserver.php Ver fichero

@@ -17,7 +17,7 @@ class BillObserver
17 17
 
18 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 21
             $bill->status = BillStatus::Open;
22 22
 
23 23
             return;

+ 1
- 1
app/Observers/InvoiceObserver.php Ver fichero

@@ -16,7 +16,7 @@ class InvoiceObserver
16 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 20
             $invoice->status = $invoice->hasBeenSent() ? InvoiceStatus::Sent : InvoiceStatus::Unsent;
21 21
 
22 22
             return;

Loading…
Cancelar
Guardar