From da08e9ff3720a4d0f7a48f040696efef5ac03f2a Mon Sep 17 00:00:00 2001
From: Kevin Adametz
Date: Wed, 1 Jul 2020 13:21:35 +0200
Subject: [PATCH] MwSt
---
.idea/workspace.xml | 43 +--
.../Api/ShoppingUserController.php | 29 +-
app/Http/Controllers/Web/CardController.php | 6 +-
.../Controllers/Web/CheckoutController.php | 8 +-
app/Models/Product.php | 2 +-
app/Models/ShoppingOrder.php | 2 +-
app/Models/ShoppingOrderItem.php | 1 +
app/Services/Yard.php | 16 +-
public/wartung.html | 314 ++++++++++++++++++
.../views/emails/checkout_status.blade.php | 2 +-
resources/views/web/templates/card.blade.php | 7 +-
.../views/web/templates/checkout.blade.php | 2 +-
.../web/templates/produkte-show.blade.php | 2 +-
13 files changed, 378 insertions(+), 56 deletions(-)
create mode 100644 public/wartung.html
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 49f8ee3..68d84af 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,8 +4,16 @@
+
+
-
+
+
+
+
+
+
+
@@ -474,6 +482,10 @@
+
+
+
+
@@ -506,14 +518,6 @@
-
-
-
-
-
-
-
-
@@ -524,18 +528,10 @@
-
-
-
-
-
-
-
-
@@ -545,18 +541,18 @@
-
+
-
+
-
+
-
+
@@ -567,11 +563,6 @@
15
-
- file://$PROJECT_DIR$/resources/views/web/templates/card.blade.php
- 135
-
-
file://$PROJECT_DIR$/resources/views/emails/checkout.blade.php
360
diff --git a/app/Http/Controllers/Api/ShoppingUserController.php b/app/Http/Controllers/Api/ShoppingUserController.php
index 64ce2a6..686372d 100755
--- a/app/Http/Controllers/Api/ShoppingUserController.php
+++ b/app/Http/Controllers/Api/ShoppingUserController.php
@@ -56,13 +56,14 @@ class ShoppingUserController extends Controller
], 400);
}
$status = [];
+ //TODO Status
foreach ($wp_order_numbers as $wp_order_number){
$shopping_user = ShoppingUser::where('wp_order_number', '=', $wp_order_number)->first();
$status[] = [
'wp_order_number' => $wp_order_number,
'user' => $shopping_user ? true : false,
'order' => ($shopping_user && $shopping_user->shopping_order) ? true : false,
- 'status' => 'open | sent | ...',
+ 'status' => 'free',
];
}
return response()->json([
@@ -109,13 +110,15 @@ class ShoppingUserController extends Controller
$user = $this->prepareForShow($shopping_user);
$order = $this->prepareForShowOrder($shopping_user->shopping_order);
}
+ //TODO Status
+
$data[] = [
'wp_order_number' => $wp_order_number,
'user' => $user,
'order' => $order,
'customer_number' => $shopping_user ? $shopping_user->number : false,
'member_email' => ($shopping_user && $shopping_user->member) ? $shopping_user->member->email : false,
- 'status' => 'open | sent | ...',
+ 'status' => 'free',
];
}
return response()->json([
@@ -195,7 +198,7 @@ class ShoppingUserController extends Controller
$priority = CustomerPriority::checkChangeOne($shopping_user, $data, true);
$updated = $shopping_user->fill($data)->save();
\App\Services\Shop::newUserOrder($shopping_user->number);
-
+ //TODO Status
if ($updated){
$user = $this->prepareForShow($shopping_user);
$order = $this->prepareForShowOrder($shopping_user->shopping_order);
@@ -208,7 +211,7 @@ class ShoppingUserController extends Controller
'customer_priority' => $priority,
'customer_number' => $shopping_user ? $shopping_user->number : false,
'member_email' => ($shopping_user && $shopping_user->member) ? $shopping_user->member->email : false,
- 'status' => 'open | sent | ...',
+ 'status' => 'free',
],
'time' => Carbon::now()->toDateTimeString()
], 200);
@@ -249,6 +252,7 @@ class ShoppingUserController extends Controller
$wp_order = $request->wp_order;
}
$wp_order = $this->prepareOrder($wp_order, $shopping_user);
+ //TODO Status
if ($wp_order){
$user = $this->prepareForShow($shopping_user);
$order = $this->prepareForShowOrder($shopping_user->shopping_order);
@@ -261,6 +265,7 @@ class ShoppingUserController extends Controller
'order' => $order,
'customer_number' => $shopping_user->number,
'member_email' => $shopping_user->member->email,
+ 'status' => 'free',
],
'time' => Carbon::now()->toDateTimeString()
], 200);
@@ -291,6 +296,8 @@ class ShoppingUserController extends Controller
}
$shopping_order->delete();
}
+ $shopping_user->wp_order_number = time();
+ $shopping_user->save();
if ($shopping_user->delete()) {
return response()->json([
'success' => true
@@ -368,7 +375,7 @@ class ShoppingUserController extends Controller
//$salutation = array(1 => 'mr', 2 => 'ms', 3=>null);
$ret = [];
- $needs = [ 'billing_salutation', 'billing_company', 'billing_firstname', 'billing_lastname', 'billing_address', 'billing_address_2', 'billing_zipcode', 'billing_city', 'billing_phone', 'billing_email',
+ $needs = [ 'billing_salutation', 'billing_company', 'billing_firstname', 'billing_lastname', 'billing_address', 'billing_address_2', 'billing_zipcode', 'billing_city', 'billing_phone', 'billing_email', 'same_as_billing',
'shipping_salutation', 'shipping_company', 'shipping_firstname', 'shipping_lastname', 'shipping_address', 'shipping_address_2', 'shipping_zipcode', 'shipping_city', 'shipping_phone'];
foreach ($data as $key=>$value){
@@ -404,7 +411,7 @@ class ShoppingUserController extends Controller
$ret = [];
$needs = [ 'billing_salutation', 'billing_company', 'billing_firstname', 'billing_lastname', 'billing_address', 'billing_address_2', 'billing_zipcode', 'billing_city', 'billing_country_id', 'billing_phone', 'billing_email',
'shipping_salutation', 'shipping_company', 'shipping_firstname', 'shipping_lastname', 'shipping_address', 'shipping_address_2', 'shipping_zipcode', 'shipping_city', 'shipping_country_id', 'shipping_phone',
- //'same_as_billing', 'has_buyed', 'subscribed',
+ 'same_as_billing', //'has_buyed', 'subscribed',
'wp_order_number', 'wp_order_date'];
foreach ($needs as $need){
@@ -432,10 +439,10 @@ class ShoppingUserController extends Controller
if ($need === 'wp_order_date') {
$ret['wp_order_date'] = Carbon::parse($ret['wp_order_date'])->toDateTimeString();
}
-
-
+ if ($need === 'same_as_billing') {
+ $ret['same_as_billing'] = isset($data['same_as_billing']) ? $data['same_as_billing'] : true;
+ }
}
- $ret['same_as_billing'] = $ret['shipping_lastname'] !== null ? true : false;
$ret['has_buyed'] = true;
$ret['subscribed'] = false;
return $ret;
@@ -490,7 +497,7 @@ class ShoppingUserController extends Controller
'total' => Yard::instance('shopping')->total(2, '.', ''),
'shipping' => Yard::instance('shopping')->shipping(2, '.', ','),
'subtotal' => Yard::instance('shopping')->subtotalWithShipping(2, '.', ''),
- 'tax_rate' => Yard::getTaxRate(),
+ //'tax_rate' => Yard::getTaxRate(),
'tax' => Yard::instance('shopping')->taxWithShipping(2, '.', ''),
'total_shipping' => Yard::instance('shopping')->totalWithShipping(2, '.', ''),
'weight' => Yard::instance('shopping')->weight(),
@@ -516,6 +523,7 @@ class ShoppingUserController extends Controller
'product_id' => $item->id,
'qty' => $item->qty,
'price' => $item->price,
+ 'tax_rate' => $item->taxRate,
'slug' => $item->options->slug,
])->save();
return false;
@@ -533,6 +541,7 @@ class ShoppingUserController extends Controller
'product_id' => $item->id,
'qty' => $item->qty,
'price' => $item->price,
+ 'tax_rate' => $item->taxRate,
'slug' => $item->options->slug
]);
}
diff --git a/app/Http/Controllers/Web/CardController.php b/app/Http/Controllers/Web/CardController.php
index 84218b7..c945f08 100755
--- a/app/Http/Controllers/Web/CardController.php
+++ b/app/Http/Controllers/Web/CardController.php
@@ -32,7 +32,8 @@ class CardController extends Controller
if($product->images->count()){
$image = $product->images->first()->slug;
}
- Yard::instance('shopping')->add($product->id, $product->getLang('name'), $quantity, $product->price, ['image' => $image, 'slug' => $product_slug, 'weight' => $product->weight]);
+ $cartItem = Yard::instance('shopping')->add($product->id, $product->getLang('name'), $quantity, $product->price, ['image' => $image, 'slug' => $product_slug, 'weight' => $product->weight]);
+ Yard::setTax($cartItem->rowId, $product->tax);
Yard::instance('shopping')->reCalculateShippingPrice();
\Session()->flash('show-card-after-add', true);
@@ -53,7 +54,8 @@ class CardController extends Controller
$image = $product->images->first()->slug;
}
$quantity = Request::get('quantity') ? Request::get('quantity') : 1;
- Yard::instance('shopping')->add($product->id, $product->getLang('name'), $quantity, $product->price, ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight]);
+ $cartItem = Yard::instance('shopping')->add($product->id, $product->getLang('name'), $quantity, $product->price, ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight]);
+ Yard::setTax($cartItem->rowId, $product->tax);
Yard::instance('shopping')->reCalculateShippingPrice();
\Session()->flash('show-card-after-add', true);
diff --git a/app/Http/Controllers/Web/CheckoutController.php b/app/Http/Controllers/Web/CheckoutController.php
index 49f15cd..cf44410 100755
--- a/app/Http/Controllers/Web/CheckoutController.php
+++ b/app/Http/Controllers/Web/CheckoutController.php
@@ -168,7 +168,7 @@ class CheckoutController extends Controller
if(Request::get('payment_method') === 'elv' && is_null(Request::get('mandate_identification'))){
$pay = new PayoneController();
$pay->init($shopping_user, $shopping_order);
- $amount = (int) (float) Yard::instance('shopping')->totalWithShipping(2, '.', '') *100;
+ $amount = Yard::instance('shopping')->totalWithShipping(2, '.', '') * 100;
$ret['elv'] = $pay->checkBankAccount($data, $amount, 'EUR', $shopping_user);
if($ret['elv']['status'] === 'ERROR' || $ret['elv']['status'] === 'INVALID'){
@@ -214,7 +214,7 @@ class CheckoutController extends Controller
//other
$pay = new PayoneController();
$pay->init($shopping_user, $shopping_order);
- $amount = (int) (float) Yard::instance('shopping')->totalWithShipping(2, '.', '') * 100;
+ $amount = Yard::instance('shopping')->totalWithShipping(2, '.', '') * 100;
$reference = $pay->setPrePayment(Request::get('payment_method'), $amount, 'EUR', $ret);
$this->putPayments('payment_reference', $reference);
$pay->setPersonalData();
@@ -333,7 +333,7 @@ class CheckoutController extends Controller
'total' => Yard::instance('shopping')->total(2, '.', ''),
'shipping' => Yard::instance('shopping')->shipping(2, '.', ','),
'subtotal' => Yard::instance('shopping')->subtotalWithShipping(2, '.', ''),
- 'tax_rate' => Yard::getTaxRate(),
+ //'tax_rate' => Yard::getTaxRate(),
'tax' => Yard::instance('shopping')->taxWithShipping(2, '.', ''),
'total_shipping' => Yard::instance('shopping')->totalWithShipping(2, '.', ''),
'weight' => Yard::instance('shopping')->weight(),
@@ -364,6 +364,7 @@ class CheckoutController extends Controller
'product_id' => $item->id,
'qty' => $item->qty,
'price' => $item->price,
+ 'tax_rate' => $item->taxRate,
'slug' => $item->options->slug,
])->save();
return false;
@@ -380,6 +381,7 @@ class CheckoutController extends Controller
'product_id' => $item->id,
'qty' => $item->qty,
'price' => $item->price,
+ 'tax_rate' => $item->taxRate,
'slug' => $item->options->slug
]);
};
diff --git a/app/Models/Product.php b/app/Models/Product.php
index 26ba2a9..4c69c0c 100644
--- a/app/Models/Product.php
+++ b/app/Models/Product.php
@@ -263,7 +263,7 @@ class Product extends Model
public function getFormattedTax()
{
- return isset($this->attributes['tax']) ? Util::formatNumber($this->attributes['tax']) : "";
+ return isset($this->attributes['tax']) ? Util::formatNumber($this->attributes['tax'], 0) : "";
}
public function getFormattedPriceOld()
diff --git a/app/Models/ShoppingOrder.php b/app/Models/ShoppingOrder.php
index 59889d4..908d026 100644
--- a/app/Models/ShoppingOrder.php
+++ b/app/Models/ShoppingOrder.php
@@ -84,7 +84,7 @@ class ShoppingOrder extends Model
'total',
'shipping',
'subtotal',
- 'tax_rate',
+ //'tax_rate',
'tax',
'total_shipping',
'weight',
diff --git a/app/Models/ShoppingOrderItem.php b/app/Models/ShoppingOrderItem.php
index 4adc4e4..a7209ed 100644
--- a/app/Models/ShoppingOrderItem.php
+++ b/app/Models/ShoppingOrderItem.php
@@ -46,6 +46,7 @@ class ShoppingOrderItem extends Model
'product_id',
'qty',
'price',
+ 'tax_rate',
'slug',
];
diff --git a/app/Services/Yard.php b/app/Services/Yard.php
index 7d71204..a65fdf5 100644
--- a/app/Services/Yard.php
+++ b/app/Services/Yard.php
@@ -43,6 +43,7 @@ class Yard extends Cart
public static function getTaxRate()
{
+
return config('cart.tax');
}
@@ -121,7 +122,6 @@ class Yard extends Cart
//sec by weight
if(!$price){
$price = $this->shippingPriceByWeight($shipping->prices, intval($this->weight()));
-
}
//default
if(!$price){
@@ -182,18 +182,20 @@ class Yard extends Cart
public function subtotalWithShipping($decimals = null, $decimalPoint = null, $thousandSeperator = null)
{
- $taxRate =config('cart.tax');
- $total = (float) ($this->total(2, '.', '')) + $this->shipping;
- $totalTax = $total/ (100 + $taxRate) * $taxRate;
- return $this->numberFormat(($total - $totalTax), $decimals, $decimalPoint, $thousandSeperator);
+ $subtotal = $this->subtotal(2, '.', '') + $this->shipping;
+ //$taxRate =config('cart.tax');
+ /*$total = (float) ($this->total(2, '.', '')) + $this->shipping;
+ $totalTax = $total/ (100 + $taxRate) * $taxRate;*/
+ return $this->numberFormat($subtotal, $decimals, $decimalPoint, $thousandSeperator);
}
public function taxWithShipping($decimals = null, $decimalPoint = null, $thousandSeperator = null)
{
- $taxRate =config('cart.tax');
+ $totalTax = $this->tax(2, '.', '');
+ /* $taxRate =config('cart.tax');
$total = (float) ($this->total(2, '.', '')) + $this->shipping;
- $totalTax = $total/ (100 + $taxRate) * $taxRate;
+ $totalTax = $total/ (100 + $taxRate) * $taxRate; */
return $this->numberFormat($totalTax, $decimals, $decimalPoint, $thousandSeperator);
}
diff --git a/public/wartung.html b/public/wartung.html
new file mode 100644
index 0000000..f55aba5
--- /dev/null
+++ b/public/wartung.html
@@ -0,0 +1,314 @@
+
+
+
+
+ Wartungsmodus
+
+
+
+
+
+
Unsere Website befindet sich gerade in der Wartung.
+
+
+ Wir stehen Ihnen bald wieder zur Verfügung. Entschuldigen Sie etwaige Unannehmlichkeiten.
+
+
+
+
+
Our website is currently undergoing maintenance.
+
+
+ We'll be back very soon. Sorry for any inconvenience.
+
+
+
+
+
+
\ No newline at end of file
diff --git a/resources/views/emails/checkout_status.blade.php b/resources/views/emails/checkout_status.blade.php
index 009a697..c81c87e 100644
--- a/resources/views/emails/checkout_status.blade.php
+++ b/resources/views/emails/checkout_status.blade.php
@@ -169,7 +169,7 @@
{{__('email.checkout_mail_bank_iban')}} {{ $pay_trans->transmitted_data['clearing_bankiban'] }}
{{__('email.checkout_mail_bank_bic')}} {{ $pay_trans->transmitted_data['clearing_bankbic'] }}
{{__('email.checkout_mail_bank_name')}} {{ $pay_trans->transmitted_data['clearing_bankname'] }}
- {{__('email.checkout_mail_bank_total')}} {{ number_format( floatval($pay_trans->shopping_payment->amount/100), 2, ",", ".") }} EUR
+ {{__('email.checkout_mail_bank_total')}} {{ number_format( (float) ($pay_trans->shopping_payment->amount/100), 2, ",", ".") }} EUR
{{__('email.checkout_mail_bank_code')}} {{ $pay_trans->transmitted_data['txid'] }}
diff --git a/resources/views/web/templates/card.blade.php b/resources/views/web/templates/card.blade.php
index 67db80a..8fac40a 100644
--- a/resources/views/web/templates/card.blade.php
+++ b/resources/views/web/templates/card.blade.php
@@ -146,7 +146,9 @@
@foreach(Yard::instance('shopping')->content() as $row)
+
@php($product = \App\Models\Product::find($row->id))
+
|
@if($row->options->has('image'))
@@ -167,7 +169,7 @@
|
{{ $row->price() }} €
{{$product->getBasePriceFormattedFull()}}
-
+ inkl. {{ number_format($row->taxRate, 0)}}% MwSt.
|
@@ -278,10 +280,9 @@
{{ Yard::instance('shopping')->subtotalWithShipping() }} €
Summe ohne MwSt:
-
{{ Yard::instance('shopping')->taxWithShipping() }} €
- zzgl. {{ Yard::getTaxRate() }} % MwSt:
+ zzgl. {{-- Yard::getTaxRate() --}} MwSt:
diff --git a/resources/views/web/templates/checkout.blade.php b/resources/views/web/templates/checkout.blade.php
index 82e28d4..9953f93 100644
--- a/resources/views/web/templates/checkout.blade.php
+++ b/resources/views/web/templates/checkout.blade.php
@@ -670,7 +670,7 @@
{{ Yard::instance('shopping')->taxWithShipping() }} €
- zzgl. {{ Yard::getTaxRate() }} % MwSt:
+ zzgl. {{-- Yard::getTaxRate() --}} MwSt:
diff --git a/resources/views/web/templates/produkte-show.blade.php b/resources/views/web/templates/produkte-show.blade.php
index 69b647d..bed4109 100644
--- a/resources/views/web/templates/produkte-show.blade.php
+++ b/resources/views/web/templates/produkte-show.blade.php
@@ -104,7 +104,7 @@
{{ $product->getFormattedPrice() }} €
@endif
{{$product->getBasePriceFormattedFull()}}
- inkl. 19% MwSt. zzgl. Versandkosten
+ inkl. {{$product->getFormattedTax()}}% MwSt. zzgl. Versandkosten
|