fix parameters for invoices
This commit is contained in:
@@ -40,12 +40,13 @@ class OrderController extends Controller
|
||||
{
|
||||
if (ShopCart::count()) {
|
||||
$customer = Customers::getWithAddresses();
|
||||
$deliveries = Deliveries::getByCustomer();
|
||||
|
||||
$data = [
|
||||
'customer' => $customer ? $customer->toArray() : false,
|
||||
'basket' => Baskets::getBasketTotal(),
|
||||
// 'deliveries' => Deliveries::getAllWithSaleChannel()->toArray(),
|
||||
'deliveries' => Deliveries::getByCustomer()->toArray(),
|
||||
'deliveries' => $deliveries ? $deliveries->toArray() : [],
|
||||
'delivery_types' => DeliveryTypes::getWithPrice(Baskets::getWeight()),
|
||||
];
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@ class Invoices
|
||||
public static function saveInvoice($orderId, $data)
|
||||
{
|
||||
$data['order_id'] = $orderId;
|
||||
$data['date_invoice'] = date('Y-m-d');
|
||||
|
||||
return self::store($data);
|
||||
}
|
||||
|
||||
@@ -36,17 +36,26 @@ class Orders
|
||||
public static function saveOrder($data)
|
||||
{
|
||||
$basket = $data['basket'];
|
||||
unset($data['basket']);
|
||||
$invoice = $data['invoice'];
|
||||
unset($data['basket'], $data['invoice']);
|
||||
$data += self::getSummaryOfBasket($basket);
|
||||
$order = self::store($data);
|
||||
$detail = OrderDetails::saveBasket($order->id, $basket['detail']);
|
||||
$data['ref'] = $order->ref;
|
||||
unset($data['comment']);
|
||||
unset($data['agree']);
|
||||
unset($data['delivery_address_id']);
|
||||
unset($data['detail']);
|
||||
unset($data['sale_channel_id']);
|
||||
$detail = $order ? OrderDetails::saveBasket($order->id, $basket['detail']) : false;
|
||||
unset($data['comment'], $data['agree'], $data['delivery_address_id'], $data['sale_channel_id']);
|
||||
$invoice = $detail ? Invoices::saveInvoice($order->id, $data + $invoice) : false;
|
||||
|
||||
return ($order && $detail) ? Invoices::saveInvoice($order->id, $data) : false;
|
||||
return $invoice ? $order : false;
|
||||
}
|
||||
|
||||
public static function getSummaryOfBasket($basket)
|
||||
{
|
||||
return [
|
||||
'total' => $basket['total'],
|
||||
'taxes' => $basket['taxes'],
|
||||
'total_taxed' => $basket['total_taxed'],
|
||||
'shipping' => $basket['shipping'],
|
||||
'total_shipped' => $basket['total_shipped'],
|
||||
];
|
||||
}
|
||||
|
||||
public static function edit($id)
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
namespace App\Repositories\Shop;
|
||||
|
||||
use App;
|
||||
use Devpark\PayboxGateway\Requests\AuthorizationWithCapture;
|
||||
use Devpark\PayboxGateway\Requests\Capture;
|
||||
use Devpark\PayboxGateway\Responses\Verify;
|
||||
use Bnb\PayboxGateway\Requests\AuthorizationWithCapture;
|
||||
use Bnb\PayboxGateway\Requests\Capture;
|
||||
use Bnb\PayboxGateway\Responses\Verify;
|
||||
|
||||
class Paybox
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user