fixes
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user