fix: actulizada sql intrastat y se muestra solamente cuando toca
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
d715f5ab7b
commit
ac3faddac1
|
@ -0,0 +1,30 @@
|
||||||
|
DROP FUNCTION IF EXISTS `vn`.`invoiceOut_getWeight`;
|
||||||
|
|
||||||
|
DELIMITER $$
|
||||||
|
$$
|
||||||
|
CREATE DEFINER=`root`@`localhost` FUNCTION `vn`.`invoiceOut_getWeight`(vInvoice VARCHAR(15)) RETURNS decimal(10,2)
|
||||||
|
READS SQL DATA
|
||||||
|
BEGIN
|
||||||
|
/**
|
||||||
|
* Calcula el peso de una factura emitida
|
||||||
|
*
|
||||||
|
* @param vInvoice Id de la factura
|
||||||
|
* @return vTotalWeight peso de la factura
|
||||||
|
*/
|
||||||
|
DECLARE vTotalWeight DECIMAL(10,2);
|
||||||
|
|
||||||
|
SELECT SUM(CAST(IFNULL(i.stems, 1)
|
||||||
|
* s.quantity
|
||||||
|
* IF(ic.grams, ic.grams, IFNULL(i.weightByPiece, 0)) / 1000 AS DECIMAL(10,2)))
|
||||||
|
INTO vTotalWeight
|
||||||
|
FROM ticket t
|
||||||
|
JOIN sale s ON s.ticketFk = t.id
|
||||||
|
JOIN item i ON i.id = s.itemFk
|
||||||
|
JOIN itemCost ic ON ic.itemFk = i.id
|
||||||
|
AND ic.warehouseFk = t.warehouseFk
|
||||||
|
WHERE t.refFk = vInvoice
|
||||||
|
AND i.intrastatFk;
|
||||||
|
|
||||||
|
RETURN vTotalWeight;
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -203,7 +203,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="size100 no-page-break" v-if="intrastat.length > 0">
|
<div class="size100 no-page-break" v-if="hasIntrastat">
|
||||||
<h2>{{$t('intrastat')}}</h2>
|
<h2>{{$t('intrastat')}}</h2>
|
||||||
<table class="column-oriented">
|
<table class="column-oriented">
|
||||||
<thead>
|
<thead>
|
||||||
|
|
|
@ -10,7 +10,8 @@ module.exports = {
|
||||||
this.checkMainEntity(this.invoice);
|
this.checkMainEntity(this.invoice);
|
||||||
this.client = await this.findOneFromDef('client', [this.reference]);
|
this.client = await this.findOneFromDef('client', [this.reference]);
|
||||||
this.taxes = await this.rawSqlFromDef(`taxes`, [this.reference]);
|
this.taxes = await this.rawSqlFromDef(`taxes`, [this.reference]);
|
||||||
this.intrastat = await this.rawSqlFromDef(`intrastat`, [this.reference, this.reference, this.reference]);
|
this.hasIntrastat = await this.findValueFromDef(`hasIntrastat`, [this.reference]);
|
||||||
|
this.intrastat = await this.rawSqlFromDef(`intrastat`, [this.reference, this.reference, this.reference, this.reference]);
|
||||||
this.rectified = await this.rawSqlFromDef(`rectified`, [this.reference]);
|
this.rectified = await this.rawSqlFromDef(`rectified`, [this.reference]);
|
||||||
this.hasIncoterms = await this.findValueFromDef(`hasIncoterms`, [this.reference]);
|
this.hasIncoterms = await this.findValueFromDef(`hasIncoterms`, [this.reference]);
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
SELECT taxAreaFk != 'NATIONAL'
|
||||||
|
FROM vn.invoiceOutSerial ios
|
||||||
|
JOIN vn.invoiceOut io ON io.serial = ios.code
|
||||||
|
WHERE io.ref = ?;
|
|
@ -1,26 +1,36 @@
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM invoiceOut io
|
FROM (
|
||||||
JOIN invoiceOutSerial ios ON io.serial = ios.code
|
SELECT i.intrastatFk code,
|
||||||
JOIN(
|
it.description,
|
||||||
SELECT ir.id code,
|
CAST(SUM(ROUND((s.quantity * s.price * (100 - s.discount) / 100 ) , 2))AS DECIMAL(10, 2)) subtotal,
|
||||||
ir.description,
|
SUM(IFNULL(i.stems, 1) * s.quantity) stems,
|
||||||
iii.stems,
|
CAST(SUM(IFNULL(i.stems, 1)
|
||||||
iii.net netKg,
|
* s.quantity
|
||||||
iii.amount subtotal
|
* IF(ic.grams, ic.grams, IFNULL(i.weightByPiece, 0)) / 1000)
|
||||||
FROM vn.invoiceInIntrastat iii
|
* IF(sub.totalWeight, sub.totalWeight / vn.invoiceOut_getWeight(?), 1)
|
||||||
LEFT JOIN vn.invoiceIn ii ON ii.id = iii.invoiceInFk
|
AS DECIMAL(10,2)) netKg
|
||||||
LEFT JOIN vn.invoiceOut io ON io.ref = ii.supplierRef
|
FROM sale s
|
||||||
LEFT JOIN vn.intrastat ir ON ir.id = iii.intrastatFk
|
JOIN ticket t ON s.ticketFk = t.id
|
||||||
WHERE io.`ref` = ?
|
JOIN supplier su ON su.id = t.companyFk
|
||||||
|
JOIN item i ON i.id = s.itemFk
|
||||||
|
JOIN intrastat it ON it.id = i.intrastatFk
|
||||||
|
LEFT JOIN itemCost ic ON ic.itemFk = i.id AND ic.warehouseFk = t.warehouseFk
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT SUM(weight)totalWeight
|
||||||
|
FROM vn.ticket
|
||||||
|
WHERE refFk = ?
|
||||||
|
AND weight
|
||||||
|
) sub ON TRUE
|
||||||
|
WHERE t.refFk =?
|
||||||
|
GROUP BY i.intrastatFk
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT NULL code,
|
SELECT NULL ,
|
||||||
'Servicios' description,
|
IF((SUM((ts.quantity * ts.price))), 'Servicios', NULL),
|
||||||
0 stems,
|
IFNULL(CAST(SUM((ts.quantity * ts.price)) AS DECIMAL(10,2)), 0),
|
||||||
0 netKg,
|
0 ,
|
||||||
IF(CAST(SUM((ts.quantity * ts.price)) AS DECIMAL(10,2)), CAST(SUM((ts.quantity * ts.price)) AS DECIMAL(10,2)), 0) subtotal
|
0
|
||||||
FROM vn.ticketService ts
|
FROM vn.ticketService ts
|
||||||
JOIN vn.ticket t ON ts.ticketFk = t.id
|
JOIN vn.ticket t ON ts.ticketFk = t.id
|
||||||
WHERE t.refFk = ?
|
WHERE t.refFk = ?
|
||||||
) sub
|
) sub2
|
||||||
WHERE io.ref = ? AND ios.isCEE
|
WHERE `description` IS NOT NULL;
|
||||||
ORDER BY sub.code;
|
|
||||||
|
|
Loading…
Reference in New Issue