add shipping rules
This commit is contained in:
@@ -2,9 +2,9 @@
|
||||
|
||||
namespace App\Repositories\Shop;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Carbon\Carbon;
|
||||
use App\Models\Shop\Invoice;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class Invoices
|
||||
{
|
||||
@@ -19,6 +19,7 @@ class Invoices
|
||||
'order' => $order->toArray(),
|
||||
'customer' => $customer->toArray(),
|
||||
];
|
||||
|
||||
return view('Shop.Invoices.mail', $data)->render();
|
||||
}
|
||||
|
||||
@@ -30,6 +31,7 @@ class Invoices
|
||||
public static function saveInvoice($order_id, $data)
|
||||
{
|
||||
$data['order_id'] = $order_id;
|
||||
|
||||
return self::store($data);
|
||||
}
|
||||
|
||||
@@ -46,6 +48,7 @@ class Invoices
|
||||
public static function countByMonth()
|
||||
{
|
||||
$start = Carbon::now()->beginOfMonth();
|
||||
|
||||
return Invoice::where('created_at', '>', $start);
|
||||
}
|
||||
|
||||
@@ -59,6 +62,7 @@ class Invoices
|
||||
InvoiceStats::increase($data['total_taxed']);
|
||||
$data['uuid'] = Str::uuid()->toString();
|
||||
$data['ref'] = self::getNewRef();
|
||||
|
||||
return Invoice::create($data);
|
||||
}
|
||||
|
||||
@@ -67,6 +71,7 @@ class Invoices
|
||||
$id = $id ? $id : $data['id'];
|
||||
$item = self::get($id);
|
||||
$item->update($data);
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
@@ -74,13 +79,15 @@ class Invoices
|
||||
{
|
||||
$invoice = self::get($id);
|
||||
InvoiceStats::decrease($invoice->total_priced);
|
||||
|
||||
return Invoice::destroy($id);
|
||||
}
|
||||
|
||||
public static function getNewRef()
|
||||
{
|
||||
$ref = date('ym') . '00000';
|
||||
$ref = date('ym').'00000';
|
||||
$last_ref = Invoice::orderBy('id', 'desc')->first();
|
||||
|
||||
return $last_ref ? $last_ref->ref + 1 : $ref + 1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user