Polish the manual invoice feature with 4 improvements: 1. Admin invoice form: numeric fields (unit_price, discount_amount) now display values with thousand-separators (e.g. 1,000,000 instead of 1000000) via formatStateUsing/dehydrateStateUsing for easier reading of large Rial amounts. The placeholder/subtotal/total calculations also strip commas before arithmetic. 2. Fix 'total amount payable = 0' bug in the form. The placeholder had a typo: 'foreach ( as )' overwrote the loop variable and made the inner calculation use the array instead of each item, so the sum was always 0. Now correctly iterates with . 3. Customer dashboard widget: add an 'Invoices pending payment' card showing the count, with a link to /my-account/?tab=invoices if > 0. Relabel the existing 'Pending payment' card to 'Pending payment (orders)' to clarify it's for orders, not invoices. 4. Customer profile financial status: include manual invoices in the accounting_balance and pending_payments_total. Show a breakdown list (orders vs invoices) under the balance card, plus two new stat cards (pending invoices count/total, paid invoices count/total) with a link to the invoices tab.
44 lines
1.3 KiB
PHP
44 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Notifications;
|
|
|
|
use App\Models\ManualInvoice;
|
|
use App\Models\User;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Notifications\Notification;
|
|
|
|
/**
|
|
* اعلان به مشتری: فاکتور دستی جدیدی برای شما صادر شده است.
|
|
*
|
|
* Trigger: ManualInvoiceService::createInvoice()
|
|
*/
|
|
class ManualInvoiceCreatedNotification extends Notification
|
|
{
|
|
use Queueable;
|
|
|
|
public function __construct(
|
|
public ManualInvoice $invoice,
|
|
public ?User $issuedBy = null,
|
|
) {}
|
|
|
|
public function via($notifiable): array
|
|
{
|
|
return ['database'];
|
|
}
|
|
|
|
public function toArray($notifiable): array
|
|
{
|
|
return [
|
|
'type' => 'manual_invoice_created',
|
|
'invoice_id' => $this->invoice->id,
|
|
'invoice_number' => $this->invoice->invoice_number,
|
|
'total_amount' => $this->invoice->total_amount,
|
|
'due_date' => $this->invoice->due_date?->toDateString(),
|
|
'message' => "فاکتور جدید {$this->invoice->invoice_number} به مبلغ "
|
|
. number_format($this->invoice->total_amount) . " ریال برای شما صادر شد.",
|
|
'action_url' => '/my-account/?tab=invoices',
|
|
'issued_by' => $this->issuedBy?->name,
|
|
];
|
|
}
|
|
}
|