From 8abce3302a54848494142011075cbb44f9dd9013 Mon Sep 17 00:00:00 2001 From: Steffen Mahler Date: Fri, 31 Jan 2020 16:08:01 +0100 Subject: [PATCH 01/38] tax helper introduced, views changed to display multiple tax rates --- config/app.php | 2 +- .../views/sales/orders/view.blade.php | 11 +- packages/Webkul/Checkout/src/Cart.php | 375 ++++++++++-------- packages/Webkul/Checkout/src/Helpers/Tax.php | 31 ++ .../views/checkout/total/summary.blade.php | 6 +- .../emails/sales/new-admin-order.blade.php | 10 +- .../views/emails/sales/new-invoice.blade.php | 18 +- .../views/emails/sales/new-order.blade.php | 12 +- .../views/emails/sales/new-refund.blade.php | 6 +- .../views/emails/sales/order-cancel.blade.php | 14 +- 10 files changed, 297 insertions(+), 188 deletions(-) create mode 100644 packages/Webkul/Checkout/src/Helpers/Tax.php diff --git a/config/app.php b/config/app.php index a3cf7f964..1f0b07847 100755 --- a/config/app.php +++ b/config/app.php @@ -104,7 +104,7 @@ return [ | */ - 'default_country' => null, + 'default_country' => 'DE', /* |-------------------------------------------------------------------------- diff --git a/packages/Webkul/Admin/src/Resources/views/sales/orders/view.blade.php b/packages/Webkul/Admin/src/Resources/views/sales/orders/view.blade.php index a1b28cbd0..499fbfe74 100755 --- a/packages/Webkul/Admin/src/Resources/views/sales/orders/view.blade.php +++ b/packages/Webkul/Admin/src/Resources/views/sales/orders/view.blade.php @@ -266,7 +266,7 @@ @if (isset($item->additional['attributes']))
- + @foreach ($item->additional['attributes'] as $attribute) {{ $attribute['attribute_name'] }} : {{ $attribute['option_label'] }}
@endforeach @@ -344,11 +344,14 @@ @endif - - {{ __('admin::app.sales.orders.tax') }} + @php ($taxRates = Webkul\Checkout\Helpers\Tax::getTaxRatesWithAmount($order, true)) + @foreach ($taxRates as $taxRate => $baseTaxAmount) + last ? 'class=border' : ''}}> + {{ __('admin::app.sales.orders.tax') }} {{ $taxRate }} % - - {{ core()->formatBasePrice($order->base_tax_amount) }} + {{ core()->formatBasePrice($baseTaxAmount) }} + @endforeach {{ __('admin::app.sales.orders.grand-total') }} diff --git a/packages/Webkul/Checkout/src/Cart.php b/packages/Webkul/Checkout/src/Cart.php index 9157dc392..c6eca6000 100755 --- a/packages/Webkul/Checkout/src/Cart.php +++ b/packages/Webkul/Checkout/src/Cart.php @@ -5,6 +5,7 @@ namespace Webkul\Checkout; use Webkul\Checkout\Repositories\CartRepository; use Webkul\Checkout\Repositories\CartItemRepository; use Webkul\Checkout\Repositories\CartAddressRepository; +use Webkul\Customer\Models\CustomerAddress; use Webkul\Product\Repositories\ProductRepository; use Webkul\Tax\Repositories\TaxCategoryRepository; use Webkul\Checkout\Models\CartItem; @@ -14,6 +15,17 @@ use Webkul\Customer\Repositories\CustomerAddressRepository; use Illuminate\Support\Facades\Event; use Illuminate\Support\Arr; +class addressHelper +{ + public $country; + public $postcode; + + function __construct() + { + $this->country = config('app.default_country'); + } +} + /** * Facades handler for all the methods to be implemented in Cart. * @@ -21,7 +33,8 @@ use Illuminate\Support\Arr; * @author Jitendra Singh * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) */ -class Cart { +class Cart +{ /** * CartRepository instance @@ -75,15 +88,16 @@ class Cart { /** * Create a new controller instance. * - * @param Webkul\Checkout\Repositories\CartRepository $cart - * @param Webkul\Checkout\Repositories\CartItemRepository $cartItem - * @param Webkul\Checkout\Repositories\CartAddressRepository $cartAddress - * @param Webkul\Product\Repositories\ProductRepository $product - * @param Webkul\Product\Repositories\TaxCategoryRepository $taxCategory - * @param Webkul\Product\Repositories\CustomerAddressRepository $customerAddress - * @param Webkul\Product\Repositories\CustomerAddressRepository $customerAddress - * @param Webkul\Discount\Repositories\CartRuleRepository $cartRule - * @param Webkul\Helpers\Discount $discount + * @param Webkul\Checkout\Repositories\CartRepository $cart + * @param Webkul\Checkout\Repositories\CartItemRepository $cartItem + * @param Webkul\Checkout\Repositories\CartAddressRepository $cartAddress + * @param Webkul\Product\Repositories\ProductRepository $product + * @param Webkul\Product\Repositories\TaxCategoryRepository $taxCategory + * @param Webkul\Product\Repositories\CustomerAddressRepository $customerAddress + * @param Webkul\Product\Repositories\CustomerAddressRepository $customerAddress + * @param Webkul\Discount\Repositories\CartRuleRepository $cartRule + * @param Webkul\Helpers\Discount $discount + * * @return void */ public function __construct( @@ -94,8 +108,7 @@ class Cart { TaxCategoryRepository $taxCategoryRepository, WishlistRepository $wishlistRepository, CustomerAddressRepository $customerAddressRepository - ) - { + ) { $this->cartRepository = $cartRepository; $this->cartItemRepository = $cartItemRepository; @@ -128,6 +141,7 @@ class Cart { * * @param integer $productId * @param array $data + * * @return Cart */ public function addProduct($productId, $data) @@ -136,8 +150,9 @@ class Cart { $cart = $this->getCart(); - if (! $cart && ! $cart = $this->create($data)) + if (!$cart && !$cart = $this->create($data)) { return; + } $product = $this->productRepository->findOneByField('id', $productId); @@ -146,7 +161,7 @@ class Cart { if (is_string($cartProducts)) { $this->collectTotals(); - if (! count($cart->all_items) > 0) { + if (!count($cart->all_items) > 0) { session()->forget('cart'); } @@ -157,21 +172,24 @@ class Cart { foreach ($cartProducts as $cartProduct) { $cartItem = $this->getItemByProduct($cartProduct); - if (isset($cartProduct['parent_id'])) + if (isset($cartProduct['parent_id'])) { $cartProduct['parent_id'] = $parentCartItem->id; + } - if (! $cartItem) { + if (!$cartItem) { $cartItem = $this->cartItemRepository->create(array_merge($cartProduct, ['cart_id' => $cart->id])); } else { if (isset($cartProduct['parent_id']) && $cartItem->parent_id != $parentCartItem->id) { - $cartItem = $this->cartItemRepository->create(array_merge($cartProduct, ['cart_id' => $cart->id])); + $cartItem = $this->cartItemRepository->create(array_merge($cartProduct, + ['cart_id' => $cart->id])); } else { $cartItem = $this->cartItemRepository->update($cartProduct, $cartItem->id); } } - if (! $parentCartItem) + if (!$parentCartItem) { $parentCartItem = $cartItem; + } } } @@ -186,17 +204,18 @@ class Cart { * Create new cart instance. * * @param array $data + * * @return Cart|null */ public function create($data) { $cartData = [ - 'channel_id' => core()->getCurrentChannel()->id, - 'global_currency_code' => core()->getBaseCurrencyCode(), - 'base_currency_code' => core()->getBaseCurrencyCode(), + 'channel_id' => core()->getCurrentChannel()->id, + 'global_currency_code' => core()->getBaseCurrencyCode(), + 'base_currency_code' => core()->getBaseCurrencyCode(), 'channel_currency_code' => core()->getChannelBaseCurrencyCode(), - 'cart_currency_code' => core()->getCurrentCurrencyCode(), - 'items_count' => 1 + 'cart_currency_code' => core()->getCurrentCurrencyCode(), + 'items_count' => 1, ]; //Authentication details @@ -212,7 +231,7 @@ class Cart { $cart = $this->cartRepository->create($cartData); - if (! $cart) { + if (!$cart) { session()->flash('error', trans('shop::app.checkout.cart.create-error')); return; @@ -235,8 +254,9 @@ class Cart { foreach ($data['qty'] as $itemId => $quantity) { $item = $this->cartItemRepository->findOneByField('id', $itemId); - if (! $item) + if (!$item) { continue; + } if ($quantity <= 0) { $this->removeItem($itemId); @@ -246,18 +266,19 @@ class Cart { $item->quantity = $quantity; - if (! $this->isItemHaveQuantity($item)) + if (!$this->isItemHaveQuantity($item)) { throw new \Exception(trans('shop::app.checkout.cart.quantity.inventory_warning')); + } Event::dispatch('checkout.cart.update.before', $item); $this->cartItemRepository->update([ - 'quantity' => $quantity, - 'total' => core()->convertPrice($item->price * $quantity), - 'base_total' => $item->price * $quantity, - 'total_weight' => $item->weight * $quantity, - 'base_total_weight' => $item->weight * $quantity - ], $itemId); + 'quantity' => $quantity, + 'total' => core()->convertPrice($item->price * $quantity), + 'base_total' => $item->price * $quantity, + 'total_weight' => $item->weight * $quantity, + 'base_total_weight' => $item->weight * $quantity, + ], $itemId); Event::dispatch('checkout.cart.update.after', $item); } @@ -271,6 +292,7 @@ class Cart { * Get cart item by product * * @param array $data + * * @return CartItem|void */ public function getItemByProduct($data) @@ -280,8 +302,10 @@ class Cart { foreach ($items as $item) { if ($item->product->getTypeInstance()->compareOptions($item->additional, $data['additional'])) { if (isset($data['additional']['parent_id'])) { - if ($item->parent->product->getTypeInstance()->compareOptions($item->parent->additional, request()->all())) + if ($item->parent->product->getTypeInstance()->compareOptions($item->parent->additional, + request()->all())) { return $item; + } } else { return $item; } @@ -293,14 +317,16 @@ class Cart { * Remove the item from the cart * * @param integer $itemId + * * @return boolean */ public function removeItem($itemId) { Event::dispatch('checkout.cart.delete.before', $itemId); - if (! $cart = $this->getCart()) + if (!$cart = $this->getCart()) { return false; + } $this->cartItemRepository->delete($itemId); @@ -328,18 +354,21 @@ class Cart { public function mergeCart() { if (session()->has('cart')) { - $cart = $this->cartRepository->findOneWhere(['customer_id' => $this->getCurrentCustomer()->user()->id, 'is_active' => 1]); + $cart = $this->cartRepository->findOneWhere([ + 'customer_id' => $this->getCurrentCustomer()->user()->id, + 'is_active' => 1, + ]); $guestCart = session()->get('cart'); //when the logged in customer is not having any of the cart instance previously and are active. - if (! $cart) { + if (!$cart) { $this->cartRepository->update([ - 'customer_id' => $this->getCurrentCustomer()->user()->id, - 'is_guest' => 0, + 'customer_id' => $this->getCurrentCustomer()->user()->id, + 'is_guest' => 0, 'customer_first_name' => $this->getCurrentCustomer()->user()->first_name, - 'customer_last_name' => $this->getCurrentCustomer()->user()->last_name, - 'customer_email' => $this->getCurrentCustomer()->user()->email + 'customer_last_name' => $this->getCurrentCustomer()->user()->last_name, + 'customer_email' => $this->getCurrentCustomer()->user()->email, ], $guestCart->id); session()->forget('cart'); @@ -352,23 +381,25 @@ class Cart { $found = false; foreach ($cart->items as $cartItem) { - if (! $cartItem->product->getTypeInstance()->compareOptions($cartItem->additional, $guestCartItem->additional)) + if (!$cartItem->product->getTypeInstance()->compareOptions($cartItem->additional, + $guestCartItem->additional)) { continue; + } $cartItem->quantity = $newQuantity = $cartItem->quantity + $guestCartItem->quantity; - if (! $this->isItemHaveQuantity($cartItem)) { + if (!$this->isItemHaveQuantity($cartItem)) { $this->cartItemRepository->delete($guestCartItem->id); continue; } $this->cartItemRepository->update([ - 'quantity' => $newQuantity, - 'total' => core()->convertPrice($cartItem->price * $newQuantity), - 'base_total' => $cartItem->price * $newQuantity, - 'total_weight' => $cartItem->weight * $newQuantity, - 'base_total_weight' => $cartItem->weight * $newQuantity + 'quantity' => $newQuantity, + 'total' => core()->convertPrice($cartItem->price * $newQuantity), + 'base_total' => $cartItem->price * $newQuantity, + 'total_weight' => $cartItem->weight * $newQuantity, + 'base_total_weight' => $cartItem->weight * $newQuantity, ], $cartItem->id); $guestCart->items->forget($key); @@ -378,14 +409,14 @@ class Cart { $found = true; } - if (! $found) { + if (!$found) { $this->cartItemRepository->update([ - 'cart_id' => $cart->id + 'cart_id' => $cart->id, ], $guestCartItem->id); foreach ($guestCartItem->children as $child) { $this->cartItemRepository->update([ - 'cart_id' => $cart->id + 'cart_id' => $cart->id, ], $child->id); } } @@ -405,11 +436,12 @@ class Cart { * Save cart * * @param Cart $cart + * * @return void */ public function putCart($cart) { - if (! $this->getCurrentCustomer()->check()) { + if (!$this->getCurrentCustomer()->check()) { session()->put('cart', $cart); } } @@ -426,7 +458,7 @@ class Cart { if ($this->getCurrentCustomer()->check()) { $cart = $this->cartRepository->findOneWhere([ 'customer_id' => $this->getCurrentCustomer()->user()->id, - 'is_active' => 1 + 'is_active' => 1, ]); } elseif (session()->has('cart')) { $cart = $this->cartRepository->find(session()->get('cart')->id); @@ -465,18 +497,20 @@ class Cart { * Save customer address * * @param array $data + * * @return boolean */ public function saveCustomerAddress($data) { - if (! $cart = $this->getCart()) + if (!$cart = $this->getCart()) { return false; + } $billingAddress = $data['billing']; $billingAddress['cart_id'] = $cart->id; if (isset($data['billing']['address_id']) && $data['billing']['address_id']) { - $address = $this->customerAddressRepository->findOneWhere(['id'=> $data['billing']['address_id']])->toArray(); + $address = $this->customerAddressRepository->findOneWhere(['id' => $data['billing']['address_id']])->toArray(); $billingAddress['first_name'] = $this->getCurrentCustomer()->user()->first_name; $billingAddress['last_name'] = $this->getCurrentCustomer()->user()->last_name; @@ -490,7 +524,7 @@ class Cart { } if (isset($data['billing']['save_as_address']) && $data['billing']['save_as_address']) { - $billingAddress['customer_id'] = $this->getCurrentCustomer()->user()->id; + $billingAddress['customer_id'] = $this->getCurrentCustomer()->user()->id; $this->customerAddressRepository->create($billingAddress); } @@ -499,7 +533,7 @@ class Cart { $shippingAddress['cart_id'] = $cart->id; if (isset($data['shipping']['address_id']) && $data['shipping']['address_id']) { - $address = $this->customerAddressRepository->findOneWhere(['id'=> $data['shipping']['address_id']])->toArray(); + $address = $this->customerAddressRepository->findOneWhere(['id' => $data['shipping']['address_id']])->toArray(); $shippingAddress['first_name'] = $this->getCurrentCustomer()->user()->first_name; $shippingAddress['last_name'] = $this->getCurrentCustomer()->user()->last_name; @@ -513,7 +547,7 @@ class Cart { } if (isset($data['shipping']['save_as_address']) && $data['shipping']['save_as_address']) { - $shippingAddress['customer_id'] = $this->getCurrentCustomer()->user()->id; + $shippingAddress['customer_id'] = $this->getCurrentCustomer()->user()->id; $this->customerAddressRepository->create($shippingAddress); } @@ -531,9 +565,11 @@ class Cart { } } else { if (isset($billingAddress['use_for_shipping']) && $billingAddress['use_for_shipping']) { - $this->cartAddressRepository->create(array_merge($billingAddress, ['address_type' => 'shipping'])); + $this->cartAddressRepository->create(array_merge($billingAddress, + ['address_type' => 'shipping'])); } else { - $this->cartAddressRepository->create(array_merge($shippingAddress, ['address_type' => 'shipping'])); + $this->cartAddressRepository->create(array_merge($shippingAddress, + ['address_type' => 'shipping'])); } } } @@ -568,12 +604,14 @@ class Cart { * Save shipping method for cart * * @param string $shippingMethodCode + * * @return boolean */ public function saveShippingMethod($shippingMethodCode) { - if (! $cart = $this->getCart()) + if (!$cart = $this->getCart()) { return false; + } $cart->shipping_method = $shippingMethodCode; $cart->save(); @@ -585,15 +623,18 @@ class Cart { * Save payment method for cart * * @param string $payment + * * @return CartPayment */ public function savePaymentMethod($payment) { - if (! $cart = $this->getCart()) + if (!$cart = $this->getCart()) { return false; + } - if ($cartPayment = $cart->payment) + if ($cartPayment = $cart->payment) { $cartPayment->delete(); + } $cartPayment = new CartPayment; @@ -613,11 +654,13 @@ class Cart { { $validated = $this->validateItems(); - if (! $validated) + if (!$validated) { return false; + } - if (! $cart = $this->getCart()) + if (!$cart = $this->getCart()) { return false; + } Event::dispatch('checkout.cart.collect.totals.before', $cart); @@ -632,19 +675,19 @@ class Cart { $cart->discount_amount += $item->discount_amount; $cart->base_discount_amount += $item->base_discount_amount; - $cart->grand_total = (float) $cart->grand_total + $item->total + $item->tax_amount - $item->discount_amount; - $cart->base_grand_total = (float) $cart->base_grand_total + $item->base_total + $item->base_tax_amount - $item->base_discount_amount; + $cart->grand_total = (float)$cart->grand_total + $item->total + $item->tax_amount - $item->discount_amount; + $cart->base_grand_total = (float)$cart->base_grand_total + $item->base_total + $item->base_tax_amount - $item->base_discount_amount; - $cart->sub_total = (float) $cart->sub_total + $item->total; - $cart->base_sub_total = (float) $cart->base_sub_total + $item->base_total; + $cart->sub_total = (float)$cart->sub_total + $item->total; + $cart->base_sub_total = (float)$cart->base_sub_total + $item->base_total; - $cart->tax_total = (float) $cart->tax_total + $item->tax_amount; - $cart->base_tax_total = (float) $cart->base_tax_total + $item->base_tax_amount; + $cart->tax_total = (float)$cart->tax_total + $item->tax_amount; + $cart->base_tax_total = (float)$cart->base_tax_total + $item->base_tax_amount; } if ($shipping = $cart->selected_shipping_rate) { - $cart->grand_total = (float) $cart->grand_total + $shipping->price - $shipping->discount_amount; - $cart->base_grand_total = (float) $cart->base_grand_total + $shipping->base_price - $shipping->base_discount_amount; + $cart->grand_total = (float)$cart->grand_total + $shipping->price - $shipping->discount_amount; + $cart->base_grand_total = (float)$cart->base_grand_total + $shipping->base_price - $shipping->base_discount_amount; $cart->discount_amount += $shipping->discount_amount; $cart->base_discount_amount += $shipping->base_discount_amount; @@ -673,8 +716,9 @@ class Cart { */ public function validateItems() { - if (! $cart = $this->getCart()) + if (!$cart = $this->getCart()) { return; + } //rare case of accident-->used when there are no items. if (count($cart->items) == 0) { @@ -685,12 +729,12 @@ class Cart { foreach ($cart->items as $item) { $item->product->getTypeInstance()->validateCartItem($item); - $price = ! is_null($item->custom_price) ? $item->custom_price : $item->base_price; + $price = !is_null($item->custom_price) ? $item->custom_price : $item->base_price; $this->cartItemRepository->update([ - 'price' => core()->convertPrice($price), + 'price' => core()->convertPrice($price), 'base_price' => $price, - 'total' => core()->convertPrice($price * $item->quantity), + 'total' => core()->convertPrice($price * $item->quantity), 'base_total' => $price * $item->quantity, ], $item->id); } @@ -706,17 +750,19 @@ class Cart { */ public function calculateItemsTax() { - if (! $cart = $this->getCart()) + if (!$cart = $this->getCart()) { return false; + } - if (! $cart->shipping_address && ! $cart->billing_address) - return; +// if (! $cart->shipping_address && ! $cart->billing_address) +// return; foreach ($cart->items()->get() as $item) { $taxCategory = $this->taxCategoryRepository->find($item->product->tax_category_id); - if (! $taxCategory) + if (!$taxCategory) { continue; + } if ($item->product->getTypeInstance()->isStockable()) { $address = $cart->shipping_address; @@ -724,25 +770,30 @@ class Cart { $address = $cart->billing_address; } + if ($address === null) { + $address = new addressHelper(); + } + $taxRates = $taxCategory->tax_rates()->where([ - 'country' => $address->country, - ])->orderBy('tax_rate', 'desc')->get(); + 'country' => $address->country, + ])->orderBy('tax_rate', 'desc')->get(); if ($taxRates->count()) { foreach ($taxRates as $rate) { $haveTaxRate = false; - if ($rate->state != '' && $rate->state != $address->state) + if ($rate->state != '' && $rate->state != $address->state) { continue; - - if (! $rate->is_zip) { - if ($rate->zip_code == '*' || $rate->zip_code == $address->postcode) - $haveTaxRate = true; - } else { - if ($address->postcode >= $rate->zip_from && $address->postcode <= $rate->zip_to) - $haveTaxRate = true; } - + if (!$rate->is_zip) { + if ($rate->zip_code == '*' || $rate->zip_code == $address->postcode) { + $haveTaxRate = true; + } + } else { + if ($address->postcode >= $rate->zip_from && $address->postcode <= $rate->zip_to) { + $haveTaxRate = true; + } + } if ($haveTaxRate) { $item->tax_percent = $rate->tax_rate; $item->tax_amount = ($item->total * $rate->tax_rate) / 100; @@ -769,11 +820,13 @@ class Cart { */ public function hasError() { - if (! $this->getCart()) + if (!$this->getCart()) { return true; + } - if (! $this->isItemsHaveSufficientQuantity()) + if (!$this->isItemsHaveSufficientQuantity()) { return true; + } return false; } @@ -786,8 +839,9 @@ class Cart { public function isItemsHaveSufficientQuantity() { foreach ($this->getCart()->items as $item) { - if (! $this->isItemHaveQuantity($item)) + if (!$this->isItemHaveQuantity($item)) { return false; + } } return true; @@ -797,6 +851,7 @@ class Cart { * Checks if all cart items have sufficient quantity. * * @param CartItem $item + * * @return boolean */ public function isItemHaveQuantity($item) @@ -830,42 +885,42 @@ class Cart { $data = $this->toArray(); $finalData = [ - 'cart_id' => $this->getCart()->id, - 'customer_id' => $data['customer_id'], - 'is_guest' => $data['is_guest'], - 'customer_email' => $data['customer_email'], - 'customer_first_name' => $data['customer_first_name'], - 'customer_last_name' => $data['customer_last_name'], - 'customer' => $this->getCurrentCustomer()->check() ? $this->getCurrentCustomer()->user() : null, - 'total_item_count' => $data['items_count'], - 'total_qty_ordered' => $data['items_qty'], - 'base_currency_code' => $data['base_currency_code'], + 'cart_id' => $this->getCart()->id, + 'customer_id' => $data['customer_id'], + 'is_guest' => $data['is_guest'], + 'customer_email' => $data['customer_email'], + 'customer_first_name' => $data['customer_first_name'], + 'customer_last_name' => $data['customer_last_name'], + 'customer' => $this->getCurrentCustomer()->check() ? $this->getCurrentCustomer()->user() : null, + 'total_item_count' => $data['items_count'], + 'total_qty_ordered' => $data['items_qty'], + 'base_currency_code' => $data['base_currency_code'], 'channel_currency_code' => $data['channel_currency_code'], - 'order_currency_code' => $data['cart_currency_code'], - 'grand_total' => $data['grand_total'], - 'base_grand_total' => $data['base_grand_total'], - 'sub_total' => $data['sub_total'], - 'base_sub_total' => $data['base_sub_total'], - 'tax_amount' => $data['tax_total'], - 'base_tax_amount' => $data['base_tax_total'], - 'coupon_code' => $data['coupon_code'], + 'order_currency_code' => $data['cart_currency_code'], + 'grand_total' => $data['grand_total'], + 'base_grand_total' => $data['base_grand_total'], + 'sub_total' => $data['sub_total'], + 'base_sub_total' => $data['base_sub_total'], + 'tax_amount' => $data['tax_total'], + 'base_tax_amount' => $data['base_tax_total'], + 'coupon_code' => $data['coupon_code'], 'applied_cart_rule_ids' => $data['applied_cart_rule_ids'], - 'discount_amount' => $data['discount_amount'], - 'base_discount_amount' => $data['base_discount_amount'], - 'billing_address' => Arr::except($data['billing_address'], ['id', 'cart_id']), - 'payment' => Arr::except($data['payment'], ['id', 'cart_id']), - 'channel' => core()->getCurrentChannel(), + 'discount_amount' => $data['discount_amount'], + 'base_discount_amount' => $data['base_discount_amount'], + 'billing_address' => Arr::except($data['billing_address'], ['id', 'cart_id']), + 'payment' => Arr::except($data['payment'], ['id', 'cart_id']), + 'channel' => core()->getCurrentChannel(), ]; if ($this->getCart()->haveStockableItems()) { $finalData = array_merge($finalData, [ - 'shipping_method' => $data['selected_shipping_rate']['method'], - 'shipping_title' => $data['selected_shipping_rate']['carrier_title'] . ' - ' . $data['selected_shipping_rate']['method_title'], - 'shipping_description' => $data['selected_shipping_rate']['method_description'], - 'shipping_amount' => $data['selected_shipping_rate']['price'], - 'base_shipping_amount' => $data['selected_shipping_rate']['base_price'], - 'shipping_address' => Arr::except($data['shipping_address'], ['id', 'cart_id']), - 'shipping_discount_amount' => $data['selected_shipping_rate']['discount_amount'], + 'shipping_method' => $data['selected_shipping_rate']['method'], + 'shipping_title' => $data['selected_shipping_rate']['carrier_title'] . ' - ' . $data['selected_shipping_rate']['method_title'], + 'shipping_description' => $data['selected_shipping_rate']['method_description'], + 'shipping_amount' => $data['selected_shipping_rate']['price'], + 'base_shipping_amount' => $data['selected_shipping_rate']['base_price'], + 'shipping_address' => Arr::except($data['shipping_address'], ['id', 'cart_id']), + 'shipping_discount_amount' => $data['selected_shipping_rate']['discount_amount'], 'base_shipping_discount_amount' => $data['selected_shipping_rate']['base_discount_amount'], ]); } @@ -881,29 +936,30 @@ class Cart { * Prepares data for order item * * @param array $data + * * @return array */ public function prepareDataForOrderItem($data) { $finalData = [ - 'product' => $this->productRepository->find($data['product_id']), - 'sku' => $data['sku'], - 'type' => $data['type'], - 'name' => $data['name'], - 'weight' => $data['weight'], - 'total_weight' => $data['total_weight'], - 'qty_ordered' => $data['quantity'], - 'price' => $data['price'], - 'base_price' => $data['base_price'], - 'total' => $data['total'], - 'base_total' => $data['base_total'], - 'tax_percent' => $data['tax_percent'], - 'tax_amount' => $data['tax_amount'], - 'base_tax_amount' => $data['base_tax_amount'], - 'discount_percent' => $data['discount_percent'], - 'discount_amount' => $data['discount_amount'], + 'product' => $this->productRepository->find($data['product_id']), + 'sku' => $data['sku'], + 'type' => $data['type'], + 'name' => $data['name'], + 'weight' => $data['weight'], + 'total_weight' => $data['total_weight'], + 'qty_ordered' => $data['quantity'], + 'price' => $data['price'], + 'base_price' => $data['base_price'], + 'total' => $data['total'], + 'base_total' => $data['base_total'], + 'tax_percent' => $data['tax_percent'], + 'tax_amount' => $data['tax_amount'], + 'base_tax_amount' => $data['base_tax_amount'], + 'discount_percent' => $data['discount_percent'], + 'discount_amount' => $data['discount_amount'], 'base_discount_amount' => $data['base_discount_amount'], - 'additional' => $data['additional'], + 'additional' => $data['additional'], ]; if (isset($data['children']) && $data['children']) { @@ -921,15 +977,18 @@ class Cart { * Move a wishlist item to cart * * @param WishlistItem $wishlistItem + * * @return boolean */ public function moveToCart($wishlistItem) { - if (! $wishlistItem->product->getTypeInstance()->canBeMovedFromWishlistToCart($wishlistItem)) + if (!$wishlistItem->product->getTypeInstance()->canBeMovedFromWishlistToCart($wishlistItem)) { return false; + } - if (! $wishlistItem->additional) + if (!$wishlistItem->additional) { $wishlistItem->additional = ['product_id' => $wishlistItem->product_id]; + } request()->merge($wishlistItem->additional); @@ -948,6 +1007,7 @@ class Cart { * Function to move a already added product to wishlist will run only on customer authentication. * * @param integer $itemId + * * @return boolean|void */ public function moveToWishlist($itemId) @@ -956,34 +1016,38 @@ class Cart { $cartItem = $cart->items()->find($itemId); - if (! $cartItem) + if (!$cartItem) { return false; + } $wishlistItems = $this->wishlistRepository->findWhere([ - 'customer_id' => $this->getCurrentCustomer()->user()->id, - 'product_id' => $cartItem->product_id - ]); + 'customer_id' => $this->getCurrentCustomer()->user()->id, + 'product_id' => $cartItem->product_id, + ]); $found = false; foreach ($wishlistItems as $wishlistItem) { - if ($cartItem->product->getTypeInstance()->compareOptions($cartItem->additional, $wishlistItem->item_options)) + if ($cartItem->product->getTypeInstance()->compareOptions($cartItem->additional, + $wishlistItem->item_options)) { $found = true; + } } - if (! $found) { + if (!$found) { $this->wishlistRepository->create([ - 'channel_id' => $cart->channel_id, - 'customer_id' => $this->getCurrentCustomer()->user()->id, - 'product_id' => $cartItem->product_id, - 'additional' => $cartItem->additional - ]); + 'channel_id' => $cart->channel_id, + 'customer_id' => $this->getCurrentCustomer()->user()->id, + 'product_id' => $cartItem->product_id, + 'additional' => $cartItem->additional, + ]); } $result = $this->cartItemRepository->delete($itemId); - if (! $cart->items()->count()) + if (!$cart->items()->count()) { $this->cartRepository->delete($cart->id); + } $this->collectTotals(); @@ -994,6 +1058,7 @@ class Cart { * Set coupon code to the cart * * @param string $code + * * @return Cart */ public function setCouponCode($code) diff --git a/packages/Webkul/Checkout/src/Helpers/Tax.php b/packages/Webkul/Checkout/src/Helpers/Tax.php new file mode 100644 index 000000000..2b4a28523 --- /dev/null +++ b/packages/Webkul/Checkout/src/Helpers/Tax.php @@ -0,0 +1,31 @@ +items as $item) { + $taxRate = (string)round((float)$item->tax_percent, self::TAX_PRECISION); + + if (array_key_exists($taxRate, $taxes)) { + $taxes[$taxRate] += $asBase ? $item->base_tax_amount : $item->tax_amount; + } else { + $taxes += [$taxRate => $asBase ? $item->base_tax_amount : $item->tax_amount]; + } + } + + return $taxes; + } +} \ No newline at end of file diff --git a/packages/Webkul/Shop/src/Resources/views/checkout/total/summary.blade.php b/packages/Webkul/Shop/src/Resources/views/checkout/total/summary.blade.php index 70d5d87d6..c1feb3508 100755 --- a/packages/Webkul/Shop/src/Resources/views/checkout/total/summary.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/checkout/total/summary.blade.php @@ -18,10 +18,12 @@ @endif @if ($cart->base_tax_total) + @foreach (Webkul\Checkout\Helpers\Tax::getTaxRatesWithAmount($cart, false) as $taxRate => $taxAmount )
- - + +
+ @endforeach @endif
base_discount_amount && $cart->base_discount_amount > 0) style="display: block;" @else style="display: none;" @endif> diff --git a/packages/Webkul/Shop/src/Resources/views/emails/sales/new-admin-order.blade.php b/packages/Webkul/Shop/src/Resources/views/emails/sales/new-admin-order.blade.php index 9e913b50b..a3b952743 100644 --- a/packages/Webkul/Shop/src/Resources/views/emails/sales/new-admin-order.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/emails/sales/new-admin-order.blade.php @@ -123,7 +123,7 @@ @if (isset($item->additional['attributes']))
- + @foreach ($item->additional['attributes'] as $attribute) {{ $attribute['attribute_name'] }} : {{ $attribute['option_label'] }}
@endforeach @@ -161,12 +161,14 @@
+ @foreach (Webkul\Checkout\Helpers\Tax::getTaxRatesWithAmount($order, true) as $taxRate => $baseTaxAmount )
- {{ __('shop::app.mail.order.tax') }} - - {{ core()->formatBasePrice($order->base_tax_amount) }} + {{ __('shop::app.mail.order.tax') }} {{ $taxRate }} % + + {{ core()->formatBasePrice($baseTaxAmount) }}
+ @endforeach @if ($order->discount_amount > 0)
diff --git a/packages/Webkul/Shop/src/Resources/views/emails/sales/new-invoice.blade.php b/packages/Webkul/Shop/src/Resources/views/emails/sales/new-invoice.blade.php index 55b0d5264..8cba444fe 100755 --- a/packages/Webkul/Shop/src/Resources/views/emails/sales/new-invoice.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/emails/sales/new-invoice.blade.php @@ -115,10 +115,10 @@ {{ $item->name }} - + @if (isset($item->additional['attributes']))
- + @foreach ($item->additional['attributes'] as $attribute) {{ $attribute['attribute_name'] }} : {{ $attribute['option_label'] }}
@endforeach @@ -146,7 +146,7 @@ {{ core()->formatPrice($invoice->sub_total, $invoice->order_currency_code) }}
- + @if ($order->shipping_address)
{{ __('shop::app.mail.order.shipping-handling') }} @@ -156,12 +156,14 @@
@endif -
- {{ __('shop::app.mail.order.tax') }} - - {{ core()->formatPrice($invoice->tax_amount, $invoice->order_currency_code) }} + @foreach ($order->getTaxRatesWithAmount(false) as $taxRate => $taxAmount) +
+ {{ __('shop::app.mail.order.tax') }} {{ $taxRate }} % + + {{ core()->formatPrice($taxAmount, $order->order_currency_code) }} -
+
+ @endforeach @if ($invoice->discount_amount > 0)
diff --git a/packages/Webkul/Shop/src/Resources/views/emails/sales/new-order.blade.php b/packages/Webkul/Shop/src/Resources/views/emails/sales/new-order.blade.php index 2d848b5ca..f2ca139b0 100755 --- a/packages/Webkul/Shop/src/Resources/views/emails/sales/new-order.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/emails/sales/new-order.blade.php @@ -116,10 +116,10 @@ {{ $item->name }} - + @if (isset($item->additional['attributes']))
- + @foreach ($item->additional['attributes'] as $attribute) {{ $attribute['attribute_name'] }} : {{ $attribute['option_label'] }}
@endforeach @@ -156,12 +156,14 @@
@endif + @foreach (Webkul\Checkout\Helpers\Tax::getTaxRatesWithAmount($order, false) as $taxRate => $taxAmount )
- {{ __('shop::app.mail.order.tax') }} - - {{ core()->formatPrice($order->tax_amount, $order->order_currency_code) }} + {{ __('shop::app.mail.order.tax') }} {{ $taxRate }} % + + {{ core()->formatPrice($taxAmount, $order->order_currency_code) }}
+ @endforeach @if ($order->discount_amount > 0)
diff --git a/packages/Webkul/Shop/src/Resources/views/emails/sales/new-refund.blade.php b/packages/Webkul/Shop/src/Resources/views/emails/sales/new-refund.blade.php index d80d9937d..604d2f65b 100644 --- a/packages/Webkul/Shop/src/Resources/views/emails/sales/new-refund.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/emails/sales/new-refund.blade.php @@ -115,10 +115,10 @@ {{ $item->name }} - + @if (isset($item->additional['attributes']))
- + @foreach ($item->additional['attributes'] as $attribute) {{ $attribute['attribute_name'] }} : {{ $attribute['option_label'] }}
@endforeach @@ -158,7 +158,7 @@
@endif - +@php(//ToDo: taxes) @if ($refund->tax_amount > 0)
{{ __('shop::app.mail.order.tax') }} diff --git a/packages/Webkul/Shop/src/Resources/views/emails/sales/order-cancel.blade.php b/packages/Webkul/Shop/src/Resources/views/emails/sales/order-cancel.blade.php index cd6b9600e..19e677626 100644 --- a/packages/Webkul/Shop/src/Resources/views/emails/sales/order-cancel.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/emails/sales/order-cancel.blade.php @@ -119,7 +119,7 @@ @if (isset($item->additional['attributes']))
- + @foreach ($item->additional['attributes'] as $attribute) {{ $attribute['attribute_name'] }} : {{ $attribute['option_label'] }}
@endforeach @@ -157,12 +157,14 @@
-
- {{ __('shop::app.mail.order.cancel.tax') }} - - {{ core()->formatPrice($order->tax_amount, $order->order_currency_code) }} + @foreach (Webkul\Checkout\Helpers\Tax::getTaxRatesWithAmount($order, false) as $taxRate => $taxAmount ) +
+ {{ __('shop::app.mail.order.cancel.tax') }} {{ $taxRate }} % + + {{ core()->formatPrice($taxAmount, $order->order_currency_code) }} -
+
+ @endforeach @if ($order->discount_amount > 0)
From cb5e3a47f6d9aa6595626f1579259714d35833a9 Mon Sep 17 00:00:00 2001 From: Steffen Mahler Date: Tue, 4 Feb 2020 08:50:37 +0100 Subject: [PATCH 02/38] fix tax handling, add functional cest for cart --- .../views/sales/orders/view.blade.php | 4 +- packages/Webkul/Checkout/src/Cart.php | 13 +- .../Core/src/Helpers/Laravel5Helper.php | 2 +- .../ProductAttributeValueFactory.php | 2 +- .../views/checkout/total/summary.blade.php | 4 +- .../emails/sales/new-admin-order.blade.php | 2 +- .../views/emails/sales/new-invoice.blade.php | 2 +- .../views/emails/sales/new-order.blade.php | 2 +- .../views/emails/sales/new-refund.blade.php | 4 +- .../views/emails/sales/order-cancel.blade.php | 2 +- .../Database/Factories/TaxCategoryFactory.php | 17 +++ .../src/Database/Factories/TaxMapFactory.php | 19 +++ .../src/Database/Factories/TaxRateFactory.php | 19 +++ .../{Checkout => Tax}/src/Helpers/Tax.php | 17 ++- .../Tax/src/Providers/TaxServiceProvider.php | 13 ++ tests/functional/Shop/CartCest.php | 114 ++++++++++++++++++ tests/functional/Shop/GuestCheckoutCest.php | 2 +- 17 files changed, 217 insertions(+), 21 deletions(-) create mode 100644 packages/Webkul/Tax/src/Database/Factories/TaxCategoryFactory.php create mode 100644 packages/Webkul/Tax/src/Database/Factories/TaxMapFactory.php create mode 100644 packages/Webkul/Tax/src/Database/Factories/TaxRateFactory.php rename packages/Webkul/{Checkout => Tax}/src/Helpers/Tax.php (61%) create mode 100644 tests/functional/Shop/CartCest.php diff --git a/packages/Webkul/Admin/src/Resources/views/sales/orders/view.blade.php b/packages/Webkul/Admin/src/Resources/views/sales/orders/view.blade.php index 499fbfe74..8787b2767 100755 --- a/packages/Webkul/Admin/src/Resources/views/sales/orders/view.blade.php +++ b/packages/Webkul/Admin/src/Resources/views/sales/orders/view.blade.php @@ -344,12 +344,12 @@ @endif - @php ($taxRates = Webkul\Checkout\Helpers\Tax::getTaxRatesWithAmount($order, true)) + @php ($taxRates = Webkul\Tax\Helpers\Tax::getTaxRatesWithAmount($order, true)) @foreach ($taxRates as $taxRate => $baseTaxAmount) last ? 'class=border' : ''}}> {{ __('admin::app.sales.orders.tax') }} {{ $taxRate }} % - - {{ core()->formatBasePrice($baseTaxAmount) }} + {{ core()->formatBasePrice($baseTaxAmount) }} @endforeach diff --git a/packages/Webkul/Checkout/src/Cart.php b/packages/Webkul/Checkout/src/Cart.php index c6eca6000..28021ecde 100755 --- a/packages/Webkul/Checkout/src/Cart.php +++ b/packages/Webkul/Checkout/src/Cart.php @@ -7,6 +7,7 @@ use Webkul\Checkout\Repositories\CartItemRepository; use Webkul\Checkout\Repositories\CartAddressRepository; use Webkul\Customer\Models\CustomerAddress; use Webkul\Product\Repositories\ProductRepository; +use Webkul\Tax\Helpers\Tax; use Webkul\Tax\Repositories\TaxCategoryRepository; use Webkul\Checkout\Models\CartItem; use Webkul\Checkout\Models\CartPayment; @@ -675,16 +676,16 @@ class Cart $cart->discount_amount += $item->discount_amount; $cart->base_discount_amount += $item->base_discount_amount; - $cart->grand_total = (float)$cart->grand_total + $item->total + $item->tax_amount - $item->discount_amount; - $cart->base_grand_total = (float)$cart->base_grand_total + $item->base_total + $item->base_tax_amount - $item->base_discount_amount; - $cart->sub_total = (float)$cart->sub_total + $item->total; $cart->base_sub_total = (float)$cart->base_sub_total + $item->base_total; - - $cart->tax_total = (float)$cart->tax_total + $item->tax_amount; - $cart->base_tax_total = (float)$cart->base_tax_total + $item->base_tax_amount; } + $cart->tax_total = Tax::getTaxTotal($cart, false); + $cart->base_tax_total = Tax::getTaxTotal($cart, true); + + $cart->grand_total = $cart->sub_total + $cart->tax_total + $cart->discount_amount; + $cart->base_grand_total = $cart->base_sub_total + $cart->base_tax_total - $cart->base_discount_amount; + if ($shipping = $cart->selected_shipping_rate) { $cart->grand_total = (float)$cart->grand_total + $shipping->price - $shipping->discount_amount; $cart->base_grand_total = (float)$cart->base_grand_total + $shipping->base_price - $shipping->base_discount_amount; diff --git a/packages/Webkul/Core/src/Helpers/Laravel5Helper.php b/packages/Webkul/Core/src/Helpers/Laravel5Helper.php index 7b8cfb7f2..1d212ab80 100644 --- a/packages/Webkul/Core/src/Helpers/Laravel5Helper.php +++ b/packages/Webkul/Core/src/Helpers/Laravel5Helper.php @@ -68,7 +68,7 @@ class Laravel5Helper extends Laravel5 ): Product { $I = $this; /** @var Product $product */ - $product = factory(Product::class)->states($productStates)->create($configs['productAttributes'] ?? []);; + $product = factory(Product::class)->states($productStates)->create($configs['productAttributes'] ?? []); $I->createAttributeValues($product->id,$configs['attributeValues'] ?? []); $I->have(ProductInventory::class, array_merge($configs['productInventory'] ?? [], [ 'product_id' => $product->id, diff --git a/packages/Webkul/Product/src/Database/Factories/ProductAttributeValueFactory.php b/packages/Webkul/Product/src/Database/Factories/ProductAttributeValueFactory.php index 4da6ddaf0..cf06abca4 100644 --- a/packages/Webkul/Product/src/Database/Factories/ProductAttributeValueFactory.php +++ b/packages/Webkul/Product/src/Database/Factories/ProductAttributeValueFactory.php @@ -42,7 +42,7 @@ $factory->defineAs(ProductAttributeValue::class, 'tax_category_id', function (Fa return factory(Product::class)->create()->id; }, 'channel' => 'default', - 'integer_value' => null, // ToDo + 'integer_value' => null, 'attribute_id' => 4, ]; }); diff --git a/packages/Webkul/Shop/src/Resources/views/checkout/total/summary.blade.php b/packages/Webkul/Shop/src/Resources/views/checkout/total/summary.blade.php index c1feb3508..e492cb91f 100755 --- a/packages/Webkul/Shop/src/Resources/views/checkout/total/summary.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/checkout/total/summary.blade.php @@ -18,10 +18,10 @@ @endif @if ($cart->base_tax_total) - @foreach (Webkul\Checkout\Helpers\Tax::getTaxRatesWithAmount($cart, false) as $taxRate => $taxAmount ) + @foreach (Webkul\Tax\Helpers\Tax::getTaxRatesWithAmount($cart, true) as $taxRate => $baseTaxAmount )
- +
@endforeach @endif diff --git a/packages/Webkul/Shop/src/Resources/views/emails/sales/new-admin-order.blade.php b/packages/Webkul/Shop/src/Resources/views/emails/sales/new-admin-order.blade.php index a3b952743..7e077768b 100644 --- a/packages/Webkul/Shop/src/Resources/views/emails/sales/new-admin-order.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/emails/sales/new-admin-order.blade.php @@ -161,7 +161,7 @@
- @foreach (Webkul\Checkout\Helpers\Tax::getTaxRatesWithAmount($order, true) as $taxRate => $baseTaxAmount ) + @foreach (Webkul\Tax\Helpers\Tax::getTaxRatesWithAmount($order, true) as $taxRate => $baseTaxAmount )
{{ __('shop::app.mail.order.tax') }} {{ $taxRate }} % diff --git a/packages/Webkul/Shop/src/Resources/views/emails/sales/new-invoice.blade.php b/packages/Webkul/Shop/src/Resources/views/emails/sales/new-invoice.blade.php index 8cba444fe..b8f70beaa 100755 --- a/packages/Webkul/Shop/src/Resources/views/emails/sales/new-invoice.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/emails/sales/new-invoice.blade.php @@ -156,7 +156,7 @@
@endif - @foreach ($order->getTaxRatesWithAmount(false) as $taxRate => $taxAmount) + @foreach (Webkul\Tax\Helpers\Tax::getTaxRatesWithAmount($refund, false) as $taxRate => $taxAmount)
{{ __('shop::app.mail.order.tax') }} {{ $taxRate }} % diff --git a/packages/Webkul/Shop/src/Resources/views/emails/sales/new-order.blade.php b/packages/Webkul/Shop/src/Resources/views/emails/sales/new-order.blade.php index f2ca139b0..8089ce37a 100755 --- a/packages/Webkul/Shop/src/Resources/views/emails/sales/new-order.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/emails/sales/new-order.blade.php @@ -156,7 +156,7 @@
@endif - @foreach (Webkul\Checkout\Helpers\Tax::getTaxRatesWithAmount($order, false) as $taxRate => $taxAmount ) + @foreach (Webkul\Tax\Helpers\Tax::getTaxRatesWithAmount($order, false) as $taxRate => $taxAmount )
{{ __('shop::app.mail.order.tax') }} {{ $taxRate }} % diff --git a/packages/Webkul/Shop/src/Resources/views/emails/sales/new-refund.blade.php b/packages/Webkul/Shop/src/Resources/views/emails/sales/new-refund.blade.php index 604d2f65b..8bd270795 100644 --- a/packages/Webkul/Shop/src/Resources/views/emails/sales/new-refund.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/emails/sales/new-refund.blade.php @@ -158,14 +158,16 @@
@endif -@php(//ToDo: taxes) + @if ($refund->tax_amount > 0) + @foreach (Webkul\Tax\Helpers\Tax::getTaxRatesWithAmount($refund, false) as $taxRate => $taxAmount)
{{ __('shop::app.mail.order.tax') }} {{ core()->formatPrice($refund->tax_amount, $refund->order_currency_code) }}
+ @endforeach @endif @if ($refund->discount_amount > 0) diff --git a/packages/Webkul/Shop/src/Resources/views/emails/sales/order-cancel.blade.php b/packages/Webkul/Shop/src/Resources/views/emails/sales/order-cancel.blade.php index 19e677626..c3b007370 100644 --- a/packages/Webkul/Shop/src/Resources/views/emails/sales/order-cancel.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/emails/sales/order-cancel.blade.php @@ -157,7 +157,7 @@
- @foreach (Webkul\Checkout\Helpers\Tax::getTaxRatesWithAmount($order, false) as $taxRate => $taxAmount ) + @foreach (Webkul\Tax\Helpers\Tax::getTaxRatesWithAmount($order, false) as $taxRate => $taxAmount )
{{ __('shop::app.mail.order.cancel.tax') }} {{ $taxRate }} % diff --git a/packages/Webkul/Tax/src/Database/Factories/TaxCategoryFactory.php b/packages/Webkul/Tax/src/Database/Factories/TaxCategoryFactory.php new file mode 100644 index 000000000..b704d1d84 --- /dev/null +++ b/packages/Webkul/Tax/src/Database/Factories/TaxCategoryFactory.php @@ -0,0 +1,17 @@ +define(TaxCategory::class, function (Faker $faker) { + return [ + 'channel_id' => function () { + return core()->getCurrentChannel()->id; + }, + 'code' => $faker->uuid, + 'name' => $faker->words(2, true), + 'description' => $faker->sentence(10), + ]; +}); diff --git a/packages/Webkul/Tax/src/Database/Factories/TaxMapFactory.php b/packages/Webkul/Tax/src/Database/Factories/TaxMapFactory.php new file mode 100644 index 000000000..7e7d50769 --- /dev/null +++ b/packages/Webkul/Tax/src/Database/Factories/TaxMapFactory.php @@ -0,0 +1,19 @@ +define(TaxMap::class, function (Faker $faker) { + return [ + 'tax_category_id' => function () { + return factory(TaxCategory::class)->create()->id; + }, + 'tax_rate_id' => function () { + return factory(TaxRate::class)->create()->id; + }, + ]; +}); diff --git a/packages/Webkul/Tax/src/Database/Factories/TaxRateFactory.php b/packages/Webkul/Tax/src/Database/Factories/TaxRateFactory.php new file mode 100644 index 000000000..a611bebc0 --- /dev/null +++ b/packages/Webkul/Tax/src/Database/Factories/TaxRateFactory.php @@ -0,0 +1,19 @@ +define(TaxRate::class, function (Faker $faker) { + return [ + 'identifier' => $faker->uuid, + 'is_zip' => 0, + 'zip_code' => '*', + 'zip_from' => null, + 'zip_to' => null, + 'state' => '', + 'country' => $faker->countryCode, + 'tax_rate' => $faker->randomFloat(2, 3, 25), + ]; +}); diff --git a/packages/Webkul/Checkout/src/Helpers/Tax.php b/packages/Webkul/Tax/src/Helpers/Tax.php similarity index 61% rename from packages/Webkul/Checkout/src/Helpers/Tax.php rename to packages/Webkul/Tax/src/Helpers/Tax.php index 2b4a28523..908aa8be7 100644 --- a/packages/Webkul/Checkout/src/Helpers/Tax.php +++ b/packages/Webkul/Tax/src/Helpers/Tax.php @@ -1,19 +1,19 @@ items as $item) { @@ -28,4 +28,15 @@ class Tax return $taxes; } + + public static function getTaxTotal(object $that, bool $asBase = false): float + { + $taxes = self::getTaxRatesWithAmount($that, $asBase); + + $result = 0; + foreach ($taxes as $taxRate => $taxAmount) { + $result += round($taxAmount, 2); + } + return $result; + } } \ No newline at end of file diff --git a/packages/Webkul/Tax/src/Providers/TaxServiceProvider.php b/packages/Webkul/Tax/src/Providers/TaxServiceProvider.php index 9f67df0df..047ec84b4 100755 --- a/packages/Webkul/Tax/src/Providers/TaxServiceProvider.php +++ b/packages/Webkul/Tax/src/Providers/TaxServiceProvider.php @@ -2,6 +2,7 @@ namespace Webkul\Tax\Providers; use Illuminate\Support\ServiceProvider; +use Illuminate\Database\Eloquent\Factory as EloquentFactory; class TaxServiceProvider extends ServiceProvider { @@ -22,5 +23,17 @@ class TaxServiceProvider extends ServiceProvider */ public function register() { + $this->registerEloquentFactoriesFrom(__DIR__ . '/../Database/Factories'); + } + + /** + * Register factories. + * + * @param string $path + * @return void + */ + protected function registerEloquentFactoriesFrom($path): void + { + $this->app->make(EloquentFactory::class)->load($path); } } \ No newline at end of file diff --git a/tests/functional/Shop/CartCest.php b/tests/functional/Shop/CartCest.php new file mode 100644 index 000000000..87f9aa131 --- /dev/null +++ b/tests/functional/Shop/CartCest.php @@ -0,0 +1,114 @@ +faker = Factory::create(); + + $this->country = 'DE'; //$this->faker->countryCode; + + $this->tax1 = $I->have(TaxRate::class, ['tax_rate' => 7.00, 'country' => $this->country]); + $taxCategorie1 = $I->have(TaxCategory::class, []); + $I->have(TaxMap::class, ['tax_rate_id' => $this->tax1->id, 'tax_category_id' => $taxCategorie1->id]); + + $this->tax2 = $I->have(TaxRate::class, ['tax_rate' => 19.00, 'country' => $this->country]); + $taxCategorie2 = $I->have(TaxCategory::class, []); + $I->have(TaxMap::class, ['tax_rate_id' => $this->tax2->id, 'tax_category_id' => $taxCategorie2->id]); + + $config1 = [ + 'productInventory' => ['qty' => 100], + 'attributeValues' => [ + 'status' => true, + 'new' => 1, + 'tax_category_id' => $taxCategorie1->id, + ], + ]; + $this->product1 = $I->haveProduct($config1, ['simple']); + + $config2 = [ + 'productInventory' => ['qty' => 100], + 'attributeValues' => [ + 'status' => true, + 'new' => 1, + 'tax_category_id' => $taxCategorie2->id, + ], + ]; + $this->product2 = $I->haveProduct($config2, ['simple']); + } + + public function checkCartWithMultipleTaxRates(FunctionalTester $I) + { + $I->setConfigData(['default_country' => $this->country]); + + $prod1Quantity = $this->faker->numberBetween(9, 30); + if ($prod1Quantity % 2 !== 0) { + $prod1Quantity -= 1; + } + + $prod2Quantity = $this->faker->numberBetween(9, 30); + if ($prod2Quantity % 2 == 0) { + $prod2Quantity -= 1; + } + + Cart::addProduct($this->product1->id, [ + '_token' => session('_token'), + 'product_id' => $this->product1->id, + 'quantity' => 1, + ]); + + $I->amOnPage('/checkout/cart'); + $I->see('Tax ' . $this->tax1->tax_rate . ' %', '#taxrate-' . $this->tax1->tax_rate); + $I->see(round($this->product1->price * $this->tax1->tax_rate / 100, 2), + '#basetaxamount-' . $this->tax1->tax_rate); + + Cart::addProduct($this->product1->id, [ + '_token' => session('_token'), + 'product_id' => $this->product1->id, + 'quantity' => $prod1Quantity, + ]); + + $I->amOnPage('/checkout/cart'); + $I->see('Tax ' . $this->tax1->tax_rate . ' %', '#taxrate-' . $this->tax1->tax_rate); + $I->see(round(($prod1Quantity + 1) * $this->product1->price * $this->tax1->tax_rate / 100, 2), + '#basetaxamount-' . $this->tax1->tax_rate); + + Cart::addProduct($this->product2->id, [ + '_token' => session('_token'), + 'product_id' => $this->product2->id, + 'quantity' => $prod2Quantity, + ]); + + $I->amOnPage('/checkout/cart'); + $I->see('Tax ' . $this->tax1->tax_rate . ' %', '#taxrate-' . $this->tax1->tax_rate); + $taxAmount1 = round(($prod1Quantity + 1) * $this->product1->price * $this->tax1->tax_rate / 100, 2); + $I->see(core()->currency($taxAmount1),'#basetaxamount-' . $this->tax1->tax_rate); + + $I->see('Tax ' . $this->tax2->tax_rate . ' %', '#taxrate-' . $this->tax2->tax_rate); + $taxAmount2 = round($prod2Quantity * $this->product2->price * $this->tax2->tax_rate / 100, 2); + $I->see(core()->currency($taxAmount2),'#basetaxamount-' . $this->tax2->tax_rate); + + $cart = Cart::getCart(); + + $I->assertEquals(2, $cart->items_count); + $I->assertEquals((float)($prod1Quantity + 1 + $prod2Quantity), $cart->items_qty); + $I->assertEquals($taxAmount1 + $taxAmount2, $cart->tax_total); + + + } +} \ No newline at end of file diff --git a/tests/functional/Shop/GuestCheckoutCest.php b/tests/functional/Shop/GuestCheckoutCest.php index ea712b673..94e2e4e6e 100644 --- a/tests/functional/Shop/GuestCheckoutCest.php +++ b/tests/functional/Shop/GuestCheckoutCest.php @@ -1,6 +1,6 @@ Date: Tue, 4 Feb 2020 11:18:40 +0100 Subject: [PATCH 03/38] add unit tests, refactoring --- .../views/sales/orders/view.blade.php | 4 +- packages/Webkul/Core/src/Core.php | 11 ++++ .../views/checkout/total/summary.blade.php | 4 +- .../emails/sales/new-admin-order.blade.php | 4 +- .../views/emails/sales/new-invoice.blade.php | 4 +- .../views/emails/sales/new-order.blade.php | 4 +- .../views/emails/sales/order-cancel.blade.php | 4 +- packages/Webkul/Tax/src/Helpers/Tax.php | 7 +++ tests/_support/UnitTester.php | 59 +++++++++++++++++-- tests/functional/Shop/CartCest.php | 46 +++++++++------ tests/unit/Core/CoreCest.php | 34 +++++++++++ tests/unit/Tax/Helpers/TaxCest.php | 18 ++++++ 12 files changed, 164 insertions(+), 35 deletions(-) create mode 100644 tests/unit/Core/CoreCest.php create mode 100644 tests/unit/Tax/Helpers/TaxCest.php diff --git a/packages/Webkul/Admin/src/Resources/views/sales/orders/view.blade.php b/packages/Webkul/Admin/src/Resources/views/sales/orders/view.blade.php index 8787b2767..dcf5d8872 100755 --- a/packages/Webkul/Admin/src/Resources/views/sales/orders/view.blade.php +++ b/packages/Webkul/Admin/src/Resources/views/sales/orders/view.blade.php @@ -347,9 +347,9 @@ @php ($taxRates = Webkul\Tax\Helpers\Tax::getTaxRatesWithAmount($order, true)) @foreach ($taxRates as $taxRate => $baseTaxAmount) last ? 'class=border' : ''}}> - {{ __('admin::app.sales.orders.tax') }} {{ $taxRate }} % + {{ __('admin::app.sales.orders.tax') }} {{ $taxRate }} % - - {{ core()->formatBasePrice($baseTaxAmount) }} + {{ core()->formatBasePrice($baseTaxAmount) }} @endforeach diff --git a/packages/Webkul/Core/src/Core.php b/packages/Webkul/Core/src/Core.php index 963af1b00..832e3c178 100755 --- a/packages/Webkul/Core/src/Core.php +++ b/packages/Webkul/Core/src/Core.php @@ -933,4 +933,15 @@ class Core return $instance[$className] = app($className); } + + /** + * Returns a string as selector part for identifying elements in views + * @param float $taxRate + * + * @return string + */ + public static function taxRateAsIdentifier(float $taxRate): string + { + return str_replace('.', '_', (string)$taxRate); + } } \ No newline at end of file diff --git a/packages/Webkul/Shop/src/Resources/views/checkout/total/summary.blade.php b/packages/Webkul/Shop/src/Resources/views/checkout/total/summary.blade.php index e492cb91f..76a6b238b 100755 --- a/packages/Webkul/Shop/src/Resources/views/checkout/total/summary.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/checkout/total/summary.blade.php @@ -20,8 +20,8 @@ @if ($cart->base_tax_total) @foreach (Webkul\Tax\Helpers\Tax::getTaxRatesWithAmount($cart, true) as $taxRate => $baseTaxAmount )
- - + +
@endforeach @endif diff --git a/packages/Webkul/Shop/src/Resources/views/emails/sales/new-admin-order.blade.php b/packages/Webkul/Shop/src/Resources/views/emails/sales/new-admin-order.blade.php index 7e077768b..ec6933735 100644 --- a/packages/Webkul/Shop/src/Resources/views/emails/sales/new-admin-order.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/emails/sales/new-admin-order.blade.php @@ -163,8 +163,8 @@ @foreach (Webkul\Tax\Helpers\Tax::getTaxRatesWithAmount($order, true) as $taxRate => $baseTaxAmount )
- {{ __('shop::app.mail.order.tax') }} {{ $taxRate }} % - + {{ __('shop::app.mail.order.tax') }} {{ $taxRate }} % + {{ core()->formatBasePrice($baseTaxAmount) }}
diff --git a/packages/Webkul/Shop/src/Resources/views/emails/sales/new-invoice.blade.php b/packages/Webkul/Shop/src/Resources/views/emails/sales/new-invoice.blade.php index b8f70beaa..32a35705f 100755 --- a/packages/Webkul/Shop/src/Resources/views/emails/sales/new-invoice.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/emails/sales/new-invoice.blade.php @@ -158,8 +158,8 @@ @foreach (Webkul\Tax\Helpers\Tax::getTaxRatesWithAmount($refund, false) as $taxRate => $taxAmount)
- {{ __('shop::app.mail.order.tax') }} {{ $taxRate }} % - + {{ __('shop::app.mail.order.tax') }} {{ $taxRate }} % + {{ core()->formatPrice($taxAmount, $order->order_currency_code) }}
diff --git a/packages/Webkul/Shop/src/Resources/views/emails/sales/new-order.blade.php b/packages/Webkul/Shop/src/Resources/views/emails/sales/new-order.blade.php index 8089ce37a..a1b58f641 100755 --- a/packages/Webkul/Shop/src/Resources/views/emails/sales/new-order.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/emails/sales/new-order.blade.php @@ -158,8 +158,8 @@ @foreach (Webkul\Tax\Helpers\Tax::getTaxRatesWithAmount($order, false) as $taxRate => $taxAmount )
- {{ __('shop::app.mail.order.tax') }} {{ $taxRate }} % - + {{ __('shop::app.mail.order.tax') }} {{ $taxRate }} % + {{ core()->formatPrice($taxAmount, $order->order_currency_code) }}
diff --git a/packages/Webkul/Shop/src/Resources/views/emails/sales/order-cancel.blade.php b/packages/Webkul/Shop/src/Resources/views/emails/sales/order-cancel.blade.php index c3b007370..2b0139e1c 100644 --- a/packages/Webkul/Shop/src/Resources/views/emails/sales/order-cancel.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/emails/sales/order-cancel.blade.php @@ -159,8 +159,8 @@ @foreach (Webkul\Tax\Helpers\Tax::getTaxRatesWithAmount($order, false) as $taxRate => $taxAmount )
- {{ __('shop::app.mail.order.cancel.tax') }} {{ $taxRate }} % - + {{ __('shop::app.mail.order.cancel.tax') }} {{ $taxRate }} % + {{ core()->formatPrice($taxAmount, $order->order_currency_code) }}
diff --git a/packages/Webkul/Tax/src/Helpers/Tax.php b/packages/Webkul/Tax/src/Helpers/Tax.php index 908aa8be7..cc10b2baf 100644 --- a/packages/Webkul/Tax/src/Helpers/Tax.php +++ b/packages/Webkul/Tax/src/Helpers/Tax.php @@ -29,6 +29,13 @@ class Tax return $taxes; } + /** + * Returns the total tax amount + * @param object $that + * @param bool $asBase + * + * @return float + */ public static function getTaxTotal(object $that, bool $asBase = false): float { $taxes = self::getTaxRatesWithAmount($that, $asBase); diff --git a/tests/_support/UnitTester.php b/tests/_support/UnitTester.php index e19544a51..b056dc732 100644 --- a/tests/_support/UnitTester.php +++ b/tests/_support/UnitTester.php @@ -1,5 +1,6 @@ comment('I execute function "' + . $functionName + . '" of class "' + . (is_object($className) ? get_class($className) : $className) + . '" with ' + . count($methodParams) + . ' method-params, ' + . count($constructParams) + . ' constuctor-params and ' + . count($mocks) + . ' mocked class-methods/params' + ); + $class = new \ReflectionClass($className); + $method = $class->getMethod($functionName); + $method->setAccessible(true); + if (is_object($className)) { + $reflectedClass = $className; + } elseif (empty($constructParams)) { + $reflectedClass = Stub::make($className, $mocks); + } else { + $reflectedClass = Stub::construct($className, $constructParams, $mocks); + } + + return $method->invokeArgs($reflectedClass, $methodParams); + } +} \ No newline at end of file diff --git a/tests/functional/Shop/CartCest.php b/tests/functional/Shop/CartCest.php index 87f9aa131..8381defa2 100644 --- a/tests/functional/Shop/CartCest.php +++ b/tests/functional/Shop/CartCest.php @@ -4,6 +4,7 @@ namespace Tests\Functional\Cart; use FunctionalTester; use Faker\Factory; +use Illuminate\Support\Facades\Config; use Webkul\Tax\Models\TaxMap; use Webkul\Tax\Models\TaxRate; use Webkul\Tax\Models\TaxCategory; @@ -21,15 +22,27 @@ class CartCest { $this->faker = Factory::create(); - $this->country = 'DE'; //$this->faker->countryCode; + $this->country = Config::get('app.default_country'); - $this->tax1 = $I->have(TaxRate::class, ['tax_rate' => 7.00, 'country' => $this->country]); + $this->tax1 = $I->have(TaxRate::class, [ + //'tax_rate' => 7.00, + 'country' => $this->country + ]); $taxCategorie1 = $I->have(TaxCategory::class, []); - $I->have(TaxMap::class, ['tax_rate_id' => $this->tax1->id, 'tax_category_id' => $taxCategorie1->id]); + $I->have(TaxMap::class, [ + 'tax_rate_id' => $this->tax1->id, + 'tax_category_id' => $taxCategorie1->id + ]); - $this->tax2 = $I->have(TaxRate::class, ['tax_rate' => 19.00, 'country' => $this->country]); + $this->tax2 = $I->have(TaxRate::class, [ + //'tax_rate' => 19.00, + 'country' => $this->country + ]); $taxCategorie2 = $I->have(TaxCategory::class, []); - $I->have(TaxMap::class, ['tax_rate_id' => $this->tax2->id, 'tax_category_id' => $taxCategorie2->id]); + $I->have(TaxMap::class, [ + 'tax_rate_id' => $this->tax2->id, + 'tax_category_id' => $taxCategorie2->id + ]); $config1 = [ 'productInventory' => ['qty' => 100], @@ -54,7 +67,6 @@ class CartCest public function checkCartWithMultipleTaxRates(FunctionalTester $I) { - $I->setConfigData(['default_country' => $this->country]); $prod1Quantity = $this->faker->numberBetween(9, 30); if ($prod1Quantity % 2 !== 0) { @@ -73,9 +85,9 @@ class CartCest ]); $I->amOnPage('/checkout/cart'); - $I->see('Tax ' . $this->tax1->tax_rate . ' %', '#taxrate-' . $this->tax1->tax_rate); - $I->see(round($this->product1->price * $this->tax1->tax_rate / 100, 2), - '#basetaxamount-' . $this->tax1->tax_rate); + $I->see('Tax ' . $this->tax1->tax_rate . ' %', '#taxrate-' . core()->taxRateAsIdentifier($this->tax1->tax_rate)); + $I->see(core()->currency(round($this->product1->price * $this->tax1->tax_rate / 100, 2)), + '#basetaxamount-' . core()->taxRateAsIdentifier($this->tax1->tax_rate)); Cart::addProduct($this->product1->id, [ '_token' => session('_token'), @@ -84,9 +96,9 @@ class CartCest ]); $I->amOnPage('/checkout/cart'); - $I->see('Tax ' . $this->tax1->tax_rate . ' %', '#taxrate-' . $this->tax1->tax_rate); - $I->see(round(($prod1Quantity + 1) * $this->product1->price * $this->tax1->tax_rate / 100, 2), - '#basetaxamount-' . $this->tax1->tax_rate); + $I->see('Tax ' . $this->tax1->tax_rate . ' %', '#taxrate-' . core()->taxRateAsIdentifier($this->tax1->tax_rate)); + $I->see(core()->currency(round(($prod1Quantity + 1) * $this->product1->price * $this->tax1->tax_rate / 100, 2)), + '#basetaxamount-' . core()->taxRateAsIdentifier($this->tax1->tax_rate)); Cart::addProduct($this->product2->id, [ '_token' => session('_token'), @@ -95,20 +107,18 @@ class CartCest ]); $I->amOnPage('/checkout/cart'); - $I->see('Tax ' . $this->tax1->tax_rate . ' %', '#taxrate-' . $this->tax1->tax_rate); + $I->see('Tax ' . $this->tax1->tax_rate . ' %', '#taxrate-' . core()->taxRateAsIdentifier($this->tax1->tax_rate)); $taxAmount1 = round(($prod1Quantity + 1) * $this->product1->price * $this->tax1->tax_rate / 100, 2); - $I->see(core()->currency($taxAmount1),'#basetaxamount-' . $this->tax1->tax_rate); + $I->see(core()->currency($taxAmount1),'#basetaxamount-' . core()->taxRateAsIdentifier($this->tax1->tax_rate)); - $I->see('Tax ' . $this->tax2->tax_rate . ' %', '#taxrate-' . $this->tax2->tax_rate); + $I->see('Tax ' . $this->tax2->tax_rate . ' %', '#taxrate-' . core()->taxRateAsIdentifier($this->tax2->tax_rate)); $taxAmount2 = round($prod2Quantity * $this->product2->price * $this->tax2->tax_rate / 100, 2); - $I->see(core()->currency($taxAmount2),'#basetaxamount-' . $this->tax2->tax_rate); + $I->see(core()->currency($taxAmount2),'#basetaxamount-' . core()->taxRateAsIdentifier($this->tax2->tax_rate)); $cart = Cart::getCart(); $I->assertEquals(2, $cart->items_count); $I->assertEquals((float)($prod1Quantity + 1 + $prod2Quantity), $cart->items_qty); $I->assertEquals($taxAmount1 + $taxAmount2, $cart->tax_total); - - } } \ No newline at end of file diff --git a/tests/unit/Core/CoreCest.php b/tests/unit/Core/CoreCest.php new file mode 100644 index 000000000..25189b907 --- /dev/null +++ b/tests/unit/Core/CoreCest.php @@ -0,0 +1,34 @@ + 0, + 'expected' => '0', + ], + [ + 'input' => 0.01, + 'expected' => '0_01', + ], + [ + 'input' => .12, + 'expected' => '0_12', + ], + [ + 'input' => 1234.5678, + 'expected' => '1234_5678', + ], + ]; + + foreach ($scenarios as $scenario) { + $I->assertEquals($scenario['expected'], $I->executeFunction(\Webkul\Core\Core::class, 'taxRateAsIdentifier', [$scenario['input']])); + } + } +} diff --git a/tests/unit/Tax/Helpers/TaxCest.php b/tests/unit/Tax/Helpers/TaxCest.php new file mode 100644 index 000000000..9b8caa20f --- /dev/null +++ b/tests/unit/Tax/Helpers/TaxCest.php @@ -0,0 +1,18 @@ +assertTrue(false); + } + + public function testGetTaxTotal(UnitTester $I) + { + $I->assertTrue(false); + } +} From 721091cf3228b147dd7e12ec644d4ff02bf9a7b6 Mon Sep 17 00:00:00 2001 From: Steffen Mahler Date: Tue, 4 Feb 2020 13:27:47 +0100 Subject: [PATCH 04/38] unit test --- packages/Webkul/Tax/src/Helpers/Tax.php | 2 +- tests/unit.suite.yml | 2 +- tests/unit/Tax/Helpers/TaxCest.php | 95 ++++++++++++++++++++++++- 3 files changed, 95 insertions(+), 4 deletions(-) diff --git a/packages/Webkul/Tax/src/Helpers/Tax.php b/packages/Webkul/Tax/src/Helpers/Tax.php index cc10b2baf..e7bd81eee 100644 --- a/packages/Webkul/Tax/src/Helpers/Tax.php +++ b/packages/Webkul/Tax/src/Helpers/Tax.php @@ -4,7 +4,7 @@ namespace Webkul\Tax\Helpers; class Tax { - private const TAX_PRECISION = 4; + public const TAX_PRECISION = 4; /** * Returns an array with tax rates and tax amount diff --git a/tests/unit.suite.yml b/tests/unit.suite.yml index 53b2aa210..ba6191f9a 100644 --- a/tests/unit.suite.yml +++ b/tests/unit.suite.yml @@ -8,7 +8,7 @@ modules: - Asserts - Filesystem - \Helper\Unit - - Laravel5: + - Webkul\Core\Helpers\Laravel5Helper: environment_file: .env.testing run_database_migrations: true run_database_seeder: true diff --git a/tests/unit/Tax/Helpers/TaxCest.php b/tests/unit/Tax/Helpers/TaxCest.php index 9b8caa20f..5d987aacf 100644 --- a/tests/unit/Tax/Helpers/TaxCest.php +++ b/tests/unit/Tax/Helpers/TaxCest.php @@ -2,17 +2,108 @@ namespace Tests\Unit\Tax\Helpers; +use Faker\Factory; +use Illuminate\Support\Facades\Config; use UnitTester; +use Webkul\Tax\Models\TaxCategory; +use Webkul\Tax\Models\TaxMap; +use Webkul\Tax\Models\TaxRate; +use Cart; class TaxCest { + public $scenario; + + public function _before(UnitTester $I) + { + $faker = Factory::create(); + + $country = Config::get('app.default_country'); + + $tax1 = $I->have(TaxRate::class, [ + 'country' => $country, + ]); + $taxCategorie1 = $I->have(TaxCategory::class, []); + $I->have(TaxMap::class, [ + 'tax_rate_id' => $tax1->id, + 'tax_category_id' => $taxCategorie1->id, + ]); + + $tax2 = $I->have(TaxRate::class, [ + 'country' => $country, + ]); + $taxCategorie2 = $I->have(TaxCategory::class, []); + $I->have(TaxMap::class, [ + 'tax_rate_id' => $tax2->id, + 'tax_category_id' => $taxCategorie2->id, + ]); + + $config1 = [ + 'productInventory' => ['qty' => 100], + 'attributeValues' => [ + 'status' => true, + 'new' => 1, + 'tax_category_id' => $taxCategorie1->id, + ], + ]; + $product1 = $I->haveProduct($config1, ['simple']); + + $config2 = [ + 'productInventory' => ['qty' => 100], + 'attributeValues' => [ + 'status' => true, + 'new' => 1, + 'tax_category_id' => $taxCategorie2->id, + ], + ]; + $product2 = $I->haveProduct($config2, ['simple']); + + Cart::addProduct($product1->id, [ + '_token' => session('_token'), + 'product_id' => $product1->id, + 'quantity' => 11, + ]); + + Cart::addProduct($product2->id, [ + '_token' => session('_token'), + 'product_id' => $product2->id, + 'quantity' => 7, + ]); + + + $this->scenario = [ + 'object' => Cart::getCart(), + 'expectedTaxRates' => [ + (string)round((float)$tax1->tax_rate, \Webkul\Tax\Helpers\Tax::TAX_PRECISION) + => round(11 * $product1->price * $tax1->tax_rate / 100, 4), + + (string)round((float)$tax2->tax_rate, \Webkul\Tax\Helpers\Tax::TAX_PRECISION) + => round(7 * $product2->price * $tax2->tax_rate / 100, 4), + ], + 'expectedTaxTotal' => + round( + round(11 * $product1->price * $tax1->tax_rate / 100, 2) + + round(7 * $product2->price * $tax2->tax_rate / 100, 2) + , 2), + ]; + } + public function testGetTaxRatesWithAmount(UnitTester $I) { - $I->assertTrue(false); + $result = $I->executeFunction(\Webkul\Tax\Helpers\Tax::class, 'getTaxRatesWithAmount', + [$this->scenario['object'], false]); + + foreach ($result as $taxRate => $taxAmount) { + $I->assertTrue(array_key_exists($taxRate, $result)); + $I->assertEquals($this->scenario['expectedTaxRates'][$taxRate], $taxAmount); + } } public function testGetTaxTotal(UnitTester $I) { - $I->assertTrue(false); + $result = $I->executeFunction(\Webkul\Tax\Helpers\Tax::class, 'getTaxTotal', + [$this->scenario['object'], false]); + + $I->assertEquals($this->scenario['expectedTaxTotal'], $result); } } From a61446f1aa174ce9d2dad111f12798c378edd7ac Mon Sep 17 00:00:00 2001 From: Steffen Mahler Date: Tue, 4 Feb 2020 14:31:18 +0100 Subject: [PATCH 05/38] refactoring --- packages/Webkul/Checkout/src/Cart.php | 24 ++++++--------- packages/Webkul/Tax/src/Helpers/Tax.php | 7 ++--- .../Tax/src/Providers/TaxServiceProvider.php | 13 +------- tests/functional/Shop/CartCest.php | 27 +++++++++-------- tests/unit/Core/CoreCest.php | 30 ++++++++++++++----- tests/unit/Tax/Helpers/TaxCest.php | 20 ++++++++----- 6 files changed, 62 insertions(+), 59 deletions(-) diff --git a/packages/Webkul/Checkout/src/Cart.php b/packages/Webkul/Checkout/src/Cart.php index 28021ecde..5da54ae3b 100755 --- a/packages/Webkul/Checkout/src/Cart.php +++ b/packages/Webkul/Checkout/src/Cart.php @@ -16,17 +16,6 @@ use Webkul\Customer\Repositories\CustomerAddressRepository; use Illuminate\Support\Facades\Event; use Illuminate\Support\Arr; -class addressHelper -{ - public $country; - public $postcode; - - function __construct() - { - $this->country = config('app.default_country'); - } -} - /** * Facades handler for all the methods to be implemented in Cart. * @@ -755,9 +744,6 @@ class Cart return false; } -// if (! $cart->shipping_address && ! $cart->billing_address) -// return; - foreach ($cart->items()->get() as $item) { $taxCategory = $this->taxCategoryRepository->find($item->product->tax_category_id); @@ -772,7 +758,15 @@ class Cart } if ($address === null) { - $address = new addressHelper(); + $address = new class() { + public $country; + public $postcode; + + function __construct() + { + $this->country = config('app.default_country'); + } + }; } $taxRates = $taxCategory->tax_rates()->where([ diff --git a/packages/Webkul/Tax/src/Helpers/Tax.php b/packages/Webkul/Tax/src/Helpers/Tax.php index e7bd81eee..fac5dc7ca 100644 --- a/packages/Webkul/Tax/src/Helpers/Tax.php +++ b/packages/Webkul/Tax/src/Helpers/Tax.php @@ -19,11 +19,10 @@ class Tax foreach ($that->items as $item) { $taxRate = (string)round((float)$item->tax_percent, self::TAX_PRECISION); - if (array_key_exists($taxRate, $taxes)) { - $taxes[$taxRate] += $asBase ? $item->base_tax_amount : $item->tax_amount; - } else { - $taxes += [$taxRate => $asBase ? $item->base_tax_amount : $item->tax_amount]; + if (!array_key_exists($taxRate, $taxes)) { + $taxes[$taxRate] = 0; } + $taxes[$taxRate] += $asBase ? $item->base_tax_amount : $item->tax_amount; } return $taxes; diff --git a/packages/Webkul/Tax/src/Providers/TaxServiceProvider.php b/packages/Webkul/Tax/src/Providers/TaxServiceProvider.php index 047ec84b4..886962155 100755 --- a/packages/Webkul/Tax/src/Providers/TaxServiceProvider.php +++ b/packages/Webkul/Tax/src/Providers/TaxServiceProvider.php @@ -23,17 +23,6 @@ class TaxServiceProvider extends ServiceProvider */ public function register() { - $this->registerEloquentFactoriesFrom(__DIR__ . '/../Database/Factories'); - } - - /** - * Register factories. - * - * @param string $path - * @return void - */ - protected function registerEloquentFactoriesFrom($path): void - { - $this->app->make(EloquentFactory::class)->load($path); + $this->loadFactoriesFrom(__DIR__ . '/../Database/Factories'); } } \ No newline at end of file diff --git a/tests/functional/Shop/CartCest.php b/tests/functional/Shop/CartCest.php index 8381defa2..2a6ab3a7b 100644 --- a/tests/functional/Shop/CartCest.php +++ b/tests/functional/Shop/CartCest.php @@ -20,25 +20,23 @@ class CartCest function _before(FunctionalTester $I) { - $this->faker = Factory::create(); + $this->country = Config::get('app.default_country'); $this->tax1 = $I->have(TaxRate::class, [ - //'tax_rate' => 7.00, 'country' => $this->country ]); - $taxCategorie1 = $I->have(TaxCategory::class, []); + $taxCategorie1 = $I->have(TaxCategory::class); $I->have(TaxMap::class, [ 'tax_rate_id' => $this->tax1->id, 'tax_category_id' => $taxCategorie1->id ]); $this->tax2 = $I->have(TaxRate::class, [ - //'tax_rate' => 19.00, 'country' => $this->country ]); - $taxCategorie2 = $I->have(TaxCategory::class, []); + $taxCategorie2 = $I->have(TaxCategory::class); $I->have(TaxMap::class, [ 'tax_rate_id' => $this->tax2->id, 'tax_category_id' => $taxCategorie2->id @@ -67,13 +65,14 @@ class CartCest public function checkCartWithMultipleTaxRates(FunctionalTester $I) { - - $prod1Quantity = $this->faker->numberBetween(9, 30); + $prod1Quantity = $I->fake()->numberBetween(9, 30); + // quantity of product1 should be not even if ($prod1Quantity % 2 !== 0) { $prod1Quantity -= 1; } - $prod2Quantity = $this->faker->numberBetween(9, 30); + $prod2Quantity = $I->fake()->numberBetween(9, 30); + // quantity of product2 should be even if ($prod2Quantity % 2 == 0) { $prod2Quantity -= 1; } @@ -86,8 +85,10 @@ class CartCest $I->amOnPage('/checkout/cart'); $I->see('Tax ' . $this->tax1->tax_rate . ' %', '#taxrate-' . core()->taxRateAsIdentifier($this->tax1->tax_rate)); - $I->see(core()->currency(round($this->product1->price * $this->tax1->tax_rate / 100, 2)), - '#basetaxamount-' . core()->taxRateAsIdentifier($this->tax1->tax_rate)); + $I->see( + core()->currency(round($this->product1->price * $this->tax1->tax_rate / 100, 2)), + '#basetaxamount-' . core()->taxRateAsIdentifier($this->tax1->tax_rate) + ); Cart::addProduct($this->product1->id, [ '_token' => session('_token'), @@ -97,8 +98,10 @@ class CartCest $I->amOnPage('/checkout/cart'); $I->see('Tax ' . $this->tax1->tax_rate . ' %', '#taxrate-' . core()->taxRateAsIdentifier($this->tax1->tax_rate)); - $I->see(core()->currency(round(($prod1Quantity + 1) * $this->product1->price * $this->tax1->tax_rate / 100, 2)), - '#basetaxamount-' . core()->taxRateAsIdentifier($this->tax1->tax_rate)); + $I->see( + core()->currency(round(($prod1Quantity + 1) * $this->product1->price * $this->tax1->tax_rate / 100, 2)), + '#basetaxamount-' . core()->taxRateAsIdentifier($this->tax1->tax_rate) + ); Cart::addProduct($this->product2->id, [ '_token' => session('_token'), diff --git a/tests/unit/Core/CoreCest.php b/tests/unit/Core/CoreCest.php index 25189b907..acb996f79 100644 --- a/tests/unit/Core/CoreCest.php +++ b/tests/unit/Core/CoreCest.php @@ -2,13 +2,31 @@ namespace Tests\Unit\Core; +use Codeception\Example; use UnitTester; class CoreCest { - public function testTaxRateAsIdentifier(UnitTester $I) + /** + * @param \UnitTester $I + * + * @param \Codeception\Example $scenario + * + * @throws \Exception + * @dataProvider getTaxRateScenarios + * + */ + public function testTaxRateAsIdentifier(UnitTester $I, Example $scenario): void { - $scenarios = [ + $I->assertEquals( + $scenario['expected'], + $I->executeFunction(\Webkul\Core\Core::class, 'taxRateAsIdentifier', [$scenario['input']]) + ); + } + + protected function getTaxRateScenarios(): array + { + return [ [ 'input' => 0, 'expected' => '0', @@ -18,17 +36,13 @@ class CoreCest 'expected' => '0_01', ], [ - 'input' => .12, + 'input' => .12, 'expected' => '0_12', ], [ - 'input' => 1234.5678, + 'input' => 1234.5678, 'expected' => '1234_5678', ], ]; - - foreach ($scenarios as $scenario) { - $I->assertEquals($scenario['expected'], $I->executeFunction(\Webkul\Core\Core::class, 'taxRateAsIdentifier', [$scenario['input']])); - } } } diff --git a/tests/unit/Tax/Helpers/TaxCest.php b/tests/unit/Tax/Helpers/TaxCest.php index 5d987aacf..e1d7d1461 100644 --- a/tests/unit/Tax/Helpers/TaxCest.php +++ b/tests/unit/Tax/Helpers/TaxCest.php @@ -16,14 +16,12 @@ class TaxCest public function _before(UnitTester $I) { - $faker = Factory::create(); - $country = Config::get('app.default_country'); $tax1 = $I->have(TaxRate::class, [ 'country' => $country, ]); - $taxCategorie1 = $I->have(TaxCategory::class, []); + $taxCategorie1 = $I->have(TaxCategory::class); $I->have(TaxMap::class, [ 'tax_rate_id' => $tax1->id, 'tax_category_id' => $taxCategorie1->id, @@ -32,7 +30,7 @@ class TaxCest $tax2 = $I->have(TaxRate::class, [ 'country' => $country, ]); - $taxCategorie2 = $I->have(TaxCategory::class, []); + $taxCategorie2 = $I->have(TaxCategory::class); $I->have(TaxMap::class, [ 'tax_rate_id' => $tax2->id, 'tax_category_id' => $taxCategorie2->id, @@ -90,8 +88,11 @@ class TaxCest public function testGetTaxRatesWithAmount(UnitTester $I) { - $result = $I->executeFunction(\Webkul\Tax\Helpers\Tax::class, 'getTaxRatesWithAmount', - [$this->scenario['object'], false]); + $result = $I->executeFunction( + \Webkul\Tax\Helpers\Tax::class, + 'getTaxRatesWithAmount', + [$this->scenario['object'], false] + ); foreach ($result as $taxRate => $taxAmount) { $I->assertTrue(array_key_exists($taxRate, $result)); @@ -101,8 +102,11 @@ class TaxCest public function testGetTaxTotal(UnitTester $I) { - $result = $I->executeFunction(\Webkul\Tax\Helpers\Tax::class, 'getTaxTotal', - [$this->scenario['object'], false]); + $result = $I->executeFunction( + \Webkul\Tax\Helpers\Tax::class, + 'getTaxTotal', + [$this->scenario['object'], false] + ); $I->assertEquals($this->scenario['expectedTaxTotal'], $result); } From 763ccf3af9a32a02eb3a169d1c525aa16e62399a Mon Sep 17 00:00:00 2001 From: Steffen Mahler Date: Tue, 4 Feb 2020 14:33:25 +0100 Subject: [PATCH 06/38] set default_country to EN --- config/app.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/app.php b/config/app.php index 1f0b07847..818d39fa8 100755 --- a/config/app.php +++ b/config/app.php @@ -104,7 +104,7 @@ return [ | */ - 'default_country' => 'DE', + 'default_country' => 'EN', /* |-------------------------------------------------------------------------- From 01010db842f8e57f76eb7270da7857b5509f3bce Mon Sep 17 00:00:00 2001 From: Steffen Mahler Date: Tue, 4 Feb 2020 14:38:52 +0100 Subject: [PATCH 07/38] set default_country to null, add fallback for test --- config/app.php | 2 +- tests/functional/Shop/CartCest.php | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/config/app.php b/config/app.php index 818d39fa8..a3cf7f964 100755 --- a/config/app.php +++ b/config/app.php @@ -104,7 +104,7 @@ return [ | */ - 'default_country' => 'EN', + 'default_country' => null, /* |-------------------------------------------------------------------------- diff --git a/tests/functional/Shop/CartCest.php b/tests/functional/Shop/CartCest.php index 2a6ab3a7b..3a486e536 100644 --- a/tests/functional/Shop/CartCest.php +++ b/tests/functional/Shop/CartCest.php @@ -14,15 +14,12 @@ use Cart; class CartCest { private $country; - private $faker; private $product1, $product2; private $tax1, $tax2; function _before(FunctionalTester $I) { - - - $this->country = Config::get('app.default_country'); + $this->country = Config::get('app.default_country') ?? 'DE'; $this->tax1 = $I->have(TaxRate::class, [ 'country' => $this->country From dd8f653df4096d8050530b055ccc8ebbc4310443 Mon Sep 17 00:00:00 2001 From: Steffen Mahler Date: Tue, 4 Feb 2020 14:48:15 +0100 Subject: [PATCH 08/38] minor improvements --- config/app.php | 2 ++ packages/Webkul/Checkout/src/Cart.php | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/config/app.php b/config/app.php index a3cf7f964..4efe78849 100755 --- a/config/app.php +++ b/config/app.php @@ -102,6 +102,8 @@ return [ | Ensure it is uppercase and reflects the 'code' column of the | countries table. | + | for example: DE EN FR + | (use capital letters!) */ 'default_country' => null, diff --git a/packages/Webkul/Checkout/src/Cart.php b/packages/Webkul/Checkout/src/Cart.php index 5da54ae3b..3f69fbe1d 100755 --- a/packages/Webkul/Checkout/src/Cart.php +++ b/packages/Webkul/Checkout/src/Cart.php @@ -764,7 +764,7 @@ class Cart function __construct() { - $this->country = config('app.default_country'); + $this->country = strtoupper(config('app.default_country')); } }; } From cdd61fa77eb24e53aba6655ed856100c9fc4a257 Mon Sep 17 00:00:00 2001 From: Steffen Mahler Date: Tue, 4 Feb 2020 17:21:18 +0100 Subject: [PATCH 09/38] fix test for misconfigured config/app.php --- tests/unit/Tax/Helpers/TaxCest.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/unit/Tax/Helpers/TaxCest.php b/tests/unit/Tax/Helpers/TaxCest.php index e1d7d1461..741fcf75c 100644 --- a/tests/unit/Tax/Helpers/TaxCest.php +++ b/tests/unit/Tax/Helpers/TaxCest.php @@ -17,6 +17,9 @@ class TaxCest public function _before(UnitTester $I) { $country = Config::get('app.default_country'); + if ($country === null) { + $country = 'DE'; + } $tax1 = $I->have(TaxRate::class, [ 'country' => $country, From ec89d9781661e673d9440fef091846717ccef576 Mon Sep 17 00:00:00 2001 From: Steffen Mahler Date: Tue, 4 Feb 2020 17:41:05 +0100 Subject: [PATCH 10/38] refactoring --- tests/functional/Shop/CartCest.php | 2 +- tests/unit/Tax/Helpers/TaxCest.php | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/tests/functional/Shop/CartCest.php b/tests/functional/Shop/CartCest.php index 3a486e536..47505945c 100644 --- a/tests/functional/Shop/CartCest.php +++ b/tests/functional/Shop/CartCest.php @@ -19,7 +19,7 @@ class CartCest function _before(FunctionalTester $I) { - $this->country = Config::get('app.default_country') ?? 'DE'; + $this->country = strtoupper(Config::get('app.default_country')) ?? 'DE'; $this->tax1 = $I->have(TaxRate::class, [ 'country' => $this->country diff --git a/tests/unit/Tax/Helpers/TaxCest.php b/tests/unit/Tax/Helpers/TaxCest.php index 741fcf75c..0712352f3 100644 --- a/tests/unit/Tax/Helpers/TaxCest.php +++ b/tests/unit/Tax/Helpers/TaxCest.php @@ -16,10 +16,7 @@ class TaxCest public function _before(UnitTester $I) { - $country = Config::get('app.default_country'); - if ($country === null) { - $country = 'DE'; - } + $country = strtoupper(Config::get('app.default_country')) ?? 'DE'; $tax1 = $I->have(TaxRate::class, [ 'country' => $country, From e678a467fc058506e5678a096a945c2a1e9f5b2b Mon Sep 17 00:00:00 2001 From: Steffen Mahler Date: Wed, 5 Feb 2020 11:18:21 +0100 Subject: [PATCH 11/38] call collectTotals in saveCustomerAddress --- packages/Webkul/Checkout/src/Cart.php | 2 ++ packages/Webkul/Core/src/Helpers/Laravel5Helper.php | 1 + tests/functional/Shop/CartCest.php | 2 -- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/Webkul/Checkout/src/Cart.php b/packages/Webkul/Checkout/src/Cart.php index d2c3ec78a..6102d582a 100755 --- a/packages/Webkul/Checkout/src/Cart.php +++ b/packages/Webkul/Checkout/src/Cart.php @@ -590,6 +590,8 @@ class Cart $cart->save(); + $this->collectTotals(); + return true; } diff --git a/packages/Webkul/Core/src/Helpers/Laravel5Helper.php b/packages/Webkul/Core/src/Helpers/Laravel5Helper.php index b15b3d89f..baa7a650c 100644 --- a/packages/Webkul/Core/src/Helpers/Laravel5Helper.php +++ b/packages/Webkul/Core/src/Helpers/Laravel5Helper.php @@ -72,6 +72,7 @@ class Laravel5Helper extends Laravel5 * @param array $productStates * * @return \Webkul\Product\Models\Product + * @part ORM */ public function haveProduct(int $productType, array $configs = [], array $productStates = []): Product { diff --git a/tests/functional/Shop/CartCest.php b/tests/functional/Shop/CartCest.php index dc61c5384..eeddd3eaa 100644 --- a/tests/functional/Shop/CartCest.php +++ b/tests/functional/Shop/CartCest.php @@ -3,12 +3,10 @@ namespace Tests\Functional\Cart; use FunctionalTester; -use Faker\Factory; use Illuminate\Support\Facades\Config; use Webkul\Tax\Models\TaxMap; use Webkul\Tax\Models\TaxRate; use Webkul\Tax\Models\TaxCategory; -use Webkul\Checkout\Models\Cart as CartModel; use Cart; class CartCest From 1d08f8a1f59f3cc24f85009f929469145b8eb0c6 Mon Sep 17 00:00:00 2001 From: Steffen Mahler Date: Fri, 7 Feb 2020 19:09:41 +0100 Subject: [PATCH 12/38] extend API endpoint for Cart by taxes --- .../API/Http/Resources/Checkout/Cart.php | 31 +++++++++++++++++++ packages/Webkul/Checkout/src/Cart.php | 6 ++++ 2 files changed, 37 insertions(+) diff --git a/packages/Webkul/API/Http/Resources/Checkout/Cart.php b/packages/Webkul/API/Http/Resources/Checkout/Cart.php index 2a6401b9e..028d42f43 100644 --- a/packages/Webkul/API/Http/Resources/Checkout/Cart.php +++ b/packages/Webkul/API/Http/Resources/Checkout/Cart.php @@ -16,6 +16,12 @@ class Cart extends JsonResource */ public function toArray($request) { + $taxes = \Webkul\Tax\Helpers\Tax::getTaxRatesWithAmount($this, false); + $baseTaxes = \Webkul\Tax\Helpers\Tax::getTaxRatesWithAmount($this, true); + + $formatedTaxes = $this->formatTaxAmounts($taxes, false); + $formatedBaseTaxes = $this->formatTaxAmounts($baseTaxes, true); + return [ 'id' => $this->id, 'customer_email' => $this->customer_email, @@ -60,6 +66,31 @@ class Cart extends JsonResource 'shipping_address' => new CartAddress($this->shipping_address), 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, + 'taxes' => json_encode($taxes, JSON_FORCE_OBJECT), + 'formated_taxes' => json_encode($formatedTaxes, JSON_FORCE_OBJECT), + 'base_taxes' => json_encode($baseTaxes, JSON_FORCE_OBJECT), + 'formated_base_taxes' => json_encode($formatedBaseTaxes, JSON_FORCE_OBJECT), ]; } + + /** + * @param array $taxes + * @param bool $isBase + * + * @return array + */ + private function formatTaxAmounts(array $taxes, bool $isBase = false): array + { + $result = []; + + foreach ($taxes as $taxRate => $taxAmount) { + if ($isBase === true) { + $result[$taxRate] = core()->formatBasePrice($taxAmount); + } else { + $result[$taxRate] = core()->formatPrice($taxAmount, $this->cart_currency_code); + } + } + + return $result; + } } \ No newline at end of file diff --git a/packages/Webkul/Checkout/src/Cart.php b/packages/Webkul/Checkout/src/Cart.php index 1539fab12..5fd8aae46 100755 --- a/packages/Webkul/Checkout/src/Cart.php +++ b/packages/Webkul/Checkout/src/Cart.php @@ -762,6 +762,12 @@ class Cart $address = $cart->billing_address; } + + if ($address === null && auth()->guard('customer')->check()) { + $address = auth()->guard('customer')->user()->addresses() + ->where('default_address',1)->first(); + } + if ($address === null) { $address = new class() { public $country; From 00c43e21de6c035a72e71d4707a7b332e905ccdd Mon Sep 17 00:00:00 2001 From: Steffen Mahler Date: Fri, 7 Feb 2020 19:23:15 +0100 Subject: [PATCH 13/38] cleanup --- packages/Webkul/Checkout/src/Cart.php | 1 - packages/Webkul/Tax/src/Providers/TaxServiceProvider.php | 1 - 2 files changed, 2 deletions(-) diff --git a/packages/Webkul/Checkout/src/Cart.php b/packages/Webkul/Checkout/src/Cart.php index 5fd8aae46..eae2a9ee3 100755 --- a/packages/Webkul/Checkout/src/Cart.php +++ b/packages/Webkul/Checkout/src/Cart.php @@ -762,7 +762,6 @@ class Cart $address = $cart->billing_address; } - if ($address === null && auth()->guard('customer')->check()) { $address = auth()->guard('customer')->user()->addresses() ->where('default_address',1)->first(); diff --git a/packages/Webkul/Tax/src/Providers/TaxServiceProvider.php b/packages/Webkul/Tax/src/Providers/TaxServiceProvider.php index 886962155..181258405 100755 --- a/packages/Webkul/Tax/src/Providers/TaxServiceProvider.php +++ b/packages/Webkul/Tax/src/Providers/TaxServiceProvider.php @@ -2,7 +2,6 @@ namespace Webkul\Tax\Providers; use Illuminate\Support\ServiceProvider; -use Illuminate\Database\Eloquent\Factory as EloquentFactory; class TaxServiceProvider extends ServiceProvider { From 7dff220da9f78d34597b175d7beaaa03c6ee10ab Mon Sep 17 00:00:00 2001 From: Steffen Mahler Date: Sat, 8 Feb 2020 20:42:32 +0100 Subject: [PATCH 14/38] fix issue with zip based taxes, added functional test --- packages/Webkul/Checkout/src/Cart.php | 17 +- tests/functional/Shop/CartCest.php | 122 ------- tests/functional/Shop/CartTaxesCest.php | 436 ++++++++++++++++++++++++ 3 files changed, 444 insertions(+), 131 deletions(-) delete mode 100644 tests/functional/Shop/CartCest.php create mode 100644 tests/functional/Shop/CartTaxesCest.php diff --git a/packages/Webkul/Checkout/src/Cart.php b/packages/Webkul/Checkout/src/Cart.php index eae2a9ee3..a076cbea2 100755 --- a/packages/Webkul/Checkout/src/Cart.php +++ b/packages/Webkul/Checkout/src/Cart.php @@ -743,10 +743,10 @@ class Cart * * @return void */ - public function calculateItemsTax() + public function calculateItemsTax(): void { if (!$cart = $this->getCart()) { - return false; + return; } foreach ($cart->items()->get() as $item) { @@ -783,6 +783,10 @@ class Cart 'country' => $address->country, ])->orderBy('tax_rate', 'desc')->get(); + $item->tax_percent = 0; + $item->tax_amount = 0; + $item->base_tax_amount = 0; + if ($taxRates->count()) { foreach ($taxRates as $rate) { $haveTaxRate = false; @@ -804,17 +808,12 @@ class Cart $item->tax_amount = ($item->total * $rate->tax_rate) / 100; $item->base_tax_amount = ($item->base_total * $rate->tax_rate) / 100; - $item->save(); break; } } - } else { - $item->tax_percent = 0; - $item->tax_amount = 0; - $item->base_tax_amount = 0; - - $item->save(); } + + $item->save(); } } diff --git a/tests/functional/Shop/CartCest.php b/tests/functional/Shop/CartCest.php deleted file mode 100644 index eeddd3eaa..000000000 --- a/tests/functional/Shop/CartCest.php +++ /dev/null @@ -1,122 +0,0 @@ -country = strtoupper(Config::get('app.default_country')) ?? 'DE'; - - $this->tax1 = $I->have(TaxRate::class, [ - 'country' => $this->country - ]); - $taxCategorie1 = $I->have(TaxCategory::class); - $I->have(TaxMap::class, [ - 'tax_rate_id' => $this->tax1->id, - 'tax_category_id' => $taxCategorie1->id - ]); - - $this->tax2 = $I->have(TaxRate::class, [ - 'country' => $this->country - ]); - $taxCategorie2 = $I->have(TaxCategory::class); - $I->have(TaxMap::class, [ - 'tax_rate_id' => $this->tax2->id, - 'tax_category_id' => $taxCategorie2->id - ]); - - $config1 = [ - 'productInventory' => ['qty' => 100], - 'attributeValues' => [ - 'status' => true, - 'new' => 1, - 'tax_category_id' => $taxCategorie1->id, - ], - ]; - $this->product1 = $I->haveProduct(\Webkul\Core\Helpers\Laravel5Helper::SIMPLE_PRODUCT, $config1); - - $config2 = [ - 'productInventory' => ['qty' => 100], - 'attributeValues' => [ - 'status' => true, - 'new' => 1, - 'tax_category_id' => $taxCategorie2->id, - ], - ]; - $this->product2 = $I->haveProduct(\Webkul\Core\Helpers\Laravel5Helper::SIMPLE_PRODUCT, $config2); - } - - public function checkCartWithMultipleTaxRates(FunctionalTester $I) - { - $prod1Quantity = $I->fake()->numberBetween(9, 30); - // quantity of product1 should be not even - if ($prod1Quantity % 2 !== 0) { - $prod1Quantity -= 1; - } - - $prod2Quantity = $I->fake()->numberBetween(9, 30); - // quantity of product2 should be even - if ($prod2Quantity % 2 == 0) { - $prod2Quantity -= 1; - } - - Cart::addProduct($this->product1->id, [ - '_token' => session('_token'), - 'product_id' => $this->product1->id, - 'quantity' => 1, - ]); - - $I->amOnPage('/checkout/cart'); - $I->see('Tax ' . $this->tax1->tax_rate . ' %', '#taxrate-' . core()->taxRateAsIdentifier($this->tax1->tax_rate)); - $I->see( - core()->currency(round($this->product1->price * $this->tax1->tax_rate / 100, 2)), - '#basetaxamount-' . core()->taxRateAsIdentifier($this->tax1->tax_rate) - ); - - Cart::addProduct($this->product1->id, [ - '_token' => session('_token'), - 'product_id' => $this->product1->id, - 'quantity' => $prod1Quantity, - ]); - - $I->amOnPage('/checkout/cart'); - $I->see('Tax ' . $this->tax1->tax_rate . ' %', '#taxrate-' . core()->taxRateAsIdentifier($this->tax1->tax_rate)); - $I->see( - core()->currency(round(($prod1Quantity + 1) * $this->product1->price * $this->tax1->tax_rate / 100, 2)), - '#basetaxamount-' . core()->taxRateAsIdentifier($this->tax1->tax_rate) - ); - - Cart::addProduct($this->product2->id, [ - '_token' => session('_token'), - 'product_id' => $this->product2->id, - 'quantity' => $prod2Quantity, - ]); - - $I->amOnPage('/checkout/cart'); - $I->see('Tax ' . $this->tax1->tax_rate . ' %', '#taxrate-' . core()->taxRateAsIdentifier($this->tax1->tax_rate)); - $taxAmount1 = round(($prod1Quantity + 1) * $this->product1->price * $this->tax1->tax_rate / 100, 2); - $I->see(core()->currency($taxAmount1),'#basetaxamount-' . core()->taxRateAsIdentifier($this->tax1->tax_rate)); - - $I->see('Tax ' . $this->tax2->tax_rate . ' %', '#taxrate-' . core()->taxRateAsIdentifier($this->tax2->tax_rate)); - $taxAmount2 = round($prod2Quantity * $this->product2->price * $this->tax2->tax_rate / 100, 2); - $I->see(core()->currency($taxAmount2),'#basetaxamount-' . core()->taxRateAsIdentifier($this->tax2->tax_rate)); - - $cart = Cart::getCart(); - - $I->assertEquals(2, $cart->items_count); - $I->assertEquals((float)($prod1Quantity + 1 + $prod2Quantity), $cart->items_qty); - $I->assertEquals($taxAmount1 + $taxAmount2, $cart->tax_total); - } -} \ No newline at end of file diff --git a/tests/functional/Shop/CartTaxesCest.php b/tests/functional/Shop/CartTaxesCest.php new file mode 100644 index 000000000..6e474fe16 --- /dev/null +++ b/tests/functional/Shop/CartTaxesCest.php @@ -0,0 +1,436 @@ +country = strtoupper(Config::get('app.default_country')) ?? 'DE'; + } + + public function checkCartWithMultipleTaxRates(FunctionalTester $I): void + { + $tax1 = $I->have(TaxRate::class, [ + 'country' => $this->country, + ]); + $taxCategorie1 = $I->have(TaxCategory::class); + $I->have(TaxMap::class, [ + 'tax_rate_id' => $tax1->id, + 'tax_category_id' => $taxCategorie1->id, + ]); + + $tax2 = $I->have(TaxRate::class, [ + 'country' => $this->country, + ]); + $taxCategorie2 = $I->have(TaxCategory::class); + $I->have(TaxMap::class, [ + 'tax_rate_id' => $tax2->id, + 'tax_category_id' => $taxCategorie2->id, + ]); + + $config1 = [ + 'productInventory' => ['qty' => 100], + 'attributeValues' => [ + 'status' => true, + 'new' => 1, + 'tax_category_id' => $taxCategorie1->id, + ], + ]; + $product1 = $I->haveProduct(Laravel5Helper::SIMPLE_PRODUCT, $config1); + + $config2 = [ + 'productInventory' => ['qty' => 100], + 'attributeValues' => [ + 'status' => true, + 'new' => 1, + 'tax_category_id' => $taxCategorie2->id, + ], + ]; + $product2 = $I->haveProduct(Laravel5Helper::SIMPLE_PRODUCT, $config2); + + $prod1Quantity = $I->fake()->numberBetween(9, 30); + // quantity of product1 should be not even + if ($prod1Quantity % 2 !== 0) { + $prod1Quantity -= 1; + } + + $prod2Quantity = $I->fake()->numberBetween(9, 30); + // quantity of product2 should be even + if ($prod2Quantity % 2 == 0) { + $prod2Quantity -= 1; + } + + Cart::addProduct($product1->id, [ + '_token' => session('_token'), + 'product_id' => $product1->id, + 'quantity' => 1, + ]); + + $I->amOnPage('/checkout/cart'); + $I->see('Tax ' . $tax1->tax_rate . ' %', '#taxrate-' . core()->taxRateAsIdentifier($tax1->tax_rate)); + $I->see( + core()->currency(round($product1->price * $tax1->tax_rate / 100, 2)), + '#basetaxamount-' . core()->taxRateAsIdentifier($tax1->tax_rate) + ); + + Cart::addProduct($product1->id, [ + '_token' => session('_token'), + 'product_id' => $product1->id, + 'quantity' => $prod1Quantity, + ]); + + $I->amOnPage('/checkout/cart'); + $I->see('Tax ' . $tax1->tax_rate . ' %', '#taxrate-' . core()->taxRateAsIdentifier($tax1->tax_rate)); + $I->see( + core()->currency(round(($prod1Quantity + 1) * $product1->price * $tax1->tax_rate / 100, 2)), + '#basetaxamount-' . core()->taxRateAsIdentifier($tax1->tax_rate) + ); + + Cart::addProduct($product2->id, [ + '_token' => session('_token'), + 'product_id' => $product2->id, + 'quantity' => $prod2Quantity, + ]); + + $I->amOnPage('/checkout/cart'); + $I->see('Tax ' . $tax1->tax_rate . ' %', '#taxrate-' . core()->taxRateAsIdentifier($tax1->tax_rate)); + $taxAmount1 = round(($prod1Quantity + 1) * $product1->price * $tax1->tax_rate / 100, 2); + $I->see(core()->currency($taxAmount1), '#basetaxamount-' . core()->taxRateAsIdentifier($tax1->tax_rate)); + + $I->see('Tax ' . $tax2->tax_rate . ' %', '#taxrate-' . core()->taxRateAsIdentifier($tax2->tax_rate)); + $taxAmount2 = round($prod2Quantity * $product2->price * $tax2->tax_rate / 100, 2); + $I->see(core()->currency($taxAmount2), '#basetaxamount-' . core()->taxRateAsIdentifier($tax2->tax_rate)); + + $cart = Cart::getCart(); + + $I->assertEquals(2, $cart->items_count); + $I->assertEquals((float)($prod1Quantity + 1 + $prod2Quantity), $cart->items_qty); + $I->assertEquals($taxAmount1 + $taxAmount2, $cart->tax_total); + + Cart::removeItem($cart->items[1]->id); + + $I->amOnPage('/checkout/cart'); + $I->amOnPage('/checkout/cart'); + $I->see('Tax ' . $tax1->tax_rate . ' %', '#taxrate-' . core()->taxRateAsIdentifier($tax1->tax_rate)); + $taxAmount1 = round(($prod1Quantity + 1) * $product1->price * $tax1->tax_rate / 100, 2); + $I->see(core()->currency($taxAmount1), '#basetaxamount-' . core()->taxRateAsIdentifier($tax1->tax_rate)); + + $I->dontSee('Tax ' . $tax2->tax_rate . ' %', '#taxrate-' . core()->taxRateAsIdentifier($tax2->tax_rate)); + $taxAmount2 = round($prod2Quantity * $product2->price * $tax2->tax_rate / 100, 2); + $I->dontSee(core()->currency($taxAmount2), '#basetaxamount-' . core()->taxRateAsIdentifier($tax2->tax_rate)); + + $cart = Cart::getCart(); + + $I->assertEquals(1, $cart->items_count); + $I->assertEquals((float)($prod1Quantity + 1), $cart->items_qty); + $I->assertEquals($taxAmount1, $cart->tax_total); + } + + public function checkCartWithMultipleZipRangeBasedTaxes(FunctionalTester $I): void + { + $tax11 = $I->have(TaxRate::class, [ + 'country' => $this->country, + 'is_zip' => 1, + 'zip_code' => null, + 'zip_from' => '00000', + 'zip_to' => '49999', + 'tax_rate' => $I->fake()->randomFloat(2, 3, 8), + ]); + $tax12 = $I->have(TaxRate::class, [ + 'country' => $this->country, + 'is_zip' => 1, + 'zip_code' => null, + 'zip_from' => '50000', + 'zip_to' => '89999', + 'tax_rate' => $I->fake()->randomFloat(2, 3, 8), + ]); + + $taxCategorie1 = $I->have(TaxCategory::class); + + $I->have(TaxMap::class, [ + 'tax_rate_id' => $tax11->id, + 'tax_category_id' => $taxCategorie1->id, + ]); + $I->have(TaxMap::class, [ + 'tax_rate_id' => $tax12->id, + 'tax_category_id' => $taxCategorie1->id, + ]); + + $tax21 = $I->have(TaxRate::class, [ + 'country' => $this->country, + 'is_zip' => 1, + 'zip_code' => null, + 'zip_from' => '00000', + 'zip_to' => '49999', + 'tax_rate' => $I->fake()->randomFloat(2, 14, 25), + ]); + $tax22 = $I->have(TaxRate::class, [ + 'country' => $this->country, + 'is_zip' => 1, + 'zip_code' => null, + 'zip_from' => '50000', + 'zip_to' => '89999', + 'tax_rate' => $I->fake()->randomFloat(2, 14, 25), + ]); + + $taxCategorie2 = $I->have(TaxCategory::class); + + $I->have(TaxMap::class, [ + 'tax_rate_id' => $tax21->id, + 'tax_category_id' => $taxCategorie2->id, + ]); + $I->have(TaxMap::class, [ + 'tax_rate_id' => $tax22->id, + 'tax_category_id' => $taxCategorie2->id, + ]); + + $config1 = [ + 'productInventory' => ['qty' => 100], + 'attributeValues' => [ + 'status' => true, + 'new' => 1, + 'tax_category_id' => $taxCategorie1->id, + ], + ]; + $product1 = $I->haveProduct(Laravel5Helper::SIMPLE_PRODUCT, $config1); + + $config2 = [ + 'productInventory' => ['qty' => 100], + 'attributeValues' => [ + 'status' => true, + 'new' => 1, + 'tax_category_id' => $taxCategorie2->id, + ], + ]; + $product2 = $I->haveProduct(Laravel5Helper::SIMPLE_PRODUCT, $config2); + + $customer = $I->have(Customer::class); + + $addressZip012345 = $I->have(CustomerAddress::class, [ + 'customer_id' => $customer->id, + 'postcode' => '012345', + 'vat_id' => 'DE123456789', + 'country' => $this->country, + 'default_address' => 1, + ]); + + Cart::addProduct($product1->id, [ + '_token' => session('_token'), + 'product_id' => $product1->id, + 'quantity' => 1, + ]); + + Cart::saveCustomerAddress( + [ + 'billing' => [ + 'address1' => $addressZip012345->address1, + 'use_for_shipping' => 1, + 'email' => $customer->email, + 'company_name' => $addressZip012345->company_name, + 'first_name' => $addressZip012345->first_name, + 'last_name' => $addressZip012345->last_name, + 'city' => $addressZip012345->city, + 'state' => $addressZip012345->state, + 'postcode' => $addressZip012345->postcode, + 'country' => $addressZip012345->country, + ], + 'shipping' => [ + 'address1' => '', + ], + ]); + + $I->wantToTest('customer address with postcode in range of 00000 - 49999'); + $I->amOnPage('/checkout/cart'); + + $I->see('Tax ' . $tax11->tax_rate . ' %', '#taxrate-' . core()->taxRateAsIdentifier($tax11->tax_rate)); + $I->see( + core()->currency(round($product1->price * $tax11->tax_rate / 100, 2)), + '#basetaxamount-' . core()->taxRateAsIdentifier($tax11->tax_rate) + ); + + $I->dontSee('Tax ' . $tax12->tax_rate . ' %', '#taxrate-' . core()->taxRateAsIdentifier($tax12->tax_rate)); + $I->dontSee( + core()->currency(round($product1->price * $tax12->tax_rate / 100, 2)), + '#basetaxamount-' . core()->taxRateAsIdentifier($tax12->tax_rate) + ); + + $I->dontSee('Tax ' . $tax21->tax_rate . ' %', '#taxrate-' . core()->taxRateAsIdentifier($tax21->tax_rate)); + $I->dontSee( + core()->currency(round($product2->price * $tax21->tax_rate / 100, 2)), + '#basetaxamount-' . core()->taxRateAsIdentifier($tax21->tax_rate) + ); + + $I->dontSee('Tax ' . $tax22->tax_rate . ' %', '#taxrate-' . core()->taxRateAsIdentifier($tax22->tax_rate)); + $I->dontSee( + core()->currency(round($product2->price * $tax22->tax_rate / 100, 2)), + '#basetaxamount-' . core()->taxRateAsIdentifier($tax22->tax_rate) + ); + + Cart::addProduct($product2->id, [ + '_token' => session('_token'), + 'product_id' => $product2->id, + 'quantity' => 1, + ]); + + $I->amOnPage('/checkout/cart'); + + $I->see('Tax ' . $tax11->tax_rate . ' %', '#taxrate-' . core()->taxRateAsIdentifier($tax11->tax_rate)); + $I->see( + core()->currency(round($product1->price * $tax11->tax_rate / 100, 2)), + '#basetaxamount-' . core()->taxRateAsIdentifier($tax11->tax_rate) + ); + + $I->dontSee('Tax ' . $tax12->tax_rate . ' %', '#taxrate-' . core()->taxRateAsIdentifier($tax12->tax_rate)); + $I->dontSee( + core()->currency(round($product1->price * $tax12->tax_rate / 100, 2)), + '#basetaxamount-' . core()->taxRateAsIdentifier($tax12->tax_rate) + ); + + $I->see('Tax ' . $tax21->tax_rate . ' %', '#taxrate-' . core()->taxRateAsIdentifier($tax21->tax_rate)); + $I->see( + core()->currency(round($product2->price * $tax21->tax_rate / 100, 2)), + '#basetaxamount-' . core()->taxRateAsIdentifier($tax21->tax_rate) + ); + + $I->dontSee('Tax ' . $tax22->tax_rate . ' %', '#taxrate-' . core()->taxRateAsIdentifier($tax22->tax_rate)); + $I->dontSee( + core()->currency(round($product2->price * $tax22->tax_rate / 100, 2)), + '#basetaxamount-' . core()->taxRateAsIdentifier($tax22->tax_rate) + ); + + $taxAmount1 = round($product1->price * $tax11->tax_rate / 100, 2); + $I->see(core()->currency($taxAmount1), '#basetaxamount-' . core()->taxRateAsIdentifier($tax11->tax_rate)); + + $taxAmount2 = round($product2->price * $tax21->tax_rate / 100, 2); + $I->see(core()->currency($taxAmount2), '#basetaxamount-' . core()->taxRateAsIdentifier($tax21->tax_rate)); + + + $I->wantToTest('customer address with postcode in range of 50000 - 89999'); + $addressZip67890 = $I->have(CustomerAddress::class, [ + 'customer_id' => $customer->id, + 'postcode' => '67890', + 'vat_id' => 'DE123456789', + 'country' => $this->country, + 'default_address' => 1, + ]); + + Cart::saveCustomerAddress( + [ + 'billing' => [ + 'address1' => $addressZip67890->address1, + 'use_for_shipping' => 1, + 'email' => $customer->email, + 'company_name' => $addressZip67890->company_name, + 'first_name' => $addressZip67890->first_name, + 'last_name' => $addressZip67890->last_name, + 'city' => $addressZip67890->city, + 'state' => $addressZip67890->state, + 'postcode' => $addressZip67890->postcode, + 'country' => $addressZip67890->country, + ], + 'shipping' => [ + 'address1' => '', + ], + ]); + + $I->amOnPage('/checkout/cart'); + + $I->dontSee('Tax ' . $tax11->tax_rate . ' %', '#taxrate-' . core()->taxRateAsIdentifier($tax11->tax_rate)); + $I->dontSee( + core()->currency(round($product1->price * $tax11->tax_rate / 100, 2)), + '#basetaxamount-' . core()->taxRateAsIdentifier($tax11->tax_rate) + ); + + $I->see('Tax ' . $tax12->tax_rate . ' %', '#taxrate-' . core()->taxRateAsIdentifier($tax12->tax_rate)); + $I->see( + core()->currency(round($product1->price * $tax12->tax_rate / 100, 2)), + '#basetaxamount-' . core()->taxRateAsIdentifier($tax12->tax_rate) + ); + + $I->dontSee('Tax ' . $tax21->tax_rate . ' %', '#taxrate-' . core()->taxRateAsIdentifier($tax21->tax_rate)); + $I->dontSee( + core()->currency(round($product2->price * $tax21->tax_rate / 100, 2)), + '#basetaxamount-' . core()->taxRateAsIdentifier($tax21->tax_rate) + ); + + $I->see('Tax ' . $tax22->tax_rate . ' %', '#taxrate-' . core()->taxRateAsIdentifier($tax22->tax_rate)); + $I->see( + core()->currency(round($product2->price * $tax22->tax_rate / 100, 2)), + '#basetaxamount-' . core()->taxRateAsIdentifier($tax22->tax_rate) + ); + + $taxAmount1 = round($product1->price * $tax12->tax_rate / 100, 2); + $I->see(core()->currency($taxAmount1), '#basetaxamount-' . core()->taxRateAsIdentifier($tax12->tax_rate)); + + $taxAmount2 = round($product2->price * $tax22->tax_rate / 100, 2); + $I->see(core()->currency($taxAmount2), '#basetaxamount-' . core()->taxRateAsIdentifier($tax22->tax_rate)); + + $I->wantToTest('customer address with postcode in range of 90000 - 99000'); + $I->wanttoTest('as we dont have any taxes in this zip range'); + $addressZip98765 = $I->have(CustomerAddress::class, [ + 'customer_id' => $customer->id, + 'postcode' => '98765', + 'vat_id' => 'DE123456789', + 'country' => $this->country, + 'default_address' => 1, + ]); + + Cart::saveCustomerAddress( + [ + 'billing' => [ + 'address1' => $addressZip98765->address1, + 'use_for_shipping' => 1, + 'email' => $customer->email, + 'company_name' => $addressZip98765->company_name, + 'first_name' => $addressZip98765->first_name, + 'last_name' => $addressZip98765->last_name, + 'city' => $addressZip98765->city, + 'state' => $addressZip98765->state, + 'postcode' => $addressZip98765->postcode, + 'country' => $addressZip98765->country, + ], + 'shipping' => [ + 'address1' => '', + ], + ]); + + $I->amOnPage('/checkout/cart'); + + $I->dontSee('Tax ' . $tax11->tax_rate . ' %', '#taxrate-' . core()->taxRateAsIdentifier($tax11->tax_rate)); + $I->dontSee( + core()->currency(round($product1->price * $tax11->tax_rate / 100, 2)), + '#basetaxamount-' . core()->taxRateAsIdentifier($tax11->tax_rate) + ); + + $I->dontSee('Tax ' . $tax12->tax_rate . ' %', '#taxrate-' . core()->taxRateAsIdentifier($tax12->tax_rate)); + $I->dontSee( + core()->currency(round($product1->price * $tax12->tax_rate / 100, 2)), + '#basetaxamount-' . core()->taxRateAsIdentifier($tax12->tax_rate) + ); + + $I->dontSee('Tax ' . $tax21->tax_rate . ' %', '#taxrate-' . core()->taxRateAsIdentifier($tax21->tax_rate)); + $I->dontSee( + core()->currency(round($product2->price * $tax21->tax_rate / 100, 2)), + '#basetaxamount-' . core()->taxRateAsIdentifier($tax21->tax_rate) + ); + + $I->dontSee('Tax ' . $tax22->tax_rate . ' %', '#taxrate-' . core()->taxRateAsIdentifier($tax22->tax_rate)); + $I->dontSee( + core()->currency(round($product2->price * $tax22->tax_rate / 100, 2)), + '#basetaxamount-' . core()->taxRateAsIdentifier($tax22->tax_rate) + ); + } +} \ No newline at end of file From 229117c7b9dd3ea91e34a13f7ad819d84feb7348 Mon Sep 17 00:00:00 2001 From: rahul shukla Date: Wed, 19 Feb 2020 21:10:27 +0530 Subject: [PATCH 15/38] change log updated and Isssue #2500 fixed --- CHANGELOG for v1.x.x.md | 2 ++ .../2019_05_13_024321_create_cart_rules_table.php | 10 ++++++++++ .../2018_07_24_082930_create_customers_table.php | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/CHANGELOG for v1.x.x.md b/CHANGELOG for v1.x.x.md index eed7a7f61..c285bd804 100644 --- a/CHANGELOG for v1.x.x.md +++ b/CHANGELOG for v1.x.x.md @@ -56,6 +56,8 @@ * #2459 [fixed] - shipping address field warning for guest customer not translated. +* #2463 [fixed] - Tax rate is not update on same product. + * #2469 [fixed] - Displaying wrong amount for bundle product in cart. * #2479 [fixed] - showing total review in recent view product list. diff --git a/packages/Webkul/CartRule/src/Database/Migrations/2019_05_13_024321_create_cart_rules_table.php b/packages/Webkul/CartRule/src/Database/Migrations/2019_05_13_024321_create_cart_rules_table.php index 6912df3c1..bba6ed173 100644 --- a/packages/Webkul/CartRule/src/Database/Migrations/2019_05_13_024321_create_cart_rules_table.php +++ b/packages/Webkul/CartRule/src/Database/Migrations/2019_05_13_024321_create_cart_rules_table.php @@ -47,6 +47,16 @@ class CreateCartRulesTable extends Migration */ public function down() { + Schema::table('cart_rule_customers', function (Blueprint $table) { + $table->dropForeign('cart_rule_customers_cart_rule_id_foreign'); + }); + + Schema::table('cart_rule_coupons', function (Blueprint $table) { + $table->dropForeign('cart_rule_coupons_cart_rule_id_foreign'); + }); + + // Schema::dropIfExists('cart_rule_coupons'); + Schema::dropIfExists('cart_rules'); } } diff --git a/packages/Webkul/Customer/src/Database/Migrations/2018_07_24_082930_create_customers_table.php b/packages/Webkul/Customer/src/Database/Migrations/2018_07_24_082930_create_customers_table.php index 92fd6f824..1d0c43d57 100755 --- a/packages/Webkul/Customer/src/Database/Migrations/2018_07_24_082930_create_customers_table.php +++ b/packages/Webkul/Customer/src/Database/Migrations/2018_07_24_082930_create_customers_table.php @@ -39,6 +39,12 @@ class CreateCustomersTable extends Migration */ public function down() { + Schema::table('cart_rule_customers', function (Blueprint $table) { + $table->dropForeign('cart_rule_customers_customer_id_foreign'); + }); + + // Schema::dropIfExists('cart_rule_customers'); + Schema::dropIfExists('customers'); } } From d999bc18d99d1433ce8dcac05dbad6baacc7c70b Mon Sep 17 00:00:00 2001 From: rahul shukla Date: Wed, 19 Feb 2020 21:16:20 +0530 Subject: [PATCH 16/38] Issue #2500 fixed --- .../Migrations/2019_05_13_024321_create_cart_rules_table.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/Webkul/CartRule/src/Database/Migrations/2019_05_13_024321_create_cart_rules_table.php b/packages/Webkul/CartRule/src/Database/Migrations/2019_05_13_024321_create_cart_rules_table.php index bba6ed173..bb0a4658d 100644 --- a/packages/Webkul/CartRule/src/Database/Migrations/2019_05_13_024321_create_cart_rules_table.php +++ b/packages/Webkul/CartRule/src/Database/Migrations/2019_05_13_024321_create_cart_rules_table.php @@ -55,7 +55,7 @@ class CreateCartRulesTable extends Migration $table->dropForeign('cart_rule_coupons_cart_rule_id_foreign'); }); - // Schema::dropIfExists('cart_rule_coupons'); + // Schema::dropIfExists('cart_rule_coupons'); Schema::dropIfExists('cart_rules'); } From e5a0bc8a0e4013e320b4c456c5df5a63d60c0c87 Mon Sep 17 00:00:00 2001 From: rahul shukla Date: Thu, 20 Feb 2020 10:56:59 +0530 Subject: [PATCH 17/38] Issue #2500 and chaneelog updated --- CHANGELOG for v1.x.x.md | 4 ++++ .../2019_05_13_024325_create_cart_rule_customers_table.php | 2 +- .../2019_05_13_024326_create_cart_rule_coupons_table.php | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG for v1.x.x.md b/CHANGELOG for v1.x.x.md index eed7a7f61..3739dc054 100644 --- a/CHANGELOG for v1.x.x.md +++ b/CHANGELOG for v1.x.x.md @@ -56,6 +56,8 @@ * #2459 [fixed] - shipping address field warning for guest customer not translated. +* #2463 [fixed] - Tax rate is not update on same product. + * #2469 [fixed] - Displaying wrong amount for bundle product in cart. * #2479 [fixed] - showing total review in recent view product list. @@ -70,6 +72,8 @@ * #2494 [fixed] - Product total inventory for all locale is showing wrong. +* #2500 [fixed] - Database reset fails. + ## **v1.0.0-BETA1(5th of February 2020)** - *Release* * [feature] Updated to laravel version 6. diff --git a/packages/Webkul/CartRule/src/Database/Migrations/2019_05_13_024325_create_cart_rule_customers_table.php b/packages/Webkul/CartRule/src/Database/Migrations/2019_05_13_024325_create_cart_rule_customers_table.php index a16452c6f..b9e2abba6 100644 --- a/packages/Webkul/CartRule/src/Database/Migrations/2019_05_13_024325_create_cart_rule_customers_table.php +++ b/packages/Webkul/CartRule/src/Database/Migrations/2019_05_13_024325_create_cart_rule_customers_table.php @@ -32,6 +32,6 @@ class CreateCartruleCustomersTable extends Migration */ public function down() { - Schema::dropIfExists('cartrule_customers'); + Schema::dropIfExists('cart_rule_customers'); } } diff --git a/packages/Webkul/CartRule/src/Database/Migrations/2019_05_13_024326_create_cart_rule_coupons_table.php b/packages/Webkul/CartRule/src/Database/Migrations/2019_05_13_024326_create_cart_rule_coupons_table.php index 89741800e..9741c1654 100644 --- a/packages/Webkul/CartRule/src/Database/Migrations/2019_05_13_024326_create_cart_rule_coupons_table.php +++ b/packages/Webkul/CartRule/src/Database/Migrations/2019_05_13_024326_create_cart_rule_coupons_table.php @@ -22,7 +22,7 @@ class CreateCartruleCouponsTable extends Migration $table->integer('type')->unsigned()->default(0); $table->boolean('is_primary')->default(0); $table->date('expired_at')->nullable(); - + $table->integer('cart_rule_id')->unsigned(); $table->foreign('cart_rule_id')->references('id')->on('cart_rules')->onDelete('cascade'); $table->timestamps(); @@ -36,6 +36,6 @@ class CreateCartruleCouponsTable extends Migration */ public function down() { - Schema::dropIfExists('cartrule_coupons'); + Schema::dropIfExists('cart_rule_coupons'); } } From e82fb888abf213b22af341662a601787eac206d6 Mon Sep 17 00:00:00 2001 From: rahul shukla Date: Thu, 20 Feb 2020 11:00:34 +0530 Subject: [PATCH 18/38] merge with master --- .../2019_05_13_024321_create_cart_rules_table.php | 10 ---------- .../2018_07_24_082930_create_customers_table.php | 6 ------ 2 files changed, 16 deletions(-) diff --git a/packages/Webkul/CartRule/src/Database/Migrations/2019_05_13_024321_create_cart_rules_table.php b/packages/Webkul/CartRule/src/Database/Migrations/2019_05_13_024321_create_cart_rules_table.php index bb0a4658d..6912df3c1 100644 --- a/packages/Webkul/CartRule/src/Database/Migrations/2019_05_13_024321_create_cart_rules_table.php +++ b/packages/Webkul/CartRule/src/Database/Migrations/2019_05_13_024321_create_cart_rules_table.php @@ -47,16 +47,6 @@ class CreateCartRulesTable extends Migration */ public function down() { - Schema::table('cart_rule_customers', function (Blueprint $table) { - $table->dropForeign('cart_rule_customers_cart_rule_id_foreign'); - }); - - Schema::table('cart_rule_coupons', function (Blueprint $table) { - $table->dropForeign('cart_rule_coupons_cart_rule_id_foreign'); - }); - - // Schema::dropIfExists('cart_rule_coupons'); - Schema::dropIfExists('cart_rules'); } } diff --git a/packages/Webkul/Customer/src/Database/Migrations/2018_07_24_082930_create_customers_table.php b/packages/Webkul/Customer/src/Database/Migrations/2018_07_24_082930_create_customers_table.php index 1d0c43d57..92fd6f824 100755 --- a/packages/Webkul/Customer/src/Database/Migrations/2018_07_24_082930_create_customers_table.php +++ b/packages/Webkul/Customer/src/Database/Migrations/2018_07_24_082930_create_customers_table.php @@ -39,12 +39,6 @@ class CreateCustomersTable extends Migration */ public function down() { - Schema::table('cart_rule_customers', function (Blueprint $table) { - $table->dropForeign('cart_rule_customers_customer_id_foreign'); - }); - - // Schema::dropIfExists('cart_rule_customers'); - Schema::dropIfExists('customers'); } } From 663e21a771033af1c6a12a7333b4c3c565a5e944 Mon Sep 17 00:00:00 2001 From: rahul shukla Date: Thu, 20 Feb 2020 12:17:40 +0530 Subject: [PATCH 19/38] Issue #2435 and change log updated --- CHANGELOG for v1.x.x.md | 4 +- composer.json | 6 +- composer.lock | 831 +++++++++++++++++++--------------------- 3 files changed, 393 insertions(+), 448 deletions(-) diff --git a/CHANGELOG for v1.x.x.md b/CHANGELOG for v1.x.x.md index 3739dc054..6a477f564 100644 --- a/CHANGELOG for v1.x.x.md +++ b/CHANGELOG for v1.x.x.md @@ -2,7 +2,7 @@ #### This changelog consists the bug & security fixes and new features being included in the releases listed below. -## **v1.0.0-BETA2(13th of February 2020)** - *Release* +## **v1.0.0-BETA2(20th of February 2020)** - *Release* * #2377 [fixed] - Getting exception on creating a new category under any other category. @@ -48,6 +48,8 @@ * #2439 [fixed] - can't process for further checkout steps until all the address line filled. +* #2435 [fixed] - error composer install --no-dev. + * #2440 [fixed] - Advertisement Three Images is not working. * #2449 [fixed] - error clicking empty cart. diff --git a/composer.json b/composer.json index 74f093097..385ff7ad7 100755 --- a/composer.json +++ b/composer.json @@ -33,17 +33,17 @@ "maatwebsite/excel": "3.1.18", "nwidart/laravel-modules": "^3.2", "prettus/l5-repository": "^2.6", - "tymon/jwt-auth": "^1.0.0" + "tymon/jwt-auth": "^1.0.0", + "barryvdh/laravel-debugbar": "^3.1", + "fzaninotto/faker": "^1.4" }, "require-dev": { - "barryvdh/laravel-debugbar": "^3.1", "codeception/codeception": "^4.0", "codeception/module-asserts": "^1.1", "codeception/module-filesystem": "^1.0", "codeception/module-laravel5": "^1.0", "filp/whoops": "^2.0", - "fzaninotto/faker": "^1.4", "laravel/dusk": "^5.7.0", "mockery/mockery": "^1.0", "nunomaduro/collision": "^2.0", diff --git a/composer.lock b/composer.lock index 1a2050986..3162eb99d 100644 --- a/composer.lock +++ b/composer.lock @@ -4,20 +4,20 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "f89fd224d5966e4af23fb443f7074697", + "content-hash": "2e158f9cd141beb41f6bc0dd7ee82767", "packages": [ { "name": "astrotomic/laravel-translatable", - "version": "v11.6.1", + "version": "v11.7.0", "source": { "type": "git", "url": "https://github.com/Astrotomic/laravel-translatable.git", - "reference": "f7b294cb7b2a853cb11b0e51bc60d9170f2b11a0" + "reference": "889f8b91f28a8a72873099cf452945adbd03dc9f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Astrotomic/laravel-translatable/zipball/f7b294cb7b2a853cb11b0e51bc60d9170f2b11a0", - "reference": "f7b294cb7b2a853cb11b0e51bc60d9170f2b11a0", + "url": "https://api.github.com/repos/Astrotomic/laravel-translatable/zipball/889f8b91f28a8a72873099cf452945adbd03dc9f", + "reference": "889f8b91f28a8a72873099cf452945adbd03dc9f", "shasum": "" }, "require": { @@ -68,7 +68,75 @@ "laravel", "translation" ], - "time": "2019-11-06T09:12:49+00:00" + "time": "2020-01-28T11:49:28+00:00" + }, + { + "name": "barryvdh/laravel-debugbar", + "version": "v3.2.8", + "source": { + "type": "git", + "url": "https://github.com/barryvdh/laravel-debugbar.git", + "reference": "18208d64897ab732f6c04a19b319fe8f1d57a9c0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/barryvdh/laravel-debugbar/zipball/18208d64897ab732f6c04a19b319fe8f1d57a9c0", + "reference": "18208d64897ab732f6c04a19b319fe8f1d57a9c0", + "shasum": "" + }, + "require": { + "illuminate/routing": "^5.5|^6", + "illuminate/session": "^5.5|^6", + "illuminate/support": "^5.5|^6", + "maximebf/debugbar": "~1.15.0", + "php": ">=7.0", + "symfony/debug": "^3|^4", + "symfony/finder": "^3|^4" + }, + "require-dev": { + "laravel/framework": "5.5.x" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.2-dev" + }, + "laravel": { + "providers": [ + "Barryvdh\\Debugbar\\ServiceProvider" + ], + "aliases": { + "Debugbar": "Barryvdh\\Debugbar\\Facade" + } + } + }, + "autoload": { + "psr-4": { + "Barryvdh\\Debugbar\\": "src/" + }, + "files": [ + "src/helpers.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Barry vd. Heuvel", + "email": "barryvdh@gmail.com" + } + ], + "description": "PHP Debugbar integration for Laravel", + "keywords": [ + "debug", + "debugbar", + "laravel", + "profiler", + "webprofiler" + ], + "time": "2019-08-29T07:01:03+00:00" }, { "name": "barryvdh/laravel-dompdf", @@ -650,16 +718,16 @@ }, { "name": "egulias/email-validator", - "version": "2.1.15", + "version": "2.1.17", "source": { "type": "git", "url": "https://github.com/egulias/EmailValidator.git", - "reference": "e834eea5306d85d67de5a05db5882911d5b29357" + "reference": "ade6887fd9bd74177769645ab5c474824f8a418a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/egulias/EmailValidator/zipball/e834eea5306d85d67de5a05db5882911d5b29357", - "reference": "e834eea5306d85d67de5a05db5882911d5b29357", + "url": "https://api.github.com/repos/egulias/EmailValidator/zipball/ade6887fd9bd74177769645ab5c474824f8a418a", + "reference": "ade6887fd9bd74177769645ab5c474824f8a418a", "shasum": "" }, "require": { @@ -704,7 +772,7 @@ "validation", "validator" ], - "time": "2020-01-20T21:40:59+00:00" + "time": "2020-02-13T22:36:52+00:00" }, { "name": "fideloper/proxy", @@ -818,6 +886,56 @@ ], "time": "2019-07-28T22:19:29+00:00" }, + { + "name": "fzaninotto/faker", + "version": "v1.9.1", + "source": { + "type": "git", + "url": "https://github.com/fzaninotto/Faker.git", + "reference": "fc10d778e4b84d5bd315dad194661e091d307c6f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/fzaninotto/Faker/zipball/fc10d778e4b84d5bd315dad194661e091d307c6f", + "reference": "fc10d778e4b84d5bd315dad194661e091d307c6f", + "shasum": "" + }, + "require": { + "php": "^5.3.3 || ^7.0" + }, + "require-dev": { + "ext-intl": "*", + "phpunit/phpunit": "^4.8.35 || ^5.7", + "squizlabs/php_codesniffer": "^2.9.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.9-dev" + } + }, + "autoload": { + "psr-4": { + "Faker\\": "src/Faker/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "François Zaninotto" + } + ], + "description": "Faker is a PHP library that generates fake data for you.", + "keywords": [ + "data", + "faker", + "fixtures" + ], + "time": "2019-12-12T13:22:17+00:00" + }, { "name": "guzzlehttp/guzzle", "version": "6.5.2", @@ -1511,16 +1629,16 @@ }, { "name": "laravel/framework", - "version": "v6.12.0", + "version": "v6.16.0", "source": { "type": "git", "url": "https://github.com/laravel/framework.git", - "reference": "8e189a8dee7ff76bf50acb7e80aa1a36afaf54d4" + "reference": "b47217e41868d3049ec545cbb713aa94c6f39e55" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/framework/zipball/8e189a8dee7ff76bf50acb7e80aa1a36afaf54d4", - "reference": "8e189a8dee7ff76bf50acb7e80aa1a36afaf54d4", + "url": "https://api.github.com/repos/laravel/framework/zipball/b47217e41868d3049ec545cbb713aa94c6f39e55", + "reference": "b47217e41868d3049ec545cbb713aa94c6f39e55", "shasum": "" }, "require": { @@ -1530,8 +1648,7 @@ "ext-json": "*", "ext-mbstring": "*", "ext-openssl": "*", - "league/commonmark": "^1.1", - "league/commonmark-ext-table": "^2.1", + "league/commonmark": "^1.3", "league/flysystem": "^1.0.8", "monolog/monolog": "^1.12|^2.0", "nesbot/carbon": "^2.0", @@ -1589,7 +1706,7 @@ "aws/aws-sdk-php": "^3.0", "doctrine/dbal": "^2.6", "filp/whoops": "^2.4", - "guzzlehttp/guzzle": "^6.3", + "guzzlehttp/guzzle": "^6.3|^7.0", "league/flysystem-cached-adapter": "^1.0", "mockery/mockery": "^1.3.1", "moontoast/math": "^1.1", @@ -1608,9 +1725,9 @@ "ext-posix": "Required to use all features of the queue worker.", "ext-redis": "Required to use the Redis cache and queue drivers.", "filp/whoops": "Required for friendly error pages in development (^2.4).", - "fzaninotto/faker": "Required to use the eloquent factory builder (^1.4).", - "guzzlehttp/guzzle": "Required to use the Mailgun mail driver and the ping methods on schedules (^6.0).", - "laravel/tinker": "Required to use the tinker console command (^1.0).", + "fzaninotto/faker": "Required to use the eloquent factory builder (^1.9.1).", + "guzzlehttp/guzzle": "Required to use the Mailgun mail driver and the ping methods on schedules (^6.0|^7.0).", + "laravel/tinker": "Required to use the tinker console command (^2.0).", "league/flysystem-aws-s3-v3": "Required to use the Flysystem S3 driver (^1.0).", "league/flysystem-cached-adapter": "Required to use the Flysystem cache (^1.0).", "league/flysystem-sftp": "Required to use the Flysystem SFTP driver (^1.0).", @@ -1654,7 +1771,7 @@ "framework", "laravel" ], - "time": "2020-01-21T15:10:03+00:00" + "time": "2020-02-18T15:17:52+00:00" }, { "name": "laravel/helpers", @@ -1829,30 +1946,31 @@ }, { "name": "league/commonmark", - "version": "1.2.2", + "version": "1.3.0", "source": { "type": "git", "url": "https://github.com/thephpleague/commonmark.git", - "reference": "34cf4ddb3892c715ae785c880e6691d839cff88d" + "reference": "4f30be7a2cbf3bfa5788abab71384713e48f451f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/commonmark/zipball/34cf4ddb3892c715ae785c880e6691d839cff88d", - "reference": "34cf4ddb3892c715ae785c880e6691d839cff88d", + "url": "https://api.github.com/repos/thephpleague/commonmark/zipball/4f30be7a2cbf3bfa5788abab71384713e48f451f", + "reference": "4f30be7a2cbf3bfa5788abab71384713e48f451f", "shasum": "" }, "require": { "ext-mbstring": "*", "php": "^7.1" }, - "replace": { - "colinodell/commonmark-php": "*" + "conflict": { + "scrutinizer/ocular": "1.7.*" }, "require-dev": { "cebe/markdown": "~1.0", "commonmark/commonmark.js": "0.29.1", "erusev/parsedown": "~1.0", "ext-json": "*", + "github/gfm": "0.29.0", "michelf/php-markdown": "~1.4", "mikehaertl/php-shellcommand": "^1.4", "phpstan/phpstan-shim": "^0.11.5", @@ -1860,16 +1978,13 @@ "scrutinizer/ocular": "^1.5", "symfony/finder": "^4.2" }, - "suggest": { - "league/commonmark-extras": "Library of useful extensions including smart punctuation" - }, "bin": [ "bin/commonmark" ], "type": "library", "extra": { "branch-alias": { - "dev-master": "1.3-dev" + "dev-master": "1.4-dev" } }, "autoload": { @@ -1889,92 +2004,32 @@ "role": "Lead Developer" } ], - "description": "PHP Markdown parser based on the CommonMark spec", + "description": "Highly-extensible PHP Markdown parser which fully supports the CommonMark spec and Github-Flavored Markdown (GFM)", "homepage": "https://commonmark.thephpleague.com", "keywords": [ "commonmark", + "flavored", + "gfm", + "github", + "github-flavored", "markdown", + "md", "parser" ], - "time": "2020-01-16T01:18:13+00:00" - }, - { - "name": "league/commonmark-ext-table", - "version": "v2.1.0", - "source": { - "type": "git", - "url": "https://github.com/thephpleague/commonmark-ext-table.git", - "reference": "3228888ea69636e855efcf6636ff8e6316933fe7" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/thephpleague/commonmark-ext-table/zipball/3228888ea69636e855efcf6636ff8e6316933fe7", - "reference": "3228888ea69636e855efcf6636ff8e6316933fe7", - "shasum": "" - }, - "require": { - "league/commonmark": "~0.19.3|^1.0", - "php": "^7.1" - }, - "require-dev": { - "friendsofphp/php-cs-fixer": "^2.14", - "phpstan/phpstan": "~0.11", - "phpunit/phpunit": "^7.0|^8.0", - "symfony/var-dumper": "^4.0", - "vimeo/psalm": "^3.0" - }, - "type": "commonmark-extension", - "extra": { - "branch-alias": { - "dev-master": "2.2-dev" - } - }, - "autoload": { - "psr-4": { - "League\\CommonMark\\Ext\\Table\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Martin Hasoň", - "email": "martin.hason@gmail.com" - }, - { - "name": "Webuni s.r.o.", - "homepage": "https://www.webuni.cz" - }, - { - "name": "Colin O'Dell", - "email": "colinodell@gmail.com", - "homepage": "https://www.colinodell.com" - } - ], - "description": "Table extension for league/commonmark", - "homepage": "https://github.com/thephpleague/commonmark-ext-table", - "keywords": [ - "commonmark", - "extension", - "markdown", - "table" - ], - "time": "2019-09-26T13:28:33+00:00" + "time": "2020-02-08T23:42:03+00:00" }, { "name": "league/flysystem", - "version": "1.0.63", + "version": "1.0.64", "source": { "type": "git", "url": "https://github.com/thephpleague/flysystem.git", - "reference": "8132daec326565036bc8e8d1876f77ec183a7bd6" + "reference": "d13c43dbd4b791f815215959105a008515d1a2e0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/8132daec326565036bc8e8d1876f77ec183a7bd6", - "reference": "8132daec326565036bc8e8d1876f77ec183a7bd6", + "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/d13c43dbd4b791f815215959105a008515d1a2e0", + "reference": "d13c43dbd4b791f815215959105a008515d1a2e0", "shasum": "" }, "require": { @@ -1986,7 +2041,7 @@ }, "require-dev": { "phpspec/phpspec": "^3.4", - "phpunit/phpunit": "^5.7.10" + "phpunit/phpunit": "^5.7.26" }, "suggest": { "ext-fileinfo": "Required for MimeType", @@ -2045,7 +2100,7 @@ "sftp", "storage" ], - "time": "2020-01-04T16:30:31+00:00" + "time": "2020-02-05T18:14:17+00:00" }, { "name": "maatwebsite/excel", @@ -2278,6 +2333,67 @@ ], "time": "2019-10-06T11:29:25+00:00" }, + { + "name": "maximebf/debugbar", + "version": "v1.15.1", + "source": { + "type": "git", + "url": "https://github.com/maximebf/php-debugbar.git", + "reference": "6c4277f6117e4864966c9cb58fb835cee8c74a1e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/6c4277f6117e4864966c9cb58fb835cee8c74a1e", + "reference": "6c4277f6117e4864966c9cb58fb835cee8c74a1e", + "shasum": "" + }, + "require": { + "php": ">=5.6", + "psr/log": "^1.0", + "symfony/var-dumper": "^2.6|^3|^4" + }, + "require-dev": { + "phpunit/phpunit": "^5" + }, + "suggest": { + "kriswallsmith/assetic": "The best way to manage assets", + "monolog/monolog": "Log using Monolog", + "predis/predis": "Redis storage" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.15-dev" + } + }, + "autoload": { + "psr-4": { + "DebugBar\\": "src/DebugBar/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Maxime Bouroumeau-Fuseau", + "email": "maxime.bouroumeau@gmail.com", + "homepage": "http://maximebf.com" + }, + { + "name": "Barry vd. Heuvel", + "email": "barryvdh@gmail.com" + } + ], + "description": "Debug bar in the browser for php application", + "homepage": "https://github.com/maximebf/php-debugbar", + "keywords": [ + "debug", + "debugbar" + ], + "time": "2019-09-24T14:55:42+00:00" + }, { "name": "monolog/monolog", "version": "2.0.2", @@ -2424,16 +2540,16 @@ }, { "name": "nesbot/carbon", - "version": "2.29.1", + "version": "2.30.0", "source": { "type": "git", "url": "https://github.com/briannesbitt/Carbon.git", - "reference": "e509be5bf2d703390e69e14496d9a1168452b0a2" + "reference": "912dff66d2690ca66abddb9b291a1df5f371d3b4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/e509be5bf2d703390e69e14496d9a1168452b0a2", - "reference": "e509be5bf2d703390e69e14496d9a1168452b0a2", + "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/912dff66d2690ca66abddb9b291a1df5f371d3b4", + "reference": "912dff66d2690ca66abddb9b291a1df5f371d3b4", "shasum": "" }, "require": { @@ -2490,7 +2606,7 @@ "datetime", "time" ], - "time": "2020-01-21T09:36:43+00:00" + "time": "2020-02-07T15:25:46+00:00" }, { "name": "nikic/php-parser", @@ -2947,16 +3063,16 @@ }, { "name": "prettus/l5-repository", - "version": "2.6.40", + "version": "2.6.41", "source": { "type": "git", "url": "https://github.com/andersao/l5-repository.git", - "reference": "48ed6d347941bf04927a3cd490df7bba7a02ca36" + "reference": "363904bd1d01325223197d3de1ea3f6fc9da2a06" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/andersao/l5-repository/zipball/48ed6d347941bf04927a3cd490df7bba7a02ca36", - "reference": "48ed6d347941bf04927a3cd490df7bba7a02ca36", + "url": "https://api.github.com/repos/andersao/l5-repository/zipball/363904bd1d01325223197d3de1ea3f6fc9da2a06", + "reference": "363904bd1d01325223197d3de1ea3f6fc9da2a06", "shasum": "" }, "require": { @@ -3008,7 +3124,7 @@ "model", "repository" ], - "time": "2019-12-22T13:53:50+00:00" + "time": "2020-02-05T06:48:26+00:00" }, { "name": "prettus/laravel-validation", @@ -3557,16 +3673,16 @@ }, { "name": "symfony/console", - "version": "v4.4.3", + "version": "v4.4.4", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "e9ee09d087e2c88eaf6e5fc0f5c574f64d100e4f" + "reference": "f512001679f37e6a042b51897ed24a2f05eba656" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/e9ee09d087e2c88eaf6e5fc0f5c574f64d100e4f", - "reference": "e9ee09d087e2c88eaf6e5fc0f5c574f64d100e4f", + "url": "https://api.github.com/repos/symfony/console/zipball/f512001679f37e6a042b51897ed24a2f05eba656", + "reference": "f512001679f37e6a042b51897ed24a2f05eba656", "shasum": "" }, "require": { @@ -3629,11 +3745,11 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2020-01-10T21:54:01+00:00" + "time": "2020-01-25T12:44:29+00:00" }, { "name": "symfony/css-selector", - "version": "v5.0.3", + "version": "v5.0.4", "source": { "type": "git", "url": "https://github.com/symfony/css-selector.git", @@ -3686,16 +3802,16 @@ }, { "name": "symfony/debug", - "version": "v4.4.3", + "version": "v4.4.4", "source": { "type": "git", "url": "https://github.com/symfony/debug.git", - "reference": "89c3fd5c299b940333bc6fe9f1b8db1b0912c759" + "reference": "20236471058bbaa9907382500fc14005c84601f0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/debug/zipball/89c3fd5c299b940333bc6fe9f1b8db1b0912c759", - "reference": "89c3fd5c299b940333bc6fe9f1b8db1b0912c759", + "url": "https://api.github.com/repos/symfony/debug/zipball/20236471058bbaa9907382500fc14005c84601f0", + "reference": "20236471058bbaa9907382500fc14005c84601f0", "shasum": "" }, "require": { @@ -3738,20 +3854,20 @@ ], "description": "Symfony Debug Component", "homepage": "https://symfony.com", - "time": "2020-01-08T17:29:02+00:00" + "time": "2020-01-25T12:44:29+00:00" }, { "name": "symfony/error-handler", - "version": "v4.4.3", + "version": "v4.4.4", "source": { "type": "git", "url": "https://github.com/symfony/error-handler.git", - "reference": "a59789092e40ad08465dc2cdc55651be503d0d5a" + "reference": "d2721499ffcaf246a743e01cdf6696d3d5dd74c1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/error-handler/zipball/a59789092e40ad08465dc2cdc55651be503d0d5a", - "reference": "a59789092e40ad08465dc2cdc55651be503d0d5a", + "url": "https://api.github.com/repos/symfony/error-handler/zipball/d2721499ffcaf246a743e01cdf6696d3d5dd74c1", + "reference": "d2721499ffcaf246a743e01cdf6696d3d5dd74c1", "shasum": "" }, "require": { @@ -3794,11 +3910,11 @@ ], "description": "Symfony ErrorHandler Component", "homepage": "https://symfony.com", - "time": "2020-01-08T17:29:02+00:00" + "time": "2020-01-27T09:48:47+00:00" }, { "name": "symfony/event-dispatcher", - "version": "v4.4.3", + "version": "v4.4.4", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", @@ -3926,7 +4042,7 @@ }, { "name": "symfony/finder", - "version": "v4.4.3", + "version": "v4.4.4", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", @@ -3975,16 +4091,16 @@ }, { "name": "symfony/http-foundation", - "version": "v4.4.3", + "version": "v4.4.4", "source": { "type": "git", "url": "https://github.com/symfony/http-foundation.git", - "reference": "c33998709f3fe9b8e27e0277535b07fbf6fde37a" + "reference": "491a20dfa87e0b3990170593bc2de0bb34d828a5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-foundation/zipball/c33998709f3fe9b8e27e0277535b07fbf6fde37a", - "reference": "c33998709f3fe9b8e27e0277535b07fbf6fde37a", + "url": "https://api.github.com/repos/symfony/http-foundation/zipball/491a20dfa87e0b3990170593bc2de0bb34d828a5", + "reference": "491a20dfa87e0b3990170593bc2de0bb34d828a5", "shasum": "" }, "require": { @@ -4026,20 +4142,20 @@ ], "description": "Symfony HttpFoundation Component", "homepage": "https://symfony.com", - "time": "2020-01-04T13:00:46+00:00" + "time": "2020-01-31T09:11:17+00:00" }, { "name": "symfony/http-kernel", - "version": "v4.4.3", + "version": "v4.4.4", "source": { "type": "git", "url": "https://github.com/symfony/http-kernel.git", - "reference": "16f2aa3c54b08483fba5375938f60b1ff83b6bd2" + "reference": "62116a9c8fb15faabb158ad9cb785c353c2572e5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-kernel/zipball/16f2aa3c54b08483fba5375938f60b1ff83b6bd2", - "reference": "16f2aa3c54b08483fba5375938f60b1ff83b6bd2", + "url": "https://api.github.com/repos/symfony/http-kernel/zipball/62116a9c8fb15faabb158ad9cb785c353c2572e5", + "reference": "62116a9c8fb15faabb158ad9cb785c353c2572e5", "shasum": "" }, "require": { @@ -4116,11 +4232,11 @@ ], "description": "Symfony HttpKernel Component", "homepage": "https://symfony.com", - "time": "2020-01-21T13:23:17+00:00" + "time": "2020-01-31T12:45:06+00:00" }, { "name": "symfony/mime", - "version": "v5.0.3", + "version": "v5.0.4", "source": { "type": "git", "url": "https://github.com/symfony/mime.git", @@ -4182,16 +4298,16 @@ }, { "name": "symfony/polyfill-ctype", - "version": "v1.13.1", + "version": "v1.14.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "f8f0b461be3385e56d6de3dbb5a0df24c0c275e3" + "reference": "fbdeaec0df06cf3d51c93de80c7eb76e271f5a38" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/f8f0b461be3385e56d6de3dbb5a0df24c0c275e3", - "reference": "f8f0b461be3385e56d6de3dbb5a0df24c0c275e3", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/fbdeaec0df06cf3d51c93de80c7eb76e271f5a38", + "reference": "fbdeaec0df06cf3d51c93de80c7eb76e271f5a38", "shasum": "" }, "require": { @@ -4203,7 +4319,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.13-dev" + "dev-master": "1.14-dev" } }, "autoload": { @@ -4236,20 +4352,20 @@ "polyfill", "portable" ], - "time": "2019-11-27T13:56:44+00:00" + "time": "2020-01-13T11:15:53+00:00" }, { "name": "symfony/polyfill-iconv", - "version": "v1.13.1", + "version": "v1.14.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-iconv.git", - "reference": "a019efccc03f1a335af6b4f20c30f5ea8060be36" + "reference": "926832ce51059bb58211b7b2080a88e0c3b5328e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-iconv/zipball/a019efccc03f1a335af6b4f20c30f5ea8060be36", - "reference": "a019efccc03f1a335af6b4f20c30f5ea8060be36", + "url": "https://api.github.com/repos/symfony/polyfill-iconv/zipball/926832ce51059bb58211b7b2080a88e0c3b5328e", + "reference": "926832ce51059bb58211b7b2080a88e0c3b5328e", "shasum": "" }, "require": { @@ -4261,7 +4377,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.13-dev" + "dev-master": "1.14-dev" } }, "autoload": { @@ -4295,26 +4411,26 @@ "portable", "shim" ], - "time": "2019-11-27T13:56:44+00:00" + "time": "2020-01-13T11:15:53+00:00" }, { "name": "symfony/polyfill-intl-idn", - "version": "v1.13.1", + "version": "v1.14.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-idn.git", - "reference": "6f9c239e61e1b0c9229a28ff89a812dc449c3d46" + "reference": "6842f1a39cf7d580655688069a03dd7cd83d244a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/6f9c239e61e1b0c9229a28ff89a812dc449c3d46", - "reference": "6f9c239e61e1b0c9229a28ff89a812dc449c3d46", + "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/6842f1a39cf7d580655688069a03dd7cd83d244a", + "reference": "6842f1a39cf7d580655688069a03dd7cd83d244a", "shasum": "" }, "require": { "php": ">=5.3.3", "symfony/polyfill-mbstring": "^1.3", - "symfony/polyfill-php72": "^1.9" + "symfony/polyfill-php72": "^1.10" }, "suggest": { "ext-intl": "For best performance" @@ -4322,7 +4438,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.13-dev" + "dev-master": "1.14-dev" } }, "autoload": { @@ -4357,20 +4473,20 @@ "portable", "shim" ], - "time": "2019-11-27T13:56:44+00:00" + "time": "2020-01-17T12:01:36+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.13.1", + "version": "v1.14.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "7b4aab9743c30be783b73de055d24a39cf4b954f" + "reference": "34094cfa9abe1f0f14f48f490772db7a775559f2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/7b4aab9743c30be783b73de055d24a39cf4b954f", - "reference": "7b4aab9743c30be783b73de055d24a39cf4b954f", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/34094cfa9abe1f0f14f48f490772db7a775559f2", + "reference": "34094cfa9abe1f0f14f48f490772db7a775559f2", "shasum": "" }, "require": { @@ -4382,7 +4498,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.13-dev" + "dev-master": "1.14-dev" } }, "autoload": { @@ -4416,20 +4532,20 @@ "portable", "shim" ], - "time": "2019-11-27T14:18:11+00:00" + "time": "2020-01-13T11:15:53+00:00" }, { "name": "symfony/polyfill-php56", - "version": "v1.13.1", + "version": "v1.14.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php56.git", - "reference": "53dd1cdf3cb986893ccf2b96665b25b3abb384f4" + "reference": "16ec91cb06998b609501b55b7177b7d7c02badb3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php56/zipball/53dd1cdf3cb986893ccf2b96665b25b3abb384f4", - "reference": "53dd1cdf3cb986893ccf2b96665b25b3abb384f4", + "url": "https://api.github.com/repos/symfony/polyfill-php56/zipball/16ec91cb06998b609501b55b7177b7d7c02badb3", + "reference": "16ec91cb06998b609501b55b7177b7d7c02badb3", "shasum": "" }, "require": { @@ -4439,7 +4555,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.13-dev" + "dev-master": "1.14-dev" } }, "autoload": { @@ -4472,20 +4588,20 @@ "portable", "shim" ], - "time": "2019-11-27T13:56:44+00:00" + "time": "2020-01-13T11:15:53+00:00" }, { "name": "symfony/polyfill-php72", - "version": "v1.13.1", + "version": "v1.14.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php72.git", - "reference": "66fea50f6cb37a35eea048d75a7d99a45b586038" + "reference": "46ecacf4751dd0dc81e4f6bf01dbf9da1dc1dadf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/66fea50f6cb37a35eea048d75a7d99a45b586038", - "reference": "66fea50f6cb37a35eea048d75a7d99a45b586038", + "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/46ecacf4751dd0dc81e4f6bf01dbf9da1dc1dadf", + "reference": "46ecacf4751dd0dc81e4f6bf01dbf9da1dc1dadf", "shasum": "" }, "require": { @@ -4494,7 +4610,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.13-dev" + "dev-master": "1.14-dev" } }, "autoload": { @@ -4527,20 +4643,20 @@ "portable", "shim" ], - "time": "2019-11-27T13:56:44+00:00" + "time": "2020-01-13T11:15:53+00:00" }, { "name": "symfony/polyfill-php73", - "version": "v1.13.1", + "version": "v1.14.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php73.git", - "reference": "4b0e2222c55a25b4541305a053013d5647d3a25f" + "reference": "5e66a0fa1070bf46bec4bea7962d285108edd675" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/4b0e2222c55a25b4541305a053013d5647d3a25f", - "reference": "4b0e2222c55a25b4541305a053013d5647d3a25f", + "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/5e66a0fa1070bf46bec4bea7962d285108edd675", + "reference": "5e66a0fa1070bf46bec4bea7962d285108edd675", "shasum": "" }, "require": { @@ -4549,7 +4665,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.13-dev" + "dev-master": "1.14-dev" } }, "autoload": { @@ -4585,20 +4701,20 @@ "portable", "shim" ], - "time": "2019-11-27T16:25:15+00:00" + "time": "2020-01-13T11:15:53+00:00" }, { "name": "symfony/polyfill-util", - "version": "v1.13.1", + "version": "v1.14.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-util.git", - "reference": "964a67f293b66b95883a5ed918a65354fcd2258f" + "reference": "ba3cfcea6d0192cae46c62041f61cbb704b526d3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-util/zipball/964a67f293b66b95883a5ed918a65354fcd2258f", - "reference": "964a67f293b66b95883a5ed918a65354fcd2258f", + "url": "https://api.github.com/repos/symfony/polyfill-util/zipball/ba3cfcea6d0192cae46c62041f61cbb704b526d3", + "reference": "ba3cfcea6d0192cae46c62041f61cbb704b526d3", "shasum": "" }, "require": { @@ -4607,7 +4723,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.13-dev" + "dev-master": "1.14-dev" } }, "autoload": { @@ -4637,11 +4753,11 @@ "polyfill", "shim" ], - "time": "2019-11-27T13:56:44+00:00" + "time": "2020-01-13T11:15:53+00:00" }, { "name": "symfony/process", - "version": "v4.4.3", + "version": "v4.4.4", "source": { "type": "git", "url": "https://github.com/symfony/process.git", @@ -4690,7 +4806,7 @@ }, { "name": "symfony/routing", - "version": "v4.4.3", + "version": "v4.4.4", "source": { "type": "git", "url": "https://github.com/symfony/routing.git", @@ -4824,7 +4940,7 @@ }, { "name": "symfony/translation", - "version": "v4.4.3", + "version": "v4.4.4", "source": { "type": "git", "url": "https://github.com/symfony/translation.git", @@ -4957,16 +5073,16 @@ }, { "name": "symfony/var-dumper", - "version": "v4.4.3", + "version": "v4.4.4", "source": { "type": "git", "url": "https://github.com/symfony/var-dumper.git", - "reference": "7cfa470bc3b1887a7b2a47c0a702a84ad614fa92" + "reference": "46b53fd714568af343953c039ff47b67ce8af8d6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-dumper/zipball/7cfa470bc3b1887a7b2a47c0a702a84ad614fa92", - "reference": "7cfa470bc3b1887a7b2a47c0a702a84ad614fa92", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/46b53fd714568af343953c039ff47b67ce8af8d6", + "reference": "46b53fd714568af343953c039ff47b67ce8af8d6", "shasum": "" }, "require": { @@ -5029,7 +5145,7 @@ "debug", "dump" ], - "time": "2020-01-04T13:00:46+00:00" + "time": "2020-01-25T12:44:29+00:00" }, { "name": "tijsverkoyen/css-to-inline-styles", @@ -5214,74 +5330,6 @@ } ], "packages-dev": [ - { - "name": "barryvdh/laravel-debugbar", - "version": "v3.2.8", - "source": { - "type": "git", - "url": "https://github.com/barryvdh/laravel-debugbar.git", - "reference": "18208d64897ab732f6c04a19b319fe8f1d57a9c0" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/barryvdh/laravel-debugbar/zipball/18208d64897ab732f6c04a19b319fe8f1d57a9c0", - "reference": "18208d64897ab732f6c04a19b319fe8f1d57a9c0", - "shasum": "" - }, - "require": { - "illuminate/routing": "^5.5|^6", - "illuminate/session": "^5.5|^6", - "illuminate/support": "^5.5|^6", - "maximebf/debugbar": "~1.15.0", - "php": ">=7.0", - "symfony/debug": "^3|^4", - "symfony/finder": "^3|^4" - }, - "require-dev": { - "laravel/framework": "5.5.x" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.2-dev" - }, - "laravel": { - "providers": [ - "Barryvdh\\Debugbar\\ServiceProvider" - ], - "aliases": { - "Debugbar": "Barryvdh\\Debugbar\\Facade" - } - } - }, - "autoload": { - "psr-4": { - "Barryvdh\\Debugbar\\": "src/" - }, - "files": [ - "src/helpers.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Barry vd. Heuvel", - "email": "barryvdh@gmail.com" - } - ], - "description": "PHP Debugbar integration for Laravel", - "keywords": [ - "debug", - "debugbar", - "laravel", - "profiler", - "webprofiler" - ], - "time": "2019-08-29T07:01:03+00:00" - }, { "name": "behat/gherkin", "version": "v4.6.0", @@ -5343,22 +5391,22 @@ }, { "name": "codeception/codeception", - "version": "4.0.2", + "version": "4.1.1", "source": { "type": "git", "url": "https://github.com/Codeception/Codeception.git", - "reference": "e610c15ebb73b56722c67e1c799bf0565f062899" + "reference": "be584da4859baf34e05afd26fe4c587be4787ff0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Codeception/Codeception/zipball/e610c15ebb73b56722c67e1c799bf0565f062899", - "reference": "e610c15ebb73b56722c67e1c799bf0565f062899", + "url": "https://api.github.com/repos/Codeception/Codeception/zipball/be584da4859baf34e05afd26fe4c587be4787ff0", + "reference": "be584da4859baf34e05afd26fe4c587be4787ff0", "shasum": "" }, "require": { "behat/gherkin": "^4.4.0", "codeception/lib-asserts": "^1.0", - "codeception/phpunit-wrapper": ">6.0.15 <6.1.0 | ^6.6.1 | ^7.7.1 | ^8.1.1", + "codeception/phpunit-wrapper": ">6.0.15 <6.1.0 | ^6.6.1 | ^7.7.1 | ^8.1.1 | ^9.0", "codeception/stub": "^2.0 | ^3.0", "ext-curl": "*", "ext-json": "*", @@ -5424,24 +5472,24 @@ "functional testing", "unit testing" ], - "time": "2020-01-14T14:44:10+00:00" + "time": "2020-02-19T16:56:20+00:00" }, { "name": "codeception/lib-asserts", - "version": "1.1.1", + "version": "1.2.0", "source": { "type": "git", "url": "https://github.com/Codeception/lib-asserts.git", - "reference": "e7decb48defc5dd89e26ae05019e63260a9c4c0f" + "reference": "74bfe433af24e2f75c6386b9d843ec69029f4337" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Codeception/lib-asserts/zipball/e7decb48defc5dd89e26ae05019e63260a9c4c0f", - "reference": "e7decb48defc5dd89e26ae05019e63260a9c4c0f", + "url": "https://api.github.com/repos/Codeception/lib-asserts/zipball/74bfe433af24e2f75c6386b9d843ec69029f4337", + "reference": "74bfe433af24e2f75c6386b9d843ec69029f4337", "shasum": "" }, "require": { - "codeception/phpunit-wrapper": ">6.0.15 <6.1.0 | ^6.6.1 | ^7.7.1 | ^8.0.3", + "codeception/phpunit-wrapper": ">6.0.15 <6.1.0 | ^6.6.1 | ^7.7.1 | ^8.0.3 | ^9.0", "php": ">=5.6.0 <8.0" }, "type": "library", @@ -5469,20 +5517,20 @@ "keywords": [ "codeception" ], - "time": "2019-11-13T17:28:28+00:00" + "time": "2020-02-07T17:47:55+00:00" }, { "name": "codeception/lib-innerbrowser", - "version": "1.2.3", + "version": "1.3.0", "source": { "type": "git", "url": "https://github.com/Codeception/lib-innerbrowser.git", - "reference": "289028f011dcc954c530e946ea34bb7ce4ec2721" + "reference": "eb43279b3c1c34a10e1d4cda14e69924b0546ff2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Codeception/lib-innerbrowser/zipball/289028f011dcc954c530e946ea34bb7ce4ec2721", - "reference": "289028f011dcc954c530e946ea34bb7ce4ec2721", + "url": "https://api.github.com/repos/Codeception/lib-innerbrowser/zipball/eb43279b3c1c34a10e1d4cda14e69924b0546ff2", + "reference": "eb43279b3c1c34a10e1d4cda14e69924b0546ff2", "shasum": "" }, "require": { @@ -5522,7 +5570,7 @@ "keywords": [ "codeception" ], - "time": "2019-11-26T16:50:12+00:00" + "time": "2020-01-27T09:23:41+00:00" }, { "name": "codeception/module-asserts", @@ -5868,56 +5916,6 @@ ], "time": "2020-01-15T10:00:00+00:00" }, - { - "name": "fzaninotto/faker", - "version": "v1.9.1", - "source": { - "type": "git", - "url": "https://github.com/fzaninotto/Faker.git", - "reference": "fc10d778e4b84d5bd315dad194661e091d307c6f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/fzaninotto/Faker/zipball/fc10d778e4b84d5bd315dad194661e091d307c6f", - "reference": "fc10d778e4b84d5bd315dad194661e091d307c6f", - "shasum": "" - }, - "require": { - "php": "^5.3.3 || ^7.0" - }, - "require-dev": { - "ext-intl": "*", - "phpunit/phpunit": "^4.8.35 || ^5.7", - "squizlabs/php_codesniffer": "^2.9.2" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.9-dev" - } - }, - "autoload": { - "psr-4": { - "Faker\\": "src/Faker/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "François Zaninotto" - } - ], - "description": "Faker is a PHP library that generates fake data for you.", - "keywords": [ - "data", - "faker", - "fixtures" - ], - "time": "2019-12-12T13:22:17+00:00" - }, { "name": "hamcrest/hamcrest-php", "version": "v2.0.0", @@ -5968,16 +5966,16 @@ }, { "name": "laravel/dusk", - "version": "v5.8.2", + "version": "v5.9.2", "source": { "type": "git", "url": "https://github.com/laravel/dusk.git", - "reference": "c95d70b5fff000c54a9186c2011b236592fcf948" + "reference": "7abf5a7152863f8597a43d640cce3adb6cd8ab3f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/dusk/zipball/c95d70b5fff000c54a9186c2011b236592fcf948", - "reference": "c95d70b5fff000c54a9186c2011b236592fcf948", + "url": "https://api.github.com/repos/laravel/dusk/zipball/7abf5a7152863f8597a43d640cce3adb6cd8ab3f", + "reference": "7abf5a7152863f8597a43d640cce3adb6cd8ab3f", "shasum": "" }, "require": { @@ -5987,7 +5985,7 @@ "illuminate/support": "~5.7.0|~5.8.0|^6.0|^7.0", "nesbot/carbon": "^1.20|^2.0", "php": ">=7.1.0", - "php-webdriver/webdriver": "^1.7", + "php-webdriver/webdriver": "^1.8.1", "symfony/console": "^4.0|^5.0", "symfony/finder": "^4.0|^5.0", "symfony/process": "^4.0|^5.0", @@ -6032,68 +6030,7 @@ "testing", "webdriver" ], - "time": "2020-01-21T20:57:39+00:00" - }, - { - "name": "maximebf/debugbar", - "version": "v1.15.1", - "source": { - "type": "git", - "url": "https://github.com/maximebf/php-debugbar.git", - "reference": "6c4277f6117e4864966c9cb58fb835cee8c74a1e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/6c4277f6117e4864966c9cb58fb835cee8c74a1e", - "reference": "6c4277f6117e4864966c9cb58fb835cee8c74a1e", - "shasum": "" - }, - "require": { - "php": ">=5.6", - "psr/log": "^1.0", - "symfony/var-dumper": "^2.6|^3|^4" - }, - "require-dev": { - "phpunit/phpunit": "^5" - }, - "suggest": { - "kriswallsmith/assetic": "The best way to manage assets", - "monolog/monolog": "Log using Monolog", - "predis/predis": "Redis storage" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.15-dev" - } - }, - "autoload": { - "psr-4": { - "DebugBar\\": "src/DebugBar/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Maxime Bouroumeau-Fuseau", - "email": "maxime.bouroumeau@gmail.com", - "homepage": "http://maximebf.com" - }, - { - "name": "Barry vd. Heuvel", - "email": "barryvdh@gmail.com" - } - ], - "description": "Debug bar in the browser for php application", - "homepage": "https://github.com/maximebf/php-debugbar", - "keywords": [ - "debug", - "debugbar" - ], - "time": "2019-09-24T14:55:42+00:00" + "time": "2020-02-18T19:13:12+00:00" }, { "name": "mockery/mockery", @@ -6376,35 +6313,36 @@ }, { "name": "php-webdriver/webdriver", - "version": "1.7.1", + "version": "1.8.1", "source": { "type": "git", "url": "https://github.com/php-webdriver/php-webdriver.git", - "reference": "e43de70f3c7166169d0f14a374505392734160e5" + "reference": "262ea0d209c292e0330be1041424887bbbffef04" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-webdriver/php-webdriver/zipball/e43de70f3c7166169d0f14a374505392734160e5", - "reference": "e43de70f3c7166169d0f14a374505392734160e5", + "url": "https://api.github.com/repos/php-webdriver/php-webdriver/zipball/262ea0d209c292e0330be1041424887bbbffef04", + "reference": "262ea0d209c292e0330be1041424887bbbffef04", "shasum": "" }, "require": { "ext-curl": "*", "ext-json": "*", - "ext-mbstring": "*", "ext-zip": "*", "php": "^5.6 || ~7.0", - "symfony/process": "^2.8 || ^3.1 || ^4.0" + "symfony/polyfill-mbstring": "^1.12", + "symfony/process": "^2.8 || ^3.1 || ^4.0 || ^5.0" }, "require-dev": { "friendsofphp/php-cs-fixer": "^2.0", - "jakub-onderka/php-parallel-lint": "^0.9.2", + "jakub-onderka/php-parallel-lint": "^1.0", "php-coveralls/php-coveralls": "^2.0", "php-mock/php-mock-phpunit": "^1.1", "phpunit/phpunit": "^5.7", "sebastian/environment": "^1.3.4 || ^2.0 || ^3.0", - "squizlabs/php_codesniffer": "^2.6", - "symfony/var-dumper": "^3.3 || ^4.0" + "sminnee/phpunit-mock-objects": "^3.4", + "squizlabs/php_codesniffer": "^3.5", + "symfony/var-dumper": "^3.3 || ^4.0 || ^5.0" }, "suggest": { "ext-SimpleXML": "For Firefox profile creation" @@ -6412,27 +6350,31 @@ "type": "library", "extra": { "branch-alias": { - "dev-community": "1.5-dev" + "dev-master": "1.8.x-dev" } }, "autoload": { "psr-4": { "Facebook\\WebDriver\\": "lib/" - } + }, + "files": [ + "lib/Exception/TimeoutException.php" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ - "Apache-2.0" + "MIT" ], - "description": "A PHP client for Selenium WebDriver", - "homepage": "https://github.com/facebook/php-webdriver", + "description": "A PHP client for Selenium WebDriver. Previously facebook/webdriver.", + "homepage": "https://github.com/php-webdriver/php-webdriver", "keywords": [ - "facebook", + "Chromedriver", + "geckodriver", "php", "selenium", "webdriver" ], - "time": "2019-06-13T08:02:18+00:00" + "time": "2020-02-17T08:14:38+00:00" }, { "name": "phpdocumentor/reflection-common", @@ -6488,41 +6430,38 @@ }, { "name": "phpdocumentor/reflection-docblock", - "version": "4.3.4", + "version": "5.0.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "da3fd972d6bafd628114f7e7e036f45944b62e9c" + "reference": "a48807183a4b819072f26e347bbd0b5199a9d15f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/da3fd972d6bafd628114f7e7e036f45944b62e9c", - "reference": "da3fd972d6bafd628114f7e7e036f45944b62e9c", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/a48807183a4b819072f26e347bbd0b5199a9d15f", + "reference": "a48807183a4b819072f26e347bbd0b5199a9d15f", "shasum": "" }, "require": { - "php": "^7.0", - "phpdocumentor/reflection-common": "^1.0.0 || ^2.0.0", - "phpdocumentor/type-resolver": "~0.4 || ^1.0.0", - "webmozart/assert": "^1.0" + "ext-filter": "^7.1", + "php": "^7.2", + "phpdocumentor/reflection-common": "^2.0", + "phpdocumentor/type-resolver": "^1.0", + "webmozart/assert": "^1" }, "require-dev": { - "doctrine/instantiator": "^1.0.5", - "mockery/mockery": "^1.0", - "phpdocumentor/type-resolver": "0.4.*", - "phpunit/phpunit": "^6.4" + "doctrine/instantiator": "^1", + "mockery/mockery": "^1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.x-dev" + "dev-master": "5.x-dev" } }, "autoload": { "psr-4": { - "phpDocumentor\\Reflection\\": [ - "src/" - ] + "phpDocumentor\\Reflection\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -6533,10 +6472,14 @@ { "name": "Mike van Riel", "email": "me@mikevanriel.com" + }, + { + "name": "Jaap van Otterdijk", + "email": "account@ijaap.nl" } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "time": "2019-12-28T18:55:12+00:00" + "time": "2020-02-09T09:16:15+00:00" }, { "name": "phpdocumentor/type-resolver", @@ -7552,7 +7495,7 @@ }, { "name": "symfony/browser-kit", - "version": "v5.0.3", + "version": "v5.0.4", "source": { "type": "git", "url": "https://github.com/symfony/browser-kit.git", @@ -7611,7 +7554,7 @@ }, { "name": "symfony/dom-crawler", - "version": "v5.0.3", + "version": "v5.0.4", "source": { "type": "git", "url": "https://github.com/symfony/dom-crawler.git", @@ -7672,7 +7615,7 @@ }, { "name": "symfony/yaml", - "version": "v5.0.3", + "version": "v5.0.4", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", @@ -7771,16 +7714,16 @@ }, { "name": "webmozart/assert", - "version": "1.6.0", + "version": "1.7.0", "source": { "type": "git", "url": "https://github.com/webmozart/assert.git", - "reference": "573381c0a64f155a0d9a23f4b0c797194805b925" + "reference": "aed98a490f9a8f78468232db345ab9cf606cf598" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozart/assert/zipball/573381c0a64f155a0d9a23f4b0c797194805b925", - "reference": "573381c0a64f155a0d9a23f4b0c797194805b925", + "url": "https://api.github.com/repos/webmozart/assert/zipball/aed98a490f9a8f78468232db345ab9cf606cf598", + "reference": "aed98a490f9a8f78468232db345ab9cf606cf598", "shasum": "" }, "require": { @@ -7815,7 +7758,7 @@ "check", "validate" ], - "time": "2019-11-24T13:36:37+00:00" + "time": "2020-02-14T12:15:55+00:00" } ], "aliases": [], From 38f1251568b09d53d06fa8f11b6b038e0dfd4756 Mon Sep 17 00:00:00 2001 From: rahul shukla Date: Thu, 20 Feb 2020 12:30:00 +0530 Subject: [PATCH 20/38] Issue #2468 --- .../Webkul/Shop/src/Http/Controllers/OnepageController.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/Webkul/Shop/src/Http/Controllers/OnepageController.php b/packages/Webkul/Shop/src/Http/Controllers/OnepageController.php index a9095721e..822e6cf98 100755 --- a/packages/Webkul/Shop/src/Http/Controllers/OnepageController.php +++ b/packages/Webkul/Shop/src/Http/Controllers/OnepageController.php @@ -103,6 +103,10 @@ class OnepageController extends Controller { $data = request()->all(); + if (! auth()->guard('customer')->check() && ! $cart->hasGuestCheckoutItems()) { + return response()->json(['redirect_url' => route('customer.session.index')], 403); + } + $data['billing']['address1'] = implode(PHP_EOL, array_filter($data['billing']['address1'])); $data['shipping']['address1'] = implode(PHP_EOL, array_filter($data['shipping']['address1'])); From aeb4d1a6eef82780ec703582c5088fd0a501585e Mon Sep 17 00:00:00 2001 From: rahul shukla Date: Thu, 20 Feb 2020 12:31:00 +0530 Subject: [PATCH 21/38] Change log update --- CHANGELOG for v1.x.x.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG for v1.x.x.md b/CHANGELOG for v1.x.x.md index 6a477f564..2ee680429 100644 --- a/CHANGELOG for v1.x.x.md +++ b/CHANGELOG for v1.x.x.md @@ -60,6 +60,8 @@ * #2463 [fixed] - Tax rate is not update on same product. +* #2468 [fixed] - Guest user is able to checkout if guest checkout is disabled. + * #2469 [fixed] - Displaying wrong amount for bundle product in cart. * #2479 [fixed] - showing total review in recent view product list. From 6714b1d7c87b9735eae983178a2a981cb83cac47 Mon Sep 17 00:00:00 2001 From: rahul shukla Date: Thu, 20 Feb 2020 13:13:02 +0530 Subject: [PATCH 22/38] Issue #2468 --- packages/Webkul/Shop/src/Http/Controllers/OnepageController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/Webkul/Shop/src/Http/Controllers/OnepageController.php b/packages/Webkul/Shop/src/Http/Controllers/OnepageController.php index 822e6cf98..541787a87 100755 --- a/packages/Webkul/Shop/src/Http/Controllers/OnepageController.php +++ b/packages/Webkul/Shop/src/Http/Controllers/OnepageController.php @@ -103,7 +103,7 @@ class OnepageController extends Controller { $data = request()->all(); - if (! auth()->guard('customer')->check() && ! $cart->hasGuestCheckoutItems()) { + if (! auth()->guard('customer')->check() && ! Cart::getCart()->hasGuestCheckoutItems()) { return response()->json(['redirect_url' => route('customer.session.index')], 403); } From 75d22eaf3affa38663bc25ba8728f30341d8eaa8 Mon Sep 17 00:00:00 2001 From: Herbert Maschke Date: Thu, 20 Feb 2020 11:25:33 +0100 Subject: [PATCH 23/38] improve validation style of starts_from and ends_till in CartRuleRepository --- .../Http/Controllers/CartRuleController.php | 58 ++++++++++--------- .../src/Repositories/CartRuleRepository.php | 4 +- 2 files changed, 33 insertions(+), 29 deletions(-) diff --git a/packages/Webkul/CartRule/src/Http/Controllers/CartRuleController.php b/packages/Webkul/CartRule/src/Http/Controllers/CartRuleController.php index 0e74172ac..726d60b5e 100644 --- a/packages/Webkul/CartRule/src/Http/Controllers/CartRuleController.php +++ b/packages/Webkul/CartRule/src/Http/Controllers/CartRuleController.php @@ -10,7 +10,7 @@ use Webkul\CartRule\Repositories\CartRuleCouponRepository; /** * Cart Rule controller * - * @author Jitendra Singh + * @author Jitendra Singh * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) */ class CartRuleController extends Controller @@ -39,8 +39,9 @@ class CartRuleController extends Controller /** * Create a new controller instance. * - * @param \Webkul\CartRule\Repositories\CartRuleRepository $cartRuleRepository - * @param \Webkul\CartRule\Repositories\CartRuleCouponRepository $cartRuleCouponRepository + * @param \Webkul\CartRule\Repositories\CartRuleRepository $cartRuleRepository + * @param \Webkul\CartRule\Repositories\CartRuleCouponRepository $cartRuleCouponRepository + * * @return void */ public function __construct( @@ -83,16 +84,16 @@ class CartRuleController extends Controller public function store() { $this->validate(request(), [ - 'name' => 'required', - 'channels' => 'required|array|min:1', - 'customer_groups' => 'required|array|min:1', - 'coupon_type' => 'required', + 'name' => 'required', + 'channels' => 'required|array|min:1', + 'customer_groups' => 'required|array|min:1', + 'coupon_type' => 'required', 'use_auto_generation' => 'required_if:coupon_type,==,1', - 'coupon_code' => 'required_if:use_auto_generation,==,0', - 'starts_from' => 'nullable|date', - 'ends_till' => 'nullable|date|after_or_equal:starts_from', - 'action_type' => 'required', - 'discount_amount' => 'required|numeric' + 'coupon_code' => 'required_if:use_auto_generation,==,0', + 'starts_from' => 'nullable|date', + 'ends_till' => 'nullable|date|after_or_equal:starts_from', + 'action_type' => 'required', + 'discount_amount' => 'required|numeric', ]); $data = request()->all(); @@ -112,6 +113,7 @@ class CartRuleController extends Controller * Show the form for editing the specified resource. * * @param int $id + * * @return \Illuminate\Http\Response */ public function edit($id) @@ -124,23 +126,24 @@ class CartRuleController extends Controller /** * Update the specified resource in storage. * - * @param \Illuminate\Http\Request $request - * @param int $id + * @param \Illuminate\Http\Request $request + * @param int $id + * * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { $this->validate(request(), [ - 'name' => 'required', - 'channels' => 'required|array|min:1', - 'customer_groups' => 'required|array|min:1', - 'coupon_type' => 'required', + 'name' => 'required', + 'channels' => 'required|array|min:1', + 'customer_groups' => 'required|array|min:1', + 'coupon_type' => 'required', 'use_auto_generation' => 'required_if:coupon_type,==,1', - 'coupon_code' => 'required_if:use_auto_generation,==,0', - 'starts_from' => 'nullable|date', - 'ends_till' => 'nullable|date|after_or_equal:starts_from', - 'action_type' => 'required', - 'discount_amount' => 'required|numeric' + 'coupon_code' => 'required_if:use_auto_generation,==,0', + 'starts_from' => 'nullable|date', + 'ends_till' => 'nullable|date|after_or_equal:starts_from', + 'action_type' => 'required', + 'discount_amount' => 'required|numeric', ]); $cartRule = $this->cartRuleRepository->findOrFail($id); @@ -159,7 +162,8 @@ class CartRuleController extends Controller /** * Remove the specified resource from storage. * - * @param int $id + * @param int $id + * * @return \Illuminate\Http\Response */ public function destroy($id) @@ -176,7 +180,7 @@ class CartRuleController extends Controller session()->flash('success', trans('admin::app.response.delete-success', ['name' => 'Cart Rule'])); return response()->json(['message' => true], 200); - } catch(\Exception $e) { + } catch (\Exception $e) { session()->flash('error', trans('admin::app.response.delete-failed', ['name' => 'Cart Rule'])); } @@ -191,9 +195,9 @@ class CartRuleController extends Controller public function generateCoupons() { $this->validate(request(), [ - 'coupon_qty' => 'required|integer|min:1', + 'coupon_qty' => 'required|integer|min:1', 'code_length' => 'required|integer|min:10', - 'code_format' => 'required' + 'code_format' => 'required', ]); if (! request('id')) diff --git a/packages/Webkul/CartRule/src/Repositories/CartRuleRepository.php b/packages/Webkul/CartRule/src/Repositories/CartRuleRepository.php index 80847ee67..5d15a8bf2 100755 --- a/packages/Webkul/CartRule/src/Repositories/CartRuleRepository.php +++ b/packages/Webkul/CartRule/src/Repositories/CartRuleRepository.php @@ -125,9 +125,9 @@ class CartRuleRepository extends Repository */ public function create(array $data) { - $data['starts_from'] = $data['starts_from'] ?: null; + $data['starts_from'] = isset($data['starts_from']) ? $data['starts_from'] : null; - $data['ends_till'] = $data['ends_till'] ?: null; + $data['ends_till'] = isset($data['ends_till']) ? $data['ends_till'] : null; $data['status'] = ! isset($data['status']) ? 0 : 1; From ac3a09368786422cfddd6a8fd640c957eca01765 Mon Sep 17 00:00:00 2001 From: "shubhammehrotra.symfony@webkul.com" Date: Thu, 20 Feb 2020 16:12:23 +0530 Subject: [PATCH 24/38] quick view short description issue --- .../Velocity/src/Http/Controllers/Shop/ShopController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/Webkul/Velocity/src/Http/Controllers/Shop/ShopController.php b/packages/Webkul/Velocity/src/Http/Controllers/Shop/ShopController.php index 47253f770..d87371a9d 100644 --- a/packages/Webkul/Velocity/src/Http/Controllers/Shop/ShopController.php +++ b/packages/Webkul/Velocity/src/Http/Controllers/Shop/ShopController.php @@ -228,7 +228,7 @@ use Webkul\Velocity\Repositories\Product\ProductRepository as VelocityProductRep 'slug' => $product->url_key, 'image' => $productImage, 'description' => $product->description, - 'shortDescription' => $product->meta_description, + 'shortDescription' => $product->short_description, 'galleryImages' => $galleryImages, 'priceHTML' => view('shop::products.price', ['product' => $product])->render(), 'totalReviews' => $totalReviews, From 8b5def97563b142c4139d9c736fb20f73abcdc5e Mon Sep 17 00:00:00 2001 From: Herbert Maschke Date: Thu, 20 Feb 2020 11:56:07 +0100 Subject: [PATCH 25/38] introduce CartRuleCest.php --- .env.example | 2 +- bin/test.sh | 8 ++++ tests/functional/CartRule/CartRuleCest.php | 49 ++++++++++++++++++++++ 3 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 tests/functional/CartRule/CartRuleCest.php diff --git a/.env.example b/.env.example index d09d2b8fd..e710496ca 100644 --- a/.env.example +++ b/.env.example @@ -19,7 +19,7 @@ DB_PREFIX= BROADCAST_DRIVER=log CACHE_DRIVER=file SESSION_DRIVER=file -SESSION_LIFETIME=20 +SESSION_LIFETIME=120 QUEUE_DRIVER=sync REDIS_HOST=127.0.0.1 diff --git a/bin/test.sh b/bin/test.sh index 6f82ff04a..bf7c9962d 100755 --- a/bin/test.sh +++ b/bin/test.sh @@ -15,6 +15,14 @@ printf "### start preparation ###\n" printf ">> truncate and migrate database\n" php artisan migrate:fresh --env=testing --quiet + printf ">> cleaning laravel caches ###\n" + ${WORKPATH}/../php artisan view:clear + ${WORKPATH}/../php artisan route:clear + ${WORKPATH}/../php artisan cache:clear + ${WORKPATH}/../php artisan config:clear + + printf ">> cleaning previous tests ###\n" + ${WORKPATH}/../vendor/bin/codecept clean printf "### finish preparation ###\n" printf "### start tests ###\n" diff --git a/tests/functional/CartRule/CartRuleCest.php b/tests/functional/CartRule/CartRuleCest.php new file mode 100644 index 000000000..18191ff9b --- /dev/null +++ b/tests/functional/CartRule/CartRuleCest.php @@ -0,0 +1,49 @@ +loginAsAdmin(); + + $I->amOnAdminRoute('admin.cart-rules.index'); + + // we are dealing with vue.js so we can not do classical form filling + $I->sendAjaxPostRequest(route('admin.cart-rules.store'), [ + '_token' => csrf_token(), + 'name' => 'Demo Cart Rule', + + // the following fields are important to send with the POST request: + 'starts_from' => '', + 'ends_till' => '', + + 'use_auto_generation' => 0, + 'coupon_type' => 0, // no coupon + 'action_type' => 'by_percent', + 'coupon_code' => 'coupon', + 'discount_amount' => '10', + + 'channels' => [ + 'default', + ], + + 'customer_groups' => [ + 'guest', + ], + ]); + + $cartRule = $I->grabRecord(CartRule::class, [ + 'name' => 'Demo Cart Rule', + ]); + + $I->seeResponseCodeIsSuccessful(); + + } +} From 66ba69586d39434f11d769bea29bfa097a5fc91d Mon Sep 17 00:00:00 2001 From: rahul shukla Date: Thu, 20 Feb 2020 16:31:46 +0530 Subject: [PATCH 26/38] filter issue in category --- .../Webkul/Product/src/Repositories/ProductFlatRepository.php | 2 +- .../views/products/list/layered-navigation.blade.php | 4 +++- .../views/shop/products/list/layered-navigation.blade.php | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/Webkul/Product/src/Repositories/ProductFlatRepository.php b/packages/Webkul/Product/src/Repositories/ProductFlatRepository.php index 2d2295854..85399f8a8 100644 --- a/packages/Webkul/Product/src/Repositories/ProductFlatRepository.php +++ b/packages/Webkul/Product/src/Repositories/ProductFlatRepository.php @@ -73,7 +73,7 @@ class ProductFlatRepository extends Repository public function getFilterableAttributes($category, $products) { $filterAttributes = []; - if (count($category->filterableAttributes) > 0 && count($products)) { + if (count($category->filterableAttributes) > 0 ) { $filterAttributes = $category->filterableAttributes; } else { $categoryProductAttributes = $this->getCategoryProductAttribute($category->id); diff --git a/packages/Webkul/Shop/src/Resources/views/products/list/layered-navigation.blade.php b/packages/Webkul/Shop/src/Resources/views/products/list/layered-navigation.blade.php index 6cd7262b9..f8327f68c 100755 --- a/packages/Webkul/Shop/src/Resources/views/products/list/layered-navigation.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/products/list/layered-navigation.blade.php @@ -11,7 +11,9 @@ $products = $productRepository->getAll($category->id); $filterAttributes = $productFlatRepository->getFilterableAttributes($category, $products); - } else { + } + + if (! count($filterAttributes) > 0) { $filterAttributes = $attributeRepository->getFilterAttributes(); } diff --git a/packages/Webkul/Velocity/src/Resources/views/shop/products/list/layered-navigation.blade.php b/packages/Webkul/Velocity/src/Resources/views/shop/products/list/layered-navigation.blade.php index 632bdfaaa..d73c3d012 100644 --- a/packages/Webkul/Velocity/src/Resources/views/shop/products/list/layered-navigation.blade.php +++ b/packages/Webkul/Velocity/src/Resources/views/shop/products/list/layered-navigation.blade.php @@ -9,7 +9,9 @@ $products = $productRepository->getAll($category->id); $filterAttributes = $productFlatRepository->getFilterableAttributes($category, $products); - } else { + } + + if (! count($filterAttributes) > 0) { $filterAttributes = $attributeRepository->getFilterAttributes(); } From 80724d24116e6009dbfa46799a1f0597f10b9ea4 Mon Sep 17 00:00:00 2001 From: Herbert Maschke Date: Thu, 20 Feb 2020 12:51:23 +0100 Subject: [PATCH 27/38] fix bin/test.sh --- bin/test.sh | 6 ------ 1 file changed, 6 deletions(-) diff --git a/bin/test.sh b/bin/test.sh index bf7c9962d..ef0e70d73 100755 --- a/bin/test.sh +++ b/bin/test.sh @@ -15,12 +15,6 @@ printf "### start preparation ###\n" printf ">> truncate and migrate database\n" php artisan migrate:fresh --env=testing --quiet - printf ">> cleaning laravel caches ###\n" - ${WORKPATH}/../php artisan view:clear - ${WORKPATH}/../php artisan route:clear - ${WORKPATH}/../php artisan cache:clear - ${WORKPATH}/../php artisan config:clear - printf ">> cleaning previous tests ###\n" ${WORKPATH}/../vendor/bin/codecept clean printf "### finish preparation ###\n" From f7219767edc0681d63b7ac9a93b3707daa1b7a83 Mon Sep 17 00:00:00 2001 From: Herbert Maschke Date: Thu, 20 Feb 2020 13:26:14 +0100 Subject: [PATCH 28/38] fix CartRuleRepository once more --- .../Webkul/CartRule/src/Repositories/CartRuleRepository.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/Webkul/CartRule/src/Repositories/CartRuleRepository.php b/packages/Webkul/CartRule/src/Repositories/CartRuleRepository.php index 5d15a8bf2..b7f7abd5d 100755 --- a/packages/Webkul/CartRule/src/Repositories/CartRuleRepository.php +++ b/packages/Webkul/CartRule/src/Repositories/CartRuleRepository.php @@ -125,9 +125,9 @@ class CartRuleRepository extends Repository */ public function create(array $data) { - $data['starts_from'] = isset($data['starts_from']) ? $data['starts_from'] : null; + $data['starts_from'] = isset($data['starts_from']) && $data['starts_from'] ? $data['starts_from'] : null; - $data['ends_till'] = isset($data['ends_till']) ? $data['ends_till'] : null; + $data['ends_till'] = isset($data['ends_till']) && $data['ends_till'] ? $data['ends_till'] : null; $data['status'] = ! isset($data['status']) ? 0 : 1; From 75f4d9925c58b0da1f9c2fbc6632a46ea698b9bd Mon Sep 17 00:00:00 2001 From: SteffenMahler <57138594+SteffenMahler@users.noreply.github.com> Date: Thu, 20 Feb 2020 13:58:10 +0100 Subject: [PATCH 29/38] Fire event if customer wants to "buy now" If a customer wants to buy a single product directly, the CartController add() method fires an event. The same event has to be fired via api request. In this case it's store() method. --- .../Webkul/API/Http/Controllers/Shop/CartController.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/Webkul/API/Http/Controllers/Shop/CartController.php b/packages/Webkul/API/Http/Controllers/Shop/CartController.php index 8e76ef534..a1281faef 100644 --- a/packages/Webkul/API/Http/Controllers/Shop/CartController.php +++ b/packages/Webkul/API/Http/Controllers/Shop/CartController.php @@ -98,6 +98,10 @@ class CartController extends Controller */ public function store($id) { + if (request()->get('is_buy_now')) { + Event::dispatch('shop.item.buy-now', $id); + } + Event::dispatch('checkout.cart.item.add.before', $id); $result = Cart::addProduct($id, request()->except('_token')); @@ -228,4 +232,4 @@ class CartController extends Controller 'data' => $cart ? new CartResource($cart) : null ]); } -} \ No newline at end of file +} From 9937f52de2aeb0fd2f6751d41ab9ebebe6a58974 Mon Sep 17 00:00:00 2001 From: rahul shukla Date: Thu, 20 Feb 2020 19:50:27 +0530 Subject: [PATCH 30/38] Issue #2526 --- .../Velocity/src/Resources/lang/en/app.php | 3 ++ .../views/admin/meta-info/meta-data.blade.php | 33 +++++-------------- 2 files changed, 11 insertions(+), 25 deletions(-) diff --git a/packages/Webkul/Velocity/src/Resources/lang/en/app.php b/packages/Webkul/Velocity/src/Resources/lang/en/app.php index 56629ba14..13e508239 100644 --- a/packages/Webkul/Velocity/src/Resources/lang/en/app.php +++ b/packages/Webkul/Velocity/src/Resources/lang/en/app.php @@ -108,6 +108,9 @@ return [ 'footer-middle-content' => 'Footer Middle Content', 'advertisement-four' => 'Advertisement Four Images', 'advertisement-three' => 'Advertisement Three Images', + 'images' => 'Images', + 'general' => 'General', + 'add-image-btn-title' => 'Add Image' ], 'category' => [ 'save-btn-title' => 'Save Menu', diff --git a/packages/Webkul/Velocity/src/Resources/views/admin/meta-info/meta-data.blade.php b/packages/Webkul/Velocity/src/Resources/views/admin/meta-info/meta-data.blade.php index 1f849d92f..a5f390a90 100644 --- a/packages/Webkul/Velocity/src/Resources/views/admin/meta-info/meta-data.blade.php +++ b/packages/Webkul/Velocity/src/Resources/views/admin/meta-info/meta-data.blade.php @@ -30,7 +30,7 @@
- +
@@ -106,19 +106,19 @@
- +
@if(! isset($metaData->advertisement[4])) @else @endif @@ -128,12 +128,12 @@ @if(! isset($metaData->advertisement[3])) @else @endif @@ -144,33 +144,16 @@ @if(! isset($metaData->advertisement[2])) @else @endif
- - {{--
- - - - -
--}} - - {{--
- - - - -
--}}
From 623b7893a26dedf9165341f70989be53317228db Mon Sep 17 00:00:00 2001 From: Annika Wolff <57894757+AnnikaWolff@users.noreply.github.com> Date: Thu, 20 Feb 2020 19:23:01 +0100 Subject: [PATCH 31/38] resolve merge conflicts --- packages/Webkul/Checkout/src/Cart.php | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/packages/Webkul/Checkout/src/Cart.php b/packages/Webkul/Checkout/src/Cart.php index 771845934..74e75be04 100755 --- a/packages/Webkul/Checkout/src/Cart.php +++ b/packages/Webkul/Checkout/src/Cart.php @@ -784,18 +784,17 @@ class Cart 'country' => $address->country, ])->orderBy('tax_rate', 'desc')->get(); + $item = $this->setItemTaxToZero($item); + if ($taxRates->count()) { foreach ($taxRates as $rate) { $haveTaxRate = false; if ($rate->state != '' && $rate->state != $address->state) { - $this->setItemTaxToZero($item); - continue; } - - if (! $rate->is_zip) { - if ($rate->zip_code == '*' || $rate->zip_code == $address->postcode) + if (!$rate->is_zip) { + if ($rate->zip_code == '*' || $rate->zip_code == $address->postcode) { $haveTaxRate = true; } } else { @@ -808,15 +807,9 @@ class Cart $item->tax_amount = ($item->total * $rate->tax_rate) / 100; $item->base_tax_amount = ($item->base_total * $rate->tax_rate) / 100; - break; - } else { - $this->setItemTaxToZero($item); - break; } } - } else { - $this->setItemTaxToZero($item); } $item->save(); @@ -826,14 +819,15 @@ class Cart /** * Set Item tax to zero. * - * @return void + * @param CartItem $item + * @return CartItem */ protected function setItemTaxToZero($item) { $item->tax_percent = 0; $item->tax_amount = 0; $item->base_tax_amount = 0; - - $item->save(); + + return $item; } /** @@ -1113,4 +1107,4 @@ class Cart return $this; } -} \ No newline at end of file +} From c87562622b25fd706d6a7b49990020f2c2dddcb4 Mon Sep 17 00:00:00 2001 From: rahul shukla Date: Fri, 21 Feb 2020 10:53:59 +0530 Subject: [PATCH 32/38] cart product quantitiy for bundle product in velocity and change log updated --- CHANGELOG for v1.x.x.md | 4 ++++ .../shop/products/view/bundle-options.blade.php | 12 +++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CHANGELOG for v1.x.x.md b/CHANGELOG for v1.x.x.md index 2ee680429..6922aca54 100644 --- a/CHANGELOG for v1.x.x.md +++ b/CHANGELOG for v1.x.x.md @@ -78,6 +78,10 @@ * #2500 [fixed] - Database reset fails. +* #2519 [fixed] - filter price attribute throwing an exception. + +* #2526 [fixed] - Velocity backend route is not accessible in arabic locale. + ## **v1.0.0-BETA1(5th of February 2020)** - *Release* * [feature] Updated to laravel version 6. diff --git a/packages/Webkul/Velocity/src/Resources/views/shop/products/view/bundle-options.blade.php b/packages/Webkul/Velocity/src/Resources/views/shop/products/view/bundle-options.blade.php index 4dc76b617..1dfefed08 100644 --- a/packages/Webkul/Velocity/src/Resources/views/shop/products/view/bundle-options.blade.php +++ b/packages/Webkul/Velocity/src/Resources/views/shop/products/view/bundle-options.blade.php @@ -202,9 +202,15 @@ computed: { product_qty: function() { - return this.option.products[this.selected_product] - ? this.option.products[this.selected_product].qty - : 0; + var self = this; + self.qty = 0; + + self.option.products.forEach(function(product, key){ + if (self.selected_product == product.id) + self.qty = self.option.products[key].qty; + }); + + return self.qty; } }, From 5ad6afd2986d2749d235df451c3f5a8710b46a87 Mon Sep 17 00:00:00 2001 From: rahul shukla Date: Fri, 21 Feb 2020 11:58:33 +0530 Subject: [PATCH 33/38] change log updated --- CHANGELOG for v1.x.x.md | 2 +- .../views/shop/checkout/total/summary.blade.php | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG for v1.x.x.md b/CHANGELOG for v1.x.x.md index 6922aca54..37faf0772 100644 --- a/CHANGELOG for v1.x.x.md +++ b/CHANGELOG for v1.x.x.md @@ -2,7 +2,7 @@ #### This changelog consists the bug & security fixes and new features being included in the releases listed below. -## **v1.0.0-BETA2(20th of February 2020)** - *Release* +## **v1.0.0 (21st of February 2020)** - *Release* * #2377 [fixed] - Getting exception on creating a new category under any other category. diff --git a/packages/Webkul/Velocity/src/Resources/views/shop/checkout/total/summary.blade.php b/packages/Webkul/Velocity/src/Resources/views/shop/checkout/total/summary.blade.php index 5bdab75b6..558bef89f 100644 --- a/packages/Webkul/Velocity/src/Resources/views/shop/checkout/total/summary.blade.php +++ b/packages/Webkul/Velocity/src/Resources/views/shop/checkout/total/summary.blade.php @@ -20,6 +20,15 @@
@endif + {{-- @if ($cart->base_tax_total) + @foreach (Webkul\Tax\Helpers\Tax::getTaxRatesWithAmount($cart, true) as $taxRate => $baseTaxAmount ) +
+ {{ __('shop::app.checkout.total.tax') }} {{ $taxRate }} % + {{ core()->currency($baseTaxAmount) }} +
+ @endforeach + @endif --}} + @if ( $cart->base_discount_amount && $cart->base_discount_amount > 0 From d50510a626732bf890edff1b33b16e6ba2ed30d3 Mon Sep 17 00:00:00 2001 From: Annika Wolff Date: Fri, 21 Feb 2020 08:36:52 +0100 Subject: [PATCH 34/38] resolve merge issue, add type hints in Cart helper function --- packages/Webkul/Checkout/src/Cart.php | 6 +- .../views/emails/sales/new-invoice.blade.php | 66 ++++++++++--------- 2 files changed, 38 insertions(+), 34 deletions(-) diff --git a/packages/Webkul/Checkout/src/Cart.php b/packages/Webkul/Checkout/src/Cart.php index 74e75be04..7b125b01a 100755 --- a/packages/Webkul/Checkout/src/Cart.php +++ b/packages/Webkul/Checkout/src/Cart.php @@ -785,7 +785,7 @@ class Cart ])->orderBy('tax_rate', 'desc')->get(); $item = $this->setItemTaxToZero($item); - + if ($taxRates->count()) { foreach ($taxRates as $rate) { $haveTaxRate = false; @@ -822,11 +822,11 @@ class Cart * @param CartItem $item * @return CartItem */ - protected function setItemTaxToZero($item) { + protected function setItemTaxToZero(CartItem $item): CartItem { $item->tax_percent = 0; $item->tax_amount = 0; $item->base_tax_amount = 0; - + return $item; } diff --git a/packages/Webkul/Shop/src/Resources/views/emails/sales/new-invoice.blade.php b/packages/Webkul/Shop/src/Resources/views/emails/sales/new-invoice.blade.php index 32a35705f..5c24a70fd 100755 --- a/packages/Webkul/Shop/src/Resources/views/emails/sales/new-invoice.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/emails/sales/new-invoice.blade.php @@ -30,7 +30,8 @@ {{ __('shop::app.mail.invoice.summary') }}
-
+
@if ($order->shipping_address)
@@ -103,37 +104,41 @@ - - - - - + + + + + - @foreach ($invoice->items as $item) - - + + + @endif + - + - - + + - @endforeach + @endforeach
{{ __('shop::app.customer.account.order.view.product-name') }}{{ __('shop::app.customer.account.order.view.price') }}{{ __('shop::app.customer.account.order.view.qty') }}
{{ __('shop::app.customer.account.order.view.product-name') }}{{ __('shop::app.customer.account.order.view.price') }}{{ __('shop::app.customer.account.order.view.qty') }}
- {{ $item->name }} + @foreach ($invoice->items as $item) +
+ {{ $item->name }} - @if (isset($item->additional['attributes'])) -
+ @if (isset($item->additional['attributes'])) +
- @foreach ($item->additional['attributes'] as $attribute) - {{ $attribute['attribute_name'] }} : {{ $attribute['option_label'] }}
- @endforeach + @foreach ($item->additional['attributes'] as $attribute) + {{ $attribute['attribute_name'] }} + : {{ $attribute['option_label'] }}
+ @endforeach -
- @endif -
{{ core()->formatPrice($item->price, $order->order_currency_code) }} - {{ core()->formatPrice($item->price, $order->order_currency_code) }} + {{ $item->qty }}
{{ $item->qty }}
@@ -156,14 +161,12 @@
@endif - @foreach (Webkul\Tax\Helpers\Tax::getTaxRatesWithAmount($refund, false) as $taxRate => $taxAmount) -
- {{ __('shop::app.mail.order.tax') }} {{ $taxRate }} % - - {{ core()->formatPrice($taxAmount, $order->order_currency_code) }} +
+ {{ __('shop::app.mail.order.tax') }} + + {{ core()->formatPrice($invoice->tax_amount, $order->order_currency_code) }} -
- @endforeach +
@if ($invoice->discount_amount > 0)
@@ -182,7 +185,8 @@
-
+

{!! __('shop::app.mail.order.help', [ From a4b3316b29b99dde3decefc961c2173758ac629d Mon Sep 17 00:00:00 2001 From: rahul shukla Date: Fri, 21 Feb 2020 14:41:42 +0530 Subject: [PATCH 35/38] Issue #2533 fixed and change log updated --- CHANGELOG for v1.x.x.md | 2 ++ .../emails/sales/new-inventorysource-shipment.blade.php | 6 +++--- .../src/Resources/views/emails/sales/new-shipment.blade.php | 6 +++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/CHANGELOG for v1.x.x.md b/CHANGELOG for v1.x.x.md index 37faf0772..da36aba04 100644 --- a/CHANGELOG for v1.x.x.md +++ b/CHANGELOG for v1.x.x.md @@ -82,6 +82,8 @@ * #2526 [fixed] - Velocity backend route is not accessible in arabic locale. +* #2533 [fixed] - Shipment email notification is not sending to customer + ## **v1.0.0-BETA1(5th of February 2020)** - *Release* * [feature] Updated to laravel version 6. diff --git a/packages/Webkul/Shop/src/Resources/views/emails/sales/new-inventorysource-shipment.blade.php b/packages/Webkul/Shop/src/Resources/views/emails/sales/new-inventorysource-shipment.blade.php index 889124a65..3564b7bfd 100644 --- a/packages/Webkul/Shop/src/Resources/views/emails/sales/new-inventorysource-shipment.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/emails/sales/new-inventorysource-shipment.blade.php @@ -125,14 +125,14 @@ @foreach ($shipment->items as $item) - {{ $item->getTypeInstance()->getOrderedItem($item)->sku }} + {{ $item->sku }} {{ $item->name }} - + @if (isset($item->additional['attributes']))

- + @foreach ($item->additional['attributes'] as $attribute) {{ $attribute['attribute_name'] }} : {{ $attribute['option_label'] }}
@endforeach diff --git a/packages/Webkul/Shop/src/Resources/views/emails/sales/new-shipment.blade.php b/packages/Webkul/Shop/src/Resources/views/emails/sales/new-shipment.blade.php index b8d8f946e..d5fabb734 100755 --- a/packages/Webkul/Shop/src/Resources/views/emails/sales/new-shipment.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/emails/sales/new-shipment.blade.php @@ -122,14 +122,14 @@ @foreach ($shipment->items as $item) - {{ $item->getTypeInstance()->getOrderedItem($item)->sku }} + {{ $item->sku }} {{ $item->name }} - + @if (isset($item->additional['attributes']))
- + @foreach ($item->additional['attributes'] as $attribute) {{ $attribute['attribute_name'] }} : {{ $attribute['option_label'] }}
@endforeach From 78e50e4e6be5b6ad0f9b3cf4abe584da32b407b2 Mon Sep 17 00:00:00 2001 From: rahul shukla Date: Fri, 21 Feb 2020 15:38:42 +0530 Subject: [PATCH 36/38] tax in velocity theme --- .../views/shop/checkout/total/summary.blade.php | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/packages/Webkul/Velocity/src/Resources/views/shop/checkout/total/summary.blade.php b/packages/Webkul/Velocity/src/Resources/views/shop/checkout/total/summary.blade.php index 558bef89f..8332803e8 100644 --- a/packages/Webkul/Velocity/src/Resources/views/shop/checkout/total/summary.blade.php +++ b/packages/Webkul/Velocity/src/Resources/views/shop/checkout/total/summary.blade.php @@ -14,20 +14,13 @@ @endif @if ($cart->base_tax_total) -
- {{ __('shop::app.checkout.total.tax') }} - {{ core()->currency($cart->base_tax_total) }} -
- @endif - - {{-- @if ($cart->base_tax_total) @foreach (Webkul\Tax\Helpers\Tax::getTaxRatesWithAmount($cart, true) as $taxRate => $baseTaxAmount )
{{ __('shop::app.checkout.total.tax') }} {{ $taxRate }} % {{ core()->currency($baseTaxAmount) }}
@endforeach - @endif --}} + @endif @if ( $cart->base_discount_amount From 253ac52cc1074ada20e85b3606ca5e4fed55bcf5 Mon Sep 17 00:00:00 2001 From: rahul shukla Date: Fri, 21 Feb 2020 16:56:57 +0530 Subject: [PATCH 37/38] post code in shipping address --- .../Resources/views/checkout/onepage/customer-info.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/Webkul/Shop/src/Resources/views/checkout/onepage/customer-info.blade.php b/packages/Webkul/Shop/src/Resources/views/checkout/onepage/customer-info.blade.php index 613317177..5214f57c0 100755 --- a/packages/Webkul/Shop/src/Resources/views/checkout/onepage/customer-info.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/checkout/onepage/customer-info.blade.php @@ -286,7 +286,7 @@
  • - @{{ addresses.country }}. + @{{ addresses.country }} @{{ addresses.postcode }}
  • From 30cb18c1f50546cde363dee930241bd80994ec27 Mon Sep 17 00:00:00 2001 From: rahul shukla Date: Fri, 21 Feb 2020 17:45:47 +0530 Subject: [PATCH 38/38] Issue #2538 fixed and change log updated --- CHANGELOG for v1.x.x.md | 4 +++- .../src/Resources/views/shop/checkout/onepage.blade.php | 8 +++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG for v1.x.x.md b/CHANGELOG for v1.x.x.md index da36aba04..cf0d34e8d 100644 --- a/CHANGELOG for v1.x.x.md +++ b/CHANGELOG for v1.x.x.md @@ -82,7 +82,9 @@ * #2526 [fixed] - Velocity backend route is not accessible in arabic locale. -* #2533 [fixed] - Shipment email notification is not sending to customer +* #2533 [fixed] - Shipment email notification is not sending to customer. + +* #2538 [fixed] - unable to place order for virtual & downloadable product. ## **v1.0.0-BETA1(5th of February 2020)** - *Release* diff --git a/packages/Webkul/Velocity/src/Resources/views/shop/checkout/onepage.blade.php b/packages/Webkul/Velocity/src/Resources/views/shop/checkout/onepage.blade.php index 184323563..70383855c 100644 --- a/packages/Webkul/Velocity/src/Resources/views/shop/checkout/onepage.blade.php +++ b/packages/Webkul/Velocity/src/Resources/views/shop/checkout/onepage.blade.php @@ -218,9 +218,11 @@ break; case 'shipping-form': - document.body.style.cursor = 'wait'; - this.saveShipping(); - break; + if (this.showShippingSection) { + document.body.style.cursor = 'wait'; + this.saveShipping(); + break; + } case 'payment-form': document.body.style.cursor = 'wait';