commit 2bdbfaec541c3d51489f32e0fa6f7523ca4e4f6f
Author: Olivier Legat <olivier.legat@ldc.fr>
Date: Thu Apr 8 15:48:13 2021 +0200
arrondis de taxe dans le panier
commit ce748bcac15a0b633cacc06b8232cbb92a8e455c
Author: Olivier Legat <olivier.legat@ldc.fr>
Date: Thu Apr 8 11:53:54 2021 +0200
Prix calcules - affichés
commit cc79e7c633d81290371eceabe9864d4d0ee9e4a5
Author: Olivier Legat <olivier.legat@ldc.fr>
Date: Wed Apr 7 18:09:12 2021 +0200
Affichage des promowork in progress => prix remisés
commit 8545d1079da2456f090557eeef005e4d37154a1e
Author: Olivier Legat <olivier.legat@ldc.fr>
Date: Wed Apr 7 13:04:28 2021 +0200
resource BO Promotions
commit d7145835de675da32e57bec3f0b8f06e1e447b27
Author: Olivier Legat <olivier.legat@ldc.fr>
Date: Tue Apr 6 18:23:36 2021 +0200
structure DB, debut BO
42 lines
1.8 KiB
PHP
42 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Lib\LDC;
|
|
|
|
use Gloudemans\Shoppingcart\CartItem;
|
|
use Gloudemans\Shoppingcart\Contracts\Calculator;
|
|
|
|
class CartCalculator implements Calculator
|
|
{
|
|
public static function getAttribute(string $attribute, CartItem $cartItem)
|
|
{
|
|
$decimals = config('cart.format.decimals', 2);
|
|
|
|
switch ($attribute) {
|
|
case 'discount':
|
|
return $cartItem->price * ($cartItem->getDiscountRate() / 100);
|
|
case 'tax':
|
|
return round($cartItem->priceTarget * ($cartItem->taxRate / 100), $decimals);
|
|
case 'priceTax':
|
|
return round($cartItem->priceTarget + $cartItem->tax, $decimals);
|
|
case 'discountTotal':
|
|
return round($cartItem->discount * $cartItem->qty, $decimals);
|
|
case 'priceTotal':
|
|
return round($cartItem->price * $cartItem->qty, $decimals);
|
|
case 'subtotal':
|
|
return max(round($cartItem->priceTotal - $cartItem->discountTotal, $decimals), 0);
|
|
case 'priceTarget':
|
|
return round(($cartItem->priceTotal - $cartItem->discountTotal) / $cartItem->qty, $decimals);
|
|
case 'taxTotal':
|
|
//taxe pour un item multiplié par la quantité
|
|
$unit_price = max($cartItem->price - $cartItem->discount,0);
|
|
$unit_tax = round($unit_price * ($cartItem->taxRate / 100), $decimals);
|
|
$taxTotal = round($unit_tax * $cartItem->qty, $decimals);
|
|
//return round($cartItem->subtotal * ($cartItem->taxRate / 100), $decimals);
|
|
return $taxTotal;
|
|
case 'total':
|
|
return round($cartItem->subtotal + $cartItem->taxTotal, $decimals);
|
|
default:
|
|
return;
|
|
}
|
|
}
|
|
}
|