8448-devToTest #3373
|
@ -19,7 +19,7 @@ module.exports = Self => {
|
|||
if (acl.principalType == 'ROLE' && acl.permission == 'ALLOW') {
|
||||
const staticAcl = {
|
||||
model: model.name,
|
||||
property: '*',
|
||||
property: acl.property,
|
||||
accessType: acl.accessType,
|
||||
permission: acl.permission,
|
||||
principalType: acl.principalType,
|
||||
|
|
|
@ -974,26 +974,30 @@ INSERT INTO `vn`.`itemFamily`(`code`, `description`)
|
|||
('SER', 'Services'),
|
||||
('VT', 'Sales');
|
||||
|
||||
INSERT INTO `vn`.`item`(`id`, `typeFk`, `stems`, `originFk`, `description`, `producerFk`, `intrastatFk`, `expenseFk`,
|
||||
`comment`, `relevancy`, `image`, `subName`, `minPrice`, `family`, `isFloramondo`, `genericFk`, `itemPackingTypeFk`, `hasMinPrice`, `weightByPiece`)
|
||||
VALUES
|
||||
(1, 2, 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '1', NULL, 0, 'EMB', 0, NULL, 'V', 0, 3),
|
||||
(2, 2, 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '2', NULL, 0, 'VT', 0, NULL, 'H', 0, 2),
|
||||
(3, 1, 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '3', NULL, 0, 'VT', 0, NULL, NULL, 0, 5),
|
||||
(4, 1, 1, 1, 'Increases block', 1, 05080000, 4751000000, NULL, 0, '4', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL),
|
||||
(5, 3, 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '5', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL),
|
||||
(6, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '6', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL),
|
||||
(7, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '7', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL),
|
||||
(8, 2, 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '8', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL),
|
||||
(9, 2, 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '9', NULL, 0, 'VT', 1, NULL, NULL, 0, NULL),
|
||||
(10, 1, 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '10', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL),
|
||||
(11, 1, 1, 1, NULL, 1, 05080000, 4751000000, NULL, 0, '11', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL),
|
||||
(12, 3, 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '12', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL),
|
||||
(13, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '13', NULL, 1, 'VT', 1, NULL, NULL, 1, NULL),
|
||||
(14, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'VT', 1, NULL, NULL, 0, NULL),
|
||||
(15, 4, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'EMB', 0, NULL, NULL, 0, NULL),
|
||||
(16, 6, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'EMB', 0, NULL, NULL, 0, NULL),
|
||||
(71, 6, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL);
|
||||
INSERT INTO `vn`.`item`(
|
||||
`id`, `typeFk`, `stems`, `originFk`, `description`, `producerFk`, `intrastatFk`, `expenseFk`,
|
||||
`comment`, `relevancy`, `image`, `subName`, `minPrice`, `family`, `isFloramondo`, `genericFk`,
|
||||
`itemPackingTypeFk`, `hasMinPrice`, `weightByPiece`, `isCustomInspectionRequired`
|
||||
)
|
||||
VALUES
|
||||
(1, 2, 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '1', NULL, 0, 'EMB', 0, NULL, 'V', 0, 3, 1),
|
||||
(2, 2, 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '2', NULL, 0, 'VT', 0, NULL, 'H', 0, 2, 1),
|
||||
(3, 1, 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '3', NULL, 0, 'VT', 0, NULL, NULL, 0, 5, 0),
|
||||
(4, 1, 1, 1, 'Increases block', 1, 05080000, 4751000000, NULL, 0, '4', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, 0),
|
||||
(5, 3, 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '5', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, 0),
|
||||
(6, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '6', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, 0),
|
||||
(7, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '7', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, 0),
|
||||
(8, 2, 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '8', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, 0),
|
||||
(9, 2, 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '9', NULL, 0, 'VT', 1, NULL, NULL, 0, NULL, 0),
|
||||
(10, 1, 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '10', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, 0),
|
||||
(11, 1, 1, 1, NULL, 1, 05080000, 4751000000, NULL, 0, '11', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, 0),
|
||||
(12, 3, 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '12', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, 0),
|
||||
(13, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '13', NULL, 1, 'VT', 1, NULL, NULL, 1, NULL, 0),
|
||||
(14, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'VT', 1, NULL, NULL, 0, NULL, 0),
|
||||
(15, 4, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'EMB', 0, NULL, NULL, 0, NULL, 0),
|
||||
(16, 6, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'EMB', 0, NULL, NULL, 0, NULL, 0),
|
||||
(71, 6, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, 0);
|
||||
|
||||
|
||||
-- Update the taxClass after insert of the items
|
||||
UPDATE `vn`.`itemTaxCountry` SET `taxClassFk` = 2
|
||||
|
@ -1516,7 +1520,8 @@ INSERT INTO `vn`.`travel`(`id`,`shipped`, `landed`, `warehouseInFk`, `warehouseO
|
|||
(8, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 1, 1, 50.00, 500, 'eight travel', 1, 2, 10, FALSE, NULL),
|
||||
(10, DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY), 5, 1, 1, 50.00, 500, 'nineth travel', 1, 2, 10, TRUE, 2),
|
||||
(11, util.VN_CURDATE() - INTERVAL 1 DAY , util.VN_CURDATE(), 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4, FALSE, NULL),
|
||||
(12, util.VN_CURDATE() , util.VN_CURDATE() + INTERVAL 1 DAY, 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4, FALSE, NULL);
|
||||
(12, util.VN_CURDATE() , util.VN_CURDATE() + INTERVAL 1 DAY, 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4, FALSE, NULL),
|
||||
(13, util.VN_CURDATE() - INTERVAL 1 MONTH - INTERVAL 1 DAY, util.VN_CURDATE() - INTERVAL 1 MONTH, 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4, FALSE, NULL);
|
||||
|
||||
INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed`, `companyFk`, `invoiceNumber`, `reference`, `isExcludedFromAvailable`, `evaNotes`, `typeFk`)
|
||||
VALUES
|
||||
|
@ -1529,8 +1534,9 @@ INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed
|
|||
(7, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'IN2007', 'Movement 7', 0, 'observation seven', 'product'),
|
||||
(8, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'IN2008', 'Movement 8', 1, '', 'product'),
|
||||
(9, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 9', 1, '', 'product'),
|
||||
(10, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 10',1, '', 'product'),
|
||||
(11, 4, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 1, 442, 'IN2001', 'Movement 11',0, '', 'product'),
|
||||
(10, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2010', 'Movement 10',1, '', 'product'),
|
||||
(11, 4, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), 1, 1, 442, 'IN2011', 'Movement 11',0, '', 'product'),
|
||||
(12, 4, util.VN_CURDATE() - INTERVAL 1 MONTH, 13, 1, 442, 'IN2012', 'Movement 12',0, '', 'product'),
|
||||
(99, 69, util.VN_CURDATE() - INTERVAL 1 MONTH, 11, 0, 442, 'IN2009', 'Movement 99',0, '', 'product');
|
||||
|
||||
INSERT INTO `vn`.`entryConfig` (`defaultEntry`, `inventorySupplierFk`, `defaultSupplierFk`)
|
||||
|
@ -1572,7 +1578,8 @@ INSERT INTO `bs`.`waste`(`buyerFk`, `year`, `week`, `itemFk`, `itemTypeFk`, `sal
|
|||
(14, 7, 2, 5, 0, 3, 1, 2.000, 2.000, 0.000, 10, 10, 'grouping', NULL, 0.00, 7.30, 7.00, 0, 1, 0, 4, util.VN_CURDATE()),
|
||||
(15, 7, 4, 1.25, 0, 3, 1, 2.000, 2.000, 0.000, 10, 10, 'grouping', NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE()),
|
||||
(16, 99,1,50.0000, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 'packing', NULL, 0.00, 99.60, 99.40, 0, 1, 0, 1.00, '2024-07-30 08:13:51.000'),
|
||||
(17, 11, 1, 50, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 'packing', NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE() - INTERVAL 2 MONTH);
|
||||
(17, 11, 1, 50, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 'packing', NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE() - INTERVAL 2 MONTH),
|
||||
(18, 12, 1, 50, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 'grouping', NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE() - INTERVAL 2 MONTH);
|
||||
|
||||
INSERT INTO `hedera`.`order`(`id`, `date_send`, `customer_id`, `delivery_method_id`, `agency_id`, `address_id`, `company_id`, `note`, `source_app`, `confirmed`,`total`, `date_make`, `first_row_stamp`, `confirm_date`)
|
||||
VALUES
|
||||
|
@ -1922,7 +1929,7 @@ INSERT INTO `vn`.`claimDestination`(`id`, `description`, `addressFk`)
|
|||
|
||||
INSERT INTO `vn`.`claimDevelopment`(`id`, `claimFk`, `claimResponsibleFk`, `workerFk`, `claimReasonFk`, `claimResultFk`, `claimRedeliveryFk`, `claimDestinationFk`)
|
||||
VALUES
|
||||
(1, 1, 1, 21, 1, 1, 2, 5),
|
||||
(1, 1, 1, 21, 7, 1, 2, 5),
|
||||
(2, 1, 2, 21, 7, 2, 2, 5),
|
||||
(3, 2, 7, 21, 9, 3, 2, 5),
|
||||
(4, 3, 7, 21, 15, 8, 2, 5),
|
||||
|
@ -3965,7 +3972,7 @@ VALUES(1, '');
|
|||
|
||||
INSERT INTO dipole.expedition_PrintOut (expeditionFk, ticketFk, addressFk, street, postalCode, city, shopName, isPrinted, created, printerFk, routeFk, parkingCode,
|
||||
truckName, clientFk, phone, province, agency, m3, workerCode, itemFk, quantity, longName, shelvingFk, comments)
|
||||
VALUES(1, 1, 0, ' ', ' ', ' ', ' ', 0, '2001-01-01 00:00:00', 1, 0, ' ', ' ', 0, NULL, '', NULL, 0.000, NULL, 10, NULL, NULL, 'NCC', NULL);
|
||||
VALUES(1, 1, 0, ' ', ' ', ' ', ' ', 0, '2001-01-01 00:00:00', 1, 0, ' ', ' ', 0, NULL, '', NULL, 0.000, NULL, 10, NULL, 'Ranged Reinforced weapon sniper rifle 700mm' , 'NCC', NULL);
|
||||
|
||||
INSERT INTO vn.accountDetail
|
||||
(id, value, accountDetailTypeFk, supplierAccountFk)
|
||||
|
@ -4038,6 +4045,11 @@ INSERT IGNORE INTO vn.saySimpleConfig (url, defaultChannel)
|
|||
INSERT INTO vn.workerIrpf (workerFk,spouseNif, geographicMobilityDate)
|
||||
VALUES (1106,'26493101E','2019-09-20');
|
||||
|
||||
INSERT INTO vn.referenceRate (currencyFk, dated, value)
|
||||
VALUES (2, '2000-12-01', 1.0495),
|
||||
(2, '2001-01-01', 1.0531),
|
||||
(2, '2001-02-01', 7.6347);
|
||||
|
||||
INSERT IGNORE INTO vn.osrmConfig (id,url,tolerance)
|
||||
VALUES (1,'https://router.project-osrm.org', 0.002);
|
||||
|
||||
|
|
|
@ -107,7 +107,7 @@ BEGIN
|
|||
) INTO vHas0Amount;
|
||||
|
||||
IF vHas0Amount THEN
|
||||
CALL util.throw('Hay líneas vacías. Por favor, elimínelas');
|
||||
CALL util.throw('orderLinesWithZero');
|
||||
END IF;
|
||||
|
||||
START TRANSACTION;
|
||||
|
|
|
@ -4,10 +4,10 @@ BEGIN
|
|||
/**
|
||||
* Traslada la info de contabilidad relacionada con las facturas recibidas
|
||||
*
|
||||
* @vInvoiceInFk Factura recibida
|
||||
* @vXDiarioFk Id tabla XDiario
|
||||
* @param vInvoiceInFk Factura recibida
|
||||
* @param vXDiarioFk Id tabla XDiario
|
||||
*/
|
||||
DECLARE vInvoiceInOriginalFk INT;
|
||||
DECLARE vInvoiceInOriginalFk INT;
|
||||
DECLARE vDone BOOL DEFAULT FALSE;
|
||||
DECLARE vBase DOUBLE;
|
||||
DECLARE vVat DOUBLE;
|
||||
|
@ -205,9 +205,9 @@ BEGIN
|
|||
WHERE correctingFk = vInvoiceInFk;
|
||||
|
||||
IF vInvoiceInOriginalFk THEN
|
||||
|
||||
UPDATE movContaIVA mci
|
||||
JOIN vn.invoiceInRefund iir ON iir.invoiceInRefundFk = vInvoiceInFk
|
||||
JOIN vn.invoiceInCorrection iic ON iic.correctingFk = vInvoiceInFk
|
||||
JOIN vn.siiTypeInvoiceIn st ON st.id = iic.siiTypeInvoiceInFk
|
||||
JOIN (SELECT issued,
|
||||
SUM(sub.taxableBase) taxableBase,
|
||||
SUM(ROUND((sub.taxableBase * sub.PorcentajeIva) / 100 , 2)) vat
|
||||
|
@ -216,7 +216,7 @@ BEGIN
|
|||
ti.PorcentajeIva
|
||||
FROM vn.invoiceIn i
|
||||
JOIN vn.invoiceInTax iit ON iit.invoiceInFk = i.id
|
||||
JOIN sage.TiposIva ti ON ti.CodigoIva = iit.taxTypeSageFk
|
||||
JOIN TiposIva ti ON ti.CodigoIva = iit.taxTypeSageFk
|
||||
WHERE i.id = vInvoiceInOriginalFk
|
||||
GROUP BY ti.CodigoIva)sub
|
||||
)invoiceInOriginal
|
||||
|
@ -229,7 +229,6 @@ BEGIN
|
|||
mci.CuotaIvaOriginal = invoiceInOriginal.vat,
|
||||
mci.ClaveOperacionFactura = co.ClaveOperacionFactura_
|
||||
WHERE mci.id = vXDiarioFk;
|
||||
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -169,6 +169,7 @@ BEGIN
|
|||
UPDATE movContaIVA mci
|
||||
JOIN vn.invoiceOut i ON i.id = vInvoiceOutCorrectedFk
|
||||
JOIN vn.invoiceCorrection ic ON ic.correctedFk = vInvoiceOutCorrectedFk
|
||||
JOIN vn.siiTypeInvoiceOut st ON st.id = ic.siiTypeInvoiceOutFk
|
||||
JOIN (SELECT SUM(IF(IFNULL(e.vatFk, TRUE), iot.taxableBase, 0)) taxableBase,
|
||||
SUM(IF(IFNULL(e.vatFk, TRUE), iot.vat, 0)) vat,
|
||||
SUM(IF(IFNULL(e.vatFk, TRUE), 0, iot.vat)) equ
|
||||
|
@ -177,8 +178,8 @@ BEGIN
|
|||
WHERE iot.invoiceOutFk = vInvoiceOutCorrectedFk
|
||||
) tax
|
||||
JOIN ClavesOperacion co ON co.Descripcion = 'Factura rectificativa'
|
||||
SET mci.TipoRectificativa = 2,
|
||||
mci.ClaseAbonoRectificativas = 1,
|
||||
SET mci.TipoRectificativa = ic.cplusRectificationTypeFk,
|
||||
mci.ClaseAbonoRectificativas = REGEXP_REPLACE(st.`code`, '[^0-9]', ''),
|
||||
mci.FechaFacturaOriginal = i.issued,
|
||||
mci.FechaOperacion = i.issued,
|
||||
mci.BaseImponibleOriginal = tax.taxableBase,
|
||||
|
|
|
@ -1,48 +0,0 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`inventoryFailureAdd`()
|
||||
BEGIN
|
||||
|
||||
DECLARE done BOOL DEFAULT FALSE;
|
||||
DECLARE vTicketFk INT;
|
||||
|
||||
DECLARE rs CURSOR FOR
|
||||
SELECT id FROM vn.ticket
|
||||
WHERE shipped = util.yesterday()
|
||||
AND clientFk = 400
|
||||
AND warehouseFk IN (1,44);
|
||||
|
||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
|
||||
|
||||
OPEN rs;
|
||||
|
||||
FETCH rs INTO vTicketFk;
|
||||
|
||||
WHILE NOT done DO
|
||||
|
||||
INSERT INTO vn.inventoryFailure(dated, itemFk, quantity, value, warehouseFk, throwerFk)
|
||||
SELECT t.shipped,
|
||||
s.itemFk,
|
||||
s.quantity,
|
||||
b.buyingValue + b.freightValue + b.packageValue + b.comissionValue,
|
||||
t.warehouseFk,
|
||||
w.id
|
||||
FROM vn.ticket t
|
||||
JOIN vn.sale s ON s.ticketFk = t.id
|
||||
LEFT JOIN cache.last_buy lb ON lb.warehouse_id = t.warehouseFk AND item_id = s.itemFk
|
||||
LEFT JOIN vn.buy b ON b.id = lb.buy_id
|
||||
LEFT JOIN vn.worker w ON w.code = LEFT(s.concept, 3)
|
||||
WHERE t.id = vTicketFk
|
||||
AND s.quantity > 0;
|
||||
|
||||
FETCH rs INTO vTicketFk;
|
||||
|
||||
END WHILE;
|
||||
|
||||
|
||||
CLOSE rs;
|
||||
|
||||
|
||||
|
||||
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -43,7 +43,7 @@ BEGIN
|
|||
ii.cplusTaxBreakFk,
|
||||
ii.cplusSubjectOpFk,
|
||||
ii.siiTypeInvoiceInFk,
|
||||
ii.cplusRectificationTypeFk,
|
||||
ic.cplusRectificationTypeFk,
|
||||
ii.booked,
|
||||
IFNULL(a.isUeeMember, c.isUeeMember) isUeeMember,
|
||||
(c.id = cc.id) isSameCountry,
|
||||
|
@ -66,6 +66,7 @@ BEGIN
|
|||
e.name expenseName
|
||||
FROM invoiceIn ii
|
||||
JOIN supplier s ON s.id = ii.supplierFk
|
||||
LEFT JOIN invoiceInCorrection ic ON ic.correctingFk = ii.id
|
||||
LEFT JOIN province p ON p.id = s.provinceFk
|
||||
LEFT JOIN autonomy a ON a.id = p.autonomyFk
|
||||
JOIN country c ON c.id = s.countryFk
|
||||
|
|
|
@ -164,10 +164,6 @@ BEGIN
|
|||
SET itemFk = vItemNew
|
||||
WHERE itemFk = vItemOld;
|
||||
|
||||
UPDATE inventoryFailure
|
||||
SET itemFk = vItemNew
|
||||
WHERE itemFk = vItemOld;
|
||||
|
||||
UPDATE genericAllocation
|
||||
SET itemFk = vItemNew
|
||||
WHERE itemFk = vItemOld;
|
||||
|
|
|
@ -52,7 +52,8 @@ BEGIN
|
|||
IFNULL(dest.nickname, origin.nickname) nickname,
|
||||
dest.landed,
|
||||
dest.preparation,
|
||||
origin.departmentFk
|
||||
origin.departmentFk,
|
||||
origin.saleClonedFk
|
||||
FROM (
|
||||
SELECT s.ticketFk,
|
||||
c.salesPersonFk workerFk,
|
||||
|
@ -73,11 +74,13 @@ BEGIN
|
|||
t.warehouseFk,
|
||||
t.companyFk,
|
||||
t.agencyModeFk,
|
||||
wd.departmentFk
|
||||
wd.departmentFk,
|
||||
sc.saleClonedFk
|
||||
FROM ticket t
|
||||
JOIN client c ON c.id = t.clientFk
|
||||
JOIN workerDepartment wd ON wd.workerFk = c.salesPersonFk
|
||||
JOIN sale s ON s.ticketFk = t.id
|
||||
LEFT JOIN saleCloned sc ON sc.saleClonedFk = s.id
|
||||
JOIN saleVolume sv ON sv.saleFk = s.id
|
||||
JOIN item i ON i.id = s.itemFk
|
||||
JOIN ticketState ts ON ts.ticketFk = t.id
|
||||
|
|
|
@ -3,24 +3,30 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`invoiceIn_afterUpdate`
|
|||
AFTER UPDATE ON `invoiceIn`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
IF NEW.issued != OLD.issued
|
||||
OR NEW.currencyFk != OLD.currencyFk THEN
|
||||
DECLARE vIsEuro BOOL;
|
||||
|
||||
SELECT `code` = 'EUR' INTO vIsEuro
|
||||
FROM currency
|
||||
WHERE id = NEW.currencyFk;
|
||||
|
||||
IF (NOT NEW.issued <=> OLD.issued
|
||||
OR NEW.currencyFk <> OLD.currencyFk) THEN
|
||||
|
||||
UPDATE invoiceInTax iit
|
||||
JOIN invoiceIn ii ON ii.id = iit.invoiceInFk
|
||||
LEFT JOIN referenceRate rr ON rr.dated = ii.issued
|
||||
AND rr.currencyFk = ii.currencyFk
|
||||
SET iit.taxableBase = IF(iit.foreignValue IS NULL, iit.taxableBase, iit.foreignValue / rr.value)
|
||||
SET iit.taxableBase = IF(vIsEuro, iit.taxableBase, iit.foreignValue / rr.value),
|
||||
iit.foreignValue = IF(vIsEuro, NULL, iit.foreignValue)
|
||||
WHERE ii.id = NEW.id;
|
||||
|
||||
UPDATE invoiceInDueDay iidd
|
||||
JOIN invoiceIn ii ON ii.id = iidd.invoiceInFk
|
||||
LEFT JOIN referenceRate rr ON rr.dated = ii.issued
|
||||
AND rr.currencyFk = ii.currencyFk
|
||||
SET iidd.amount = IF(iidd.foreignValue IS NULL, iidd.amount, iidd.foreignValue / rr.value)
|
||||
SET iidd.amount = IF(vIsEuro, iidd.amount, iidd.foreignValue / rr.value),
|
||||
iidd.foreignValue = IF(vIsEuro, NULL, iidd.foreignValue)
|
||||
WHERE ii.id = NEW.id;
|
||||
|
||||
END IF;
|
||||
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -22,6 +22,7 @@ BEGIN
|
|||
OR !(NEW.workerFk <=> OLD.workerFk)
|
||||
OR !(NEW.m3 <=> OLD.m3)
|
||||
OR !(NEW.agencyModeFk <=> OLD.agencyModeFk)
|
||||
OR !(NEW.dated <=> OLD.dated)
|
||||
OR !(NEW.vehicleFk <=> OLD.vehicleFk)THEN
|
||||
CALL route_calcCommission(NEW.id);
|
||||
END IF;
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
INSERT INTO hedera.message (code, description)
|
||||
VALUES ('orderLinesWithZero','There are empty lines. Please delete them');
|
||||
|
||||
INSERT INTO hedera.messageI18n (code, lang, description)
|
||||
VALUES ('orderLinesWithZero','es','Hay líneas vacías. Por favor, elimínelas');
|
||||
|
||||
INSERT INTO hedera.messageI18n (code, lang, description)
|
||||
VALUES ('orderLinesWithZero','fr','Il y a des lignes vides. Veuillez les supprimer');
|
||||
|
||||
INSERT INTO hedera.messageI18n (code, lang, description)
|
||||
VALUES ('orderLinesWithZero','pt','Existem linhas vazias. Por favor, apague-os');
|
|
@ -0,0 +1,48 @@
|
|||
USE vn;
|
||||
|
||||
DROP TRIGGER IF EXISTS invoiceIn_beforeUpdate;
|
||||
|
||||
UPDATE invoiceIn
|
||||
SET cplusRectificationTypeFk = NULL
|
||||
WHERE cplusRectificationTypeFk = 1;
|
||||
|
||||
DELETE IGNORE FROM cplusRectificationType WHERE id = 1;
|
||||
|
||||
UPDATE cplusRectificationType
|
||||
SET id = 1
|
||||
WHERE id = 3;
|
||||
|
||||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`invoiceIn_beforeUpdate`
|
||||
BEFORE UPDATE ON `invoiceIn`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
DECLARE vWithholdingSageFk INT;
|
||||
|
||||
IF NOT (NEW.supplierRef <=> OLD.supplierRef) AND NOT util.checkPrintableChars(NEW.supplierRef) THEN
|
||||
CALL util.throw('The invoiceIn reference contains invalid characters');
|
||||
END IF;
|
||||
|
||||
SET NEW.editorFk = account.myUser_getId();
|
||||
|
||||
IF (SELECT COUNT(*) FROM invoiceIn
|
||||
WHERE supplierRef = NEW.supplierRef
|
||||
AND supplierFk = NEW.supplierFk
|
||||
AND YEAR(issued) = YEAR(NEW.issued)
|
||||
AND id <> NEW.id
|
||||
) THEN
|
||||
CALL util.throw('reference duplicated');
|
||||
END IF;
|
||||
|
||||
IF NEW.supplierFk != OLD.supplierFk THEN
|
||||
CALL supplier_checkIsActive(NEW.supplierFk);
|
||||
SELECT withholdingSageFk INTO vWithholdingSageFk
|
||||
FROM supplier
|
||||
WHERE id = NEW.supplierFk;
|
||||
SET NEW.withholdingSageFk = vWithholdingSageFk;
|
||||
END IF;
|
||||
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId)
|
||||
VALUES('SiiTypeInvoiceIn', 'find', 'READ', 'ALLOW', 'ROLE', 'salesPerson');
|
||||
|
||||
DROP TABLE IF EXISTS vn.invoiceInCorrection;
|
||||
|
||||
CREATE TABLE `invoiceInCorrection` (
|
||||
`correctingFk` mediumint(8) unsigned NOT NULL COMMENT 'Factura rectificativa',
|
||||
`correctedFk` mediumint(8) unsigned NOT NULL COMMENT 'Factura rectificada',
|
||||
`cplusRectificationTypeFk` int(10) unsigned NOT NULL,
|
||||
`siiTypeInvoiceInFk` int(10) unsigned NOT NULL,
|
||||
`invoiceCorrectionTypeFk` int(11) NOT NULL DEFAULT 3,
|
||||
PRIMARY KEY (`correctingFk`),
|
||||
KEY `invoiceInCorrection_correctedFk` (`correctedFk`),
|
||||
KEY `invoiceInCorrection_cplusRectificationTypeFk` (`cplusRectificationTypeFk`),
|
||||
KEY `invoiceInCorrection_siiTypeInvoiceIn` (`siiTypeInvoiceInFk`),
|
||||
KEY `invoiceInCorrection_invoiceCorrectionTypeFk` (`invoiceCorrectionTypeFk`),
|
||||
CONSTRAINT `invoiceInCorrection_correctedFk` FOREIGN KEY (`correctedFk`) REFERENCES `invoiceIn` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `invoiceInCorrection_correctingFk` FOREIGN KEY (`correctingFk`) REFERENCES `invoiceIn` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `invoiceInCorrection_cplusRectificationTypeFk` FOREIGN KEY (`cplusRectificationTypeFk`) REFERENCES `cplusRectificationType` (`id`) ON UPDATE CASCADE,
|
||||
CONSTRAINT `invoiceInCorrection_invoiceCorrectionTypeFk` FOREIGN KEY (`invoiceCorrectionTypeFk`) REFERENCES `invoiceCorrectionType` (`id`) ON UPDATE CASCADE,
|
||||
CONSTRAINT `invoiceInCorrection_siiTypeInvoiceIn` FOREIGN KEY (`siiTypeInvoiceInFk`) REFERENCES `siiTypeInvoiceIn` (`id`) ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
ALTER TABLE vn.mistakeType
|
||||
ADD `time` int(10) NULL COMMENT 'Segundos que se suelen tardar en arreglar el fallo',
|
||||
ADD code varchar(50) DEFAULT NULL NULL AFTER id;
|
|
@ -0,0 +1,5 @@
|
|||
RENAME TABLE vn.inventoryFailure TO vn.inventoryFailure__;
|
||||
ALTER TABLE vn.inventoryFailure__ COMMENT='@deprecated 2024-12-16';
|
||||
|
||||
RENAME TABLE vn.inventoryFailureCause TO vn.inventoryFailureCause__;
|
||||
ALTER TABLE vn.inventoryFailureCause__ COMMENT='@deprecated 2024-12-16';
|
|
@ -0,0 +1,3 @@
|
|||
|
||||
ALTER TABLE vn.country
|
||||
ADD CONSTRAINT country_unique_name UNIQUE KEY (name);
|
|
@ -0,0 +1,2 @@
|
|||
ALTER TABLE `vn`.`item`
|
||||
ADD COLUMN `isCustomInspectionRequired` TINYINT(1) NOT NULL DEFAULT 0 COMMENT 'Indicates if the item requires physical inspection at customs';
|
|
@ -246,8 +246,9 @@
|
|||
"ticketLostExpedition": "The ticket [{{ticketId}}]({{{ticketUrl}}}) has the following lost expedition:{{ expeditionId }}",
|
||||
"The raid information is not correct": "The raid information is not correct",
|
||||
"Payment method is required": "Payment method is required",
|
||||
"Sales already moved": "Sales already moved",
|
||||
"Holidays to past days not available": "Holidays to past days not available",
|
||||
"There are tickets to be invoiced": "There are tickets to be invoiced for this zone, please delete them first",
|
||||
"Price cannot be blank": "Price cannot be blank"
|
||||
}
|
||||
"Sales already moved": "Sales already moved",
|
||||
"Holidays to past days not available": "Holidays to past days not available",
|
||||
"Price cannot be blank": "Price cannot be blank",
|
||||
"There are tickets to be invoiced": "There are tickets to be invoiced",
|
||||
"The address of the customer must have information about Incoterms and Customs Agent": "The address of the customer must have information about Incoterms and Customs Agent"
|
||||
}
|
|
@ -390,7 +390,6 @@
|
|||
"The web user's email already exists": "El correo del usuario web ya existe",
|
||||
"Sales already moved": "Ya han sido transferidas",
|
||||
"The raid information is not correct": "La información de la redada no es correcta",
|
||||
"There are tickets to be invoiced": "Hay tickets para esta zona, borralos primero",
|
||||
"No trips found because input coordinates are not connected": "No se encontraron rutas porque las coordenadas de entrada no están conectadas",
|
||||
"This request is not supported": "Esta solicitud no es compatible",
|
||||
"Invalid options or too many coordinates": "Opciones invalidas o demasiadas coordenadas",
|
||||
|
@ -398,5 +397,6 @@
|
|||
"An item type with the same code already exists": "Un tipo con el mismo código ya existe",
|
||||
"Holidays to past days not available": "Las vacaciones a días pasados no están disponibles",
|
||||
"All tickets have a route order": "Todos los tickets tienen orden de ruta",
|
||||
"Price cannot be blank": "Price cannot be blank"
|
||||
"Price cannot be blank": "Price cannot be blank",
|
||||
"There are tickets to be invoiced": "La zona tiene tickets por facturar"
|
||||
}
|
||||
|
|
|
@ -29,14 +29,14 @@ module.exports = Self => {
|
|||
const models = Self.app.models;
|
||||
const myOptions = {};
|
||||
let tx;
|
||||
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
if (!myOptions.transaction) {
|
||||
tx = await Self.beginTransaction({});
|
||||
myOptions.transaction = tx;
|
||||
};
|
||||
}
|
||||
|
||||
try {
|
||||
const user = await models.VnUser.findOne({
|
||||
|
|
|
@ -80,6 +80,12 @@ module.exports = Self => {
|
|||
description: 'The claimResponsible id',
|
||||
http: {source: 'query'}
|
||||
},
|
||||
{
|
||||
arg: 'zoneFk',
|
||||
type: 'string',
|
||||
description: 'The zone name',
|
||||
http: {source: 'query'}
|
||||
},
|
||||
{
|
||||
arg: 'myTeam',
|
||||
type: 'boolean',
|
||||
|
@ -174,6 +180,8 @@ module.exports = Self => {
|
|||
to.setHours(23, 59, 59, 999);
|
||||
|
||||
return {'cl.created': {between: [value, to]}};
|
||||
case 'zoneFk':
|
||||
return {'t.zoneFk': value};
|
||||
case 'myTeam':
|
||||
if (value)
|
||||
return {'cl.workerFk': {inq: teamMembersId}};
|
||||
|
@ -195,11 +203,15 @@ module.exports = Self => {
|
|||
u.name AS workerName,
|
||||
cs.code stateCode,
|
||||
cs.description stateDescription,
|
||||
cl.created
|
||||
cl.created,
|
||||
z.name zoneName,
|
||||
z.id zoneId
|
||||
FROM claim cl
|
||||
LEFT JOIN client c ON c.id = cl.clientFk
|
||||
LEFT JOIN account.user u ON u.id = cl.workerFk
|
||||
LEFT JOIN claimState cs ON cs.id = cl.claimStateFk`
|
||||
LEFT JOIN claimState cs ON cs.id = cl.claimStateFk
|
||||
LEFT JOIN ticket t ON t.id = cl.ticketFk
|
||||
LEFT JOIN zone z ON z.id = t.zoneFk`
|
||||
);
|
||||
|
||||
stmt.merge(conn.makeSuffix(filter));
|
||||
|
|
|
@ -2,7 +2,7 @@ const UserError = require('vn-loopback/util/user-error');
|
|||
|
||||
module.exports = function(Self) {
|
||||
Self.remoteMethod('canBeInvoiced', {
|
||||
description: 'Change property isEqualizated in all client addresses',
|
||||
description: 'Check if a client can be invoiced',
|
||||
accessType: 'READ',
|
||||
accepts: [
|
||||
{
|
||||
|
@ -38,7 +38,7 @@ module.exports = function(Self) {
|
|||
Object.assign(myOptions, options);
|
||||
|
||||
const client = await models.Client.findById(id, {
|
||||
fields: ['id', 'isTaxDataChecked', 'hasToInvoice', 'payMethodFk'],
|
||||
fields: ['id', 'isTaxDataChecked', 'hasToInvoice', 'payMethodFk', 'isActive'],
|
||||
include:
|
||||
{
|
||||
relation: 'payMethod',
|
||||
|
@ -53,9 +53,6 @@ module.exports = function(Self) {
|
|||
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)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
return client.isTaxDataChecked && client.hasToInvoice && client.isActive;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -8,6 +8,8 @@ describe('client canBeInvoiced()', () => {
|
|||
const activeCtx = {
|
||||
accessToken: {userId: userId}
|
||||
};
|
||||
let tx;
|
||||
let options;
|
||||
|
||||
beforeAll(async() => {
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
|
@ -15,60 +17,45 @@ describe('client canBeInvoiced()', () => {
|
|||
});
|
||||
});
|
||||
|
||||
beforeEach(async() => {
|
||||
tx = await models.Client.beginTransaction({});
|
||||
options = {transaction: tx};
|
||||
});
|
||||
|
||||
afterEach(async() => {
|
||||
await tx.rollback();
|
||||
});
|
||||
|
||||
it('should return falsy for a client without the data checked', async() => {
|
||||
const tx = await models.Client.beginTransaction({});
|
||||
const client = await models.Client.findById(clientId, null, options);
|
||||
await client.updateAttribute('isTaxDataChecked', false, options);
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
const canBeInvoiced = await models.Client.canBeInvoiced(clientId, companyId, options);
|
||||
|
||||
const client = await models.Client.findById(clientId, null, options);
|
||||
await client.updateAttribute('isTaxDataChecked', false, options);
|
||||
expect(canBeInvoiced).toEqual(false);
|
||||
});
|
||||
|
||||
const canBeInvoiced = await models.Client.canBeInvoiced(clientId, companyId, options);
|
||||
it('should return falsy for a client not active', async() => {
|
||||
const client = await models.Client.findById(clientId, null, options);
|
||||
await client.updateAttribute('isActive', false, options);
|
||||
|
||||
expect(canBeInvoiced).toEqual(false);
|
||||
const canBeInvoiced = await models.Client.canBeInvoiced(clientId, companyId, options);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
expect(canBeInvoiced).toEqual(false);
|
||||
});
|
||||
|
||||
it('should return falsy for a client with invoicing disabled', async() => {
|
||||
const tx = await models.Client.beginTransaction({});
|
||||
const client = await models.Client.findById(clientId, null, options);
|
||||
await client.updateAttribute('hasToInvoice', false, options);
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
const canBeInvoiced = await models.Client.canBeInvoiced(clientId, companyId, options);
|
||||
|
||||
const client = await models.Client.findById(clientId, null, options);
|
||||
await client.updateAttribute('hasToInvoice', false, options);
|
||||
|
||||
const canBeInvoiced = await models.Client.canBeInvoiced(clientId, companyId, options);
|
||||
|
||||
expect(canBeInvoiced).toEqual(false);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
expect(canBeInvoiced).toEqual(false);
|
||||
});
|
||||
|
||||
it('should return truthy for an invoiceable client', async() => {
|
||||
const tx = await models.Client.beginTransaction({});
|
||||
const canBeInvoiced = await models.Client.canBeInvoiced(clientId, companyId, options);
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const canBeInvoiced = await models.Client.canBeInvoiced(clientId, companyId, options);
|
||||
|
||||
expect(canBeInvoiced).toEqual(true);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
expect(canBeInvoiced).toEqual(true);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -17,4 +17,6 @@ columns:
|
|||
isVatDeductible: is VAT deductible
|
||||
withholdingSageFk: withholding
|
||||
expenseFkDeductible: expense deductible
|
||||
editorFk: editor
|
||||
editorFk: editor
|
||||
siiTrasCendencyInvoiceInFk: SII tax regime
|
||||
siiTypeInvoiceInFk: SII Type
|
|
@ -5,7 +5,7 @@ columns:
|
|||
serial: serie
|
||||
supplierFk: proveedor
|
||||
issued: fecha emisión
|
||||
supplierRef: referéncia proveedor
|
||||
supplierRef: referencia proveedor
|
||||
isBooked: facturado
|
||||
currencyFk: moneda
|
||||
created: creado
|
||||
|
@ -17,4 +17,6 @@ columns:
|
|||
isVatDeductible: impuesto deducible
|
||||
withholdingSageFk: código de retención
|
||||
expenseFkDeductible: gasto deducible
|
||||
editorFk: editor
|
||||
editorFk: editor
|
||||
siiTrasCendencyInvoiceInFk: régimen fiscal SII
|
||||
siiTypeInvoiceInFk: tipo SII
|
|
@ -44,7 +44,7 @@ module.exports = Self => {
|
|||
correctingFk: clone.id,
|
||||
correctedFk: id,
|
||||
cplusRectificationTypeFk: invoiceType,
|
||||
siiTypeInvoiceOutFk: invoiceClass,
|
||||
siiTypeInvoiceInFk: invoiceClass,
|
||||
invoiceCorrectionTypeFk: invoiceReason
|
||||
}, myOptions);
|
||||
|
||||
|
|
|
@ -91,6 +91,10 @@ module.exports = Self => {
|
|||
{
|
||||
arg: 'supplierActivityFk',
|
||||
type: 'string',
|
||||
},
|
||||
{
|
||||
arg: 'companyFk',
|
||||
type: 'number',
|
||||
}
|
||||
],
|
||||
returns: {
|
||||
|
@ -161,8 +165,8 @@ module.exports = Self => {
|
|||
: {'ii.id': {nin: correcteds.map(x => x.correctingFk)}};
|
||||
case 'correctedFk':
|
||||
return {'ii.id': {inq: correctings.map(x => x.correctingFk)}};
|
||||
case 'supplierActivityFk':
|
||||
return {'s.supplierActivityFk': value};
|
||||
case 'companyFk':
|
||||
return {'ii.companyFk': value};
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -184,7 +188,9 @@ module.exports = Self => {
|
|||
s.name supplierName,
|
||||
s.account,
|
||||
SUM(iid.amount) amount,
|
||||
sub.code awbCode
|
||||
sub.code awbCode,
|
||||
c.code,
|
||||
MIN(iid.dueDated) dueDated
|
||||
FROM invoiceIn ii
|
||||
JOIN supplier s ON s.id = ii.supplierFk
|
||||
LEFT JOIN invoiceInDueDay iid ON iid.invoiceInFk = ii.id
|
||||
|
@ -199,7 +205,8 @@ module.exports = Self => {
|
|||
GROUP BY de.duaFk
|
||||
) sub ON sub.duaFk = d.id
|
||||
LEFT JOIN company co ON co.id = ii.companyFk
|
||||
LEFT JOIN dms dm ON dm.id = ii.docFk`
|
||||
LEFT JOIN dms dm ON dm.id = ii.docFk
|
||||
JOIN company c ON c.id = ii.companyFk`,
|
||||
);
|
||||
|
||||
const sqlWhere = conn.makeWhere(filter.where);
|
||||
|
|
|
@ -15,11 +15,11 @@ describe('invoiceIn corrective()', () => {
|
|||
await tx.rollback();
|
||||
});
|
||||
|
||||
it('La función corrective debería devolver un id cuando se ejecuta correctamente', async() => {
|
||||
it('should return an id when executed correctly', async() => {
|
||||
const originalId = 1;
|
||||
const invoiceReason = 3;
|
||||
const invoiceType = 2;
|
||||
const invoiceClass = 1;
|
||||
const invoiceClass = 8;
|
||||
const cloneId = await models.InvoiceIn.corrective(ctx,
|
||||
originalId, invoiceReason, invoiceType, invoiceClass, options);
|
||||
|
||||
|
@ -30,7 +30,7 @@ describe('invoiceIn corrective()', () => {
|
|||
}, options);
|
||||
|
||||
expect(correction.cplusRectificationTypeFk).toEqual(invoiceType);
|
||||
expect(correction.siiTypeInvoiceOutFk).toEqual(invoiceClass);
|
||||
expect(correction.siiTypeInvoiceInFk).toEqual(invoiceClass);
|
||||
expect(correction.invoiceCorrectionTypeFk).toEqual(invoiceReason);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -166,4 +166,21 @@ describe('InvoiceIn filter()', () => {
|
|||
throw e;
|
||||
}
|
||||
});
|
||||
|
||||
it('should return the invoice in matching companyFk', async() => {
|
||||
const tx = await models.InvoiceIn.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
|
||||
try {
|
||||
const company = await models.Company.findOne({}, options);
|
||||
const invoicesByCompany = await models.InvoiceIn.find({where: {companyFk: company.id}}, options);
|
||||
const filteredInvoices = await models.InvoiceIn.filter({args: {companyFk: company.id}}, {}, options);
|
||||
|
||||
expect(filteredInvoices.length).toEqual(invoicesByCompany.length);
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('invoiceIn', () => {
|
||||
let options;
|
||||
let tx;
|
||||
const invoiceId = 1;
|
||||
const supplierId = 791;
|
||||
const currencyId = 1;
|
||||
const companyId = 442;
|
||||
|
||||
beforeEach(async() => {
|
||||
tx = await models.InvoiceIn.beginTransaction({});
|
||||
options = {transaction: tx};
|
||||
});
|
||||
|
||||
afterEach(async() => {
|
||||
await tx.rollback();
|
||||
});
|
||||
|
||||
it('should allow insert for new instance', async() => {
|
||||
const newInvoice = {
|
||||
supplierFk: supplierId,
|
||||
issued: Date.vnNew(),
|
||||
operated: Date.vnNew(),
|
||||
currencyFk: currencyId,
|
||||
companyFk: companyId,
|
||||
isBooked: false
|
||||
};
|
||||
|
||||
const createdInvoice = await models.InvoiceIn.create(newInvoice, options);
|
||||
|
||||
expect(createdInvoice).toBeDefined();
|
||||
expect(createdInvoice.id).toBeDefined();
|
||||
});
|
||||
|
||||
it('should throw an error if trying to update a booked invoice', async() => {
|
||||
const invoice = await models.InvoiceIn.findById(invoiceId, null, options);
|
||||
await invoice.updateAttribute('isBooked', true, options);
|
||||
|
||||
let error;
|
||||
try {
|
||||
await invoice.updateAttribute('supplierFk', supplierId, options);
|
||||
} catch (err) {
|
||||
error = err;
|
||||
}
|
||||
|
||||
expect(error.message).toBe('InvoiceIn is already booked');
|
||||
});
|
||||
|
||||
it('should throw an error if trying to delete a booked invoice', async() => {
|
||||
const invoice = await models.InvoiceIn.findById(invoiceId, null, options);
|
||||
await invoice.updateAttribute('isBooked', true, options);
|
||||
|
||||
let error;
|
||||
try {
|
||||
await models.InvoiceIn.deleteById(invoiceId, options);
|
||||
} catch (err) {
|
||||
error = err;
|
||||
}
|
||||
|
||||
expect(error.message).toBe('InvoiceIn is already booked');
|
||||
});
|
||||
});
|
|
@ -0,0 +1,74 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('invoiceInTax', () => {
|
||||
let options;
|
||||
let tx;
|
||||
const invoiceInId = 1;
|
||||
const invoiceInTaxId = 1;
|
||||
beforeEach(async() => {
|
||||
tx = await models.InvoiceInTax.beginTransaction({});
|
||||
options = {transaction: tx};
|
||||
});
|
||||
|
||||
afterEach(async() => {
|
||||
await tx.rollback();
|
||||
});
|
||||
|
||||
it('should throw an error if trying to save a tax from a booked invoice', async() => {
|
||||
const invoiceIn = await models.InvoiceIn.findById(invoiceInId, null, options);
|
||||
await invoiceIn.updateAttributes({isBooked: true}, options);
|
||||
const invoiceInTax = await models.InvoiceInTax.findById(invoiceInTaxId, null, options);
|
||||
let error;
|
||||
try {
|
||||
await invoiceInTax.updateAttribute('taxableBase', 100, options);
|
||||
} catch (err) {
|
||||
error = err;
|
||||
}
|
||||
|
||||
expect(error.message).toBe('InvoiceIn is already booked');
|
||||
});
|
||||
|
||||
it('should allow save if the invoice is not booked', async() => {
|
||||
const invoiceIn = await models.InvoiceIn.findById(invoiceInId, null, options);
|
||||
await invoiceIn.updateAttribute('isBooked', false, options);
|
||||
|
||||
const invoiceInTax = await models.InvoiceInTax.findById(invoiceInTaxId, null, options);
|
||||
await invoiceInTax.updateAttribute('taxableBase', 100, options);
|
||||
|
||||
const updatedInvoiceInTax = await models.InvoiceInTax.findById(invoiceInTaxId, null, options);
|
||||
|
||||
expect(updatedInvoiceInTax.taxableBase).toBe(100);
|
||||
});
|
||||
|
||||
it('should throw an error if trying to delete a tax from a booked invoice', async() => {
|
||||
const invoiceIn = await models.InvoiceIn.findById(invoiceInId, null, options);
|
||||
await invoiceIn.updateAttribute('isBooked', true, options);
|
||||
|
||||
let error;
|
||||
try {
|
||||
await models.InvoiceInTax.destroyById(invoiceInTaxId, options);
|
||||
} catch (err) {
|
||||
error = err;
|
||||
}
|
||||
|
||||
expect(error).toBeDefined();
|
||||
expect(error.message).toBe('InvoiceIn is already booked');
|
||||
});
|
||||
|
||||
it('should allow delete if the invoice is not booked', async() => {
|
||||
const invoiceIn = await models.InvoiceIn.findById(invoiceInId, null, options);
|
||||
await invoiceIn.updateAttribute('isBooked', false, options);
|
||||
|
||||
let error;
|
||||
try {
|
||||
await models.InvoiceInTax.destroyById(invoiceInTaxId, options);
|
||||
} catch (err) {
|
||||
error = err;
|
||||
}
|
||||
|
||||
const deletedInvoiceInTax = await models.InvoiceInTax.findById(invoiceInTaxId, null, options);
|
||||
|
||||
expect(error).toBeUndefined();
|
||||
expect(deletedInvoiceInTax).toBeNull();
|
||||
});
|
||||
});
|
|
@ -0,0 +1,59 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
const invoiceInId = 1;
|
||||
const supplierId = 791;
|
||||
describe('invoiceIn updateInvoiceIn()', () => {
|
||||
const ctx = beforeAll.getCtx();
|
||||
let options;
|
||||
let tx;
|
||||
|
||||
beforeEach(async() => {
|
||||
options = {transaction: tx};
|
||||
tx = await models.Sale.beginTransaction({});
|
||||
options.transaction = tx;
|
||||
});
|
||||
|
||||
afterEach(async() => {
|
||||
await tx.rollback();
|
||||
});
|
||||
|
||||
it('should update the invoice', async() => {
|
||||
const invoiceBefore = await models.InvoiceIn.findById(invoiceInId, null, options);
|
||||
await update(ctx, options);
|
||||
const invoiceAfter = await models.InvoiceIn.findById(invoiceInId, null, options);
|
||||
|
||||
expect(invoiceAfter.supplierFk).not.toBe(invoiceBefore.supplierFk);
|
||||
expect(invoiceAfter.supplierFk).toBe(supplierId);
|
||||
});
|
||||
|
||||
it('should not update the invoice if is booked', async() => {
|
||||
let error;
|
||||
try {
|
||||
await models.InvoiceIn.toBook(ctx, invoiceInId, options);
|
||||
await update(ctx, options);
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
|
||||
expect(error.message).toBe('InvoiceIn is already booked');
|
||||
});
|
||||
});
|
||||
|
||||
async function update(ctx, opts) {
|
||||
const supplierRef = 'mockRef';
|
||||
const currencyId = 1;
|
||||
await models.InvoiceIn.updateInvoiceIn(ctx,
|
||||
invoiceInId,
|
||||
supplierId,
|
||||
supplierRef,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
currencyId,
|
||||
undefined,
|
||||
undefined,
|
||||
opts);
|
||||
}
|
|
@ -37,7 +37,13 @@ module.exports = Self => {
|
|||
{
|
||||
relation: 'supplier',
|
||||
scope: {
|
||||
fields: ['id', 'name']
|
||||
fields: ['id', 'name', 'isVies', 'countryFk'],
|
||||
include: [{
|
||||
relation: 'country',
|
||||
scope: {
|
||||
fields: ['id', 'code']
|
||||
}
|
||||
}]
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
@ -52,7 +52,8 @@ module.exports = Self => {
|
|||
accountingEntries = await models.Xdiario.count({ASIEN: asien}, myOptions);
|
||||
|
||||
await models.Xdiario.destroyAll({ASIEN: asien}, myOptions);
|
||||
await Self.updateAll({id: invoiceInId}, {isBooked: false}, myOptions);
|
||||
const invoiceIn = await Self.findById(invoiceInId, myOptions);
|
||||
await invoiceIn.updateAttribute('isBooked', false, myOptions);
|
||||
} else {
|
||||
const linkedBookEntry = await models.Xdiario.findOne({
|
||||
fields: ['ASIEN'],
|
||||
|
|
|
@ -82,7 +82,7 @@ module.exports = Self => {
|
|||
|
||||
try {
|
||||
const invoiceIn = await Self.findById(id, null, myOptions);
|
||||
invoiceIn.updateAttributes({supplierFk,
|
||||
await invoiceIn.updateAttributes({supplierFk,
|
||||
supplierRef,
|
||||
issued,
|
||||
operated,
|
||||
|
@ -94,6 +94,7 @@ module.exports = Self => {
|
|||
companyFk,
|
||||
withholdingSageFk
|
||||
}, myOptions);
|
||||
|
||||
if (tx) await tx.commit();
|
||||
return invoiceIn;
|
||||
} catch (e) {
|
||||
|
|
|
@ -28,11 +28,10 @@
|
|||
"model": "InvoiceCorrectionType",
|
||||
"foreignKey": "invoiceCorrectionTypeFk"
|
||||
},
|
||||
"siiTypeInvoiceOut": {
|
||||
"siiTypeInvoiceIn": {
|
||||
"type": "belongsTo",
|
||||
"model": "SiiTypeInvoiceOut",
|
||||
"foreignKey": "siiTypeInvoiceOutFk"
|
||||
"model": "SiiTypeInvoiceIn",
|
||||
"foreignKey": "siiTypeInvoiceInFk"
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
const UserError = require('vn-loopback/util/user-error');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.observe('before save', async function(ctx) {
|
||||
if (ctx.isNewInstance) return;
|
||||
|
||||
const models = Self.app.models;
|
||||
const invoiceIn = await models.InvoiceIn.findById(ctx.currentInstance.invoiceInFk, null, ctx.options);
|
||||
if (invoiceIn.isBooked) throw new UserError('InvoiceIn is already booked');
|
||||
});
|
||||
|
||||
Self.observe('before delete', async function(ctx) {
|
||||
const models = Self.app.models;
|
||||
const invoiceInTax = await Self.findById(ctx.where.id, null, ctx.options);
|
||||
const invoiceIn = await models.InvoiceIn.findById(invoiceInTax.invoiceInFk, null, ctx.options);
|
||||
if (invoiceIn.isBooked) throw new UserError('InvoiceIn is already booked');
|
||||
});
|
||||
};
|
|
@ -22,12 +22,11 @@
|
|||
"type": "number"
|
||||
},
|
||||
"expenseFk": {
|
||||
"type": "number"
|
||||
"type": "string"
|
||||
},
|
||||
"created": {
|
||||
"type": "date"
|
||||
}
|
||||
|
||||
},
|
||||
"relations": {
|
||||
"invoiceIn": {
|
||||
|
@ -51,4 +50,4 @@
|
|||
"foreignKey": "transactionTypeSageFk"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -19,4 +19,25 @@ module.exports = Self => {
|
|||
return new UserError(`This invoice has a linked vehicle.`);
|
||||
return err;
|
||||
});
|
||||
|
||||
Self.observe('before save', async function(ctx) {
|
||||
if (ctx.isNewInstance) return;
|
||||
|
||||
const changes = ctx.data || ctx.instance;
|
||||
const orgData = ctx.currentInstance;
|
||||
let isNotEditable = orgData.isBooked || (!orgData.isBooked && changes.isBooked);
|
||||
|
||||
if (isNotEditable) {
|
||||
for (const [key, value] of Object.entries(changes)) {
|
||||
if (key !== 'isBooked' && value !== orgData[key])
|
||||
throw new UserError('InvoiceIn is already booked');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Self.observe('before delete', async function(ctx) {
|
||||
const invoiceIn = await Self.findById(ctx.where.id, null, ctx.options);
|
||||
if (invoiceIn.isBooked) throw new UserError('InvoiceIn is already booked');
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
const UserError = require('vn-loopback/util/user-error');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('clientsToInvoice', {
|
||||
description: 'Get the clients to make global invoicing',
|
||||
|
@ -47,7 +49,12 @@ module.exports = Self => {
|
|||
}
|
||||
|
||||
try {
|
||||
// Packaging liquidation
|
||||
const clientCanBeInvoiced =
|
||||
await Self.app.models.Client.canBeInvoiced(clientId, companyFk, myOptions);
|
||||
|
||||
if (!clientCanBeInvoiced)
|
||||
throw new UserError(`This client can't be invoiced`);
|
||||
|
||||
const vIsAllInvoiceable = false;
|
||||
await Self.rawSql('CALL ticketPackaging_add(?, ?, ?, ?)', [
|
||||
clientId,
|
||||
|
@ -71,9 +78,6 @@ module.exports = Self => {
|
|||
AND t.shipped BETWEEN ? AND util.dayEnd(?)
|
||||
AND (t.clientFk = ? OR ? IS NULL )
|
||||
AND t.companyFk = ?
|
||||
AND c.hasToInvoice
|
||||
AND c.isTaxDataChecked
|
||||
AND c.isActive
|
||||
AND NOT t.isDeleted
|
||||
GROUP BY IF(c.hasToInvoiceByAddress, a.id, c.id)
|
||||
HAVING SUM(t.totalWithVat) > 0;`;
|
||||
|
|
|
@ -7,7 +7,12 @@ module.exports = Self => {
|
|||
arg: 'companyFk',
|
||||
type: 'number',
|
||||
required: true
|
||||
}
|
||||
},
|
||||
{
|
||||
arg: 'serialType',
|
||||
type: 'string',
|
||||
required: true
|
||||
},
|
||||
],
|
||||
returns: {
|
||||
type: ['object'],
|
||||
|
@ -19,16 +24,16 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.getInvoiceDate = async companyFk => {
|
||||
Self.getInvoiceDate = async(companyFk, serialType) => {
|
||||
const models = Self.app.models;
|
||||
const [invoiceDate] = await models.InvoiceOut.rawSql(
|
||||
`SELECT MAX(io.issued) issued
|
||||
FROM invoiceOut io
|
||||
JOIN invoiceOutSerial ios ON ios.code = io.serial
|
||||
WHERE ios.type = 'global'
|
||||
AND io.issued
|
||||
WHERE ios.type = ?
|
||||
AND io.issued
|
||||
AND io.companyFk = ?`,
|
||||
[companyFk]
|
||||
[serialType, companyFk]
|
||||
);
|
||||
return invoiceDate;
|
||||
};
|
||||
|
|
|
@ -4,11 +4,11 @@ describe('InvoiceOut clientsToInvoice()', () => {
|
|||
const userId = 1;
|
||||
const clientId = 1101;
|
||||
const companyFk = 442;
|
||||
const maxShipped = new Date();
|
||||
const maxShipped = Date.vnNew();
|
||||
maxShipped.setMonth(11);
|
||||
maxShipped.setDate(31);
|
||||
maxShipped.setHours(23, 59, 59, 999);
|
||||
const invoiceDate = new Date();
|
||||
const invoiceDate = Date.vnNew();
|
||||
const activeCtx = {
|
||||
getLocale: () => {
|
||||
return 'en';
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const moment = require('moment');
|
||||
|
||||
describe('getInvoiceDate()', () => {
|
||||
const companyFk = 442;
|
||||
let tx;
|
||||
let options;
|
||||
|
||||
beforeEach(async() => {
|
||||
tx = await models.InvoiceOut.beginTransaction({});
|
||||
options = {transaction: tx};
|
||||
});
|
||||
|
||||
afterEach(async() => {
|
||||
await tx.rollback();
|
||||
});
|
||||
|
||||
it('should return a correct date for serialType "global"', async() => {
|
||||
const serialType = 'global';
|
||||
const result = await models.InvoiceOut.getInvoiceDate(companyFk, serialType, options);
|
||||
|
||||
expect(moment(result.issued).format('YYYY-MM-DD')).toEqual('2000-12-01');
|
||||
});
|
||||
|
||||
it('should return null for serialType "multiple"', async() => {
|
||||
const serialType = 'multiple';
|
||||
const result = await models.InvoiceOut.getInvoiceDate(companyFk, serialType, options);
|
||||
|
||||
expect(result.issued).toBeNull();
|
||||
});
|
||||
|
||||
it('should return correct date for serialType "quick"', async() => {
|
||||
const serialType = 'quick';
|
||||
const result = await models.InvoiceOut.getInvoiceDate(companyFk, serialType, options);
|
||||
|
||||
expect(moment(result.issued).format('YYYY-MM-DD')).toEqual('2001-01-01');
|
||||
});
|
||||
});
|
||||
|
|
@ -43,5 +43,8 @@
|
|||
},
|
||||
"SiiTypeInvoiceOut": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"SiiTypeInvoiceIn": {
|
||||
"dataSource": "vn"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"name": "SiiTypeInvoiceIn",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "siiTypeInvoiceIn"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"id": true,
|
||||
"type": "number",
|
||||
"description": "Identifier"
|
||||
},
|
||||
"code": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -17,9 +17,6 @@
|
|||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
"code": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -29,10 +29,12 @@ module.exports = Self => {
|
|||
Object.assign(myOptions, options);
|
||||
|
||||
const stmt = new ParameterizedSQL(
|
||||
`SELECT w.id AS warehouseFk,
|
||||
w.name AS warehouse,
|
||||
tr.landed,
|
||||
b.id AS buyFk,
|
||||
`SELECT i.id itemFk,
|
||||
w.id warehouseFk,
|
||||
w.name warehouse,
|
||||
CAST(tr.landed AS CHAR) landed,
|
||||
tr.landed landedDate,
|
||||
b.id buyFk,
|
||||
b.entryFk,
|
||||
b.isIgnored,
|
||||
b.price2,
|
||||
|
@ -47,15 +49,18 @@ module.exports = Self => {
|
|||
b.buyingValue +
|
||||
b.freightValue +
|
||||
b.comissionValue +
|
||||
b.packageValue AS cost,
|
||||
b.packageValue cost,
|
||||
b.buyingValue,
|
||||
b.freightValue,
|
||||
b.comissionValue,
|
||||
b.packageValue,
|
||||
b.packagingFk ,
|
||||
s.id AS supplierFk,
|
||||
s.name AS supplier,
|
||||
b.printedStickers
|
||||
s.id supplierFk,
|
||||
s.name supplier,
|
||||
b.printedStickers,
|
||||
c.inventoried,
|
||||
ic.supplierFk inventorySupplierFk,
|
||||
s.id = ic.supplierFk isInventorySupplier
|
||||
FROM itemType it
|
||||
RIGHT JOIN (entry e
|
||||
LEFT JOIN supplier s ON s.id = e.supplierFk
|
||||
|
@ -66,9 +71,14 @@ module.exports = Self => {
|
|||
LEFT JOIN warehouse w ON w.id = tr.warehouseInFk
|
||||
LEFT JOIN origin o ON o.id = i.originFk
|
||||
) ON it.id = i.typeFk
|
||||
LEFT JOIN edi.ekt ek ON b.ektFk = ek.id`
|
||||
LEFT JOIN edi.ekt ek ON b.ektFk = ek.id
|
||||
JOIN config c
|
||||
JOIN inventoryConfig ic`
|
||||
);
|
||||
stmt.merge(conn.makeSuffix(filter));
|
||||
|
||||
stmt.merge(conn.makeWhere(filter.where));
|
||||
stmt.merge('AND IF(s.id = ic.supplierFk, tr.landed = DATE(c.inventoried), TRUE)');
|
||||
stmt.merge(conn.makePagination(filter));
|
||||
|
||||
return conn.executeStmt(stmt, myOptions);
|
||||
};
|
||||
|
|
|
@ -1,16 +1,22 @@
|
|||
const {models} = require('vn-loopback/server/server');
|
||||
const itemFk = 1;
|
||||
|
||||
const today = Date.vnNew();
|
||||
today.setHours(23, 59, 59, 999);
|
||||
|
||||
const twoMonthsAgo = Date.vnNew();
|
||||
twoMonthsAgo.setHours(0, 0, 0, 0);
|
||||
twoMonthsAgo.setMonth(twoMonthsAgo.getMonth() - 2, 1);
|
||||
describe('item lastEntriesFilter()', () => {
|
||||
it('should return two entry for the given item', async() => {
|
||||
const minDate = Date.vnNew();
|
||||
minDate.setHours(0, 0, 0, 0);
|
||||
const maxDate = Date.vnNew();
|
||||
maxDate.setHours(23, 59, 59, 59);
|
||||
|
||||
const tx = await models.Item.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
|
||||
try {
|
||||
const filter = {where: {itemFk: 1, landed: {between: [minDate, maxDate]}}};
|
||||
const filter = {where: {itemFk, landed: {between: [minDate, today]}}};
|
||||
const result = await models.Item.lastEntriesFilter(filter, options);
|
||||
|
||||
expect(result.length).toEqual(2);
|
||||
|
@ -23,22 +29,14 @@ describe('item lastEntriesFilter()', () => {
|
|||
});
|
||||
|
||||
it('should return six entries for the given item', async() => {
|
||||
const minDate = Date.vnNew();
|
||||
minDate.setHours(0, 0, 0, 0);
|
||||
minDate.setMonth(minDate.getMonth() - 2, 1);
|
||||
|
||||
const maxDate = Date.vnNew();
|
||||
maxDate.setHours(23, 59, 59, 59);
|
||||
|
||||
const tx = await models.Item.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
|
||||
try {
|
||||
const itemFk = 1;
|
||||
const filter = {where: {itemFk, landed: {between: [minDate, maxDate]}}};
|
||||
const filter = {where: {itemFk, landed: {between: [twoMonthsAgo, today]}}};
|
||||
const result = await models.Item.lastEntriesFilter(filter, options);
|
||||
const minDateUtc = new Date(minDate).getTime();
|
||||
const maxDateUtc = new Date(maxDate).getTime();
|
||||
const twoMonthsAgoUtc = twoMonthsAgo.getTime();
|
||||
const todayUtc = today.getTime();
|
||||
|
||||
const resultMatch = (
|
||||
await Promise.all(
|
||||
|
@ -50,8 +48,8 @@ describe('item lastEntriesFilter()', () => {
|
|||
});
|
||||
|
||||
const isItemFkValid = itemRecord?.id === itemFk;
|
||||
const landedDate = new Date(item.landed).getTime();
|
||||
const isLandedValid = landedDate >= minDateUtc && landedDate <= maxDateUtc;
|
||||
const landedDate = Date.vnNew(item.landed).getTime();
|
||||
const isLandedValid = landedDate >= twoMonthsAgoUtc && landedDate <= todayUtc;
|
||||
|
||||
return isItemFkValid && isLandedValid;
|
||||
})
|
||||
|
@ -66,4 +64,31 @@ describe('item lastEntriesFilter()', () => {
|
|||
throw e;
|
||||
}
|
||||
});
|
||||
|
||||
it('should return just the inventoried inventory', async() => {
|
||||
const tx = await models.Item.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
|
||||
try {
|
||||
const filter = {where: {itemFk, landed: {between: [twoMonthsAgo, today]}}};
|
||||
const result = await models.Item.lastEntriesFilter(filter, options);
|
||||
|
||||
const {supplierFk} = await models.InventoryConfig.findOne(options);
|
||||
const {inventoried} = await models.Config.findOne(options);
|
||||
|
||||
let hasInventoriedDate = false;
|
||||
result.forEach(entry => {
|
||||
if (entry.supplierFk === supplierFk &&
|
||||
entry.landedDate.getTime() === inventoried.getTime()
|
||||
)hasInventoriedDate = true;
|
||||
});
|
||||
|
||||
expect(hasInventoriedDate).toEqual(true);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -154,6 +154,9 @@
|
|||
},
|
||||
"photoMotivation": {
|
||||
"type": "string"
|
||||
},
|
||||
"isCustomInspectionRequired": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
|
@ -222,4 +225,4 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -98,6 +98,11 @@ module.exports = Self => {
|
|||
arg: 'countryFk',
|
||||
type: 'number',
|
||||
description: 'The country id filter'
|
||||
},
|
||||
{
|
||||
arg: 'payMethod',
|
||||
type: 'string',
|
||||
description: 'The payment method filter'
|
||||
}
|
||||
],
|
||||
returns: {
|
||||
|
@ -165,6 +170,8 @@ module.exports = Self => {
|
|||
case 'clientFk':
|
||||
param = `t.${param}`;
|
||||
return {[param]: value};
|
||||
case 'payMethod':
|
||||
return {'c.payMethodFk': value};
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -205,6 +212,8 @@ module.exports = Self => {
|
|||
u.name userName,
|
||||
c.salesPersonFk,
|
||||
c.credit,
|
||||
c.payMethodFk payMethodFk,
|
||||
pm.id payMethodId,
|
||||
pm.name payMethod,
|
||||
z.hour zoneLanding,
|
||||
z.name zoneName,
|
||||
|
|
|
@ -50,7 +50,8 @@ module.exports = Self => {
|
|||
su.name scannerUserName,
|
||||
es.scanned,
|
||||
est.description state,
|
||||
de.longName
|
||||
de.longName,
|
||||
de.itemFk
|
||||
FROM vn.expedition e
|
||||
LEFT JOIN vn.expeditionStateType est ON est.id = e.stateTypeFk
|
||||
INNER JOIN vn.item i1 ON i1.id = e.freightItemFk
|
||||
|
|
|
@ -55,6 +55,11 @@ module.exports = Self => {
|
|||
type: 'number',
|
||||
description: 'Department identifier'
|
||||
},
|
||||
{
|
||||
arg: 'onlyWithDestination',
|
||||
type: 'Boolean',
|
||||
description: 'True when only tickets with destination are returned'
|
||||
},
|
||||
{
|
||||
arg: 'filter',
|
||||
type: 'object',
|
||||
|
@ -103,6 +108,8 @@ module.exports = Self => {
|
|||
return {'f.isFullMovable': value};
|
||||
case 'departmentFk':
|
||||
return {'f.departmentFk': value};
|
||||
case 'onlyWithDestination':
|
||||
return {'f.id': value ? {neq: null} : null};
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ describe('TicketFuture getTicketsAdvance()', () => {
|
|||
tomorrow.setDate(today.getDate() + 1);
|
||||
const salesDeptId = 43;
|
||||
const spain1DeptId = 95;
|
||||
const warehouseId = 1;
|
||||
beforeAll.mockLoopBackContext();
|
||||
|
||||
it('should return the tickets passing the required data', async() => {
|
||||
|
@ -19,7 +20,7 @@ describe('TicketFuture getTicketsAdvance()', () => {
|
|||
const args = {
|
||||
dateFuture: tomorrow,
|
||||
dateToAdvance: today,
|
||||
warehouseFk: 1,
|
||||
warehouseFk: warehouseId,
|
||||
};
|
||||
|
||||
ctx.args = args;
|
||||
|
@ -42,7 +43,7 @@ describe('TicketFuture getTicketsAdvance()', () => {
|
|||
const args = {
|
||||
dateFuture: tomorrow,
|
||||
dateToAdvance: today,
|
||||
warehouseFk: 1,
|
||||
warehouseFk: warehouseId,
|
||||
isFullMovable: true
|
||||
};
|
||||
|
||||
|
@ -67,7 +68,7 @@ describe('TicketFuture getTicketsAdvance()', () => {
|
|||
const args = {
|
||||
dateFuture: tomorrow,
|
||||
dateToAdvance: today,
|
||||
warehouseFk: 1,
|
||||
warehouseFk: warehouseId,
|
||||
isFullMovable: false
|
||||
};
|
||||
|
||||
|
@ -92,7 +93,7 @@ describe('TicketFuture getTicketsAdvance()', () => {
|
|||
const args = {
|
||||
dateFuture: tomorrow,
|
||||
dateToAdvance: today,
|
||||
warehouseFk: 1,
|
||||
warehouseFk: warehouseId,
|
||||
ipt: 'V'
|
||||
};
|
||||
|
||||
|
@ -117,7 +118,7 @@ describe('TicketFuture getTicketsAdvance()', () => {
|
|||
const args = {
|
||||
dateFuture: tomorrow,
|
||||
dateToAdvance: today,
|
||||
warehouseFk: 1,
|
||||
warehouseFk: warehouseId,
|
||||
tfIpt: 'V'
|
||||
};
|
||||
|
||||
|
@ -141,7 +142,7 @@ describe('TicketFuture getTicketsAdvance()', () => {
|
|||
ctx.args = {
|
||||
dateFuture: tomorrow,
|
||||
dateToAdvance: today,
|
||||
warehouseFk: 1,
|
||||
warehouseFk: warehouseId,
|
||||
};
|
||||
|
||||
await models.Ticket.updateAll({id: {inq: [12, 31]}}, {clientFk: 1}, options);
|
||||
|
@ -167,4 +168,56 @@ describe('TicketFuture getTicketsAdvance()', () => {
|
|||
throw e;
|
||||
}
|
||||
});
|
||||
|
||||
it('should return the tickets with only destination', async() => {
|
||||
const tx = await models.Ticket.beginTransaction({});
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const args = {
|
||||
dateFuture: today,
|
||||
dateToAdvance: today.setHours(23, 59, 59, 999),
|
||||
warehouseFk: warehouseId,
|
||||
};
|
||||
ctx.args = args;
|
||||
|
||||
const allTickets = await models.Ticket.getTicketsAdvance(ctx, options);
|
||||
ctx.args.onlyWithDestination = true;
|
||||
const withDestinationTickets = await models.Ticket.getTicketsAdvance(ctx, options);
|
||||
|
||||
expect(allTickets.filter(ticket => ticket.id).length).toBe(withDestinationTickets.length);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
|
||||
it('should return the tickets without only destination', async() => {
|
||||
const tx = await models.Ticket.beginTransaction({});
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const args = {
|
||||
dateFuture: today,
|
||||
dateToAdvance: today.setHours(23, 59, 59, 999),
|
||||
warehouseFk: warehouseId,
|
||||
};
|
||||
ctx.args = args;
|
||||
|
||||
const allTickets = await models.Ticket.getTicketsAdvance(ctx, options);
|
||||
ctx.args.onlyWithDestination = false;
|
||||
const withoutDestinationTickets = await models.Ticket.getTicketsAdvance(ctx, options);
|
||||
|
||||
expect(allTickets.filter(ticket => !ticket.id).length).toBe(withoutDestinationTickets.length);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -77,6 +77,8 @@ describe('ticket makeInvoice()', () => {
|
|||
await tx.rollback();
|
||||
}
|
||||
|
||||
expect(error.message).toEqual(`The address of the customer must have information about Incoterms and Customs Agent`);
|
||||
expect(error.message).toEqual(
|
||||
`The address of the customer must have information about Incoterms and Customs Agent`
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -132,18 +132,18 @@ module.exports = Self => {
|
|||
CAST(SUM(b.weight * b.stickers) AS DECIMAL(10,0)) loadedKg,
|
||||
CAST(
|
||||
SUM(
|
||||
vc.aerealVolumetricDensity *
|
||||
b.stickers *
|
||||
vc.aerealVolumetricDensity *
|
||||
b.stickers *
|
||||
IF(pkg.volume, pkg.volume, pkg.width * pkg.depth * pkg.height) / 1000000
|
||||
) AS DECIMAL(10,0)
|
||||
) volumeKg,
|
||||
CAST(
|
||||
GREATEST(
|
||||
SUM(b.weight * b.stickers) ,
|
||||
SUM(vc.aerealVolumetricDensity *
|
||||
b.stickers *
|
||||
IF(pkg.volume,
|
||||
pkg.volume,
|
||||
SUM(vc.aerealVolumetricDensity *
|
||||
b.stickers *
|
||||
IF(pkg.volume,
|
||||
pkg.volume,
|
||||
pkg.width * pkg.depth * pkg.height) / 1000000)
|
||||
) / t.kg * 100 AS INT
|
||||
) percentageKg
|
||||
|
@ -185,11 +185,12 @@ module.exports = Self => {
|
|||
CAST(SUM(b.weight * b.stickers) AS DECIMAL(10,0)) as loadedkg,
|
||||
CAST(
|
||||
SUM(
|
||||
vc.aerealVolumetricDensity *
|
||||
b.stickers *
|
||||
vc.aerealVolumetricDensity *
|
||||
b.stickers *
|
||||
IF(pkg.volume, pkg.volume, pkg.width * pkg.depth * pkg.height) / 1000000
|
||||
) AS DECIMAL(10,0)
|
||||
) as volumeKg
|
||||
) as volumeKg,
|
||||
MAX(i.isCustomInspectionRequired) isCustomInspectionRequired
|
||||
FROM tmp.travel tr
|
||||
JOIN entry e ON e.travelFk = tr.id
|
||||
JOIN buy b ON b.entryFk = e.id
|
||||
|
|
|
@ -83,6 +83,14 @@ module.exports = Self => {
|
|||
arg: 'daysOnward',
|
||||
type: 'number',
|
||||
description: 'The days onward'
|
||||
}, {
|
||||
arg: 'shipped',
|
||||
type: 'date',
|
||||
description: 'The shipped date'
|
||||
}, {
|
||||
arg: 'landed',
|
||||
type: 'date',
|
||||
description: 'The landed date'
|
||||
}
|
||||
],
|
||||
returns: {
|
||||
|
@ -108,6 +116,10 @@ module.exports = Self => {
|
|||
: {'t.ref': {like: `%${value}%`}};
|
||||
case 'ref':
|
||||
return {'t.ref': {like: `%${value}%`}};
|
||||
case 'shipped':
|
||||
return {'t.shipped': value};
|
||||
case 'landed':
|
||||
return {'t.landed': value};
|
||||
case 'shippedFrom':
|
||||
return {'t.shipped': {gte: value}};
|
||||
case 'shippedTo':
|
||||
|
|
|
@ -112,4 +112,17 @@ describe('Travel extraCommunityFilter()', () => {
|
|||
|
||||
expect(result.length).toEqual(2);
|
||||
});
|
||||
|
||||
it('should return field isCustomInspectionRequired true', async() => {
|
||||
const ctx = {
|
||||
args: {
|
||||
id: 2
|
||||
}
|
||||
};
|
||||
|
||||
const result = await app.models.Travel.extraCommunityFilter(ctx, filter);
|
||||
|
||||
expect(result[0].entries[0].isCustomInspectionRequired).toBeTruthy();
|
||||
expect(result[0].entries[1].isCustomInspectionRequired).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -128,7 +128,10 @@ module.exports = Self => {
|
|||
const account = await models.VnUser.findById(userId, null, myOptions);
|
||||
const subordinated = await models.VnUser.findById(id, null, myOptions);
|
||||
const worker = await models.Worker.findById(subordinated.id, null, myOptions);
|
||||
const departmentBoss = await models.VnUser.findById(worker.bossFk, null, myOptions);
|
||||
const receiver = await models.EmailUser.findOne({
|
||||
fields: ['email'],
|
||||
where: {userFk: worker.bossFk}
|
||||
}, myOptions);
|
||||
const url = await Self.app.models.Url.getUrl();
|
||||
const body = $t('Created absence', {
|
||||
author: account.nickname,
|
||||
|
@ -140,7 +143,7 @@ module.exports = Self => {
|
|||
await models.Mail.create({
|
||||
subject: $t('Absence change notification on the labour calendar'),
|
||||
body: body,
|
||||
receiver: departmentBoss.email
|
||||
receiver: receiver.email
|
||||
}, myOptions);
|
||||
|
||||
if (tx) await tx.commit();
|
||||
|
|
|
@ -51,7 +51,7 @@ module.exports = Self => {
|
|||
};
|
||||
|
||||
const ticketList = await models.Ticket.find(filter, myOptions);
|
||||
const hasRefFk = ticketList.some(ticket => ticket.refFk);
|
||||
const hasRefFk = ticketList.some(ticket => !ticket.refFk);
|
||||
if (hasRefFk)
|
||||
throw new UserError('There are tickets to be invoiced');
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "salix-back",
|
||||
"version": "24.52.0",
|
||||
"version": "25.02.0",
|
||||
"author": "Verdnatura Levante SL",
|
||||
"description": "Salix backend",
|
||||
"license": "GPL-3.0",
|
||||
|
|
Loading…
Reference in New Issue