Absatzstatistik: Summen aus Bestellpositionen, Kompensationsprodukte ausgewiesen, Extern-Bestellungen nachgefüllt
- Stats\Sales: alle Summenzeilen (Angezeigt/Ausgeblendet/Gesamt/Rabatte/Netto) aus price_net × qty der Positionen statt aus subtotal_full/discount des Bestellkopfs; WooCommerce-Importe (txaction extern) hatten dort NULL und zählten seit 06/2026 mit 0 € (Aug 2026: 449 € statt 3.318 € angezeigt) - Kompensationsprodukte (comp > 0) bleiben in der Menge, neue Spalten „davon Kompensation“ (aktuell + Vorjahr) und Summenzeile 9993 - Gelöschte Produkte bleiben im Umsatz sichtbar (withTrashed, „(gelöscht)“) - WP-Import setzt subtotal_full und discount jetzt wie der Checkout - Migration füllt subtotal_full/discount bestehender Extern-Bestellungen nach - Excel-Export um die beiden Kompensationsspalten erweitert - Test tests/Feature/StatsSalesVolumeTest.php (Konsistenz, Filter, Jahr) Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
2482d073a1
commit
ef19dc2ced
6 changed files with 433 additions and 255 deletions
|
|
@ -799,6 +799,10 @@ class ShoppingUserController extends Controller
|
|||
// 'user_shop_id' => auth()->user()->user_sponsor->shop->id,
|
||||
'member_id' => $shopping_user->member_id,
|
||||
'total' => Yard::instance('shopping')->total(2, '.', ''),
|
||||
// Kopf-Felder wie im Checkout füllen, sonst bleiben sie NULL und
|
||||
// die Absatzstatistik (Stats\Sales) zählt diese Bestellungen als 0 €.
|
||||
'subtotal_full' => Yard::instance('shopping')->subtotal(2, '.', '', false),
|
||||
'discount' => 0,
|
||||
'subtotal' => Yard::instance('shopping')->subtotal(2, '.', ''),
|
||||
'shipping' => Yard::instance('shopping')->shipping(2, '.', ','),
|
||||
'shipping_net' => Yard::instance('shopping')->shippingNet(2, '.', ''),
|
||||
|
|
|
|||
|
|
@ -1,26 +1,20 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace App\Http\Controllers\Stats;
|
||||
|
||||
use Auth;
|
||||
use Request;
|
||||
use App\User;
|
||||
use App\Exports\ExcelExport;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\ShoppingOrder;
|
||||
use App\Models\ShoppingOrderItem;
|
||||
use App\Services\HTMLHelper;
|
||||
use App\Services\Stats\Sales;
|
||||
use Carbon\Carbon;
|
||||
use Faker\Core\Number;
|
||||
use App\Exports\ExcelExport;
|
||||
use App\Services\HTMLHelper;
|
||||
use App\Models\ShoppingOrder;
|
||||
use App\Services\Stats\Sales;
|
||||
use App\Models\ShoppingOrderItem;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use App\Services\BusinessPlan\ExportBot;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Request;
|
||||
|
||||
class SalesController extends Controller
|
||||
{
|
||||
|
||||
private $serviceSales;
|
||||
|
||||
public function __construct(Sales $serviceSales)
|
||||
|
|
@ -37,68 +31,72 @@ class SalesController extends Controller
|
|||
'filter_years' => HTMLHelper::getYearRange(2020),
|
||||
'filter_products' => $this->serviceSales->setFilterProducts(),
|
||||
];
|
||||
|
||||
return view('admin.stats.salesvolume', $data);
|
||||
}
|
||||
|
||||
|
||||
public function download()
|
||||
{
|
||||
$this->setFilterVars();
|
||||
|
||||
if (Request::get('action') === "filter") {
|
||||
if (Request::get('action') === 'filter') {
|
||||
// $data = Request::all();
|
||||
return back();
|
||||
}
|
||||
|
||||
if (Request::get('action') === "export") {
|
||||
if (Request::get('action') === 'export') {
|
||||
$objects = $this->serviceSales->getObjects();
|
||||
$columns = [];
|
||||
$filename = "gs-absatzmengen-" . session('product_sales_vol_filter_month') . '_' . session('product_sales_vol_filter_year') . "-export";
|
||||
$headers = array(
|
||||
$filename = 'gs-absatzmengen-'.session('product_sales_vol_filter_month').'_'.session('product_sales_vol_filter_year').'-export';
|
||||
$headers = [
|
||||
'#',
|
||||
'Produkt',
|
||||
'Artikelnummer',
|
||||
'Menge',
|
||||
'davon Kompensation',
|
||||
'Gesamt Netto in EURO',
|
||||
'Vorjahr Menge',
|
||||
'Vorjahr davon Kompensation',
|
||||
'Vorjahr Gesamt Netto in EURO',
|
||||
'Einzelrabatt',
|
||||
'Einzelrabatt %',
|
||||
'VP Einzelrabatt %',
|
||||
|
||||
|
||||
);
|
||||
];
|
||||
if ($objects) {
|
||||
foreach ($objects as $key => $obj) {
|
||||
$columns[] = array(
|
||||
'id' => $key,
|
||||
'name' => $obj['name'],
|
||||
'number' => $obj['number'],
|
||||
'qty' => $obj['qty'],
|
||||
'total' => $obj['total'],
|
||||
'pre_qty' => $obj['pre_qty'],
|
||||
'pre_total' => $obj['pre_total'],
|
||||
$columns[] = [
|
||||
'id' => $key,
|
||||
'name' => $obj['name'],
|
||||
'number' => $obj['number'],
|
||||
'qty' => $obj['qty'],
|
||||
'comp_qty' => $obj['comp_qty'],
|
||||
'total' => $obj['total'],
|
||||
'pre_qty' => $obj['pre_qty'],
|
||||
'pre_comp_qty' => $obj['pre_comp_qty'],
|
||||
'pre_total' => $obj['pre_total'],
|
||||
'single_commission' => $obj['single_commission'],
|
||||
'value_commission' => $obj['value_commission'],
|
||||
'value_commission' => $obj['value_commission'],
|
||||
'partner_commission' => $obj['partner_commission'],
|
||||
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
return Excel::download(new ExcelExport($columns, $headers), $filename . '.xls');
|
||||
|
||||
return Excel::download(new ExcelExport($columns, $headers), $filename.'.xls');
|
||||
}
|
||||
}
|
||||
|
||||
private function setFilterVars()
|
||||
{
|
||||
|
||||
if (!session('product_sales_vol_filter_month')) {
|
||||
if (! session('product_sales_vol_filter_month')) {
|
||||
session(['product_sales_vol_filter_month' => intval(date('m'))]);
|
||||
}
|
||||
if (!session('product_sales_vol_filter_year')) {
|
||||
if (! session('product_sales_vol_filter_year')) {
|
||||
session(['product_sales_vol_filter_year' => intval(date('Y'))]);
|
||||
}
|
||||
if (!session('product_sales_vol_filter_products')) {
|
||||
if (! session('product_sales_vol_filter_products')) {
|
||||
session(['product_sales_vol_filter_products' => []]);
|
||||
}
|
||||
if (Request::get('product_sales_vol_filter_month')) {
|
||||
|
|
@ -118,14 +116,6 @@ class SalesController extends Controller
|
|||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public function datatable()
|
||||
{
|
||||
|
||||
|
|
@ -158,7 +148,7 @@ class SalesController extends Controller
|
|||
$counter = 0;
|
||||
foreach($ShoppingOrders as $ShoppingOrder){
|
||||
foreach($ShoppingOrder->shopping_order_items as $shopping_order_item){
|
||||
|
||||
|
||||
if($shopping_order_item->product){
|
||||
if($shopping_order_item->product->id === 122){
|
||||
//dump($shopping_order_item->qty);
|
||||
|
|
@ -168,8 +158,8 @@ class SalesController extends Controller
|
|||
$objects[$shopping_order_item->product->id]['value'] = $value;
|
||||
}else{
|
||||
$objects[$shopping_order_item->product->id] = [
|
||||
'name' => $shopping_order_item->product->name,
|
||||
'number' => $shopping_order_item->product->number,
|
||||
'name' => $shopping_order_item->product->name,
|
||||
'number' => $shopping_order_item->product->number,
|
||||
'value' => $shopping_order_item->qty
|
||||
];
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue