Fix the quick sales report on MariaDB with credits
The unit price column is unsigned, so MariaDB refused the negative product of a credit's quantity and price. The price is now cast to a signed number before multiplying. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
+2
-2
@@ -51,7 +51,7 @@ class EloquentQuickSaleReportQueries implements QuickSaleReportQueries
|
|||||||
->groupBy('quick_sale_lines.product_name')
|
->groupBy('quick_sale_lines.product_name')
|
||||||
->select('quick_sale_lines.product_name')
|
->select('quick_sale_lines.product_name')
|
||||||
->selectRaw('SUM(quick_sale_lines.quantity) as quantity')
|
->selectRaw('SUM(quick_sale_lines.quantity) as quantity')
|
||||||
->selectRaw('SUM(quick_sale_lines.quantity * quick_sale_lines.unit_price_cents) as gross_cents')
|
->selectRaw('SUM(quick_sale_lines.quantity * CAST(quick_sale_lines.unit_price_cents AS SIGNED)) as gross_cents')
|
||||||
->orderByDesc('gross_cents')
|
->orderByDesc('gross_cents')
|
||||||
->orderBy('quick_sale_lines.product_name')
|
->orderBy('quick_sale_lines.product_name')
|
||||||
->get()
|
->get()
|
||||||
@@ -74,7 +74,7 @@ class EloquentQuickSaleReportQueries implements QuickSaleReportQueries
|
|||||||
->orderBy('quick_sales.sold_on')
|
->orderBy('quick_sales.sold_on')
|
||||||
->orderBy('quick_sale_lines.vat_basis_points')
|
->orderBy('quick_sale_lines.vat_basis_points')
|
||||||
->select('quick_sales.sold_on', 'quick_sale_lines.vat_basis_points')
|
->select('quick_sales.sold_on', 'quick_sale_lines.vat_basis_points')
|
||||||
->selectRaw('SUM(quick_sale_lines.quantity * quick_sale_lines.unit_price_cents) as gross_cents')
|
->selectRaw('SUM(quick_sale_lines.quantity * CAST(quick_sale_lines.unit_price_cents AS SIGNED)) as gross_cents')
|
||||||
->get()
|
->get()
|
||||||
->map(fn (object $row): array => [
|
->map(fn (object $row): array => [
|
||||||
'day' => substr((string) $row->sold_on, 0, 10),
|
'day' => substr((string) $row->sold_on, 0, 10),
|
||||||
|
|||||||
Reference in New Issue
Block a user