#10 Promotion Modul, Kommentar 2

This commit is contained in:
Kevin Adametz 2021-11-09 18:40:18 +01:00
parent f0da981737
commit c9e1545693
128 changed files with 8194 additions and 637 deletions

View file

@ -308,14 +308,14 @@ class SalesController extends Controller
$shopping_order = ShoppingOrder::findOrFail($data['id']);
$shopping_payment = ShoppingPayment::findOrFail($data['payment_id']);
if($shopping_order->shopping_order_margin->from_payment_credit > 0){
if($shopping_order->shopping_order_margin && $shopping_order->shopping_order_margin->from_payment_credit > 0){
$last_UserPayCredit = UserPayCredit::where('shopping_order_id', $shopping_order->id)->whereIn('status', [2, 4])->orderBy('id', 'DESC')->first();
//Status Keine Zahlung, Guthaben zurückführen, wenn status 2 / deduction from payment
if($data['txaction'] === 'non' && $last_UserPayCredit->status === 2){
if($last_UserPayCredit && $data['txaction'] === 'non' && $last_UserPayCredit->status === 2){
Payment::handelUserPayCredits($shopping_order, 'return');
}
//Status Zahlung, voher gab es eine Storno, Guthaben abziehen wenn status 4 / return from order
if($last_UserPayCredit->status === 4 && ($data['txaction'] === 'open' || $data['txaction'] === 'paid')){
if($last_UserPayCredit && $last_UserPayCredit->status === 4 && ($data['txaction'] === 'open' || $data['txaction'] === 'paid')){
Payment::handelUserPayCredits($shopping_order, 'deduction');
}