Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 4825-intrastat
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Vicent Llopis 2022-12-12 14:28:58 +01:00
commit 2b7f788946
7 changed files with 54 additions and 45 deletions

View File

@ -1 +0,0 @@
Delete this file

View File

@ -138,7 +138,7 @@ module.exports = Self => {
recipient: invoiceOut.client().email recipient: invoiceOut.client().email
}; };
try { try {
await models.InvoiceOut.invoiceEmail(ctx); await models.InvoiceOut.invoiceEmail(ctx, invoiceOut.ref);
} catch (err) {} } catch (err) {}
return invoiceId; return invoiceId;

View File

@ -26,6 +26,7 @@
type="number" type="number"
label="Minimum M3" label="Minimum M3"
ng-model="$ctrl.supplierAgencyTerm.minimumM3" ng-model="$ctrl.supplierAgencyTerm.minimumM3"
step="0.01"
rule> rule>
</vn-input-number> </vn-input-number>
</vn-horizontal> </vn-horizontal>
@ -46,6 +47,7 @@
type="number" type="number"
label="M3 Price" label="M3 Price"
ng-model="$ctrl.supplierAgencyTerm.m3Price" ng-model="$ctrl.supplierAgencyTerm.m3Price"
step="0.01"
rule> rule>
</vn-input-number> </vn-input-number>
</vn-horizontal> </vn-horizontal>

View File

@ -137,7 +137,7 @@ module.exports = Self => {
const params = [args.id, args.shipped, args.warehouseFk]; const params = [args.id, args.shipped, args.warehouseFk];
const [salesMovable] = await Self.rawSql(query, params, myOptions); const [salesMovable] = await Self.rawSql(query, params, myOptions);
const sales = await models.Sale.find({ticketFk: args.id}, myOptions); const sales = await models.Sale.find({where: {ticketFk: args.id}}, myOptions);
const salesNewTicket = salesMovable.filter(sale => (sale.movable ? sale.movable : 0) >= sale.quantity); const salesNewTicket = salesMovable.filter(sale => (sale.movable ? sale.movable : 0) >= sale.quantity);
const salesNewTicketLength = salesNewTicket.length; const salesNewTicketLength = salesNewTicket.length;

View File

@ -82,7 +82,7 @@ module.exports = {
return this.rawSqlFromDef(`taxes`, [reference]); return this.rawSqlFromDef(`taxes`, [reference]);
}, },
fetchIntrastat(reference) { fetchIntrastat(reference) {
return this.rawSqlFromDef(`intrastat`, [reference, reference, reference, reference]); return this.rawSqlFromDef(`intrastat`, [reference, reference, reference, reference, reference]);
}, },
fetchRectified(reference) { fetchRectified(reference) {
return this.rawSqlFromDef(`rectified`, [reference]); return this.rawSqlFromDef(`rectified`, [reference]);

View File

@ -1,33 +1,41 @@
(SELECT SELECT *
ir.id code, FROM invoiceOut io
ir.description description, JOIN invoiceOutSerial ios ON io.serial = ios.code
CAST(SUM(IFNULL(i.stems, 1) * s.quantity) AS DECIMAL(10,2)) stems, JOIN
CAST(SUM(CAST(IFNULL(i.stems, 1) (SELECT
* s.quantity t.refFk,
* i.weightByPiece / 1000 AS DECIMAL(10,2)) ir.id code,
* IF(sub.weight, sub.weight / vn.invoiceOut_getWeight(?), 1)) AS DECIMAL(10,2)) netKg, ir.description description,
CAST(SUM((s.quantity * s.price * (100 - s.discount) / 100 )) AS DECIMAL(10,2)) subtotal CAST(SUM(IFNULL(i.stems, 1) * s.quantity) AS DECIMAL(10,2)) stems,
FROM vn.ticket t CAST(SUM(CAST(IFNULL(i.stems, 1)
JOIN vn.sale s ON s.ticketFk = t.id * s.quantity
JOIN vn.item i ON i.id = s.itemFk * i.weightByPiece / 1000 AS DECIMAL(10,2))
JOIN vn.intrastat ir ON ir.id = i.intrastatFk * IF(sub.weight, sub.weight / vn.invoiceOut_getWeight(?), 1)) AS DECIMAL(10,2)) netKg,
LEFT JOIN ( CAST(SUM((s.quantity * s.price * (100 - s.discount) / 100 )) AS DECIMAL(10,2)) subtotal
SELECT t2.weight FROM vn.ticket t
FROM vn.ticket t2 JOIN vn.sale s ON s.ticketFk = t.id
WHERE refFk = ? AND weight JOIN vn.item i ON i.id = s.itemFk
LIMIT 1 JOIN vn.itemCost ic ON ic.itemFk = i.id AND ic.warehouseFk = t.warehouseFk
) sub ON TRUE JOIN vn.intrastat ir ON ir.id = i.intrastatFk
WHERE t.refFk = ? LEFT JOIN (
AND i.intrastatFk SELECT t2.weight
GROUP BY i.intrastatFk FROM vn.ticket t2
ORDER BY i.intrastatFk) WHERE refFk = ? AND weight
UNION ALL LIMIT 1
(SELECT ) sub ON TRUE
NULL AS code, WHERE t.refFk = ?
NULL AS description, AND i.intrastatFk
0 AS stems, GROUP BY i.intrastatFk
0 AS netKg, UNION ALL
CAST(SUM((ts.quantity * ts.price)) AS DECIMAL(10,2)) AS subtotal SELECT
FROM vn.ticketService ts NULL AS refFk,
JOIN vn.ticket t ON ts.ticketFk = t.id NULL AS code,
WHERE t.refFk = ?); NULL AS description,
0 AS stems,
0 AS netKg,
IF(CAST(SUM((ts.quantity * ts.price)) AS DECIMAL(10,2)), CAST(SUM((ts.quantity * ts.price)) AS DECIMAL(10,2)), 0) AS subtotal
FROM vn.ticketService ts
JOIN vn.ticket t ON ts.ticketFk = t.id
WHERE t.refFk = ?) sub
WHERE io.`ref` = ? AND ios.isCEE
ORDER BY sub.code;

View File

@ -3,8 +3,8 @@ SELECT
io.ref, io.ref,
io.issued, io.issued,
ict.description ict.description
FROM vn.invoiceCorrection ic FROM invoiceOut io
JOIN vn.invoiceOut io ON io.id = ic.correctedFk JOIN invoiceCorrection ic ON ic.correctingFk = io.id
JOIN vn.invoiceCorrectionType ict ON ict.id = ic.invoiceCorrectionTypeFk JOIN invoiceCorrectionType ict ON ict.id = ic.invoiceCorrectionTypeFk
LEFT JOIN ticket t ON t.refFk = io.ref LEFT JOIN ticket t ON t.refFk = io.ref
WHERE t.refFk = ? WHERE io.ref = ?