#5914 - hotFix-transferInvoice #1893
|
@ -0,0 +1,7 @@
|
|||
ALTER TABLE `vn`.`invoiceCorrection` DROP FOREIGN KEY `cplusInvoiceTyoeFk`;
|
||||
ALTER TABLE `vn`.`invoiceCorrection` DROP FOREIGN KEY `invoiceCorrectionType_Fk33`;
|
||||
ALTER TABLE `vn`.`invoiceCorrection` DROP FOREIGN KEY `invoiceCorrection_ibfk_1`;
|
||||
|
||||
ALTER TABLE `vn`.`invoiceCorrection` ADD CONSTRAINT `siiTypeInvoiceOut_FK` FOREIGN KEY (`siiTypeInvoiceOutFk`) REFERENCES `vn`.`siiTypeInvoiceOut`(id) ON UPDATE CASCADE;
|
||||
ALTER TABLE `vn`.`invoiceCorrection` ADD CONSTRAINT `invoiceCorrectionType_FK` FOREIGN KEY (`invoiceCorrectionTypeFk`) REFERENCES `vn`.`invoiceCorrectionType`(id) ON UPDATE CASCADE;
|
||||
ALTER TABLE `vn`.`invoiceCorrection` ADD CONSTRAINT `cplusRectificationType_FK` FOREIGN KEY (`cplusRectificationTypeFk`) REFERENCES `vn`.`cplusRectificationType`(id) ON UPDATE CASCADE;
|
|
@ -14,7 +14,7 @@ BEGIN
|
|||
|
||||
CALL getTaxBases();
|
||||
|
||||
SELECT positive > 0 INTO hasAnyPositiveBase
|
||||
SELECT positive INTO hasAnyPositiveBase
|
||||
FROM tmp.taxBases;
|
||||
alexm marked this conversation as resolved
Outdated
|
||||
|
||||
DROP TEMPORARY TABLE
|
|
@ -14,7 +14,7 @@ BEGIN
|
|||
|
||||
CALL getTaxBases();
|
||||
|
||||
SELECT negative > 0 INTO hasAnyNegativeBase
|
||||
SELECT negative INTO hasAnyNegativeBase
|
||||
FROM tmp.taxBases;
|
||||
alexm marked this conversation as resolved
Outdated
jgallego
commented
limit 1 limit 1
|
||||
|
||||
DROP TEMPORARY TABLE
|
|
@ -26,6 +26,33 @@
|
|||
"invoiceCorrectionTypeFk": {
|
||||
"type": "number",
|
||||
"required": true
|
||||
},
|
||||
"relations": {
|
||||
"correcting": {
|
||||
alexm marked this conversation as resolved
Outdated
jsegarra
commented
No hay relación con las tablas de "types"? No hay relación con las tablas de "types"?
|
||||
"type": "belongsTo",
|
||||
"model": "InvoiceOut",
|
||||
"foreignKey": "correctingFk"
|
||||
},
|
||||
"corrected": {
|
||||
"type": "belongsTo",
|
||||
"model": "InvoiceOut",
|
||||
"foreignKey": "correctedFk"
|
||||
},
|
||||
"cplusRectificationType": {
|
||||
"type": "belongsTo",
|
||||
"model": "cplusRectificationType",
|
||||
"foreignKey": "cplusRectificationTypeFk"
|
||||
},
|
||||
"siiTypeInvoiceOut": {
|
||||
"type": "belongsTo",
|
||||
"model": "siiTypeInvoiceOut",
|
||||
"foreignKey": "siiTypeInvoiceOutFk"
|
||||
},
|
||||
"invoiceCorrectionType": {
|
||||
"type": "belongsTo",
|
||||
"model": "invoiceCorrectionType",
|
||||
"foreignKey": "invoiceCorrectionTypeFk"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,11 +17,6 @@ module.exports = function(Self) {
|
|||
type: 'boolean'
|
||||
}
|
||||
],
|
||||
returns: {
|
||||
arg: 'data',
|
||||
type: 'boolean',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/canBeInvoiced`,
|
||||
verb: 'get'
|
||||
|
@ -63,7 +58,5 @@ module.exports = function(Self) {
|
|||
if (ticketsIds.length == 1 && priceZero)
|
||||
throw new UserError(`A ticket with an amount of zero can't be invoiced`);
|
||||
});
|
||||
|
||||
return true;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -61,20 +61,19 @@ module.exports = function(Self) {
|
|||
if (!isSameClient)
|
||||
throw new UserError(`You can't invoice tickets from multiple clients`);
|
||||
|
||||
const client = await models.Client.findById(clientId, {
|
||||
fields: ['id', 'hasToInvoiceByAddress']
|
||||
const {hasToInvoiceByAddress} = await models.Client.findById(clientId, {
|
||||
fields: ['hasToInvoiceByAddress']
|
||||
alexm marked this conversation as resolved
Outdated
jsegarra
commented
La propiedad id no la usas, al igual que en la línea 50, aunque es poco significativo. La propiedad id no la usas, al igual que en la línea 50, aunque es poco significativo.
|
||||
}, myOptions);
|
||||
|
||||
let ticketsByAddress = {[firstTicket.addressFk]: ticketsIds};
|
||||
if (client.hasToInvoiceByAddress) {
|
||||
ticketsByAddress = tickets.reduce((group, ticket) => {
|
||||
const {addressFk} = ticket;
|
||||
let ticketsByAddress = hasToInvoiceByAddress
|
||||
alexm marked this conversation as resolved
Outdated
jsegarra
commented
Asignas unos valores que luego puede que se machaquen Asignas unos valores que luego puede que se machaquen
Quizás declararia la variable vacía y pondria un else, o también mover a un método aparte
|
||||
? Object.values(tickets.reduce((group, {id, addressFk}) => {
|
||||
alexm marked this conversation as resolved
Outdated
jsegarra
commented
Si es la única llamada a client, porque no haces const { hasToInvoiceByAddress} en la línea 64 Si es la única llamada a client, porque no haces const { hasToInvoiceByAddress} en la línea 64
|
||||
group[addressFk] = group[addressFk] ?? [];
|
||||
alexm marked this conversation as resolved
jsegarra
commented
Todo esto es para hacer un Set de los Ids de tickets? Todo esto es para hacer un Set de los Ids de tickets?
Porque más abajo haces object.values entonces las keys(addressFk) te dan igual, correcto?
|
||||
group[addressFk].push(ticket.id);
|
||||
group[addressFk].push(id);
|
||||
return group;
|
||||
}, {});
|
||||
}
|
||||
for (const ticketIds of Object.values(ticketsByAddress))
|
||||
}, {}))
|
||||
: [[ticketsIds]];
|
||||
|
||||
for (const ticketIds of ticketsByAddress)
|
||||
invoicesIds.push(await createInvoice(ctx, companyId, ticketIds, invoiceCorrection, myOptions));
|
||||
|
||||
if (tx) await tx.commit();
|
||||
|
|
|
@ -106,8 +106,7 @@ module.exports = function(Self) {
|
|||
);
|
||||
}
|
||||
|
||||
if (resultInvoice.id)
|
||||
await Self.rawSql('CALL invoiceOutBooking(?)', [resultInvoice.id], myOptions);
|
||||
await Self.rawSql('CALL invoiceOutBooking(?)', [resultInvoice.id], myOptions);
|
||||
alexm marked this conversation as resolved
Outdated
jsegarra
commented
Puede ser resultInvoice.id nulo? Porque en la línea 99 ya se emitiría un error Puede ser resultInvoice.id nulo? Porque en la línea 99 ya se emitiría un error
|
||||
|
||||
if (tx) await tx.commit();
|
||||
|
||||
|
|
|
@ -27,10 +27,7 @@ describe('ticket canBeInvoiced()', () => {
|
|||
WHERE id IN (?)
|
||||
`, [ticketId], options);
|
||||
|
||||
const canBeInvoiced = await models.Ticket.canBeInvoiced(ctx, [ticketId], false, options);
|
||||
|
||||
expect(canBeInvoiced).toEqual(false);
|
||||
|
||||
await models.Ticket.canBeInvoiced(ctx, [ticketId], false, options);
|
||||
alexm marked this conversation as resolved
jgallego
commented
no hi ha cap test a de canBeInvoiced amb el 3 parametro a true no hi ha cap test a de canBeInvoiced amb el 3 parametro a true
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
error = e;
|
||||
|
@ -59,10 +56,7 @@ describe('ticket canBeInvoiced()', () => {
|
|||
WHERE id IN (?)
|
||||
`, [ticketId], options);
|
||||
|
||||
const canBeInvoiced = await models.Ticket.canBeInvoiced(ctx, [ticketId], false, options);
|
||||
|
||||
expect(canBeInvoiced).toEqual(false);
|
||||
|
||||
await models.Ticket.canBeInvoiced(ctx, [ticketId], false, options);
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
error = e;
|
||||
|
@ -95,10 +89,7 @@ describe('ticket canBeInvoiced()', () => {
|
|||
WHERE id IN (?)
|
||||
`, [ticketId], options);
|
||||
|
||||
const canBeInvoiced = await models.Ticket.canBeInvoiced(ctx, [ticketId], false, options);
|
||||
|
||||
expect(canBeInvoiced).toEqual(false);
|
||||
|
||||
await models.Ticket.canBeInvoiced(ctx, [ticketId], false, options);
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
error = e;
|
||||
|
@ -123,10 +114,7 @@ describe('ticket canBeInvoiced()', () => {
|
|||
WHERE id IN (?)
|
||||
`, [ticketId], options);
|
||||
|
||||
const canBeInvoiced = await models.Ticket.canBeInvoiced(ctx, [ticketId], false, options);
|
||||
|
||||
expect(canBeInvoiced).toEqual(true);
|
||||
|
||||
await models.Ticket.canBeInvoiced(ctx, [ticketId], false, options);
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
|
|
Loading…
Reference in New Issue
sino poses un limit uno açò pot donar error si hi ha 2 en el into