From 43f04e3b428c74a855cb7d1a7fd383f7c37471b8 Mon Sep 17 00:00:00 2001 From: javi Date: Fri, 9 Dec 2022 09:24:19 +0100 Subject: [PATCH] sin item cost --- print/templates/reports/invoice/sql/intrastat.sql | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/print/templates/reports/invoice/sql/intrastat.sql b/print/templates/reports/invoice/sql/intrastat.sql index 5cc3ebd7f..63af7ac8c 100644 --- a/print/templates/reports/invoice/sql/intrastat.sql +++ b/print/templates/reports/invoice/sql/intrastat.sql @@ -2,13 +2,14 @@ ir.id code, ir.description description, CAST(SUM(IFNULL(i.stems, 1) * s.quantity) AS DECIMAL(10,2)) stems, - CAST(SUM(CAST(IFNULL(i.stems, 1) * s.quantity * IF(ic.grams, ic.grams, i.density * ic.cm3delivery / 1000) / 1000 AS DECIMAL(10,2)) * - IF(sub.weight, sub.weight / vn.invoiceOut_getWeight(?), 1)) AS DECIMAL(10,2)) netKg, + CAST(SUM(CAST(IFNULL(i.stems, 1) + * s.quantity + * i.weightByPiece / 1000 AS DECIMAL(10,2)) + * IF(sub.weight, sub.weight / vn.invoiceOut_getWeight(?), 1)) AS DECIMAL(10,2)) netKg, CAST(SUM((s.quantity * s.price * (100 - s.discount) / 100 )) AS DECIMAL(10,2)) subtotal FROM vn.ticket t JOIN vn.sale s ON s.ticketFk = t.id JOIN vn.item i ON i.id = s.itemFk - JOIN vn.itemCost ic ON ic.itemFk = i.id AND ic.warehouseFk = t.warehouseFk JOIN vn.intrastat ir ON ir.id = i.intrastatFk LEFT JOIN ( SELECT t2.weight