Skip to content

Commit be42b50

Browse files
authored
Merge pull request #28 from maximehuran/feature/fixes
Fix shipping amount and add quantities
2 parents db2c620 + d4f005b commit be42b50

File tree

9 files changed

+53
-3
lines changed

9 files changed

+53
-3
lines changed

src/Repository/AbstractReportRepository.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,12 +161,13 @@ protected function getSelectColumns(bool $isItemUnit = false, bool $isItem = fal
161161
$isItemUnit ? 'item.unitPrice - (CASE WHEN tax_adjustment.neutral = 1 THEN tax_adjustment.amount ELSE 0 END) as without_tax' : '0 as without_tax',
162162
// Only retrieve without_tax price for item units
163163
'(COALESCE(order_promotion_adjustment.amount, 0) + COALESCE(order_item_promotion_adjustment.amount, 0) + COALESCE(order_shipping_promotion_adjustment.amount, 0) + COALESCE(order_unit_promotion_adjustment.amount, 0)) AS without_tax_promo',
164-
'shipping_adjustment.amount as without_tax_shipping',
164+
'shipping_adjustment.amount - (CASE WHEN shipping_tax_adjustment.neutral = 1 AND shipping_tax_adjustment.shipment IS NOT NULL THEN shipping_tax_adjustment.amount ELSE 0 END) as without_tax_shipping',
165165
'tax_adjustment.amount as tax',
166166

167167
// Totals
168168
$isOrder ? 'o.total as total' : '0 as total',
169169
$isItem ? 'element.total as item_row' : '0 as item_row',
170+
$isItem ? 'element.quantity as item_qty' : '0 as item_qty',
170171
]);
171172
}
172173

@@ -188,7 +189,8 @@ protected function appendAdjustmentsAndParameters(
188189

189190
return $queryBuilder
190191
// Adjustments joins
191-
->leftJoin($elementAlias . '.adjustments', 'tax_adjustment', 'WITH', 'tax_adjustment.type = :tax_type')
192+
->leftJoin($elementAlias . '.adjustments', 'tax_adjustment', 'WITH', 'tax_adjustment.type = :tax_type AND tax_adjustment.shipment IS NULL')
193+
->leftJoin($elementAlias . '.adjustments', 'shipping_tax_adjustment', 'WITH', 'shipping_tax_adjustment.type = :tax_type AND shipping_tax_adjustment.shipment IS NOT NULL')
192194
->leftJoin(
193195
$elementAlias . '.adjustments',
194196
'shipping_adjustment',
@@ -320,6 +322,7 @@ protected function initResult(): void
320322
'tax_total' => 0,
321323
'total' => 0,
322324
'item_row_total' => 0,
325+
'item_qty_total' => 0,
323326
];
324327
$this->elements = [];
325328
}

src/Resources/translations/messages.en.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ monsieurbiz:
99
period_report_for: 'Period report from %from% to %to% for %channel%'
1010
global_report: 'Global report'
1111
average_report: 'Average report'
12-
number_of_orders: 'Number of orders :'
12+
number_of_orders: 'Number of orders:'
13+
quantity: 'Items total quantity: '
1314
product_report: 'Product report'
1415
product_variant_report: 'Product variant report'
1516
option_report: 'Option report'
1617
option_value_report: 'Option value report'
1718
statistics: 'Statistics'
19+
warning_options: 'Warning, a product with several options is counted as many times as options'
1820
form:
1921
channel:
2022
label: 'Channel'
@@ -31,6 +33,8 @@ monsieurbiz:
3133
tax_amount: 'Tax amount'
3234
total_amount: 'Total amount with tax'
3335
number_of_orders: 'Number of orders'
36+
quantity: 'Quantity'
37+
average_quantity: 'Average quantity'
3438
product_name: 'Product name'
3539
product_variant_name: 'Product variant name'
3640
no_result: 'No result'

src/Resources/translations/messages.fr.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ monsieurbiz:
1010
global_report: 'Synthèse globale'
1111
average_report: 'Synthèse moyenne'
1212
number_of_orders: 'Nombre de commandes :'
13+
quantity: 'Quantité d''articles :'
1314
product_report: 'Synthèse par produit'
1415
product_variant_report: 'Synthèse par variante produit'
1516
option_report: 'Synthèse par option'
1617
option_value_report: 'Synthèse par valeur d''option'
1718
statistics: 'Statistiques'
19+
warning_options: 'Attention, un produit avec plusieurs options est comptabilisé autant de fois que d''options'
1820
form:
1921
channel:
2022
label: 'Canal'
@@ -31,6 +33,8 @@ monsieurbiz:
3133
tax_amount: 'Montant TVA'
3234
total_amount: 'Montant TTC'
3335
number_of_orders: 'Nombre de commandes'
36+
quantity: 'Quantité'
37+
average_quantity: 'Quantité moyenne'
3438
product_name: 'Nom du produit'
3539
product_variant_name: 'Nom du variant produit'
3640
no_result: 'Pas de résultat'

src/Resources/translations/messages.nl.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ monsieurbiz:
1010
global_report: 'Algemene rapportage'
1111
average_report: 'Gemiddelde rapportage'
1212
number_of_orders: 'Aantal bestellingen:'
13+
quantity: 'Totaal aantal artikelen:'
1314
product_report: 'Product rapportage'
1415
product_variant_report: 'Product varianten rapportage'
1516
option_report: 'Opties rapportage'
1617
option_value_report: 'Optiewaardes rapportage'
1718
statistics: 'Statistieken'
19+
warning_options: 'Waarschu wing, een product met meerdere opties wordt geteld zoveel keer als opties'
1820
form:
1921
channel:
2022
label: 'Kanaal'
@@ -31,6 +33,8 @@ monsieurbiz:
3133
tax_amount: 'Tax amount'
3234
total_amount: 'Totaal aantallen met belasting'
3335
number_of_orders: 'Aantal bestellingen'
36+
quantity: 'Aantal'
37+
average_quantity: 'Gemiddelde aantal'
3438
product_name: 'Product naam'
3539
product_variant_name: 'Product variant naam'
3640
no_result: 'Geen resultaat'

src/Resources/views/Admin/Report/_average.html.twig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@
44
<p>
55
{{ 'monsieurbiz.sales_reports.ui.number_of_orders'|trans }}
66
<b>{{ average_sales_result.number_of_elements }}</b>
7+
-
8+
{{ 'monsieurbiz.sales_reports.ui.quantity'|trans }}
9+
<b>{{ average_sales_result.item_qty_total }}</b>
710
</p>
811
<table class="ui celled table">
912
<thead>
1013
<tr>
14+
<th>{{ 'monsieurbiz.sales_reports.view.average_quantity' | trans }}</th>
1115
<th>{{ 'monsieurbiz.sales_reports.view.amount_without_tax' | trans }}</th>
1216
<th>{{ 'monsieurbiz.sales_reports.view.promo_amount_without_tax' | trans }}</th>
1317
<th>{{ 'monsieurbiz.sales_reports.view.shipping_amount_without_tax' | trans }}</th>
@@ -17,6 +21,7 @@
1721
</thead>
1822
<tbody>
1923
<tr>
24+
<td>{{ (average_sales_result.item_qty_total / average_sales_result.number_of_elements)|round(2, 'floor') }}</td>
2025
<td>{{ money.format(average_sales_result.without_tax_total, channel.baseCurrency.code) }}</td>
2126
<td>{{ money.format(average_sales_result.without_tax_promo_total, channel.baseCurrency.code) }}</td>
2227
<td>{{ money.format(average_sales_result.without_tax_shipping_total, channel.baseCurrency.code) }}</td>

src/Resources/views/Admin/Report/_option.html.twig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,20 @@
66
{% set without_tax_shipping_total_sum = 0 %}
77
{% set tax_total_sum = 0 %}
88
{% set item_row_total_sum = 0 %}
9+
{% set item_qty_total_sum = 0 %}
910

1011
<h3>{{ 'monsieurbiz.sales_reports.ui.option_report'|trans }}</h3>
12+
13+
<div class="ui info message">
14+
<p>{{ 'monsieurbiz.sales_reports.ui.warning_options'|trans }}</p>
15+
</div>
16+
1117
<table class="ui celled table sortable">
1218
<thead>
1319
<tr>
1420
<th>{{ 'monsieurbiz.sales_reports.view.option_name'|trans }}</th>
1521
<th>{{ 'monsieurbiz.sales_reports.view.number_of_orders'|trans }}</th>
22+
<th>{{ 'monsieurbiz.sales_reports.view.quantity'|trans }}</th>
1623
<th>{{ 'monsieurbiz.sales_reports.view.amount_without_tax' | trans }}</th>
1724
<th>{{ 'monsieurbiz.sales_reports.view.promo_amount_without_tax' | trans }}</th>
1825
<th>{{ 'monsieurbiz.sales_reports.view.tax_amount' | trans }}</th>
@@ -28,9 +35,11 @@
2835
{% set without_tax_shipping_total_sum = without_tax_shipping_total_sum + result.without_tax_shipping_total %}
2936
{% set tax_total_sum = tax_total_sum + result.tax_total %}
3037
{% set item_row_total_sum = item_row_total_sum + result.item_row_total %}
38+
{% set item_qty_total_sum = item_qty_total_sum + result.item_qty_total %}
3139
<tr>
3240
<td>{{ result.option_label }}</td>
3341
<td>{{ result.number_of_elements }}</td>
42+
<td>{{ result.item_qty_total }}</td>
3443
<td>{{ money.format(result.without_tax_total, channel.baseCurrency.code) }}</td>
3544
<td>{{ money.format(result.without_tax_promo_total, channel.baseCurrency.code) }}</td>
3645
<td>{{ money.format(result.tax_total, channel.baseCurrency.code) }}</td>
@@ -48,6 +57,7 @@
4857
<tr>
4958
<th>{{ 'monsieurbiz.sales_reports.view.total'|trans }}</th>
5059
<th>{{ number_of_elements_sum }}</th>
60+
<th>{{ item_qty_total_sum }}</th>
5161
<th>{{ money.format(without_tax_total_sum, channel.baseCurrency.code) }}</th>
5262
<th>{{ money.format(without_tax_promo_total_sum, channel.baseCurrency.code) }}</th>
5363
<th>{{ money.format(tax_total_sum, channel.baseCurrency.code) }}</th>

