#5914 - hotFix-transferInvoice #1893
|
@ -2,8 +2,8 @@ DELIMITER $$
|
||||||
$$
|
$$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`getTaxBases`()
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`getTaxBases`()
|
||||||
BEGIN
|
BEGIN
|
||||||
|
/**
|
||||||
alexm marked this conversation as resolved
Outdated
|
|||||||
/* Calcula y devuelve en número de bases imponibles postivas y negativas
|
* Calcula y devuelve en número de bases imponibles postivas y negativas
|
||||||
* Requiere la tabla temporal tmp.ticketToInvoice(id)
|
* Requiere la tabla temporal tmp.ticketToInvoice(id)
|
||||||
*
|
*
|
||||||
* returns tmp.taxBases
|
* returns tmp.taxBases
|
||||||
|
@ -21,10 +21,10 @@ BEGIN
|
||||||
CREATE TEMPORARY TABLE tmp.taxBases
|
CREATE TEMPORARY TABLE tmp.taxBases
|
||||||
ENGINE = MEMORY
|
ENGINE = MEMORY
|
||||||
SELECT
|
SELECT
|
||||||
SUM(CASE WHEN taxableBase > 0 THEN 1 ELSE 0 END) as positive,
|
SUM(taxableBase > 0) as positive,
|
||||||
alexm marked this conversation as resolved
Outdated
carlosap
commented
Yo lo veo más claro así SUM(IF(taxableBase > 0, TRUE, FALSE))positive, Yo lo veo más claro así
SUM(IF(taxableBase > 0, TRUE, FALSE))positive,
SUM(IF(taxableBase < 0, TRUE; FALSE))negative
jgallego
commented
vale pero al sumar sí gastem 1 i 0 vale pero al sumar sí gastem 1 i 0
|
|||||||
SUM(CASE WHEN taxableBase < 0 THEN 1 ELSE 0 END) as negative
|
SUM(taxableBase < 0) as negative
|
||||||
FROM(
|
FROM(
|
||||||
SELECT SUM(taxableBase) as taxableBase
|
SELECT SUM(taxableBase) taxableBase
|
||||||
alexm marked this conversation as resolved
Outdated
carlosap
commented
Se pueden omitir todos los 'as' Se pueden omitir todos los 'as'
|
|||||||
FROM tmp.ticketTax
|
FROM tmp.ticketTax
|
||||||
GROUP BY pgcFk
|
GROUP BY pgcFk
|
||||||
) t;
|
) t;
|
||||||
|
|
|
@ -4,7 +4,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`hasAnyPositiveBase`(
|
||||||
DETERMINISTIC
|
DETERMINISTIC
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
||||||
/* Calcula si existe alguna base imponible positiva
|
/**
|
||||||
alexm marked this conversation as resolved
Outdated
carlosap
commented
Los comentarios están mal, la forma correcta: /** Los comentarios están mal, la forma correcta:
/**
*
*
*/
|
|||||||
|
* Calcula si existe alguna base imponible positiva
|
||||||
* Requiere la tabla temporal tmp.ticketToInvoice(id) para getTaxBases()
|
* Requiere la tabla temporal tmp.ticketToInvoice(id) para getTaxBases()
|
||||||
*
|
*
|
||||||
* returns BOOLEAN
|
* returns BOOLEAN
|
||||||
|
@ -15,7 +16,8 @@ BEGIN
|
||||||
CALL getTaxBases();
|
CALL getTaxBases();
|
||||||
|
|
||||||
SELECT positive INTO hasAnyPositiveBase
|
SELECT positive INTO hasAnyPositiveBase
|
||||||
alexm marked this conversation as resolved
Outdated
jgallego
commented
sino poses un limit uno açò pot donar error si hi ha 2 en el into sino poses un limit uno açò pot donar error si hi ha 2 en el into
|
|||||||
FROM tmp.taxBases;
|
FROM tmp.taxBases
|
||||||
|
LIMIT 1;
|
||||||
|
|
||||||
DROP TEMPORARY TABLE
|
DROP TEMPORARY TABLE
|
||||||
tmp.ticketTax,
|
tmp.ticketTax,
|
||||||
|
|
|
@ -4,7 +4,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`hasAnyNegativeBase`(
|
||||||
DETERMINISTIC
|
DETERMINISTIC
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
||||||
/* Calcula si existe alguna base imponible negativa
|
/**
|
||||||
|
* Calcula si existe alguna base imponible negativa
|
||||||
* Requiere la tabla temporal tmp.ticketToInvoice(id) para getTaxBases()
|
* Requiere la tabla temporal tmp.ticketToInvoice(id) para getTaxBases()
|
||||||
*
|
*
|
||||||
* returns BOOLEAN
|
* returns BOOLEAN
|
||||||
|
@ -15,7 +16,8 @@ BEGIN
|
||||||
CALL getTaxBases();
|
CALL getTaxBases();
|
||||||
|
|
||||||
SELECT negative INTO hasAnyNegativeBase
|
SELECT negative INTO hasAnyNegativeBase
|
||||||
alexm marked this conversation as resolved
Outdated
jgallego
commented
limit 1 limit 1
|
|||||||
FROM tmp.taxBases;
|
FROM tmp.taxBases
|
||||||
|
LIMIT 1;
|
||||||
|
|
||||||
DROP TEMPORARY TABLE
|
DROP TEMPORARY TABLE
|
||||||
tmp.ticketTax,
|
tmp.ticketTax,
|
||||||
|
@ -27,3 +29,4 @@ BEGIN
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -23,3 +23,4 @@ The following refund tickets have been created: "Se han creado los siguientes ti
|
||||||
Refund...: Abono...
|
Refund...: Abono...
|
||||||
Transfer invoice to...: Transferir factura a...
|
Transfer invoice to...: Transferir factura a...
|
||||||
Rectificative type: Tipo rectificativa
|
Rectificative type: Tipo rectificativa
|
||||||
|
Invoice trasfered!: ¡Factura transferida!
|
||||||
alexm marked this conversation as resolved
Outdated
jgallego
commented
ahir diguerem de no posar signes, de fet en la resposta al client jo tampoc ho posaria ahir diguerem de no posar signes, de fet en la resposta al client jo tampoc ho posaria
|
|||||||
|
|
|
@ -71,7 +71,7 @@ module.exports = function(Self) {
|
||||||
group[addressFk].push(id);
|
group[addressFk].push(id);
|
||||||
return group;
|
return group;
|
||||||
}, {}))
|
}, {}))
|
||||||
: [[ticketsIds]];
|
: [ticketsIds];
|
||||||
|
|
||||||
for (const ticketIds of ticketsByAddress)
|
for (const ticketIds of ticketsByAddress)
|
||||||
invoicesIds.push(await createInvoice(ctx, companyId, ticketIds, invoiceCorrection, myOptions));
|
invoicesIds.push(await createInvoice(ctx, companyId, ticketIds, invoiceCorrection, myOptions));
|
||||||
|
|
|
@ -121,4 +121,29 @@ describe('ticket canBeInvoiced()', () => {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should return falsy for a ticket has positiveBase', async() => {
|
||||||
|
const tx = await models.Ticket.beginTransaction({});
|
||||||
|
|
||||||
|
try {
|
||||||
|
const options = {transaction: tx};
|
||||||
|
|
||||||
|
await models.Ticket.rawSql(`
|
||||||
|
CREATE OR REPLACE TEMPORARY TABLE tmp.ticketToInvoice
|
||||||
|
(PRIMARY KEY (id))
|
||||||
|
ENGINE = MEMORY
|
||||||
|
SELECT id
|
||||||
|
FROM vn.ticket
|
||||||
|
WHERE id IN (?)
|
||||||
|
`, [ticketId], options);
|
||||||
|
|
||||||
|
await models.Ticket.canBeInvoiced(ctx, [ticketId], true, options);
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
error = e;
|
||||||
|
await tx.rollback();
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(error.message).toEqual(`hasAnyPositiveBase`);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Los saltos de línea entre los comentarios no son necesarios.