Andrew Wallo 10 月之前
父節點
當前提交
1aae2799d3
共有 1 個檔案被更改,包括 8 行新增8 行删除
  1. 8
    8
      app/Models/Accounting/Invoice.php

+ 8
- 8
app/Models/Accounting/Invoice.php 查看文件

263
         return $action::make('approveDraft')
263
         return $action::make('approveDraft')
264
             ->label('Approve')
264
             ->label('Approve')
265
             ->icon('heroicon-o-check-circle')
265
             ->icon('heroicon-o-check-circle')
266
-            ->visible(function (Invoice $record) {
266
+            ->visible(function (self $record) {
267
                 return $record->isDraft();
267
                 return $record->isDraft();
268
             })
268
             })
269
             ->databaseTransaction()
269
             ->databaseTransaction()
270
             ->successNotificationTitle('Invoice Approved')
270
             ->successNotificationTitle('Invoice Approved')
271
-            ->action(function (Invoice $record, MountableAction $action) {
271
+            ->action(function (self $record, MountableAction $action) {
272
                 $record->approveDraft();
272
                 $record->approveDraft();
273
 
273
 
274
                 $action->success();
274
                 $action->success();
280
         return $action::make('markAsSent')
280
         return $action::make('markAsSent')
281
             ->label('Mark as Sent')
281
             ->label('Mark as Sent')
282
             ->icon('heroicon-o-paper-airplane')
282
             ->icon('heroicon-o-paper-airplane')
283
-            ->visible(function (Invoice $record) {
283
+            ->visible(static function (self $record) {
284
                 return ! $record->last_sent;
284
                 return ! $record->last_sent;
285
             })
285
             })
286
             ->successNotificationTitle('Invoice Sent')
286
             ->successNotificationTitle('Invoice Sent')
287
-            ->action(function (Invoice $record, MountableAction $action) {
287
+            ->action(function (self $record, MountableAction $action) {
288
                 $record->update([
288
                 $record->update([
289
                     'status' => InvoiceStatus::Sent,
289
                     'status' => InvoiceStatus::Sent,
290
                     'last_sent' => now(),
290
                     'last_sent' => now(),
299
         return $action::make()
299
         return $action::make()
300
             ->excludeAttributes(['status', 'amount_paid', 'amount_due', 'created_by', 'updated_by', 'created_at', 'updated_at', 'invoice_number', 'date', 'due_date'])
300
             ->excludeAttributes(['status', 'amount_paid', 'amount_due', 'created_by', 'updated_by', 'created_at', 'updated_at', 'invoice_number', 'date', 'due_date'])
301
             ->modal(false)
301
             ->modal(false)
302
-            ->beforeReplicaSaved(function (Invoice $original, Invoice $replica) {
302
+            ->beforeReplicaSaved(function (self $original, self $replica) {
303
                 $replica->status = InvoiceStatus::Draft;
303
                 $replica->status = InvoiceStatus::Draft;
304
-                $replica->invoice_number = Invoice::getNextDocumentNumber();
304
+                $replica->invoice_number = self::getNextDocumentNumber();
305
                 $replica->date = now();
305
                 $replica->date = now();
306
                 $replica->due_date = now()->addDays($original->company->defaultInvoice->payment_terms->getDays());
306
                 $replica->due_date = now()->addDays($original->company->defaultInvoice->payment_terms->getDays());
307
             })
307
             })
308
             ->databaseTransaction()
308
             ->databaseTransaction()
309
-            ->after(function (Invoice $original, Invoice $replica) {
309
+            ->after(function (self $original, self $replica) {
310
                 $original->lineItems->each(function (DocumentLineItem $lineItem) use ($replica) {
310
                 $original->lineItems->each(function (DocumentLineItem $lineItem) use ($replica) {
311
                     $replicaLineItem = $lineItem->replicate([
311
                     $replicaLineItem = $lineItem->replicate([
312
                         'documentable_id',
312
                         'documentable_id',
327
                     $replicaLineItem->adjustments()->sync($lineItem->adjustments->pluck('id'));
327
                     $replicaLineItem->adjustments()->sync($lineItem->adjustments->pluck('id'));
328
                 });
328
                 });
329
             })
329
             })
330
-            ->successRedirectUrl(function (Invoice $replica) {
330
+            ->successRedirectUrl(static function (self $replica) {
331
                 return InvoiceResource::getUrl('edit', ['record' => $replica]);
331
                 return InvoiceResource::getUrl('edit', ['record' => $replica]);
332
             });
332
             });
333
     }
333
     }

Loading…
取消
儲存