src/Resources/views/Admin/Report/_optionValue.html.twig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,21 @@
66
{% set without_tax_shipping_total_sum = 0 %}
77
{% set tax_total_sum = 0 %}
88
{% set item_row_total_sum = 0 %}
9+
{% set item_qty_total_sum = 0 %}
910

1011
<h3>{{ 'monsieurbiz.sales_reports.ui.option_value_report'|trans }}</h3>
12+
13+
<div class="ui info message">
14+
<p>{{ 'monsieurbiz.sales_reports.ui.warning_options'|trans }}</p>
15+
</div>
16+
1117
<table class="ui celled table sortable">
1218
<thead>
1319
<tr>
1420
<th>{{ 'monsieurbiz.sales_reports.view.option_name'|trans }}</th>
1521
<th>{{ 'monsieurbiz.sales_reports.view.option_value'|trans }}</th>
1622
<th>{{ 'monsieurbiz.sales_reports.view.number_of_orders'|trans }}</th>
23+
<th>{{ 'monsieurbiz.sales_reports.view.quantity'|trans }}</th>
1724
<th>{{ 'monsieurbiz.sales_reports.view.amount_without_tax' | trans }}</th>
1825
<th>{{ 'monsieurbiz.sales_reports.view.promo_amount_without_tax' | trans }}</th>
1926
<th>{{ 'monsieurbiz.sales_reports.view.tax_amount' | trans }}</th>
@@ -29,10 +36,12 @@
2936
{% set without_tax_shipping_total_sum = without_tax_shipping_total_sum + result.without_tax_shipping_total %}
3037
{% set tax_total_sum = tax_total_sum + result.tax_total %}
3138
{% set item_row_total_sum = item_row_total_sum + result.item_row_total %}
39+
{% set item_qty_total_sum = item_qty_total_sum + result.item_qty_total %}
3240
<tr>
3341
<td>{{ result.option_label }}</td>
3442
<td>{{ result.option_value_label }}</td>
3543
<td>{{ result.number_of_elements }}</td>
44+
<td>{{ result.item_qty_total }}</td>
3645
<td>{{ money.format(result.without_tax_total, channel.baseCurrency.code) }}</td>
3746
<td>{{ money.format(result.without_tax_promo_total, channel.baseCurrency.code) }}</td>
3847
<td>{{ money.format(result.tax_total, channel.baseCurrency.code) }}</td>
@@ -50,6 +59,7 @@
5059
<tr>
5160
<th colspan="2">{{ 'monsieurbiz.sales_reports.view.total'|trans }}</th>
5261
<th>{{ number_of_elements_sum }}</th>
62+
<th>{{ item_qty_total_sum }}</th>
5363
<th>{{ money.format(without_tax_total_sum, channel.baseCurrency.code) }}</th>
5464
<th>{{ money.format(without_tax_promo_total_sum, channel.baseCurrency.code) }}</th>
5565
<th>{{ money.format(tax_total_sum, channel.baseCurrency.code) }}</th>

src/Resources/views/Admin/Report/_product.html.twig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@
66
{% set without_tax_shipping_total_sum = 0 %}
77
{% set tax_total_sum = 0 %}
88
{% set item_row_total_sum = 0 %}
9+
{% set item_qty_total_sum = 0 %}
910

