Categories, Netto Homeparty

This commit is contained in:
Kevin Adametz 2021-06-18 15:02:34 +02:00
parent 7d1ee844eb
commit 351a8f763c
13 changed files with 144 additions and 64 deletions

View file

@ -26,6 +26,8 @@ class HomepartyCart
public static $price = 0;
public static $price_net = 0;
public static $ek_price = 0;
public static $ek_price_net = 0;
public static $income_price = 0;
private static $shipping_total = 0;
@ -52,14 +54,14 @@ class HomepartyCart
private static $bonus_coupon_fault = 0;
private static $bonus_coupon_next_step = 0;
private static $bonus_coupon_next_value = 0;
private static $bonus_start = 200;
private static $bonus_start = 230;
private static $bonusTable = [
250 => 15,
300 => 20,
400 => 30,
500 => 35,
600 => 40,
700 => 50,
295 => 15,
350 => 20,
460 => 30,
565 => 35,
670 => 40,
780 => 50,
];
public static function calculateHomeparty(Homeparty $homeparty){
@ -82,6 +84,7 @@ class HomepartyCart
self::$price += $homepartyUserCart->price;
self::$price_net += $homepartyUserCart->price_net;
self::$ek_price += $homepartyUserCart->ek_price;
self::$ek_price_net += $homepartyUserCart->ek_price_net;
self::$income_price += $homepartyUserCart->income_price;
}
@ -98,8 +101,9 @@ class HomepartyCart
self::$voucher_price = $proportional_voucher->price;
self::$voucher_name = $proportional_voucher->getLang('name');
self::$price += self::$voucher_price;
self::$price_net += $proportional_voucher->getPriceWith(true, false);
//add voucher to ek
self::$ek_price += self::$voucher_price;
self::$ek_price_net += $proportional_voucher->getPriceWith(true, false);
$bonus_tmp = self::$price - self::$bonus_value;
@ -145,12 +149,16 @@ class HomepartyCart
self::$bonus_points_diff = round($user_cart->points/100*$bonus_percent);
$user_cart->points -= self::$bonus_points_diff;
$user_cart->price -= $bonus_total;
//sub bonus on host
$user_cart->price -= $bonus_total;
$user_cart->price_net -= ($bonus_total / config('app.main_tax'));
$user_cart->ek_price -= $bonus_total;
$user_cart->ek_price_net -= ($bonus_total / config('app.main_tax'));
self::$price -= $bonus_total;
self::$price_net -= ($bonus_total / config('app.main_tax'));
self::$ek_price -= $bonus_total;
self::$ek_price_net -= ($bonus_total / config('app.main_tax'));
}
}
@ -207,11 +215,25 @@ class HomepartyCart
$user_cart->shipping_tax = round($price / (100+$shipping_price->tax_rate) * 100, 2);
}
//on the end, add prices for porto
$user_cart->price += $user_cart->shipping_price;
$user_cart->price_net += $user_cart->shipping_price_net;
self::$price += $user_cart->shipping_price;
self::$price_net += $user_cart->shipping_price_net;
if($homeparty_user->is_host){
//on the end, add prices for porto
//$user_cart->price += $user_cart->shipping_price;
//$user_cart->price_net += $user_cart->shipping_price_net;
}else{
//on the end, add prices for porto
$user_cart->price += $user_cart->shipping_price;
$user_cart->price_net += $user_cart->shipping_price_net;
self::$price += $user_cart->shipping_price;
self::$price_net += $user_cart->shipping_price_net;
}
$user_cart->ek_price += $user_cart->shipping_price;
$user_cart->ek_price_net += $user_cart->shipping_price_net;
self::$ek_price += $user_cart->shipping_price;
self::$ek_price_net += $user_cart->shipping_price_net;
self::$shipping_total += $user_cart->shipping_price;
self::$shipping_net_total += $user_cart->shipping_price_net;
@ -240,6 +262,7 @@ class HomepartyCart
'price' => round(self::$price, 2),
'price_net' => round(self::$price_net, 2),
'ek_price' => round(self::$ek_price, 2),
'ek_price_net' => round(self::$ek_price_net, 2),
'income_price' => round(self::$income_price, 2),
'user_host_id' => self::$user_host_id,
'is_bonus' => self::$is_bonus,
@ -263,6 +286,7 @@ class HomepartyCart
'price' => round($user_cart->price, 2),
'price_net' => round($user_cart->price_net, 2),
'ek_price' => round($user_cart->ek_price, 2),
'ek_price_net' => round($user_cart->ek_price_net, 2),
'income_price' => round($user_cart->income_price, 2),
'weight' => $user_cart->weight,
'shipping_weight' => $user_cart->shipping_weight,
@ -302,6 +326,11 @@ class HomepartyCart
return formatNumber(self::$ek_price);
}
public static function getFormattedEkPriceNet()
{
return formatNumber(self::$ek_price_net);
}
public static function getFormattedIncomePrice()
{
return formatNumber(self::$income_price);
@ -310,6 +339,9 @@ class HomepartyCart
public static function getFormattedPriceTax(){
return formatNumber(self::$price - self::$price_net);
}
public static function getFormattedEkPriceTax(){
return formatNumber(self::$ek_price - self::$ek_price_net);
}
public static function getFormattedBonusPrice()
{
return formatNumber(self::$voucher_price);

View file

@ -30,6 +30,8 @@ class HomepartyUserCart
public $price;
public $price_net;
public $ek_price;
public $ek_price_net;
public $income_price;
public $weight;
@ -53,6 +55,8 @@ class HomepartyUserCart
$this->price = 0;
$this->price_net = 0;
$this->ek_price = 0;
$this->ek_price_net = 0;
$this->income_price = 0;
$this->weight = 0;
$this->shipping_weight = 0;
@ -70,6 +74,7 @@ class HomepartyUserCart
$this->price += $order_item->getTotalPrice();
$this->price_net += $order_item->geTotalPriceNet();
$this->ek_price += $order_item->geTotalEKPrice();
$this->ek_price_net += $order_item->geTotalEKPriceNet();
$this->income_price += $order_item->geTotalIncomePrice();
$this->weight += ($order_item->product->weight * $order_item->qty);
}