Merge branch 'dev' into 6095-refFk-null-on-search
gitea/salix/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Carlos Satorres 2024-05-24 06:26:46 +00:00
commit a5079a5ae0
18 changed files with 222 additions and 145 deletions

View File

@ -2549,18 +2549,18 @@ INSERT INTO `vn`.`duaEntry` (`duaFk`, `entryFk`, `value`, `customsValue`, `euroV
(7, 7, 1.00, 1.00, 1.00), (7, 7, 1.00, 1.00, 1.00),
(8, 8, 1.00, 1.00, 1.00); (8, 8, 1.00, 1.00, 1.00);
REPLACE INTO `vn`.`invoiceIn`(`id`, `serialNumber`,`serial`, `supplierFk`, `issued`, `created`, `supplierRef`, `isBooked`, `companyFk`, `docFk`) REPLACE INTO `vn`.`invoiceIn`(`id`, `serialNumber`,`serial`, `supplierFk`, `issued`, `created`, `supplierRef`, `isBooked`, `companyFk`, `docFk`, `bookEntried`)
VALUES VALUES
(1, 1001, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1234, 0, 442, 1), (1, 1001, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1234, 0, 442, 1,util.VN_CURDATE()),
(2, 1002, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1235, 0, 442, 1), (2, 1002, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1235, 0, 442, 1,util.VN_CURDATE()),
(3, 1003, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1236, 0, 442, 1), (3, 1003, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1236, 0, 442, 1,util.VN_CURDATE()),
(4, 1004, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1237, 0, 442, 1), (4, 1004, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1237, 0, 442, 1,util.VN_CURDATE()),
(5, 1005, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1238, 0, 442, 1), (5, 1005, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1238, 0, 442, 1,util.VN_CURDATE()),
(6, 1006, 'R', 2, util.VN_CURDATE(), util.VN_CURDATE(), 1239, 0, 442, 1), (6, 1006, 'R', 2, util.VN_CURDATE(), util.VN_CURDATE(), 1239, 0, 442, 1,util.VN_CURDATE()),
(7, 1007, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1240, 0, 442, 1), (7, 1007, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1240, 0, 442, 1,util.VN_CURDATE()),
(8, 1008, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1241, 0, 442, 1), (8, 1008, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1241, 0, 442, 1,util.VN_CURDATE()),
(9, 1009, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1242, 0, 442, 1), (9, 1009, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1242, 0, 442, 1,util.VN_CURDATE()),
(10, 1010, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1243, 0, 442, 1); (10, 1010, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1243, 0, 442, 1,util.VN_CURDATE());
INSERT INTO `vn`.`invoiceInConfig` (`id`, `retentionRate`, `retentionName`, `sageFarmerWithholdingFk`, `daysAgo`) INSERT INTO `vn`.`invoiceInConfig` (`id`, `retentionRate`, `retentionName`, `sageFarmerWithholdingFk`, `daysAgo`)
VALUES VALUES
@ -3792,3 +3792,10 @@ INSERT INTO vn.workCenter (id, name, payrollCenterFk, counter, warehouseFk, stre
VALUES(100, 'workCenterOne', 1, NULL, 1, 'gotham', NULL, NULL); VALUES(100, 'workCenterOne', 1, NULL, 1, 'gotham', NULL, NULL);
UPDATE vn.locker SET workerFk = 1110 WHERE id = 147; UPDATE vn.locker SET workerFk = 1110 WHERE id = 147;
INSERT INTO `vn`.`ledgerCompany` SET
fiscalYear = YEAR(util.VN_CURDATE()),
bookEntry = 2;
INSERT INTO `vn`.`ledgerConfig` SET
maxTolerance = 0.01;

View File

@ -7,7 +7,7 @@ BEGIN
* *
* @param vJsonData The order data in json format * @param vJsonData The order data in json format
*/ */
INSERT INTO `order` REPLACE `order`
SET catalogueFk = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.products[0].id')), SET catalogueFk = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.products[0].id')),
customerName = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.customerName')), customerName = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.customerName')),
email = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.email')), email = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.email')),
@ -15,7 +15,8 @@ BEGIN
message= JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.message')), message= JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.message')),
deliveryName = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.deliveryName')), deliveryName = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.deliveryName')),
address = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.address')), address = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.address')),
deliveryPhone = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.deliveryPhone')); deliveryPhone = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.deliveryPhone')),
observations = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.observations'));
SELECT LAST_INSERT_ID() orderFk; SELECT LAST_INSERT_ID() orderFk;
END$$ END$$

View File

@ -81,7 +81,7 @@ BEGIN
-- Código redundante -- Código redundante
DO vn.till_new( CALL vn.till_new(
vCustomer vCustomer
,vBank ,vBank
,vAmount / 100 ,vAmount / 100

View File

@ -1,79 +1,73 @@
DELIMITER $$ DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`till_new`(vClient INT CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`till_new`(
,vBank INT vClient INT,
,vAmount DOUBLE vBank INT,
,vConcept VARCHAR(25) vAmount DOUBLE,
,vDated DATE vConcept VARCHAR(25),
,vSerie CHAR(1) vDated DATE,
,vBatch TINYINT vSerie CHAR(1),
,vNumber INT vBatch TINYINT,
,vCompany SMALLINT vNumber INT,
,vWorker INT vCompany SMALLINT,
vWorker INT
) )
RETURNS int(11)
DETERMINISTIC
BEGIN BEGIN
DECLARE vAccount VARCHAR(12); DECLARE vAccount VARCHAR(12);
DECLARE vSubaccount VARCHAR(12); DECLARE vSubaccount VARCHAR(12);
DECLARE vAsiento INT DEFAULT NULL; DECLARE vAsiento INT DEFAULT NULL;
-- Inserta el registro en cajas -- Inserta el registro en cajas
INSERT INTO till INSERT INTO till
SET SET
workerFk = vWorker workerFk = vWorker,
,bankFk = vBank bankFk = vBank,
,`in` = vAmount `in` = vAmount,
,concept = vConcept concept = vConcept,
,dated = vDated dated = vDated,
,serie = vSerie serie = vSerie,
,isAccountable = vBatch isAccountable = vBatch,
,`number` = vNumber `number` = vNumber,
,companyFk = vCompany; companyFk = vCompany;
-- Inserta los asientos contables -- Inserta los asientos contables
SELECT account INTO vAccount SELECT account INTO vAccount
FROM accounting WHERE id = vBank; FROM accounting WHERE id = vBank;
SELECT accountingAccount INTO vSubaccount SELECT accountingAccount INTO vSubaccount
FROM `client` WHERE id = vClient; FROM `client` WHERE id = vClient;
SET vAsiento = xdiario_new CALL xdiario_new(
( vAsiento,
vAsiento vDated,
,vDated vAccount,
,vAccount vSubaccount,
,vSubaccount vConcept,
,vConcept vAmount,
,vAmount 0,
,0 0,
,0 NULL, -- Serie
,NULL -- Serie NULL, -- Factura
,NULL -- Factura NULL, -- IVA
,NULL -- IVA NULL, -- Recargo
,NULL -- Recargo FALSE, -- Auxiliar
,FALSE -- Auxiliar vCompany,
,vCompany vAsiento);
);
DO xdiario_new
(
vAsiento
,vDated
,vSubaccount
,vAccount
,vConcept
,0
,vAmount
,0
,NULL -- Serie
,NULL -- Factura
,NULL -- IVA
,NULL -- Recargo
,FALSE -- Auxiliar
,vCompany
);
RETURN NULL; CALL xdiario_new(
vAsiento,
vDated,
vSubaccount,
vAccount,
vConcept,
0,
vAmount,
0,
NULL, -- Serie
NULL, -- Factura
NULL, -- IVA
NULL, -- Recargo
FALSE, -- Auxiliar
vCompany,
vAsiento);
END$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -1,45 +0,0 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`xdiario_new`(
vBookNumber INT,
vDated DATE,
vSubaccount VARCHAR(12),
vAccount VARCHAR(12),
vConcept VARCHAR(25),
vDebit DOUBLE,
vCredit DOUBLE,
vEuro DOUBLE,
vSerie CHAR(1),
vInvoice VARCHAR(8),
vVat DOUBLE,
vRe DOUBLE,
vAux TINYINT,
vCompanyFk INT
)
RETURNS int(11)
NOT DETERMINISTIC
NO SQL
BEGIN
IF vBookNumber IS NULL THEN
CALL ledger_next(YEAR(vDated), vBookNumber);
END IF;
INSERT INTO XDiario
SET ASIEN = vBookNumber,
FECHA = vDated,
SUBCTA = vSubaccount,
CONTRA = vAccount,
CONCEPTO = vConcept,
EURODEBE = vDebit,
EUROHABER = vCredit,
BASEEURO = vEuro,
SERIE = vSerie,
FACTURA = vInvoice,
IVA = vVat,
RECEQUIV = vRe,
AUXILIAR = IF(vAux = FALSE, NULL, '*'),
MONEDAUSO = 2,
empresa_id = vCompanyFk;
RETURN vBookNumber;
END$$
DELIMITER ;

View File

@ -1,13 +1,55 @@
DELIMITER $$ DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ledger_next`( CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ledger_next`(
IN vFiscalYear INT, IN vFiscalYear INT,
OUT vNewBookEntry INT OUT vLastBookEntry INT
) )
BEGIN BEGIN
DECLARE vHasStartTransaction BOOLEAN;
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
IF vHasStartTransaction THEN
ROLLBACK TO sp;
RESIGNAL;
ELSE
ROLLBACK;
CALL util.throw ('It has not been possible to generate a new ledger');
END IF;
END;
IF vFiscalYear IS NULL THEN
CALL util.throw('Fiscal year is required');
END IF;
SELECT @@in_transaction INTO vHasStartTransaction;
IF NOT vHasStartTransaction THEN
START TRANSACTION;
ELSE
SAVEPOINT sp;
END IF;
SELECT bookEntry + 1 INTO vLastBookEntry
FROM ledgerCompany
WHERE fiscalYear = vFiscalYear
FOR UPDATE;
IF vLastBookEntry IS NULL THEN
INSERT INTO ledgerCompany
SET fiscalYear = vFiscalYear,
bookEntry = 1;
SET vLastBookEntry = 1;
END IF;
UPDATE ledgerCompany UPDATE ledgerCompany
SET bookEntry = LAST_INSERT_ID(bookEntry + 1) SET bookEntry = vLastBookEntry
WHERE fiscalYear = vFiscalYear; WHERE fiscalYear = vFiscalYear;
SET vNewBookEntry = LAST_INSERT_ID(); IF vHasStartTransaction THEN
RELEASE SAVEPOINT sp;
ELSE
COMMIT;
END IF;
END$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -12,12 +12,15 @@ BEGIN
CREATE OR REPLACE TEMPORARY TABLE tmp.sale CREATE OR REPLACE TEMPORARY TABLE tmp.sale
(INDEX(saleFk)) (INDEX(saleFk))
ENGINE = MEMORY ENGINE = MEMORY
SELECT s.id saleFk, sale_hasComponentLack(s.id) hasProblem SELECT saleFk, sale_hasComponentLack(saleFk)hasProblem
FROM (
SELECT s.id saleFk
FROM ticket t FROM ticket t
JOIN sale s ON s.ticketFk = t.id JOIN sale s ON s.ticketFk = t.id
LEFT JOIN saleComponent sc ON sc.saleFk = s.id LEFT JOIN saleComponent sc ON sc.saleFk = s.id
WHERE t.shipped >= util.midnight() WHERE t.shipped >= util.midnight()
AND (vComponentFk IS NULL OR sc.componentFk = vComponentFk); AND (vComponentFk IS NULL OR sc.componentFk = vComponentFk)
GROUP BY s.id) sub;
CALL sale_setProblem('hasComponentLack'); CALL sale_setProblem('hasComponentLack');

View File

@ -20,15 +20,15 @@ BEGIN
CALL buyUltimate(vWarehouseFk, vShipped); CALL buyUltimate(vWarehouseFk, vShipped);
CREATE OR REPLACE TEMPORARY TABLE tmp.ticket CREATE OR REPLACE TEMPORARY TABLE tmp.sale
SELECT vSelf saleFk, MOD(vQuantity, bu.`grouping`) hasProblem SELECT vSelf saleFk, MOD(vQuantity, b.`grouping`) hasProblem
FROM tmp.buyUltimate bu FROM tmp.buyUltimate bu
JOIN buy b ON b.id = bu.buyFk JOIN buy b ON b.id = bu.buyFk
WHERE bu.itemFk = vItemFk; WHERE bu.itemFk = vItemFk;
CALL sale_setProblem('hasRounding'); CALL sale_setProblem('hasRounding');
DROP TEMPORARY TABLE tmp.ticket; DROP TEMPORARY TABLE tmp.sale;
DROP TEMPORARY TABLE tmp.buyUltimate; DROP TEMPORARY TABLE tmp.buyUltimate;
END$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -22,7 +22,7 @@ BEGIN
SET t.hasProblem = TRUE SET t.hasProblem = TRUE
WHERE c.isFreezed; WHERE c.isFreezed;
CALL ticket_setProblem('hasTicketRequest'); CALL ticket_setProblem('isFreezed');
DROP TEMPORARY TABLE tmp.ticket; DROP TEMPORARY TABLE tmp.ticket;
END$$ END$$

View File

@ -19,7 +19,7 @@ BEGIN
WHERE t.id = vSelf; WHERE t.id = vSelf;
CREATE OR REPLACE TEMPORARY TABLE tmp.ticket CREATE OR REPLACE TEMPORARY TABLE tmp.ticket
SELECT vSelf ticketFk, vRisk hasProblem; SELECT vSelf ticketFk, vHasRisk hasProblem;
CALL ticket_setProblem('hasRisk'); CALL ticket_setProblem('hasRisk');

View File

@ -18,17 +18,17 @@ BEGIN
CALL buyUltimate(vWarehouseFk, vDated); CALL buyUltimate(vWarehouseFk, vDated);
CREATE OR REPLACE TEMPORARY TABLE tmp.ticket CREATE OR REPLACE TEMPORARY TABLE tmp.sale
SELECT s.id saleFk , MOD(s.quantity, b.`grouping`) hasProblem SELECT s.id saleFk , MOD(s.quantity, b.`grouping`) hasProblem
FROM ticket t FROM ticket t
JOIN sale s ON s.ticketFk = tl.ticketFk JOIN sale s ON s.ticketFk = t.id
JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk
JOIN buy b ON b.id = bu.buyFk JOIN buy b ON b.id = bu.buyFk
WHERE t.id = vSelf; WHERE t.id = vSelf;
CALL sale_setProblem('hasRounding'); CALL sale_setProblem('hasRounding');
DROP TEMPORARY TABLE tmp.ticket; DROP TEMPORARY TABLE tmp.sale;
DROP TEMPORARY TABLE tmp.buyUltimate; DROP TEMPORARY TABLE tmp.buyUltimate;
END$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -15,7 +15,7 @@ BEGIN
WITH tickets AS( WITH tickets AS(
SELECT t.id ticketFk SELECT t.id ticketFk
FROM vn.ticket t FROM vn.ticket t
JOIN vn.sale s ON s.ticketFk = t.id LEFT JOIN vn.sale s ON s.ticketFk = t.id
WHERE t.shipped >= util.midnight() WHERE t.shipped >= util.midnight()
AND (s.itemFk = vItemFk OR vItemFk IS NULL) AND (s.itemFk = vItemFk OR vItemFk IS NULL)
GROUP BY t.id GROUP BY t.id

View File

@ -0,0 +1,64 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`xdiario_new`(
vBookNumber INT,
vDated DATE,
vSubaccount VARCHAR(12),
vAccount VARCHAR(12),
vConcept VARCHAR(25),
vDebit DOUBLE,
vCredit DOUBLE,
vEuro DOUBLE,
vSerie CHAR(1),
vInvoice VARCHAR(8),
vVat DOUBLE,
vRe DOUBLE,
vAux TINYINT,
vCompanyFk INT,
OUT vNewBookNumber INT
)
/**
* Este procedimiento se encarga de la inserción de registros en la tabla XDiario.
* Si el número de asiento (vBookNumber) no está definido, se genera uno nuevo utilizando
* vn.ledger_next.
*
* @param vBookNumber Número de asiento. Si es NULL, se generará uno nuevo.
* @param vDated Fecha utilizada para generar un nuevo número de libro si vBookNumber es NULL.
* @param vSubaccount Subcuenta para la transacción.
* @param vAccount Cuenta para la transacción.
* @param vConcept Concepto de la transacción.
* @param vDebit Monto del débito para la transacción.
* @param vCredit Monto del crédito para la transacción.
* @param vEuro Monto en euros para la transacción.
* @param vSerie Serie para la transacción.
* @param vInvoice Número de factura para la transacción.
* @param vVat Monto del IVA para la transacción.
* @param vRe Monto del RE para la transacción.
* @param vAux Variable auxiliar para la transacción.
* @param vCompanyFk Clave foránea de la compañía para la transacción.
* @return No retorna un valor, pero realiza una inserción en la tabla XDiario.
*/
BEGIN
IF vBookNumber IS NULL THEN
CALL ledger_next(YEAR(vDated), vBookNumber);
END IF;
INSERT INTO XDiario
SET ASIEN = vBookNumber,
FECHA = vDated,
SUBCTA = vSubaccount,
CONTRA = vAccount,
CONCEPTO = vConcept,
EURODEBE = vDebit,
EUROHABER = vCredit,
BASEEURO = vEuro,
SERIE = vSerie,
FACTURA = vInvoice,
IVA = vVat,
RECEQUIV = vRe,
AUXILIAR = IF(vAux = FALSE, NULL, '*'),
MONEDAUSO = 2,
empresa_id = vCompanyFk;
SET vNewBookNumber = vBookNumber;
END$$
DELIMITER ;

View File

@ -0,0 +1,4 @@
-- Place your SQL code here
INSERT INTO salix.defaultViewConfig
(tableCode, `columns`)
VALUES('routesList', '{"ID":true,"worker":true,"agency":true,"vehicle":true,"date":true,"volume":true,"description":true,"started":true,"finished":true,"actions":true}');

View File

@ -226,5 +226,6 @@
"This password can only be changed by the user themselves": "This password can only be changed by the user themselves", "This password can only be changed by the user themselves": "This password can only be changed by the user themselves",
"They're not your subordinate": "They're not your subordinate", "They're not your subordinate": "They're not your subordinate",
"InvoiceIn is already booked": "InvoiceIn is already booked", "InvoiceIn is already booked": "InvoiceIn is already booked",
"This workCenter is already assigned to this agency": "This workCenter is already assigned to this agency" "This workCenter is already assigned to this agency": "This workCenter is already assigned to this agency",
"You can only have one PDA": "You can only have one PDA"
} }

View File

@ -357,6 +357,7 @@
"This workCenter is already assigned to this agency": "Este centro de trabajo ya está asignado a esta agencia", "This workCenter is already assigned to this agency": "Este centro de trabajo ya está asignado a esta agencia",
"Select ticket or client": "Elija un ticket o un client", "Select ticket or client": "Elija un ticket o un client",
"It was not able to create the invoice": "No se pudo crear la factura", "It was not able to create the invoice": "No se pudo crear la factura",
"This PDA is already assigned to another user": "This PDA is already assigned to another user", "ticketCommercial": "El ticket {{ ticket }} para el vendedor {{ salesMan }} está en preparación. (mensaje generado automáticamente)",
"ticketCommercial": "El ticket {{ ticket }} para el vendedor {{ salesMan }} está en preparación. (mensaje generado automáticamente)" "This PDA is already assigned to another user": "Este PDA ya está asignado a otro usuario",
"You can only have one PDA": "Solo puedes tener un PDA"
} }

View File

@ -95,9 +95,11 @@ module.exports = function(Self) {
myOptions myOptions
); );
} else if (accountingType.isAutoConciliated == true) { } else if (accountingType.isAutoConciliated == true) {
const description = `${originalClient.id} : ${originalClient.socialName} - ${accountingType.receiptDescription}`; const description =
const [xdiarioNew] = await Self.rawSql( `${originalClient.id} : ${originalClient.socialName} - ${accountingType.receiptDescription}`;
`SELECT xdiario_new(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ledger;`, const [, [xdiarioNew]] = await Self.rawSql(
`CALL xdiario_new(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, @xdiarioNew);
SELECT @xdiarioNew ledger;`,
[ [
null, null,
date, date,
@ -118,7 +120,7 @@ module.exports = function(Self) {
); );
await Self.rawSql( await Self.rawSql(
`SELECT xdiario_new(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);`, `CALL xdiario_new(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, @xdiarioNew);`,
[ [
xdiarioNew.ledger, xdiarioNew.ledger,
date, date,

View File

@ -3,6 +3,9 @@ module.exports = Self => {
Self.rewriteDbError(function(err) { Self.rewriteDbError(function(err) {
if (err.code === 'ER_DUP_ENTRY') if (err.code === 'ER_DUP_ENTRY')
return new UserError(`This PDA is already assigned to another user`); return new UserError(`This PDA is already assigned to another user`);
if (err.code === 'ER_SIGNAL_EXCEPTION' && err.sqlMessage === 'You can only have one active PDA')
return new UserError(err.sqlMessage);
return err; return err;
}); });
}; };