1011
<h3>{{ 'monsieurbiz.sales_reports.ui.product_report'|trans }}</h3>
1112
<table class="ui celled table sortable">
1213
<thead>
1314
<tr>
1415
<th>{{ 'monsieurbiz.sales_reports.view.product_name'|trans }}</th>
1516
<th>{{ 'monsieurbiz.sales_reports.view.number_of_orders'|trans }}</th>
17+
<th>{{ 'monsieurbiz.sales_reports.view.quantity'|trans }}</th>
1618
<th>{{ 'monsieurbiz.sales_reports.view.amount_without_tax' | trans }}</th>
1719
<th>{{ 'monsieurbiz.sales_reports.view.promo_amount_without_tax' | trans }}</th>
1820
<th>{{ 'monsieurbiz.sales_reports.view.tax_amount' | trans }}</th>
@@ -28,9 +30,11 @@
2830
{% set without_tax_shipping_total_sum = without_tax_shipping_total_sum + result.without_tax_shipping_total %}
2931
{% set tax_total_sum = tax_total_sum + result.tax_total %}
3032
{% set item_row_total_sum = item_row_total_sum + result.item_row_total %}
33+
{% set item_qty_total_sum = item_qty_total_sum + result.item_qty_total %}
3134
<tr>
3235
<td>{{ result.product_name }}</td>
3336
<td>{{ result.number_of_elements }}</td>
37+
<td>{{ result.item_qty_total }}</td>
3438
<td>{{ money.format(result.without_tax_total, channel.baseCurrency.code) }}</td>
3539
<td>{{ money.format(result.without_tax_promo_total, channel.baseCurrency.code) }}</td>
3640
<td>{{ money.format(result.tax_total, channel.baseCurrency.code) }}</td>
@@ -48,6 +52,7 @@
4852
<tr>
4953
<th>{{ 'monsieurbiz.sales_reports.view.total'|trans }}</th>
5054
<th>{{ number_of_elements_sum }}</th>
55+
<th>{{ item_qty_total_sum }}</th>
5156
<th>{{ money.format(without_tax_total_sum, channel.baseCurrency.code) }}</th>
5257
<th>{{ money.format(without_tax_promo_total_sum, channel.baseCurrency.code) }}</th>
5358
<th>{{ money.format(tax_total_sum, channel.baseCurrency.code) }}</th>

src/Resources/views/Admin/Report/_productVariant.html.twig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@
66
{% set without_tax_shipping_total_sum = 0 %}
77
{% set tax_total_sum = 0 %}
88
{% set item_row_total_sum = 0 %}
9+
{% set item_qty_total_sum = 0 %}
910

1011
<h3>{{ 'monsieurbiz.sales_reports.ui.product_variant_report'|trans }}</h3>
1112
<table class="ui celled table sortable">
1213
<thead>
1314
<tr>
1415
<th>{{ 'monsieurbiz.sales_reports.view.product_variant_name'|trans }}</th>
1516
<th>{{ 'monsieurbiz.sales_reports.view.number_of_orders'|trans }}</th>
17+
<th>{{ 'monsieurbiz.sales_reports.view.quantity'|trans }}</th>
1618
<th>{{ 'monsieurbiz.sales_reports.view.amount_without_tax' | trans }}</th>
1719
<th>{{ 'monsieurbiz.sales_reports.view.promo_amount_without_tax' | trans }}</th>
1820
<th>{{ 'monsieurbiz.sales_reports.view.tax_amount' | trans }}</th>
@@ -28,9 +30,11 @@
2830
{% set without_tax_shipping_total_sum = without_tax_shipping_total_sum + result.without_tax_shipping_total %}
2931
{% set tax_total_sum = tax_total_sum + result.tax_total %}
3032
{% set item_row_total_sum = item_row_total_sum + result.item_row_total %}
33+
{% set item_qty_total_sum = item_qty_total_sum + result.item_qty_total %}
3134
<tr>
3235
<td>{{ result.variant_name }}</td>
3336
<td>{{ result.number_of_elements }}</td>
37+
<td>{{ result.item_qty_total }}</td>
3438
<td>{{ money.format(result.without_tax_total, channel.baseCurrency.code) }}</td>
3539
<td>{{ money.format(result.without_tax_promo_total, channel.baseCurrency.code) }}</td>
3640
<td>{{ money.format(result.tax_total, channel.baseCurrency.code) }}</td>
@@ -48,6 +52,7 @@
4852
<tr>
4953
<th>{{ 'monsieurbiz.sales_reports.view.total'|trans }}</th>
5054
<th>{{ number_of_elements_sum }}</th>
55+
<th>{{ item_qty_total_sum }}</th>
5156
<th>{{ money.format(without_tax_total_sum, channel.baseCurrency.code) }}</th>
5257
<th>{{ money.format(without_tax_promo_total_sum, channel.baseCurrency.code) }}</th>
5358
<th>{{ money.format(tax_total_sum, channel.baseCurrency.code) }}</th>

0 commit comments

Comments
 (0)