refs #
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
b285c3e37a
commit
7bd378e9dd
|
@ -18,6 +18,9 @@
|
||||||
},
|
},
|
||||||
"expired": {
|
"expired": {
|
||||||
"type": "date"
|
"type": "date"
|
||||||
|
},
|
||||||
|
"supplierAccountFk": {
|
||||||
|
"type": "number"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"scope": {
|
"scope": {
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
ALTER TABLE `vn`.`company` MODIFY COLUMN sage200Company int(2) DEFAULT 10 NOT NULL;
|
|
@ -177,6 +177,7 @@
|
||||||
"Mail not sent": "There has been an error sending the invoice to the client [{{clientId}}]({{{clientUrl}}}), please check the email address",
|
"Mail not sent": "There has been an error sending the invoice to the client [{{clientId}}]({{{clientUrl}}}), please check the email address",
|
||||||
"The renew period has not been exceeded": "The renew period has not been exceeded",
|
"The renew period has not been exceeded": "The renew period has not been exceeded",
|
||||||
"You can not use the same password": "You can not use the same password",
|
"You can not use the same password": "You can not use the same password",
|
||||||
|
"The company has not informed the supplier account for bank transfers": "La empresa no tiene informado la cuenta de proveedor para transferencias bancarias",
|
||||||
"Valid priorities": "Valid priorities: %d",
|
"Valid priorities": "Valid priorities: %d",
|
||||||
"Negative basis of tickets": "Negative basis of tickets: {{ticketsIds}}"
|
"Negative basis of tickets": "Negative basis of tickets: {{ticketsIds}}"
|
||||||
}
|
}
|
||||||
|
|
|
@ -305,5 +305,7 @@
|
||||||
"The renew period has not been exceeded": "El periodo de renovación no ha sido superado",
|
"The renew period has not been exceeded": "El periodo de renovación no ha sido superado",
|
||||||
"Valid priorities": "Prioridades válidas: %d",
|
"Valid priorities": "Prioridades válidas: %d",
|
||||||
"Negative basis of tickets": "Base negativa para los tickets: {{ticketsIds}}",
|
"Negative basis of tickets": "Base negativa para los tickets: {{ticketsIds}}",
|
||||||
"You cannot assign an alias that you are not assigned to": "No puede asignar un alias que no tenga asignado"
|
"You cannot assign an alias that you are not assigned to": "No puede asignar un alias que no tenga asignado",
|
||||||
|
"The company has not informed the supplier account for bank transfers": "La empresa no tiene informado la cuenta de proveedor para transferencias bancarias"
|
||||||
|
"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
const UserError = require('vn-loopback/util/user-error');
|
||||||
|
|
||||||
module.exports = function(Self) {
|
module.exports = function(Self) {
|
||||||
Self.remoteMethodCtx('canBeInvoiced', {
|
Self.remoteMethodCtx('canBeInvoiced', {
|
||||||
description: 'Change property isEqualizated in all client addresses',
|
description: 'Change property isEqualizated in all client addresses',
|
||||||
|
@ -9,6 +11,12 @@ module.exports = function(Self) {
|
||||||
required: true,
|
required: true,
|
||||||
description: 'Client id',
|
description: 'Client id',
|
||||||
http: {source: 'path'}
|
http: {source: 'path'}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'companyFk',
|
||||||
|
description: 'The company id',
|
||||||
|
type: 'number',
|
||||||
|
required: true
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
returns: {
|
returns: {
|
||||||
|
@ -22,18 +30,29 @@ module.exports = function(Self) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.canBeInvoiced = async(id, options) => {
|
Self.canBeInvoiced = async(id, companyFk, options) => {
|
||||||
const models = Self.app.models;
|
const models = Self.app.models;
|
||||||
|
|
||||||
const myOptions = {};
|
const myOptions = {};
|
||||||
|
|
||||||
if (typeof options == 'object')
|
if (typeof options == 'object')
|
||||||
Object.assign(myOptions, options);
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
const client = await models.Client.findById(id, {
|
const client = await models.Client.findById(id, {
|
||||||
fields: ['id', 'isTaxDataChecked', 'hasToInvoice']
|
fields: ['id', 'isTaxDataChecked', 'hasToInvoice', 'payMethodFk'],
|
||||||
|
include:
|
||||||
|
{
|
||||||
|
relation: 'payMethod',
|
||||||
|
scope: {
|
||||||
|
fields: ['code']
|
||||||
|
}
|
||||||
|
}
|
||||||
}, myOptions);
|
}, myOptions);
|
||||||
|
|
||||||
|
const company = await models.Company.findById(companyFk, {fields: ['supplierAccountFk']}, myOptions);
|
||||||
|
|
||||||
|
if (client.payMethod().code === 'wireTransfer' && !company.supplierAccountFk)
|
||||||
|
throw new UserError('The company has not informed the supplier account for bank transfers');
|
||||||
|
|
||||||
if (client.isTaxDataChecked && client.hasToInvoice)
|
if (client.isTaxDataChecked && client.hasToInvoice)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ module.exports = function(Self) {
|
||||||
{
|
{
|
||||||
arg: 'companyFk',
|
arg: 'companyFk',
|
||||||
description: 'The company id',
|
description: 'The company id',
|
||||||
type: 'string',
|
type: 'number',
|
||||||
required: true
|
required: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -67,7 +67,7 @@ module.exports = function(Self) {
|
||||||
|
|
||||||
const [firstTicket] = tickets;
|
const [firstTicket] = tickets;
|
||||||
const clientId = firstTicket.clientFk;
|
const clientId = firstTicket.clientFk;
|
||||||
const clientCanBeInvoiced = await models.Client.canBeInvoiced(clientId, myOptions);
|
const clientCanBeInvoiced = await models.Client.canBeInvoiced(clientId, companyFk, myOptions);
|
||||||
if (!clientCanBeInvoiced)
|
if (!clientCanBeInvoiced)
|
||||||
throw new UserError(`This client can't be invoiced`);
|
throw new UserError(`This client can't be invoiced`);
|
||||||
|
|
||||||
|
|
|
@ -1,31 +1,19 @@
|
||||||
SELECT
|
SELECT
|
||||||
io.ref,
|
io.ref,
|
||||||
c.socialName,
|
|
||||||
sa.iban,
|
|
||||||
pm.name AS payMethod,
|
|
||||||
t.clientFk,
|
|
||||||
t.shipped,
|
|
||||||
t.nickname,
|
|
||||||
s.ticketFk,
|
s.ticketFk,
|
||||||
s.itemFk,
|
ib.ediBotanic botanical,
|
||||||
s.concept,
|
s.quantity,
|
||||||
s.quantity,
|
s.price,
|
||||||
s.price,
|
|
||||||
s.discount,
|
s.discount,
|
||||||
i.tag5,
|
s.itemFk,
|
||||||
i.value5,
|
s.concept,
|
||||||
i.tag6,
|
tc.code vatType
|
||||||
i.value6,
|
|
||||||
i.tag7,
|
|
||||||
i.value7,
|
|
||||||
tc.code AS vatType,
|
|
||||||
ib.ediBotanic botanical
|
|
||||||
FROM vn.invoiceOut io
|
FROM vn.invoiceOut io
|
||||||
JOIN vn.ticket t ON t.refFk = io.ref
|
JOIN vn.ticket t ON t.refFk = io.ref
|
||||||
JOIN vn.supplier su ON su.id = io.companyFk
|
JOIN vn.supplier su ON su.id = io.companyFk
|
||||||
JOIN vn.client c ON c.id = t.clientFk
|
JOIN vn.client c ON c.id = t.clientFk
|
||||||
JOIN vn.payMethod pm ON pm.id = c.payMethodFk
|
JOIN vn.payMethod pm ON pm.id = c.payMethodFk
|
||||||
JOIN vn.company co ON co.id = io.companyFk
|
JOIN vn.company co ON co.id = io.companyFk
|
||||||
JOIN vn.supplierAccount sa ON sa.id = co.supplierAccountFk
|
JOIN vn.supplierAccount sa ON sa.id = co.supplierAccountFk
|
||||||
JOIN vn.sale s ON s.ticketFk = t.id
|
JOIN vn.sale s ON s.ticketFk = t.id
|
||||||
JOIN item i ON i.id = s.itemFk
|
JOIN item i ON i.id = s.itemFk
|
||||||
|
@ -38,35 +26,23 @@ SELECT
|
||||||
AND itc.itemFk = s.itemFk
|
AND itc.itemFk = s.itemFk
|
||||||
JOIN vn.taxClass tc ON tc.id = itc.taxClassFk
|
JOIN vn.taxClass tc ON tc.id = itc.taxClassFk
|
||||||
WHERE t.refFk = ?
|
WHERE t.refFk = ?
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT
|
SELECT
|
||||||
io.ref,
|
io.ref,
|
||||||
c.socialName,
|
t.id ticketFk,
|
||||||
sa.iban,
|
NULL botanical,
|
||||||
pm.name AS payMethod,
|
ts.quantity,
|
||||||
t.clientFk,
|
ts.price,
|
||||||
t.shipped,
|
0 discount,
|
||||||
t.nickname,
|
|
||||||
t.id AS ticketFk,
|
|
||||||
'',
|
'',
|
||||||
ts.description concept,
|
ts.description concept,
|
||||||
ts.quantity,
|
tc.code vatType
|
||||||
ts.price,
|
|
||||||
0 discount,
|
|
||||||
NULL AS tag5,
|
|
||||||
NULL AS value5,
|
|
||||||
NULL AS tag6,
|
|
||||||
NULL AS value6,
|
|
||||||
NULL AS tag7,
|
|
||||||
NULL AS value7,
|
|
||||||
tc.code AS vatType,
|
|
||||||
NULL AS botanical
|
|
||||||
FROM vn.invoiceOut io
|
FROM vn.invoiceOut io
|
||||||
JOIN vn.ticket t ON t.refFk = io.ref
|
JOIN vn.ticket t ON t.refFk = io.ref
|
||||||
JOIN vn.ticketService ts ON ts.ticketFk = t.id
|
JOIN vn.ticketService ts ON ts.ticketFk = t.id
|
||||||
JOIN vn.client c ON c.id = t.clientFk
|
JOIN vn.client c ON c.id = t.clientFk
|
||||||
JOIN vn.payMethod pm ON pm.id = c.payMethodFk
|
JOIN vn.payMethod pm ON pm.id = c.payMethodFk
|
||||||
JOIN vn.company co ON co.id = io.companyFk
|
JOIN vn.company co ON co.id = io.companyFk
|
||||||
JOIN vn.supplierAccount sa ON sa.id = co.supplierAccountFk
|
JOIN vn.supplierAccount sa ON sa.id = co.supplierAccountFk
|
||||||
JOIN vn.taxClass tc ON tc.id = ts.taxClassFk
|
JOIN vn.taxClass tc ON tc.id = ts.taxClassFk
|
||||||
WHERE t.refFk = ?
|
WHERE t.refFk = ?
|
||||||
|
|
Loading…
Reference in New Issue