This commit is contained in:
ludo
2025-01-03 03:46:45 +01:00
parent b3fbfc38e7
commit befaa40b48
44 changed files with 442 additions and 165 deletions

View File

@@ -43,6 +43,31 @@ class Invoices
return $data;
}
public static function checkPayments($invoice_id)
{
$invoice = self::get($invoice_id);
$total = self::getPayments($invoice_id);
if ($total) {
$status = $total === (float) $invoice->total_shipped ? 2 : 1;
} else {
$status = 0;
}
$invoice->status = $status;
$invoice->save();
}
public static function getPayments($invoice_id)
{
$total = 0;
$invoice = self::get($invoice_id);
$payments = $invoice->payments;
foreach ($payments as $payment) {
$total += $payment->amount;
}
return $total;
}
public static function getFullByUUID($id)
{
return self::getByUUID($id, self::full());
@@ -61,6 +86,7 @@ class Invoices
'order.delivery_address',
'order.detail',
'order.sale_channel',
'order.customer',
'payments',
];
}
@@ -106,7 +132,7 @@ class Invoices
public static function statuses()
{
return ['En attente', 'Paiement partiel', 'Soldée', 'Paiement rejeté'];
return ['En attente', 'Paiement partiel', 'Soldée'];
}
public static function getModel()