MwSt
This commit is contained in:
parent
9ed251820e
commit
da08e9ff37
13 changed files with 378 additions and 56 deletions
|
|
@ -56,13 +56,14 @@ class ShoppingUserController extends Controller
|
|||
], 400);
|
||||
}
|
||||
$status = [];
|
||||
//TODO Status
|
||||
foreach ($wp_order_numbers as $wp_order_number){
|
||||
$shopping_user = ShoppingUser::where('wp_order_number', '=', $wp_order_number)->first();
|
||||
$status[] = [
|
||||
'wp_order_number' => $wp_order_number,
|
||||
'user' => $shopping_user ? true : false,
|
||||
'order' => ($shopping_user && $shopping_user->shopping_order) ? true : false,
|
||||
'status' => 'open | sent | ...',
|
||||
'status' => 'free',
|
||||
];
|
||||
}
|
||||
return response()->json([
|
||||
|
|
@ -109,13 +110,15 @@ class ShoppingUserController extends Controller
|
|||
$user = $this->prepareForShow($shopping_user);
|
||||
$order = $this->prepareForShowOrder($shopping_user->shopping_order);
|
||||
}
|
||||
//TODO Status
|
||||
|
||||
$data[] = [
|
||||
'wp_order_number' => $wp_order_number,
|
||||
'user' => $user,
|
||||
'order' => $order,
|
||||
'customer_number' => $shopping_user ? $shopping_user->number : false,
|
||||
'member_email' => ($shopping_user && $shopping_user->member) ? $shopping_user->member->email : false,
|
||||
'status' => 'open | sent | ...',
|
||||
'status' => 'free',
|
||||
];
|
||||
}
|
||||
return response()->json([
|
||||
|
|
@ -195,7 +198,7 @@ class ShoppingUserController extends Controller
|
|||
$priority = CustomerPriority::checkChangeOne($shopping_user, $data, true);
|
||||
$updated = $shopping_user->fill($data)->save();
|
||||
\App\Services\Shop::newUserOrder($shopping_user->number);
|
||||
|
||||
//TODO Status
|
||||
if ($updated){
|
||||
$user = $this->prepareForShow($shopping_user);
|
||||
$order = $this->prepareForShowOrder($shopping_user->shopping_order);
|
||||
|
|
@ -208,7 +211,7 @@ class ShoppingUserController extends Controller
|
|||
'customer_priority' => $priority,
|
||||
'customer_number' => $shopping_user ? $shopping_user->number : false,
|
||||
'member_email' => ($shopping_user && $shopping_user->member) ? $shopping_user->member->email : false,
|
||||
'status' => 'open | sent | ...',
|
||||
'status' => 'free',
|
||||
],
|
||||
'time' => Carbon::now()->toDateTimeString()
|
||||
], 200);
|
||||
|
|
@ -249,6 +252,7 @@ class ShoppingUserController extends Controller
|
|||
$wp_order = $request->wp_order;
|
||||
}
|
||||
$wp_order = $this->prepareOrder($wp_order, $shopping_user);
|
||||
//TODO Status
|
||||
if ($wp_order){
|
||||
$user = $this->prepareForShow($shopping_user);
|
||||
$order = $this->prepareForShowOrder($shopping_user->shopping_order);
|
||||
|
|
@ -261,6 +265,7 @@ class ShoppingUserController extends Controller
|
|||
'order' => $order,
|
||||
'customer_number' => $shopping_user->number,
|
||||
'member_email' => $shopping_user->member->email,
|
||||
'status' => 'free',
|
||||
],
|
||||
'time' => Carbon::now()->toDateTimeString()
|
||||
], 200);
|
||||
|
|
@ -291,6 +296,8 @@ class ShoppingUserController extends Controller
|
|||
}
|
||||
$shopping_order->delete();
|
||||
}
|
||||
$shopping_user->wp_order_number = time();
|
||||
$shopping_user->save();
|
||||
if ($shopping_user->delete()) {
|
||||
return response()->json([
|
||||
'success' => true
|
||||
|
|
@ -368,7 +375,7 @@ class ShoppingUserController extends Controller
|
|||
|
||||
//$salutation = array(1 => 'mr', 2 => 'ms', 3=>null);
|
||||
$ret = [];
|
||||
$needs = [ 'billing_salutation', 'billing_company', 'billing_firstname', 'billing_lastname', 'billing_address', 'billing_address_2', 'billing_zipcode', 'billing_city', 'billing_phone', 'billing_email',
|
||||
$needs = [ 'billing_salutation', 'billing_company', 'billing_firstname', 'billing_lastname', 'billing_address', 'billing_address_2', 'billing_zipcode', 'billing_city', 'billing_phone', 'billing_email', 'same_as_billing',
|
||||
'shipping_salutation', 'shipping_company', 'shipping_firstname', 'shipping_lastname', 'shipping_address', 'shipping_address_2', 'shipping_zipcode', 'shipping_city', 'shipping_phone'];
|
||||
|
||||
foreach ($data as $key=>$value){
|
||||
|
|
@ -404,7 +411,7 @@ class ShoppingUserController extends Controller
|
|||
$ret = [];
|
||||
$needs = [ 'billing_salutation', 'billing_company', 'billing_firstname', 'billing_lastname', 'billing_address', 'billing_address_2', 'billing_zipcode', 'billing_city', 'billing_country_id', 'billing_phone', 'billing_email',
|
||||
'shipping_salutation', 'shipping_company', 'shipping_firstname', 'shipping_lastname', 'shipping_address', 'shipping_address_2', 'shipping_zipcode', 'shipping_city', 'shipping_country_id', 'shipping_phone',
|
||||
//'same_as_billing', 'has_buyed', 'subscribed',
|
||||
'same_as_billing', //'has_buyed', 'subscribed',
|
||||
'wp_order_number', 'wp_order_date'];
|
||||
|
||||
foreach ($needs as $need){
|
||||
|
|
@ -432,10 +439,10 @@ class ShoppingUserController extends Controller
|
|||
if ($need === 'wp_order_date') {
|
||||
$ret['wp_order_date'] = Carbon::parse($ret['wp_order_date'])->toDateTimeString();
|
||||
}
|
||||
|
||||
|
||||
if ($need === 'same_as_billing') {
|
||||
$ret['same_as_billing'] = isset($data['same_as_billing']) ? $data['same_as_billing'] : true;
|
||||
}
|
||||
}
|
||||
$ret['same_as_billing'] = $ret['shipping_lastname'] !== null ? true : false;
|
||||
$ret['has_buyed'] = true;
|
||||
$ret['subscribed'] = false;
|
||||
return $ret;
|
||||
|
|
@ -490,7 +497,7 @@ class ShoppingUserController extends Controller
|
|||
'total' => Yard::instance('shopping')->total(2, '.', ''),
|
||||
'shipping' => Yard::instance('shopping')->shipping(2, '.', ','),
|
||||
'subtotal' => Yard::instance('shopping')->subtotalWithShipping(2, '.', ''),
|
||||
'tax_rate' => Yard::getTaxRate(),
|
||||
//'tax_rate' => Yard::getTaxRate(),
|
||||
'tax' => Yard::instance('shopping')->taxWithShipping(2, '.', ''),
|
||||
'total_shipping' => Yard::instance('shopping')->totalWithShipping(2, '.', ''),
|
||||
'weight' => Yard::instance('shopping')->weight(),
|
||||
|
|
@ -516,6 +523,7 @@ class ShoppingUserController extends Controller
|
|||
'product_id' => $item->id,
|
||||
'qty' => $item->qty,
|
||||
'price' => $item->price,
|
||||
'tax_rate' => $item->taxRate,
|
||||
'slug' => $item->options->slug,
|
||||
])->save();
|
||||
return false;
|
||||
|
|
@ -533,6 +541,7 @@ class ShoppingUserController extends Controller
|
|||
'product_id' => $item->id,
|
||||
'qty' => $item->qty,
|
||||
'price' => $item->price,
|
||||
'tax_rate' => $item->taxRate,
|
||||
'slug' => $item->options->slug
|
||||
]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,8 @@ class CardController extends Controller
|
|||
if($product->images->count()){
|
||||
$image = $product->images->first()->slug;
|
||||
}
|
||||
Yard::instance('shopping')->add($product->id, $product->getLang('name'), $quantity, $product->price, ['image' => $image, 'slug' => $product_slug, 'weight' => $product->weight]);
|
||||
$cartItem = Yard::instance('shopping')->add($product->id, $product->getLang('name'), $quantity, $product->price, ['image' => $image, 'slug' => $product_slug, 'weight' => $product->weight]);
|
||||
Yard::setTax($cartItem->rowId, $product->tax);
|
||||
Yard::instance('shopping')->reCalculateShippingPrice();
|
||||
|
||||
\Session()->flash('show-card-after-add', true);
|
||||
|
|
@ -53,7 +54,8 @@ class CardController extends Controller
|
|||
$image = $product->images->first()->slug;
|
||||
}
|
||||
$quantity = Request::get('quantity') ? Request::get('quantity') : 1;
|
||||
Yard::instance('shopping')->add($product->id, $product->getLang('name'), $quantity, $product->price, ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight]);
|
||||
$cartItem = Yard::instance('shopping')->add($product->id, $product->getLang('name'), $quantity, $product->price, ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight]);
|
||||
Yard::setTax($cartItem->rowId, $product->tax);
|
||||
Yard::instance('shopping')->reCalculateShippingPrice();
|
||||
|
||||
\Session()->flash('show-card-after-add', true);
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@ class CheckoutController extends Controller
|
|||
if(Request::get('payment_method') === 'elv' && is_null(Request::get('mandate_identification'))){
|
||||
$pay = new PayoneController();
|
||||
$pay->init($shopping_user, $shopping_order);
|
||||
$amount = (int) (float) Yard::instance('shopping')->totalWithShipping(2, '.', '') *100;
|
||||
$amount = Yard::instance('shopping')->totalWithShipping(2, '.', '') * 100;
|
||||
$ret['elv'] = $pay->checkBankAccount($data, $amount, 'EUR', $shopping_user);
|
||||
|
||||
if($ret['elv']['status'] === 'ERROR' || $ret['elv']['status'] === 'INVALID'){
|
||||
|
|
@ -214,7 +214,7 @@ class CheckoutController extends Controller
|
|||
//other
|
||||
$pay = new PayoneController();
|
||||
$pay->init($shopping_user, $shopping_order);
|
||||
$amount = (int) (float) Yard::instance('shopping')->totalWithShipping(2, '.', '') * 100;
|
||||
$amount = Yard::instance('shopping')->totalWithShipping(2, '.', '') * 100;
|
||||
$reference = $pay->setPrePayment(Request::get('payment_method'), $amount, 'EUR', $ret);
|
||||
$this->putPayments('payment_reference', $reference);
|
||||
$pay->setPersonalData();
|
||||
|
|
@ -333,7 +333,7 @@ class CheckoutController extends Controller
|
|||
'total' => Yard::instance('shopping')->total(2, '.', ''),
|
||||
'shipping' => Yard::instance('shopping')->shipping(2, '.', ','),
|
||||
'subtotal' => Yard::instance('shopping')->subtotalWithShipping(2, '.', ''),
|
||||
'tax_rate' => Yard::getTaxRate(),
|
||||
//'tax_rate' => Yard::getTaxRate(),
|
||||
'tax' => Yard::instance('shopping')->taxWithShipping(2, '.', ''),
|
||||
'total_shipping' => Yard::instance('shopping')->totalWithShipping(2, '.', ''),
|
||||
'weight' => Yard::instance('shopping')->weight(),
|
||||
|
|
@ -364,6 +364,7 @@ class CheckoutController extends Controller
|
|||
'product_id' => $item->id,
|
||||
'qty' => $item->qty,
|
||||
'price' => $item->price,
|
||||
'tax_rate' => $item->taxRate,
|
||||
'slug' => $item->options->slug,
|
||||
])->save();
|
||||
return false;
|
||||
|
|
@ -380,6 +381,7 @@ class CheckoutController extends Controller
|
|||
'product_id' => $item->id,
|
||||
'qty' => $item->qty,
|
||||
'price' => $item->price,
|
||||
'tax_rate' => $item->taxRate,
|
||||
'slug' => $item->options->slug
|
||||
]);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -263,7 +263,7 @@ class Product extends Model
|
|||
|
||||
public function getFormattedTax()
|
||||
{
|
||||
return isset($this->attributes['tax']) ? Util::formatNumber($this->attributes['tax']) : "";
|
||||
return isset($this->attributes['tax']) ? Util::formatNumber($this->attributes['tax'], 0) : "";
|
||||
}
|
||||
|
||||
public function getFormattedPriceOld()
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ class ShoppingOrder extends Model
|
|||
'total',
|
||||
'shipping',
|
||||
'subtotal',
|
||||
'tax_rate',
|
||||
//'tax_rate',
|
||||
'tax',
|
||||
'total_shipping',
|
||||
'weight',
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ class ShoppingOrderItem extends Model
|
|||
'product_id',
|
||||
'qty',
|
||||
'price',
|
||||
'tax_rate',
|
||||
'slug',
|
||||
];
|
||||
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ class Yard extends Cart
|
|||
|
||||
public static function getTaxRate()
|
||||
{
|
||||
|
||||
return config('cart.tax');
|
||||
|
||||
}
|
||||
|
|
@ -121,7 +122,6 @@ class Yard extends Cart
|
|||
//sec by weight
|
||||
if(!$price){
|
||||
$price = $this->shippingPriceByWeight($shipping->prices, intval($this->weight()));
|
||||
|
||||
}
|
||||
//default
|
||||
if(!$price){
|
||||
|
|
@ -182,18 +182,20 @@ class Yard extends Cart
|
|||
|
||||
public function subtotalWithShipping($decimals = null, $decimalPoint = null, $thousandSeperator = null)
|
||||
{
|
||||
$taxRate =config('cart.tax');
|
||||
$total = (float) ($this->total(2, '.', '')) + $this->shipping;
|
||||
$totalTax = $total/ (100 + $taxRate) * $taxRate;
|
||||
return $this->numberFormat(($total - $totalTax), $decimals, $decimalPoint, $thousandSeperator);
|
||||
$subtotal = $this->subtotal(2, '.', '') + $this->shipping;
|
||||
//$taxRate =config('cart.tax');
|
||||
/*$total = (float) ($this->total(2, '.', '')) + $this->shipping;
|
||||
$totalTax = $total/ (100 + $taxRate) * $taxRate;*/
|
||||
return $this->numberFormat($subtotal, $decimals, $decimalPoint, $thousandSeperator);
|
||||
}
|
||||
|
||||
|
||||
public function taxWithShipping($decimals = null, $decimalPoint = null, $thousandSeperator = null)
|
||||
{
|
||||
$taxRate =config('cart.tax');
|
||||
$totalTax = $this->tax(2, '.', '');
|
||||
/* $taxRate =config('cart.tax');
|
||||
$total = (float) ($this->total(2, '.', '')) + $this->shipping;
|
||||
$totalTax = $total/ (100 + $taxRate) * $taxRate;
|
||||
$totalTax = $total/ (100 + $taxRate) * $taxRate; */
|
||||
return $this->numberFormat($totalTax, $decimals, $decimalPoint, $thousandSeperator);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue