Edit Report:Brand - wip
Menu Anchors
'customers', 'orders', 'sales', 'payables', 'warehouse', 'dispatching', 'receivables', 'payables-dash', 'inventory', 'purchases', 'generallendger', 'users',-- Brand - wip
--
-- VARIABLE: {
-- name: "range",
-- display: "Report Range",
-- type: "daterange",
-- format: "Y-m-d",
-- default: { start: "first day of this month", end: "yesterday" },
-- }
-- VARIABLE: {
-- name: "brand",
-- display: "Brand",
-- type: "select",
-- database_options: { table: "manufacturer", display: "name", column: "manufacturer_id", order:{ column: "name" , order: "ASC"} },
-- multiple:true,
-- empty:true,
-- }
-- VARIABLE: {
-- name: "source",
-- display: "Order Source",
-- type: "select",
-- multiple: false,
-- options: [{display: 'All', value:'all'},{display: 'Store', value:'store'},{display: 'Street', value:'street'},{display: 'Web', value:'web'}],
-- empty:true
-- }
-- ROLLUP: {
-- columns: {
-- "TOTAL": "Total: {{sum}}",
-- "QTY": "Total: {{sum}}"
-- }
-- }
-- FILTER: {
-- filter: "class",
-- column: "QTY",
-- params: {
-- class: "text-center"
-- }
-- }
-- FILTER: {
-- filter: "class",
-- column: "TOTAL",
-- params: {
-- class: "text-right"
-- }
-- }
SELECT
brand as BRAND,
CAST(sum( qty * - 1 ) as DECIMAL(10,0)) AS QTY,
CAST(sum( discountedlinetotal * - 1 ) as DECIMAL(10,2)) as TOTAL
FROM
stocktrans
join mfgpartbrandtostockid on stocktrans.stockid = mfgpartbrandtostockid.stockid
join debtorsmaster on stocktrans.dno = debtorsmaster.debtorno
WHERE
1
and date(trandate) between date("{{ range.start }}") AND date("{{ range.end }}")
{% if brand[0] != '' %}
{% if brand|length > 0 %}
and mfgpartbrandtostockid.brandid in (
{% for m in brand %}
'{{ m }}'
{{ not loop.last ? ',' }}
{% endfor %})
{% endif %}
{% endif %}
{% if source == 'store'%}
and ( not stocktrans.fromstkloc = 00 and not stocktrans.placedfrom = 4 )
{% endif %}
{% if source == 'street'%}
and ( stocktrans.fromstkloc = 00 and not stocktrans.placedfrom = 4 )
{% endif %}
{% if source == 'web'%}
and ( stocktrans.placedfrom = 4 )
{% endif %}
group by brand
order by brand asc