Merge branch 'test' into dev
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Guillermo Bonet 2024-09-05 09:25:00 +02:00
commit 6df817ea5d
5 changed files with 49 additions and 64 deletions

View File

@ -2,25 +2,33 @@ DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_recalcPrices`() CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_recalcPrices`()
BEGIN BEGIN
/** /**
* Recalcula los precios para las compras insertadas en tmp.buyRecalc * Recalcula los precios para las compras insertadas en tmp.buyRecalc.
* *
* @param tmp.buyRecalc (id) * @param tmp.buyRecalc (id)
*/ */
DECLARE vLanded DATE; DECLARE vLanded DATE;
DECLARE vWarehouseFk INT; DECLARE vWarehouseFk INT;
DECLARE vHasNotPrice BOOL;
DECLARE vBuyingValue DECIMAL(10,4);
DECLARE vPackagingFk VARCHAR(10);
DECLARE vIsWarehouseFloramondo BOOL; DECLARE vIsWarehouseFloramondo BOOL;
DECLARE vDone BOOL;
SELECT t.landed, t.warehouseInFk, (w.`name` = 'Floramondo') DECLARE vTravels CURSOR FOR
INTO vLanded, vWarehouseFk, vIsWarehouseFloramondo SELECT t.landed, t.warehouseInFk, (w.code = 'flm')
FROM tmp.buyRecalc br FROM tmp.buyRecalc br
JOIN buy b ON b.id = br.id JOIN buy b ON b.id = br.id
JOIN entry e ON e.id = b.entryFk JOIN entry e ON e.id = b.entryFk
JOIN travel t ON t.id = e.travelFk JOIN travel t ON t.id = e.travelFk
JOIN warehouse w ON w.id = t.warehouseInFk JOIN warehouse w ON w.id = t.warehouseInFk
LIMIT 1; GROUP BY t.landed, t.warehouseInFk;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
OPEN vTravels;
l: LOOP
SET vDone = FALSE;
FETCH vTravels INTO vLanded, vWarehouseFk, vIsWarehouseFloramondo;
IF vDone THEN
LEAVE l;
END IF;
CALL rate_getPrices(vLanded, vWarehouseFk); CALL rate_getPrices(vLanded, vWarehouseFk);
@ -40,13 +48,12 @@ BEGIN
b.packageValue = @EF:= IF(vIsWarehouseFloramondo, 0, IFNULL(ROUND(IF(p.isPackageReturnable, p.returnCost / b.packing , p.`value` / b.packing), 3),0)), b.packageValue = @EF:= IF(vIsWarehouseFloramondo, 0, IFNULL(ROUND(IF(p.isPackageReturnable, p.returnCost / b.packing , p.`value` / b.packing), 3),0)),
b.price3 = @t3:= IF(r.rate3 = 0, b.buyingValue,ROUND((b.buyingValue + @CF + @EF + @PF) / ((100 - r.rate3 - it.promo ) /100) ,2)), -- He añadido que el coste sea igual a tarifa3 si t3 = 0 b.price3 = @t3:= IF(r.rate3 = 0, b.buyingValue,ROUND((b.buyingValue + @CF + @EF + @PF) / ((100 - r.rate3 - it.promo ) /100) ,2)), -- He añadido que el coste sea igual a tarifa3 si t3 = 0
b.price2 = @t2:= round(@t3 * (1 + ((r.rate2 - r.rate3)/100)),2), b.price2 = @t2:= round(@t3 * (1 + ((r.rate2 - r.rate3)/100)),2),
b.price2 = @t2:= IF(@t2 <= @t3,@t3 , @t2); b.price2 = @t2:= IF(@t2 <= @t3,@t3 , @t2)
WHERE tr.landed = vLanded
SELECT (b.buyingValue = b.price2), b.buyingValue, b.packagingFk AND tr.warehouseInFk = vWarehouseFk;
INTO vHasNotPrice, vBuyingValue, vPackagingFk
FROM vn.buy b
WHERE b.id = @buyId AND b.buyingValue <> 0.01;
DROP TEMPORARY TABLE tmp.rate; DROP TEMPORARY TABLE tmp.rate;
END LOOP;
CLOSE vTravels;
END$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -138,9 +138,9 @@ module.exports = Self => {
? {'ii.id': value} ? {'ii.id': value}
: {'s.name': {like: `%${value}%`}}; : {'s.name': {like: `%${value}%`}};
case 'from': case 'from':
return {'ii.created': {gte: value}}; return {'ii.issued': {gte: value}};
case 'to': case 'to':
return {'ii.created': {lte: value}}; return {'ii.issued': {lte: value}};
case 'fi': case 'fi':
return {'s.nif': value}; return {'s.nif': value};
case 'account': case 'account':
@ -173,7 +173,6 @@ module.exports = Self => {
const stmt = new ParameterizedSQL( const stmt = new ParameterizedSQL(
`SELECT `SELECT
ii.id, ii.id,
ii.serialNumber,
ii.serial, ii.serial,
ii.issued, ii.issued,
ii.isBooked, ii.isBooked,

View File

@ -27,10 +27,12 @@ module.exports = Self => {
const [result] = await Self.rawSql(` const [result] = await Self.rawSql(`
SELECT iit.*, SELECT iit.*,
SUM(iidd.amount) totalDueDay SUM(iidd.amount) totalDueDay,
SUM(iidd.foreignValue) totalDueDayForeignValue
FROM vn.invoiceIn ii FROM vn.invoiceIn ii
LEFT JOIN ( LEFT JOIN (
SELECT SUM(iit.taxableBase) totalTaxableBase, SELECT SUM(iit.taxableBase) totalTaxableBase,
SUM(iit.foreignValue) totalTaxableBaseForeignValue,
CAST( CAST(
SUM(IFNULL(iit.taxableBase * (1 + (ti.PorcentajeIva / 100)), iit.taxableBase)) SUM(IFNULL(iit.taxableBase * (1 + (ti.PorcentajeIva / 100)), iit.taxableBase))
AS DECIMAL(10, 2) AS DECIMAL(10, 2)

View File

@ -47,29 +47,6 @@ describe('InvoiceIn filter()', () => {
} }
}); });
it('should return the invoice in matching the serial number', async() => {
const tx = await models.InvoiceIn.beginTransaction({});
const options = {transaction: tx};
try {
const ctx = {
args: {
serialNumber: '1002',
}
};
const result = await models.InvoiceIn.filter(ctx, {}, options);
expect(result.length).toEqual(1);
expect(result[0].serialNumber).toEqual(1002);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
it('should return the invoice in matching the account', async() => { it('should return the invoice in matching the account', async() => {
const tx = await models.InvoiceIn.beginTransaction({}); const tx = await models.InvoiceIn.beginTransaction({});
const options = {transaction: tx}; const options = {transaction: tx};
@ -158,7 +135,7 @@ describe('InvoiceIn filter()', () => {
const result = await models.InvoiceIn.filter(ctx, {}, options); const result = await models.InvoiceIn.filter(ctx, {}, options);
expect(result.length).toEqual(5); expect(result.length).toEqual(6);
await tx.rollback(); await tx.rollback();
} catch (e) { } catch (e) {

View File

@ -13,7 +13,7 @@ module.exports = async function(ctx, Self, tickets, reqArgs = {}) {
const failedtickets = []; const failedtickets = [];
for (const ticket of tickets) { for (const ticket of tickets) {
try { try {
await Self.app.models.InvoiceOut.getSerial(ticket.clientFk, ticket.companyFk, ticket.addressFk, 'multiple'); await Self.app.models.InvoiceOut.getSerial(ticket.clientFk, ticket.companyFk, ticket.addressFk, 'quick');
await Self.rawSql( await Self.rawSql(
`CALL vn.ticket_closeByTicket(?)`, `CALL vn.ticket_closeByTicket(?)`,
[ticket.id], [ticket.id],