20-02-2026
This commit is contained in:
parent
a8b395e20d
commit
a00c42e770
252 changed files with 28785 additions and 8907 deletions
|
|
@ -34,12 +34,12 @@ class SalesPointsVolume
|
|||
$form_user = User::find($form_user_id);
|
||||
|
||||
$shoppingOrder->user_sales_volume->user_id = $to_user_id;
|
||||
$shoppingOrder->user_sales_volume->message = 'zugewiesen: ' . date('d.m.Y');
|
||||
$shoppingOrder->user_sales_volume->message = 'zugewiesen: '.date('d.m.Y');
|
||||
|
||||
$syslog = $shoppingOrder->user_sales_volume->syslog;
|
||||
$from_email = $form_user ? $form_user->email : '';
|
||||
$to_email = $to_user ? $to_user->email : '';
|
||||
$syslog[date('d.m.Y-h:i:s')] = 'change form: #' . $form_user_id . ' ' . $from_email . ' to: #' . $to_user_id . ' ' . $to_email;
|
||||
$syslog[date('d.m.Y-h:i:s')] = 'change form: #'.$form_user_id.' '.$from_email.' to: #'.$to_user_id.' '.$to_email;
|
||||
$shoppingOrder->user_sales_volume->syslog = $syslog;
|
||||
|
||||
$shoppingOrder->user_sales_volume->save();
|
||||
|
|
@ -100,6 +100,17 @@ class SalesPointsVolume
|
|||
case 5: // Registrierung
|
||||
$month_points = self::add_KP_TP_Points($userSalesVolume, $month_points);
|
||||
$month_total_net += $userSalesVolume->total_net;
|
||||
break;
|
||||
case 6: // Storno - negative Punkte und Beträge
|
||||
$month_points = self::add_KP_TP_Points($userSalesVolume, $month_points);
|
||||
|
||||
if ($userSalesVolume->status_turnover === 2) {
|
||||
$month_shop_points += $userSalesVolume->points; // bereits negativ
|
||||
$month_shop_total_net += $userSalesVolume->total_net; // bereits negativ
|
||||
} else {
|
||||
$month_total_net += $userSalesVolume->total_net; // bereits negativ
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
$userSalesVolume->month_shop_points = $month_shop_points;
|
||||
|
|
@ -200,13 +211,13 @@ class SalesPointsVolume
|
|||
$user_sales_volume->total_net = Util::reFormatNumber($data['total_net']);
|
||||
$user_sales_volume->points = Util::reFormatNumber($data['points']);
|
||||
|
||||
$user_sales_volume->message = 'geändert: ' . date('d.m.Y');
|
||||
$user_sales_volume->message = 'geändert: '.date('d.m.Y');
|
||||
$user_sales_volume->info = $data['info'];
|
||||
$user_sales_volume->status_points = $data['status_points'];
|
||||
$user_sales_volume->status_turnover = isset($data['status_turnover']) ? intval($data['status_turnover']) : null;
|
||||
|
||||
$syslog = $user_sales_volume->syslog;
|
||||
$syslog[date('d.m.Y-h:i:s')] = 'edit points: #' . $old_points . ' ' . $user_sales_volume->points . ' total: #' . $old_total_net . ' ' . $user_sales_volume->total_net;
|
||||
$syslog[date('d.m.Y-h:i:s')] = 'edit points: #'.$old_points.' '.$user_sales_volume->points.' total: #'.$old_total_net.' '.$user_sales_volume->total_net;
|
||||
$user_sales_volume->syslog = $syslog;
|
||||
|
||||
$user_sales_volume->save();
|
||||
|
|
@ -231,7 +242,7 @@ class SalesPointsVolume
|
|||
|
||||
$total_net = isset($data['total_net']) ? Util::reFormatNumber($data['total_net']) : 0;
|
||||
$points = isset($data['points']) ? Util::reFormatNumber($data['points']) : 0;
|
||||
$syslog[date('d.m.Y-h:i:s')] = 'add points: #' . $points . ' total: #' . $total_net;
|
||||
$syslog[date('d.m.Y-h:i:s')] = 'add points: #'.$points.' total: #'.$total_net;
|
||||
$status = isset($data['status']) ? intval($data['status']) : 4;
|
||||
$status_turnover = isset($data['status_turnover']) ? intval($data['status_turnover']) : null;
|
||||
|
||||
|
|
@ -245,7 +256,7 @@ class SalesPointsVolume
|
|||
'status_points' => $data['status_points'],
|
||||
'status_turnover' => $status_turnover,
|
||||
'total_net' => $total_net,
|
||||
'message' => 'hinzugefügt: ' . date('d.m.Y'),
|
||||
'message' => 'hinzugefügt: '.date('d.m.Y'),
|
||||
'info' => $data['info'],
|
||||
'syslog' => $syslog,
|
||||
'status' => $status,
|
||||
|
|
@ -255,4 +266,61 @@ class SalesPointsVolume
|
|||
|
||||
\Session()->flash('alert-success', 'Points hinzugefügt');
|
||||
}
|
||||
|
||||
/**
|
||||
* Erstellt einen Storno-Eintrag für eine stornierte Rechnung
|
||||
* Negative Punkte werden dem aktuellen Monat zugeordnet
|
||||
*
|
||||
* @param UserSalesVolume $original_sales_volume Der ursprüngliche Sales Volume Eintrag
|
||||
* @param int $cancellation_invoice_id Die ID der Stornorechnung
|
||||
* @return UserSalesVolume
|
||||
*/
|
||||
public static function cancelSalesPointsVolume(UserSalesVolume $original_sales_volume, $cancellation_invoice_id)
|
||||
{
|
||||
$month = date('m');
|
||||
$year = date('Y');
|
||||
$date = date('d.m.Y');
|
||||
|
||||
$syslog = [
|
||||
date('d.m.Y H:i:s') => 'Stornorechnung erstellt - Punkte korrigiert (Original Invoice: #'.$original_sales_volume->user_invoice_id.')',
|
||||
];
|
||||
|
||||
// Negativen Eintrag erstellen (alle Werte negativ)
|
||||
$cancellation_sales_volume = UserSalesVolume::create([
|
||||
'user_id' => $original_sales_volume->user_id,
|
||||
'shopping_order_id' => $original_sales_volume->shopping_order_id,
|
||||
'user_invoice_id' => $cancellation_invoice_id,
|
||||
'month' => $month,
|
||||
'year' => $year,
|
||||
'date' => $date,
|
||||
'points' => -$original_sales_volume->points, // Negativ!
|
||||
'month_points' => 0, // Wird durch reCalculate gesetzt
|
||||
'month_KP_points' => 0,
|
||||
'month_TP_points' => 0,
|
||||
'month_shop_points' => 0,
|
||||
'total_net' => -$original_sales_volume->total_net, // Negativ!
|
||||
'month_total_net' => 0,
|
||||
'status' => 6, // Status 6 = cancelled/storniert
|
||||
'status_points' => $original_sales_volume->status_points,
|
||||
'status_turnover' => $original_sales_volume->status_turnover,
|
||||
'message' => 'Storniert am '.date('d.m.Y'),
|
||||
'info' => 'Storno für Invoice #'.$original_sales_volume->user_invoice_id,
|
||||
'syslog' => $syslog,
|
||||
]);
|
||||
|
||||
// Neuberechnung für aktuellen Monat
|
||||
self::reCalculateSalesPointsVolume($original_sales_volume->user_id, $month, $year);
|
||||
|
||||
\Log::info('Punktekorrektur für Stornorechnung durchgeführt', [
|
||||
'original_invoice_id' => $original_sales_volume->user_invoice_id,
|
||||
'cancellation_invoice_id' => $cancellation_invoice_id,
|
||||
'original_points' => $original_sales_volume->points,
|
||||
'cancellation_points' => $cancellation_sales_volume->points,
|
||||
'user_id' => $original_sales_volume->user_id,
|
||||
'month' => $month,
|
||||
'year' => $year,
|
||||
]);
|
||||
|
||||
return $cancellation_sales_volume;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue