Merge branch 'dev' into 6553-workerBusiness
gitea/salix/pipeline/pr-dev This commit looks good
Details
gitea/salix/pipeline/pr-dev This commit looks good
Details
This commit is contained in:
commit
11d1cd8eb3
|
@ -33,9 +33,16 @@
|
|||
<mrw:CodigoServicio><%= expeditionData.serviceType %></mrw:CodigoServicio>
|
||||
<mrw:NumeroBultos>1</mrw:NumeroBultos>
|
||||
<mrw:EntregaSabado><%= expeditionData.weekDays %></mrw:EntregaSabado>
|
||||
<mrw:Peso><%= expeditionData.kg %></mrw:Peso>
|
||||
<mrw:Reembolso/>
|
||||
<mrw:ImporteReembolso/>
|
||||
<mrw:Bultos>
|
||||
<mrw:BultoRequest>
|
||||
<mrw:Alto><%= mrw.defaultHeight %></mrw:Alto>
|
||||
<mrw:Largo><%= mrw.defaultLength %></mrw:Largo>
|
||||
<mrw:Ancho><%= mrw.defaultWidth %></mrw:Ancho>
|
||||
<mrw:Peso><%= mrw.defaultWeight %></mrw:Peso>
|
||||
</mrw:BultoRequest>
|
||||
</mrw:Bultos>
|
||||
</mrw:DatosServicio>
|
||||
</mrw:request>
|
||||
</mrw:TransmEnvio>
|
||||
|
|
|
@ -27,6 +27,18 @@
|
|||
},
|
||||
"subscriberCode": {
|
||||
"type": "string"
|
||||
},
|
||||
"defaultHeight": {
|
||||
"type": "number"
|
||||
},
|
||||
"defaultLength": {
|
||||
"type": "number"
|
||||
},
|
||||
"defaultWidth": {
|
||||
"type": "number"
|
||||
},
|
||||
"defaultWeight": {
|
||||
"type": "number"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ BEGIN
|
|||
-- Marcamos para no repetir
|
||||
UPDATE vn.claimEnd ce
|
||||
JOIN vn.claim c ON c.id = ce.claimFk
|
||||
SET c.isChargedToMana = TRUE
|
||||
SET ce.isGreuge = TRUE
|
||||
WHERE ce.claimDestinationFk NOT IN (1,5)
|
||||
AND NOT ce.isGreuge
|
||||
AND c.claimStateFk = 3;
|
||||
|
|
|
@ -44,8 +44,8 @@ proc:BEGIN
|
|||
addressFk
|
||||
)
|
||||
SELECT CONCAT(i.name, ' by ',a.nickname),
|
||||
i.minPrice + apc.deliveryCost,
|
||||
i.id,
|
||||
r.price + apc.deliveryCost,
|
||||
r.itemFk,
|
||||
vLanded,
|
||||
vPostalCode,
|
||||
it.name,
|
||||
|
@ -53,13 +53,15 @@ proc:BEGIN
|
|||
i.description,
|
||||
apc.addressFk
|
||||
FROM vn.item i
|
||||
JOIN (SELECT itemFk, SUM(quantity * cost) price
|
||||
FROM recipe
|
||||
GROUP BY itemFk) r ON r.itemFk = i.id
|
||||
JOIN vn.itemType it ON it.id = i.typeFk
|
||||
JOIN addressPostCode apc
|
||||
ON apc.dayOfWeek = dayOfWeek(vLanded)
|
||||
AND NOW() < vLanded - INTERVAL apc.hoursInAdvance HOUR
|
||||
AND apc.postCode = vPostalCode
|
||||
JOIN vn.address a ON a.id = apc.addressFk
|
||||
WHERE it.code IN ('FNR','FNP');
|
||||
JOIN vn.address a ON a.id = apc.addressFk;
|
||||
|
||||
SELECT *
|
||||
FROM catalogue
|
||||
|
|
|
@ -18,10 +18,29 @@ proc:BEGIN
|
|||
DECLARE vBodyEmail TEXT;
|
||||
DECLARE vZoneFk INT;
|
||||
|
||||
DECLARE exit handler FOR SQLEXCEPTION
|
||||
BEGIN
|
||||
ROLLBACK;
|
||||
|
||||
GET DIAGNOSTICS CONDITION 2 @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
|
||||
|
||||
SELECT CONCAT('ERROR ', IFNULL(@errno,0), ': ', ifnull(@text,'texto')) AS `SQLEXCEPTION`;
|
||||
|
||||
CALL vn.mail_insert(
|
||||
'floranet@verdnatura.es,pako@verdnatura.es',
|
||||
'noreply@verdnatura.es',
|
||||
'Floranet.order_confirm failure',
|
||||
CONCAT('CatalogueFk: ', vCatalogueFk, '\n','ERROR ', IFNULL(@errno, 0), ': ', ifnull(@text, 'texto'))
|
||||
);
|
||||
END;
|
||||
|
||||
IF (SELECT isPaid FROM `order` WHERE catalogueFk = vCatalogueFk) THEN
|
||||
CALL util.throw('Esta orden ya está confirmada');
|
||||
SELECT CONCAT('CatalogueFk: ', vCatalogueFk, ' Esta orden ya está confirmada') AS `ERROR`;
|
||||
LEAVE proc;
|
||||
END IF;
|
||||
|
||||
START TRANSACTION;
|
||||
|
||||
UPDATE `order`
|
||||
SET isPaid = TRUE,
|
||||
payed = NOW()
|
||||
|
@ -89,7 +108,24 @@ proc:BEGIN
|
|||
ON apc.addressFk = c.addressFk
|
||||
AND apc.dayOfWeek = dayOfWeek(c.dated)
|
||||
WHERE c.id = vCatalogueFk;
|
||||
|
||||
|
||||
INSERT INTO vn.sale(
|
||||
ticketFk,
|
||||
itemFk,
|
||||
concept,
|
||||
price,
|
||||
quantity)
|
||||
SELECT
|
||||
vNewTicketFk,
|
||||
r.elementFk,
|
||||
i.longName,
|
||||
r.cost,
|
||||
r.quantity
|
||||
FROM catalogue c
|
||||
JOIN recipe r ON r.itemFk = c.itemFk
|
||||
JOIN vn.item i ON i.id = r.elementFk
|
||||
WHERE c.id = vCatalogueFk;
|
||||
|
||||
SELECT cl.email,
|
||||
cf.email,
|
||||
CONCAT('Nuevo pedido FLORANET para entrega el ',c.dated),
|
||||
|
@ -114,7 +150,7 @@ proc:BEGIN
|
|||
JOIN `order` o ON o.catalogueFk = c.id
|
||||
JOIN config cf
|
||||
WHERE c.id = vCatalogueFk;
|
||||
|
||||
|
||||
CALL vn.mail_insert(
|
||||
vCustomerEmail,
|
||||
vFloranetEmail,
|
||||
|
@ -124,5 +160,8 @@ proc:BEGIN
|
|||
SELECT isPaid, vNewTicketFk
|
||||
FROM `order`
|
||||
WHERE catalogueFk = vCatalogueFk;
|
||||
|
||||
COMMIT;
|
||||
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -13,28 +13,12 @@ BEGIN
|
|||
* @param vCollectionFk Id de colección
|
||||
*/
|
||||
DECLARE vHasTooMuchCollections BOOL;
|
||||
DECLARE vItemPackingTypeFk VARCHAR(1);
|
||||
DECLARE vWarehouseFk INT;
|
||||
DECLARE vLockName VARCHAR(215);
|
||||
DECLARE vLockTime INT DEFAULT 30;
|
||||
|
||||
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
||||
BEGIN
|
||||
IF vLockName IS NOT NULL THEN
|
||||
DO RELEASE_LOCK(vLockName);
|
||||
CALL util.debugAdd('releaseLock', vLockName); -- Tmp
|
||||
END IF;
|
||||
|
||||
RESIGNAL;
|
||||
END;
|
||||
|
||||
-- Si hay colecciones sin terminar, sale del proceso
|
||||
CALL collection_get(vUserFk);
|
||||
|
||||
SELECT (pc.maxNotReadyCollections - COUNT(*)) <= 0,
|
||||
collection_assign_lockname
|
||||
INTO vHasTooMuchCollections,
|
||||
vLockName
|
||||
SELECT (pc.maxNotReadyCollections - COUNT(*)) <= 0
|
||||
INTO vHasTooMuchCollections
|
||||
FROM productionConfig pc
|
||||
LEFT JOIN tCollection ON TRUE;
|
||||
|
||||
|
@ -44,21 +28,6 @@ BEGIN
|
|||
CALL util.throw('Hay colecciones pendientes');
|
||||
END IF;
|
||||
|
||||
SELECT warehouseFk, itemPackingTypeFk
|
||||
INTO vWarehouseFk, vItemPackingTypeFk
|
||||
FROM operator
|
||||
WHERE workerFk = vUserFk;
|
||||
|
||||
SET vLockName = CONCAT_WS('/',
|
||||
vLockName,
|
||||
vWarehouseFk,
|
||||
vItemPackingTypeFk
|
||||
);
|
||||
|
||||
IF NOT GET_LOCK(vLockName, vLockTime) THEN
|
||||
CALL util.throw(CONCAT('Cannot get lock: ', vLockName));
|
||||
END IF;
|
||||
|
||||
-- Se eliminan las colecciones sin asignar que estan obsoletas
|
||||
INSERT INTO ticketTracking(stateFk, ticketFk)
|
||||
SELECT s.id, tc.ticketFk
|
||||
|
@ -66,7 +35,7 @@ BEGIN
|
|||
JOIN ticketCollection tc ON tc.collectionFk = c.id
|
||||
JOIN `state` s ON s.code = 'PRINTED_AUTO'
|
||||
JOIN productionConfig pc
|
||||
WHERE c.workerFk IS NULL
|
||||
WHERE c.workerFk IS NULL
|
||||
AND TIMEDIFF(util.VN_NOW(), c.created) > pc.maxNotAssignedCollectionLifeTime;
|
||||
|
||||
DELETE c.*
|
||||
|
@ -80,8 +49,7 @@ BEGIN
|
|||
VALUES(vUserFk);
|
||||
|
||||
-- Comprueba si hay colecciones disponibles que se ajustan a su configuracion
|
||||
SELECT MIN(c.id)
|
||||
INTO vCollectionFk
|
||||
SELECT MIN(c.id) INTO vCollectionFk
|
||||
FROM `collection` c
|
||||
JOIN operator o
|
||||
ON (o.itemPackingTypeFk = c.itemPackingTypeFk OR c.itemPackingTypeFk IS NULL)
|
||||
|
@ -107,7 +75,5 @@ BEGIN
|
|||
UPDATE `collection`
|
||||
SET workerFk = vUserFk
|
||||
WHERE id = vCollectionFk;
|
||||
|
||||
DO RELEASE_LOCK(vLockName);
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -6,12 +6,12 @@ BEGIN
|
|||
*
|
||||
* @param vDuaFk Id del dua a recalcular
|
||||
*/
|
||||
DECLARE done BOOL DEFAULT FALSE;
|
||||
DECLARE vDone BOOL DEFAULT FALSE;
|
||||
DECLARE vInvoiceFk INT;
|
||||
DECLARE vASIEN BIGINT DEFAULT 0;
|
||||
DECLARE vCounter INT DEFAULT 0;
|
||||
DECLARE vBookEntry INT;
|
||||
DECLARE vFiscalYear INT;
|
||||
|
||||
DECLARE rs CURSOR FOR
|
||||
DECLARE vInvoicesIn CURSOR FOR
|
||||
SELECT DISTINCT e.invoiceInFk
|
||||
FROM entry e
|
||||
JOIN duaEntry de ON de.entryFk = e.id
|
||||
|
@ -20,9 +20,7 @@ BEGIN
|
|||
AND de.customsValue
|
||||
AND ii.isBooked = FALSE;
|
||||
|
||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
|
||||
|
||||
OPEN rs;
|
||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||
|
||||
UPDATE invoiceIn ii
|
||||
JOIN entry e ON e.invoiceInFk = ii.id
|
||||
|
@ -36,38 +34,36 @@ BEGIN
|
|||
e.isConfirmed = TRUE
|
||||
WHERE d.id = vDuaFk;
|
||||
|
||||
SELECT IFNULL(ASIEN,0) INTO vASIEN
|
||||
FROM dua
|
||||
WHERE id = vDuaFk;
|
||||
SELECT ASIEN INTO vBookEntry FROM dua WHERE id = vDuaFk;
|
||||
|
||||
FETCH rs INTO vInvoiceFk;
|
||||
IF vBookEntry IS NULL THEN
|
||||
SELECT YEAR(IFNULL(ii.bookEntried, d.bookEntried)) INTO vFiscalYear
|
||||
FROM invoiceIn ii
|
||||
JOIN entry e ON e.invoiceInFk = ii.id
|
||||
JOIN duaEntry de ON de.entryFk = e.id
|
||||
JOIN dua d ON d.id = de.duaFk
|
||||
WHERE d.id = vDuaFk
|
||||
LIMIT 1;
|
||||
CALL ledger_next(vFiscalYear, FALSE, vBookEntry);
|
||||
END IF;
|
||||
|
||||
WHILE NOT done DO
|
||||
OPEN vInvoicesIn;
|
||||
|
||||
CALL invoiceIn_booking(vInvoiceFk);
|
||||
|
||||
IF vCounter > 0 OR vASIEN > 0 THEN
|
||||
|
||||
UPDATE XDiario x
|
||||
JOIN ledgerConfig lc ON lc.lastBookEntry = x.ASIEN
|
||||
SET x.ASIEN = vASIEN;
|
||||
|
||||
ELSE
|
||||
|
||||
SELECT lastBookEntry INTO vASIEN FROM ledgerConfig;
|
||||
l: LOOP
|
||||
SET vDone = FALSE;
|
||||
FETCH vInvoicesIn INTO vInvoiceFk;
|
||||
|
||||
IF vDone THEN
|
||||
LEAVE l;
|
||||
END IF;
|
||||
|
||||
SET vCounter = vCounter + 1;
|
||||
CALL invoiceIn_booking(vInvoiceFk, vBookEntry);
|
||||
END LOOP;
|
||||
|
||||
FETCH rs INTO vInvoiceFk;
|
||||
|
||||
END WHILE;
|
||||
|
||||
CLOSE rs;
|
||||
CLOSE vInvoicesIn;
|
||||
|
||||
UPDATE dua
|
||||
SET ASIEN = vASIEN
|
||||
SET ASIEN = vBookEntry
|
||||
WHERE id = vDuaFk;
|
||||
|
||||
UPDATE invoiceIn ii
|
||||
|
|
|
@ -12,7 +12,7 @@ BEGIN
|
|||
WHERE id = vDuaFk;
|
||||
|
||||
IF vBookNumber IS NULL OR NOT vBookNumber THEN
|
||||
CALL ledger_next(YEAR(vBookDated), vBookNumber);
|
||||
CALL ledger_next(YEAR(vBookDated), FALSE, vBookNumber);
|
||||
END IF;
|
||||
|
||||
-- Apunte de la aduana
|
||||
|
|
|
@ -1,7 +1,17 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceIn_booking`(vSelf INT)
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceIn_booking`(
|
||||
vSelf INT,
|
||||
vBookNumber INT
|
||||
)
|
||||
BEGIN
|
||||
DECLARE vBookNumber INT;
|
||||
/**
|
||||
* Genera la contabilidad para una factura y la marca como contabilizada
|
||||
* Cuadra el asiento generado en si encuentra problemas derivados
|
||||
* de los calculos con decimales
|
||||
*
|
||||
* @param vSelf Id invoiceIn
|
||||
* @param vBookEntry Id de asiento, si es NULL se genera uno nuevo
|
||||
*/
|
||||
DECLARE vFiscalYear INT;
|
||||
|
||||
CREATE OR REPLACE TEMPORARY TABLE tInvoiceIn
|
||||
|
@ -58,7 +68,10 @@ BEGIN
|
|||
WHERE ii.id = vSelf;
|
||||
|
||||
SELECT YEAR(bookEntried) INTO vFiscalYear FROM tInvoiceIn LIMIT 1;
|
||||
CALL ledger_next(vFiscalYear, vBookNumber);
|
||||
|
||||
IF vBookNumber IS NULL THEN
|
||||
CALL ledger_next(vFiscalYear, FALSE, vBookNumber);
|
||||
END IF;
|
||||
|
||||
-- Apunte del proveedor
|
||||
INSERT INTO XDiario(
|
||||
|
@ -187,7 +200,7 @@ BEGIN
|
|||
LEFT JOIN (
|
||||
SELECT e.id
|
||||
FROM tInvoiceIn tii
|
||||
JOIN expense e ON e.id = tii.expenseFk
|
||||
JOIN expense e ON e.id = tii.expenseFk
|
||||
WHERE e.isWithheld
|
||||
LIMIT 1
|
||||
) eWithheld ON TRUE
|
||||
|
|
|
@ -61,7 +61,7 @@ BEGIN
|
|||
WHERE io.id = vInvoice;
|
||||
|
||||
SELECT YEAR(FECHA) INTO vFiscalYear FROM rs LIMIT 1;
|
||||
CALL ledger_next(vFiscalYear, vBookNumber);
|
||||
CALL ledger_next(vFiscalYear, FALSE, vBookNumber);
|
||||
-- Linea del cliente
|
||||
INSERT INTO XDiario(
|
||||
ASIEN,
|
||||
|
|
|
@ -28,7 +28,7 @@ BEGIN
|
|||
DECLARE vIsOriginalAClient BOOL;
|
||||
DECLARE vPayMethodCompensation INT;
|
||||
|
||||
CALL ledger_next(YEAR(vDated), vNewBookEntry);
|
||||
CALL ledger_next(YEAR(vDated), FALSE, vNewBookEntry);
|
||||
|
||||
SELECT COUNT(id) INTO vIsOriginalAClient
|
||||
FROM client
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ledger_next`(
|
||||
IN vFiscalYear INT,
|
||||
IN vIsManageTransaction BOOLEAN,
|
||||
OUT vLastBookEntry INT
|
||||
)
|
||||
BEGIN
|
||||
|
@ -22,13 +23,15 @@ BEGIN
|
|||
CALL util.throw('Fiscal year is required');
|
||||
END IF;
|
||||
|
||||
SELECT @@in_transaction INTO vHasStartTransaction;
|
||||
IF NOT vIsManageTransaction THEN
|
||||
SELECT @@in_transaction INTO vHasStartTransaction;
|
||||
|
||||
IF NOT vHasStartTransaction THEN
|
||||
START TRANSACTION;
|
||||
ELSE
|
||||
SAVEPOINT sp;
|
||||
END IF;
|
||||
IF NOT vHasStartTransaction THEN
|
||||
START TRANSACTION;
|
||||
ELSE
|
||||
SAVEPOINT sp;
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
SELECT bookEntry + 1 INTO vLastBookEntry
|
||||
FROM ledgerCompany
|
||||
|
@ -46,10 +49,12 @@ BEGIN
|
|||
SET bookEntry = vLastBookEntry
|
||||
WHERE fiscalYear = vFiscalYear;
|
||||
|
||||
IF vHasStartTransaction THEN
|
||||
RELEASE SAVEPOINT sp;
|
||||
ELSE
|
||||
COMMIT;
|
||||
END IF;
|
||||
IF NOT vIsManageTransaction THEN
|
||||
IF vHasStartTransaction THEN
|
||||
RELEASE SAVEPOINT sp;
|
||||
ELSE
|
||||
COMMIT;
|
||||
END IF;
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -39,7 +39,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`xdiario_new`(
|
|||
*/
|
||||
BEGIN
|
||||
IF vBookNumber IS NULL THEN
|
||||
CALL ledger_next(YEAR(vDated), vBookNumber);
|
||||
CALL ledger_next(YEAR(vDated), FALSE, vBookNumber);
|
||||
END IF;
|
||||
|
||||
INSERT INTO XDiario
|
||||
|
|
|
@ -9,13 +9,12 @@ BEGIN
|
|||
DECLARE vIsCash BOOLEAN;
|
||||
DECLARE vIsSupplierActive BOOLEAN;
|
||||
|
||||
-- PAK 10/02/15 No se asientan los pagos directamente, salvo en el caso de las cajas de CASH
|
||||
SELECT (at2.code = 'cash') INTO vIsCash
|
||||
FROM accounting a
|
||||
JOIN accountingType at2 ON at2.id = a.accountingTypeFk
|
||||
WHERE a.id = NEW.bankFk;
|
||||
|
||||
IF vIsCash THEN
|
||||
IF vIsCash THEN
|
||||
SELECT account INTO vBankAccount
|
||||
FROM accounting
|
||||
WHERE id = NEW.bankFk;
|
||||
|
@ -24,7 +23,7 @@ BEGIN
|
|||
FROM supplier
|
||||
WHERE id = NEW.supplierFk;
|
||||
|
||||
CALL ledger_next(YEAR(NEW.received), NEW.companyFk, vNewBookEntry);
|
||||
CALL ledger_next(YEAR(NEW.received), TRUE, vNewBookEntry);
|
||||
|
||||
INSERT INTO XDiario (
|
||||
ASIEN,
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
REVOKE UPDATE ON vn. invoiceIn FROM administrative, hrBoss, buyer, logistic;
|
||||
GRANT UPDATE (id,
|
||||
serialNumber,
|
||||
serial,
|
||||
supplierFk,
|
||||
issued,
|
||||
supplierRef,
|
||||
currencyFk,
|
||||
created,
|
||||
companyFk,
|
||||
docFk,
|
||||
booked,
|
||||
operated,
|
||||
siiTypeInvoiceInFk,
|
||||
cplusRectificationTypeFk,
|
||||
cplusSubjectOpFk,
|
||||
cplusTaxBreakFk,
|
||||
siiTrascendencyInvoiceInFk,
|
||||
bookEntried,
|
||||
isVatDeductible,
|
||||
withholdingSageFk,
|
||||
expenseFkDeductible,
|
||||
editorFk
|
||||
) ON vn.invoiceIn TO administrative, hrBoss, buyer, logistic;
|
|
@ -0,0 +1,23 @@
|
|||
UPDATE salix.ACL
|
||||
SET accessType = 'READ'
|
||||
WHERE principalId IN ('administrative','buyer')
|
||||
AND model = 'invoiceIn'
|
||||
AND property = '*';
|
||||
|
||||
INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId)
|
||||
VALUES
|
||||
('InvoiceIn', 'updateInvoiceIn', 'WRITE', 'ALLOW', 'ROLE', 'administrative'),
|
||||
('InvoiceIn', 'clone', 'WRITE', 'ALLOW', 'ROLE', 'administrative'),
|
||||
('InvoiceIn', 'corrective', 'WRITE', 'ALLOW', 'ROLE', 'administrative'),
|
||||
('InvoiceIn', 'exchangeRateUpdate', 'WRITE', 'ALLOW', 'ROLE', 'administrative'),
|
||||
('InvoiceIn', 'invoiceInEmail', 'WRITE', 'ALLOW', 'ROLE', 'administrative'),
|
||||
('InvoiceIn', 'toBook', 'WRITE', 'ALLOW', 'ROLE', 'administrative'),
|
||||
('InvoiceIn', 'toUnbook', 'WRITE', 'ALLOW', 'ROLE', 'administrative'),
|
||||
('InvoiceIn', 'deleteById', 'WRITE', 'ALLOW', 'ROLE', 'administrative'),
|
||||
('InvoiceIn', 'updateInvoiceIn', 'WRITE', 'ALLOW', 'ROLE', 'buyer'),
|
||||
('InvoiceIn', 'clone', 'WRITE', 'ALLOW', 'ROLE', 'buyer'),
|
||||
('InvoiceIn', 'corrective', 'WRITE', 'ALLOW', 'ROLE', 'buyer'),
|
||||
('InvoiceIn', 'exchangeRateUpdate', 'WRITE', 'ALLOW', 'ROLE', 'buyer'),
|
||||
('InvoiceIn', 'invoiceInEmail', 'WRITE', 'ALLOW', 'ROLE', 'buyer'),
|
||||
('InvoiceIn', 'toBook', 'WRITE', 'ALLOW', 'ROLE', 'buyer'),
|
||||
('InvoiceIn', 'deleteById', 'WRITE', 'ALLOW', 'ROLE', 'buyer');
|
|
@ -0,0 +1,20 @@
|
|||
-- Place your SQL code here
|
||||
|
||||
|
||||
-- floranet.recipe definition
|
||||
|
||||
CREATE OR REPLACE TABLE floranet.`recipe`
|
||||
(
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`itemFk` int(11) NOT NULL COMMENT 'Bouquet or plant name',
|
||||
`elementFk` int(11) NOT NULL COMMENT 'Item detail for bouquet''s composition',
|
||||
`quantity` int(10) unsigned NOT NULL DEFAULT 1,
|
||||
`cost` decimal(10,2) NOT NULL DEFAULT 1.00,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `recipe_FK` (`itemFk`),
|
||||
KEY `recipe_FK_1` (`elementFk`),
|
||||
CONSTRAINT `recipe_FK` FOREIGN KEY (`itemFk`) REFERENCES `vn`.`item` (`id`) ON UPDATE CASCADE,
|
||||
CONSTRAINT `recipe_item_FK` FOREIGN KEY (`elementFk`) REFERENCES `vn`.`item` (`id`) ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='Links handmade products with their elements';
|
||||
|
||||
DROP TABLE IF EXISTS floranet.`element`;
|
|
@ -0,0 +1,5 @@
|
|||
-- Place your SQL code here
|
||||
ALTER TABLE vn.mrwConfig ADD IF NOT EXISTS defaultHeight INT UNSIGNED NULL COMMENT 'default height in centimeters';
|
||||
ALTER TABLE vn.mrwConfig ADD IF NOT EXISTS defaultLength INT UNSIGNED NULL COMMENT 'default length in centimeters';
|
||||
ALTER TABLE vn.mrwConfig ADD IF NOT EXISTS defaultWidth INT UNSIGNED NULL COMMENT 'default width in centimeters';
|
||||
ALTER TABLE vn.mrwConfig ADD IF NOT EXISTS defaultWeight INT UNSIGNED NULL COMMENT 'default weight in centimeters';
|
|
@ -76,7 +76,16 @@
|
|||
},
|
||||
"enlazadoSage": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"enlazado": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"key": {
|
||||
"type": "number",
|
||||
"mysql": {
|
||||
"columnName": "CLAVE"
|
||||
}
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"company": {
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('invoiceIn toUnbook()', () => {
|
||||
it('should check that invoiceIn is unbooked', async() => {
|
||||
const userId = 1;
|
||||
const ctx = {
|
||||
req: {
|
||||
|
||||
accessToken: {userId: userId},
|
||||
headers: {origin: 'http://localhost:5000'},
|
||||
}
|
||||
};
|
||||
const invoiceInId = 1;
|
||||
const tx = await models.InvoiceIn.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
|
||||
try {
|
||||
await models.InvoiceIn.toBook(ctx, invoiceInId, options);
|
||||
const bookEntry = await models.InvoiceIn.toUnbook(ctx, invoiceInId, options);
|
||||
const invoiceIn = await models.InvoiceIn.findById(invoiceInId, null, options);
|
||||
|
||||
expect(bookEntry.accountingEntries).toEqual(4);
|
||||
expect(bookEntry.isLinked).toBeFalsy();
|
||||
expect(invoiceIn.isBooked).toEqual(false);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
});
|
|
@ -32,7 +32,7 @@ module.exports = Self => {
|
|||
}
|
||||
|
||||
try {
|
||||
await Self.rawSql(`CALL vn.invoiceIn_booking(?)`, [id], myOptions);
|
||||
await Self.rawSql(`CALL vn.invoiceIn_booking(?, NULL)`, [id], myOptions);
|
||||
if (tx) await tx.commit();
|
||||
} catch (e) {
|
||||
if (tx) await tx.rollback();
|
||||
|
|
|
@ -0,0 +1,80 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('toUnbook', {
|
||||
description: 'To unbook the invoiceIn',
|
||||
accessType: 'WRITE',
|
||||
accepts: {
|
||||
arg: 'id',
|
||||
type: 'number',
|
||||
required: true,
|
||||
description: 'The invoiceIn id',
|
||||
http: {source: 'path'}
|
||||
},
|
||||
returns: {
|
||||
type: 'object',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: '/:id/toUnbook',
|
||||
verb: 'POST'
|
||||
}
|
||||
});
|
||||
|
||||
Self.toUnbook = async(ctx, invoiceInId, options) => {
|
||||
let tx;
|
||||
const models = Self.app.models;
|
||||
const myOptions = {userId: ctx.req.accessToken.userId};
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
if (!myOptions.transaction) {
|
||||
tx = await Self.beginTransaction({});
|
||||
myOptions.transaction = tx;
|
||||
}
|
||||
|
||||
try {
|
||||
let isLinked;
|
||||
let accountingEntries;
|
||||
|
||||
let bookEntry = await models.Xdiario.findOne({
|
||||
fields: ['ASIEN'],
|
||||
where: {
|
||||
and: [
|
||||
{key: invoiceInId},
|
||||
{enlazado: false},
|
||||
{enlazadoSage: false}
|
||||
]
|
||||
}
|
||||
}, myOptions);
|
||||
|
||||
let asien = bookEntry?.ASIEN;
|
||||
if (asien) {
|
||||
accountingEntries = await models.Xdiario.count({ASIEN: asien}, myOptions);
|
||||
|
||||
await models.Xdiario.destroyAll({ASIEN: asien}, myOptions);
|
||||
await Self.updateAll({id: invoiceInId}, {isBooked: false}, myOptions);
|
||||
} else {
|
||||
const linkedBookEntry = await models.Xdiario.findOne({
|
||||
fields: ['ASIEN'],
|
||||
where: {
|
||||
key: invoiceInId,
|
||||
and: [{or: [{enlazado: true, enlazadoSage: true}]}]
|
||||
}
|
||||
}, myOptions);
|
||||
|
||||
asien = linkedBookEntry?.ASIEN;
|
||||
isLinked = true;
|
||||
}
|
||||
if (tx) await tx.commit();
|
||||
|
||||
return {
|
||||
isLinked,
|
||||
bookEntry: asien,
|
||||
accountingEntries
|
||||
};
|
||||
} catch (e) {
|
||||
if (tx) await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
};
|
|
@ -0,0 +1,104 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('updateInvoiceIn', {
|
||||
description: 'To update the invoiceIn attributes',
|
||||
accessType: 'WRITE',
|
||||
accepts: [{
|
||||
arg: 'id',
|
||||
type: 'number',
|
||||
required: true,
|
||||
description: 'The invoiceIn id',
|
||||
http: {source: 'path'}
|
||||
}, {
|
||||
arg: 'supplierFk',
|
||||
type: 'number',
|
||||
required: true
|
||||
}, {
|
||||
arg: 'supplierRef',
|
||||
type: 'any',
|
||||
}, {
|
||||
arg: 'issued',
|
||||
type: 'any',
|
||||
}, {
|
||||
arg: 'operated',
|
||||
type: 'any',
|
||||
}, {
|
||||
arg: 'deductibleExpenseFk',
|
||||
type: 'any',
|
||||
}, {
|
||||
arg: 'dmsFk',
|
||||
type: 'any',
|
||||
}, {
|
||||
arg: 'bookEntried',
|
||||
type: 'any',
|
||||
}, {
|
||||
arg: 'booked',
|
||||
type: 'any',
|
||||
}, {
|
||||
arg: 'currencyFk',
|
||||
type: 'number',
|
||||
required: true
|
||||
}, {
|
||||
arg: 'companyFk',
|
||||
type: 'any',
|
||||
}, {
|
||||
arg: 'withholdingSageFk',
|
||||
type: 'any',
|
||||
},
|
||||
],
|
||||
returns: {
|
||||
type: 'object',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: '/:id/updateInvoiceIn',
|
||||
verb: 'PATCH'
|
||||
}
|
||||
});
|
||||
|
||||
Self.updateInvoiceIn = async(ctx,
|
||||
id,
|
||||
supplierFk,
|
||||
supplierRef,
|
||||
issued,
|
||||
operated,
|
||||
deductibleExpenseFk,
|
||||
dmsFk,
|
||||
bookEntried,
|
||||
booked,
|
||||
currencyFk,
|
||||
companyFk,
|
||||
withholdingSageFk,
|
||||
options
|
||||
) => {
|
||||
let tx;
|
||||
const myOptions = {userId: ctx.req.accessToken.userId};
|
||||
|
||||
if (typeof options == 'object') Object.assign(myOptions, options);
|
||||
|
||||
if (!myOptions.transaction) {
|
||||
tx = await Self.beginTransaction({});
|
||||
myOptions.transaction = tx;
|
||||
}
|
||||
|
||||
try {
|
||||
const invoiceIn = await Self.findById(id, null, myOptions);
|
||||
invoiceIn.updateAttributes({supplierFk,
|
||||
supplierRef,
|
||||
issued,
|
||||
operated,
|
||||
deductibleExpenseFk,
|
||||
dmsFk,
|
||||
bookEntried,
|
||||
booked,
|
||||
currencyFk,
|
||||
companyFk,
|
||||
withholdingSageFk
|
||||
}, myOptions);
|
||||
if (tx) await tx.commit();
|
||||
return invoiceIn;
|
||||
} catch (e) {
|
||||
if (tx) await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
};
|
|
@ -11,6 +11,8 @@ module.exports = Self => {
|
|||
require('../methods/invoice-in/getSerial')(Self);
|
||||
require('../methods/invoice-in/corrective')(Self);
|
||||
require('../methods/invoice-in/exchangeRateUpdate')(Self);
|
||||
require('../methods/invoice-in/toUnbook')(Self);
|
||||
require('../methods/invoice-in/updateInvoiceIn')(Self);
|
||||
|
||||
Self.rewriteDbError(function(err) {
|
||||
if (err.code === 'ER_ROW_IS_REFERENCED_2' && err.sqlMessage.includes('vehicleInvoiceIn'))
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<mg-ajax path="InvoiceIns/{{patch.params.id}}" options="vnPatch"></mg-ajax>
|
||||
<mg-ajax path="InvoiceIns/{{patch.params.id}}/updateInvoiceIn" options="vnPatch"></mg-ajax>
|
||||
<vn-watcher
|
||||
vn-id="watcher"
|
||||
data="$ctrl.invoiceIn"
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
"properties": {
|
||||
"id": {
|
||||
"id": true,
|
||||
"type": "number",
|
||||
"type": "string",
|
||||
"description": "Identifier"
|
||||
},
|
||||
"name": {
|
||||
|
|
Loading…
Reference in New Issue