This commit is contained in:
Ludovic CANDELLIER
2022-11-11 13:05:40 +01:00
parent f89acd9399
commit 7df2421373
104 changed files with 1212 additions and 764 deletions

View File

@@ -8,12 +8,9 @@ use App\Models\Shop\Invoice;
class Invoices
{
public static function saveInvoice($order_id, $data)
{
$data['order_id'] = $order_id;
dump($data);
exit;
return self::store($data);
}
@@ -29,6 +26,7 @@ class Invoices
public static function create($data)
{
InvoiceStats::increase($data['total_taxed']);
$data['uuid'] = Str::uuid()->toString();
$data['ref'] = self::getNewRef();
return Invoice::create($data);
@@ -44,6 +42,8 @@ class Invoices
public static function delete($id)
{
$invoice = self::get($id);
InvoiceStats::decrease($invoice->total_priced);
return Invoice::destroy($id);
}
@@ -51,6 +51,6 @@ class Invoices
{
$ref = date('ym') . '00000';
$last_ref = Invoice::orderBy('ref', 'desc')->where('ref', '>', $ref)->first();
return $last_ref ? $last_ref + 1 : $ref + 1;
return $last_ref ? $last_ref->ref + 1 : $ref + 1;
}
}