Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 6861-Pasar-modo-trabajo-de-previa-a-reservas
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
This commit is contained in:
commit
8656c16165
|
@ -0,0 +1,24 @@
|
|||
const fs = require('fs');
|
||||
const {spawn} = require('child_process');
|
||||
|
||||
function watchDatabaseChanges() {
|
||||
console.log('Watching for changes in db/routines and db/versions');
|
||||
fs.watch('db', {recursive: true}, (eventType, filename) => {
|
||||
if (filename.endsWith('.sql')) {
|
||||
let command;
|
||||
if (filename.startsWith('routines')) command = 'push';
|
||||
else if (filename.startsWith('versions')) command = 'run';
|
||||
|
||||
if (command) {
|
||||
const process = spawn('myt', [command]);
|
||||
process.stdout.on('data', data => console.log(data.toString()));
|
||||
process.stderr.on('data', data => console.error(`stderr: ${data}`));
|
||||
process.on('error', error => console.error(`error: ${error.message}`));
|
||||
process.on('close', () => console.log('Watching for changes in db/routines and db/versions'));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (require.main === module) watchDatabaseChanges();
|
||||
module.exports = watchDatabaseChanges;
|
|
@ -2562,7 +2562,7 @@ REPLACE INTO `vn`.`invoiceIn`(`id`, `serialNumber`,`serial`, `supplierFk`, `issu
|
|||
(9, 1009, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1242, 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);
|
||||
|
||||
INSERT INTO `vn`.`invoiceInConfig` (`id`, `retentionRate`, `retentionName`, `sageWithholdingFk`, `daysAgo`)
|
||||
INSERT INTO `vn`.`invoiceInConfig` (`id`, `retentionRate`, `retentionName`, `sageFarmerWithholdingFk`, `daysAgo`)
|
||||
VALUES
|
||||
(1, -2, '2% retention', 2, 45);
|
||||
|
||||
|
@ -3789,4 +3789,6 @@ INSERT INTO vn.workerTeam(id, team, workerFk)
|
|||
(8, 1, 19);
|
||||
|
||||
INSERT INTO vn.workCenter (id, name, payrollCenterFk, counter, warehouseFk, street, geoFk, deliveryManAdjustment)
|
||||
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;
|
|
@ -53,7 +53,7 @@ BEGIN
|
|||
IFNULL(c.street, ''),
|
||||
c.accountingAccount,
|
||||
@fi := IF(cu.code = LEFT(TRIM(c.fi), 2) AND c.isVies, MID(TRIM(c.fi), 3, LENGTH(TRIM(c.fi))-1), TRIM(c.fi)),
|
||||
IF(c.isVies, CONCAT(cu.code, @fi ), TRIM(c.fi)),
|
||||
IF(c.isVies, CONCAT(IFNULL(cu.viesCode,cu.code), @fi ), TRIM(c.fi)),
|
||||
IFNULL(c.postcode, ''),
|
||||
IFNULL(c.city, ''),
|
||||
IFNULL(pr.CodigoProvincia, ''),
|
||||
|
@ -91,7 +91,7 @@ BEGIN
|
|||
IFNULL(s.street, ''),
|
||||
s.account,
|
||||
@nif := IF(co.code = LEFT(TRIM(s.nif), 2), MID(TRIM(s.nif), 3, LENGTH(TRIM(s.nif))-1), TRIM(s.nif)),
|
||||
IF(s.isVies, CONCAT(co.code, @nif), TRIM(s.nif)),
|
||||
IF(s.isVies, CONCAT(IFNULL(co.viesCode,co.code), @nif), TRIM(s.nif)),
|
||||
IFNULL(s.postCode,''),
|
||||
IFNULL(s.city, ''),
|
||||
IFNULL(pr.CodigoProvincia, ''),
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`balance_create`(
|
||||
IN vStartingMonth INT,
|
||||
IN vEndingMonth INT,
|
||||
IN vCompany INT,
|
||||
IN vIsConsolidated BOOLEAN,
|
||||
IN vInterGroupSalesIncluded BOOLEAN)
|
||||
vStartingMonth INT,
|
||||
vEndingMonth INT,
|
||||
vCompany INT,
|
||||
vIsConsolidated BOOLEAN,
|
||||
vInterGroupSalesIncluded BOOLEAN
|
||||
)
|
||||
BEGIN
|
||||
/**
|
||||
* Crea un balance financiero para una empresa durante
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_recalcPricesByBuy`(IN vBuyFk INT(11))
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_recalcPricesByBuy`(
|
||||
vBuyFk INT(11)
|
||||
)
|
||||
BEGIN
|
||||
/**
|
||||
* Recalcula los precios de una compra
|
||||
*
|
||||
* @param vBuyFk
|
||||
*/
|
||||
*/
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.buyRecalc;
|
||||
|
||||
CREATE TEMPORARY TABLE tmp.buyRecalc
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_recalcPricesByEntry`(IN vEntryFk INT(11))
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_recalcPricesByEntry`(
|
||||
vEntryFk INT(11)
|
||||
)
|
||||
BEGIN
|
||||
/**
|
||||
* Recalcula los precios de una entrada
|
||||
*
|
||||
* @param vEntryFk
|
||||
*/
|
||||
*/
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.buyRecalc;
|
||||
|
||||
CREATE TEMPORARY TABLE tmp.buyRecalc
|
||||
|
|
|
@ -188,11 +188,12 @@ BEGIN
|
|||
FROM tPendingDuedates vp
|
||||
LEFT JOIN supplier s ON s.id = vp.supplierFk
|
||||
LEFT JOIN client c ON c.fi = s.nif
|
||||
LEFT JOIN clientRisk cr ON cr.clientFk = c.id
|
||||
LEFT JOIN clientRisk cr ON cr.clientFk = c.id
|
||||
AND cr.companyFk = vp.companyFk
|
||||
LEFT JOIN supplierAccount sa ON sa.supplierFk = s.id
|
||||
LEFT JOIN bankEntity be ON be.id = sa.bankEntityFk
|
||||
LEFT JOIN country co ON co.id = be.countryFk;
|
||||
LEFT JOIN country co ON co.id = be.countryFk
|
||||
GROUP BY vp.id;
|
||||
|
||||
DROP TEMPORARY TABLE tOpeningBalances;
|
||||
DROP TEMPORARY TABLE tPendingDuedates;
|
||||
|
|
|
@ -1,56 +0,0 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemTrash`(
|
||||
vItemFk INT,
|
||||
vWarehouseFk INT,
|
||||
vQuantity INT,
|
||||
vIsTrash BOOLEAN)
|
||||
BEGIN
|
||||
DECLARE vTicketFk INT;
|
||||
DECLARE vClientFk INT;
|
||||
DECLARE vCompanyVnlFk INT DEFAULT 442;
|
||||
DECLARE vCalc INT;
|
||||
|
||||
SELECT barcodeToItem(vItemFk) INTO vItemFk;
|
||||
|
||||
SELECT IF(vIsTrash, 200, 400) INTO vClientFk;
|
||||
|
||||
SELECT t.id INTO vTicketFk
|
||||
FROM ticket t
|
||||
JOIN address a ON a.id=t.addressFk
|
||||
WHERE t.warehouseFk = vWarehouseFk
|
||||
AND t.clientFk = vClientFk
|
||||
AND DATE(t.shipped) = util.VN_CURDATE()
|
||||
AND a.isDefaultAddress
|
||||
LIMIT 1;
|
||||
|
||||
CALL cache.visible_refresh(vCalc, TRUE, vWarehouseFk);
|
||||
|
||||
IF vTicketFk IS NULL THEN
|
||||
CALL ticket_add(
|
||||
vClientFk,
|
||||
util.VN_CURDATE(),
|
||||
vWarehouseFk,
|
||||
vCompanyVnlFk,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
util.VN_CURDATE(),
|
||||
account.myUser_getId(),
|
||||
FALSE,
|
||||
vTicketFk);
|
||||
END IF;
|
||||
|
||||
INSERT INTO sale(ticketFk, itemFk, concept, quantity)
|
||||
SELECT vTicketFk,
|
||||
vItemFk,
|
||||
CONCAT(longName,' ',worker_getCode(), ' ', LEFT(CAST(util.VN_NOW() AS TIME),5)),
|
||||
vQuantity
|
||||
FROM item
|
||||
WHERE id = vItemFk;
|
||||
|
||||
UPDATE cache.visible
|
||||
SET visible = visible - vQuantity
|
||||
WHERE calc_id = vCalc
|
||||
AND item_id = vItemFk;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -9,7 +9,7 @@ BEGIN
|
|||
* @vItemFk item a buscar
|
||||
* @vWarehouseFk almacen donde buscar
|
||||
* @vDate Si la fecha es null, muestra el histórico desde el inventario.
|
||||
* Si la fecha no es null, muestra histórico desde la fecha pasada.
|
||||
* Si la fecha no es null, muestra histórico desde la fecha de vDate.
|
||||
*/
|
||||
DECLARE vDateInventory DATETIME;
|
||||
|
||||
|
@ -40,117 +40,154 @@ BEGIN
|
|||
inventorySupplierFk INT(10)
|
||||
);
|
||||
|
||||
INSERT INTO tItemDiary
|
||||
SELECT tr.landed shipped,
|
||||
b.quantity `in`,
|
||||
NULL `out`,
|
||||
st.alertLevel ,
|
||||
st.name stateName,
|
||||
s.name `name`,
|
||||
e.invoiceNumber reference,
|
||||
e.id origin,
|
||||
s.id clientFk,
|
||||
IF(st.`code` = 'DELIVERED', TRUE, FALSE) isPicked,
|
||||
FALSE isTicket,
|
||||
b.id lineFk,
|
||||
NULL `order`,
|
||||
NULL clientType,
|
||||
NULL claimFk,
|
||||
ec.inventorySupplierFk
|
||||
FROM buy b
|
||||
JOIN entry e ON e.id = b.entryFk
|
||||
JOIN travel tr ON tr.id = e.travelFk
|
||||
JOIN supplier s ON s.id = e.supplierFk
|
||||
JOIN state st ON st.`code` = IF( tr.landed < util.VN_CURDATE()
|
||||
OR (util.VN_CURDATE() AND tr.isReceived),
|
||||
'DELIVERED',
|
||||
'FREE')
|
||||
JOIN entryConfig ec
|
||||
WHERE tr.landed >= vDateInventory
|
||||
AND vWarehouseFk = tr.warehouseInFk
|
||||
AND (s.id <> ec.inventorySupplierFk OR vDate IS NULL)
|
||||
AND b.itemFk = vItemFk
|
||||
AND e.isExcludedFromAvailable = FALSE
|
||||
AND e.isRaid = FALSE
|
||||
UNION ALL
|
||||
SELECT tr.shipped,
|
||||
NULL,
|
||||
b.quantity,
|
||||
st.alertLevel,
|
||||
st.name,
|
||||
s.name,
|
||||
e.invoiceNumber,
|
||||
e.id,
|
||||
s.id,
|
||||
IF(st.`code` = 'DELIVERED' , TRUE, FALSE),
|
||||
FALSE,
|
||||
b.id,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
ec.inventorySupplierFk
|
||||
FROM buy b
|
||||
JOIN entry e ON e.id = b.entryFk
|
||||
JOIN travel tr ON tr.id = e.travelFk
|
||||
JOIN warehouse w ON w.id = tr.warehouseOutFk
|
||||
JOIN supplier s ON s.id = e.supplierFk
|
||||
JOIN state st ON st.`code` = IF(tr.shipped < util.VN_CURDATE()
|
||||
INSERT INTO tItemDiary
|
||||
WITH entriesIn AS (
|
||||
SELECT tr.landed shipped,
|
||||
b.quantity `in`,
|
||||
NULL `out`,
|
||||
st.alertLevel ,
|
||||
st.name stateName,
|
||||
s.name `name`,
|
||||
e.invoiceNumber reference,
|
||||
e.id origin,
|
||||
s.id clientFk,
|
||||
IF(st.`code` = 'DELIVERED', TRUE, FALSE) isPicked,
|
||||
FALSE isTicket,
|
||||
b.id lineFk,
|
||||
NULL `order`,
|
||||
NULL clientType,
|
||||
NULL claimFk,
|
||||
ec.inventorySupplierFk
|
||||
FROM vn.buy b
|
||||
JOIN vn.entry e ON e.id = b.entryFk
|
||||
JOIN vn.travel tr ON tr.id = e.travelFk
|
||||
JOIN vn.supplier s ON s.id = e.supplierFk
|
||||
JOIN vn.state st ON st.`code` = IF( tr.landed < util.VN_CURDATE()
|
||||
OR (util.VN_CURDATE() AND tr.isReceived),
|
||||
'DELIVERED',
|
||||
'FREE')
|
||||
JOIN vn.entryConfig ec
|
||||
WHERE tr.landed >= vDateInventory
|
||||
AND vWarehouseFk = tr.warehouseInFk
|
||||
AND (s.id <> ec.inventorySupplierFk OR vDate IS NULL)
|
||||
AND b.itemFk = vItemFk
|
||||
AND NOT e.isExcludedFromAvailable
|
||||
AND NOT e.isRaid
|
||||
), entriesOut AS (
|
||||
SELECT tr.shipped,
|
||||
NULL,
|
||||
b.quantity,
|
||||
st.alertLevel,
|
||||
st.name stateName,
|
||||
s.name ,
|
||||
e.invoiceNumber,
|
||||
e.id entryFk,
|
||||
s.id supplierFk,
|
||||
IF(st.`code` = 'DELIVERED' , TRUE, FALSE),
|
||||
FALSE isTicket,
|
||||
b.id,
|
||||
NULL `order`,
|
||||
NULL clientType,
|
||||
NULL claimFk,
|
||||
ec.inventorySupplierFk
|
||||
FROM vn.buy b
|
||||
JOIN vn.entry e ON e.id = b.entryFk
|
||||
JOIN vn.travel tr ON tr.id = e.travelFk
|
||||
JOIN vn.warehouse w ON w.id = tr.warehouseOutFk
|
||||
JOIN vn.supplier s ON s.id = e.supplierFk
|
||||
JOIN vn.state st ON st.`code` = IF(tr.shipped < util.VN_CURDATE()
|
||||
OR (tr.shipped = util.VN_CURDATE() AND tr.isReceived),
|
||||
'DELIVERED',
|
||||
'FREE')
|
||||
JOIN entryConfig ec
|
||||
WHERE tr.shipped >= vDateInventory
|
||||
AND vWarehouseFk = tr.warehouseOutFk
|
||||
AND (s.id <> ec.inventorySupplierFk OR vDate IS NULL)
|
||||
AND b.itemFk = vItemFk
|
||||
AND e.isExcludedFromAvailable = FALSE
|
||||
AND w.isFeedStock = FALSE
|
||||
AND e.isRaid = FALSE
|
||||
UNION ALL
|
||||
SELECT DATE(t.shipped),
|
||||
NULL,
|
||||
s.quantity,
|
||||
st2.alertLevel,
|
||||
st2.name,
|
||||
t.nickname,
|
||||
t.refFk,
|
||||
t.id,
|
||||
t.clientFk,
|
||||
stk.id,
|
||||
TRUE,
|
||||
s.id,
|
||||
st.`order`,
|
||||
c.typeFk,
|
||||
cb.claimFk,
|
||||
NULL
|
||||
FROM sale s
|
||||
JOIN ticket t ON t.id = s.ticketFk
|
||||
LEFT JOIN ticketState ts ON ts.ticketFk = t.id
|
||||
LEFT JOIN state st ON st.`code` = ts.`code`
|
||||
JOIN client c ON c.id = t.clientFk
|
||||
JOIN state st2 ON st2.`code` = IF(t.shipped < util.VN_CURDATE(),
|
||||
'DELIVERED',
|
||||
IF (t.shipped > util.dayEnd(util.VN_CURDATE()),
|
||||
'FREE',
|
||||
IFNULL(ts.code, 'FREE')))
|
||||
LEFT JOIN state stPrep ON stPrep.`code` = 'PREPARED'
|
||||
LEFT JOIN saleTracking stk ON stk.saleFk = s.id
|
||||
AND stk.stateFk = stPrep.id
|
||||
LEFT JOIN claimBeginning cb ON s.id = cb.saleFk
|
||||
WHERE t.shipped >= vDateInventory
|
||||
AND s.itemFk = vItemFk
|
||||
AND vWarehouseFk =t.warehouseFk
|
||||
ORDER BY shipped,
|
||||
(inventorySupplierFk = clientFk) DESC,
|
||||
alertLevel DESC,
|
||||
isTicket,
|
||||
`order` DESC,
|
||||
isPicked DESC,
|
||||
`in` DESC,
|
||||
`out` DESC;
|
||||
'DELIVERED',
|
||||
'FREE')
|
||||
JOIN vn.entryConfig ec
|
||||
WHERE tr.shipped >= vDateInventory
|
||||
AND vWarehouseFk = tr.warehouseOutFk
|
||||
AND (s.id <> ec.inventorySupplierFk OR vDate IS NULL)
|
||||
AND b.itemFk = vItemFk
|
||||
AND NOT e.isExcludedFromAvailable
|
||||
AND NOT w.isFeedStock
|
||||
AND NOT e.isRaid
|
||||
), sales AS (
|
||||
SELECT DATE(t.shipped) shipped,
|
||||
s.quantity,
|
||||
st2.alertLevel,
|
||||
st2.name,
|
||||
t.nickname,
|
||||
t.refFk,
|
||||
t.id ticketFk,
|
||||
t.clientFk,
|
||||
s.id saleFk,
|
||||
st.`order`,
|
||||
c.typeFk,
|
||||
cb.claimFk
|
||||
FROM vn.sale s
|
||||
JOIN vn.ticket t ON t.id = s.ticketFk
|
||||
LEFT JOIN vn.ticketState ts ON ts.ticketFk = t.id
|
||||
LEFT JOIN vn.state st ON st.`code` = ts.`code`
|
||||
JOIN vn.client c ON c.id = t.clientFk
|
||||
JOIN vn.state st2 ON st2.`code` = IF(t.shipped < util.VN_CURDATE(),
|
||||
'DELIVERED',
|
||||
IF (t.shipped > util.dayEnd(util.VN_CURDATE()),
|
||||
'FREE',
|
||||
IFNULL(ts.code, 'FREE')))
|
||||
LEFT JOIN vn.claimBeginning cb ON s.id = cb.saleFk
|
||||
WHERE t.shipped >= vDateInventory
|
||||
AND s.itemFk = vItemFk
|
||||
AND vWarehouseFk = t.warehouseFk
|
||||
),sale AS (
|
||||
SELECT s.shipped,
|
||||
NULL `in`,
|
||||
s.quantity,
|
||||
s.alertLevel,
|
||||
s.name,
|
||||
s.nickname,
|
||||
s.refFk,
|
||||
s.ticketFk,
|
||||
s.clientFk,
|
||||
IF(stk.saleFk, TRUE, NULL),
|
||||
TRUE,
|
||||
s.saleFk,
|
||||
s.`order`,
|
||||
s.typeFk,
|
||||
s.claimFk,
|
||||
NULL
|
||||
FROM sales s
|
||||
LEFT JOIN vn.state stPrep ON stPrep.`code` = 'PREPARED'
|
||||
LEFT JOIN vn.saleTracking stk ON stk.saleFk = s.saleFk
|
||||
AND stk.stateFk = stPrep.id
|
||||
GROUP BY s.saleFk
|
||||
) SELECT shipped,
|
||||
`in`,
|
||||
`out`,
|
||||
alertLevel,
|
||||
stateName,
|
||||
`name`,
|
||||
reference,
|
||||
origin,
|
||||
clientFk,
|
||||
isPicked,
|
||||
isTicket,
|
||||
lineFk,
|
||||
`order`,
|
||||
clientType,
|
||||
claimFk,
|
||||
inventorySupplierFk
|
||||
FROM entriesIn
|
||||
UNION ALL
|
||||
SELECT * FROM entriesOut
|
||||
UNION ALL
|
||||
SELECT * FROM sale
|
||||
ORDER BY shipped,
|
||||
(inventorySupplierFk = clientFk) DESC,
|
||||
alertLevel DESC,
|
||||
isTicket,
|
||||
`order` DESC,
|
||||
isPicked DESC,
|
||||
`in` DESC,
|
||||
`out` DESC;
|
||||
|
||||
IF vDate IS NULL THEN
|
||||
|
||||
|
||||
SET @a := 0;
|
||||
SET @currentLineFk := 0;
|
||||
SET @shipped := '';
|
||||
|
@ -220,7 +257,7 @@ BEGIN
|
|||
FROM tItemDiary
|
||||
WHERE shipped >= vDate;
|
||||
END IF;
|
||||
|
||||
|
||||
DROP TEMPORARY TABLE tItemDiary;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -1,121 +0,0 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`packageInvoicing`(
|
||||
IN vClient INT,
|
||||
IN vDate DATE,
|
||||
IN vCompany INT,
|
||||
IN vIsAllInvoiceable BOOLEAN,
|
||||
OUT vNewTicket INT(11)
|
||||
)
|
||||
BEGIN
|
||||
|
||||
DECLARE vGraceDays INT;
|
||||
DECLARE vDateStart DATE DEFAULT '2017-11-21';
|
||||
DECLARE vIsInvoiceable BOOLEAN;
|
||||
DECLARE vWarehouse INT DEFAULT 13;
|
||||
DECLARE vComponentCost INT DEFAULT 28;
|
||||
DECLARE vGraceDate DATE;
|
||||
DECLARE vDateEnd DATE;
|
||||
|
||||
SET vGraceDays = IF(vIsAllInvoiceable ,0, 30);
|
||||
SET vGraceDate = TIMESTAMPADD(DAY, - vGraceDays, vDate);
|
||||
|
||||
/* Clientes especiales:
|
||||
3240 MADEFLOR
|
||||
992 JAVIER FELIU
|
||||
4 TONI VENDRELL
|
||||
*/
|
||||
|
||||
IF vClient IN (992, 3240, 4) THEN
|
||||
|
||||
SET vGraceDays = 365;
|
||||
|
||||
END IF;
|
||||
/* Fin clientes especiales */
|
||||
|
||||
SET vDateEnd = DATE_ADD(vDate, INTERVAL 1 DAY);
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.packageToInvoice;
|
||||
|
||||
CREATE TEMPORARY TABLE tmp.packageToInvoice
|
||||
SELECT p.itemFk,
|
||||
tp.packagingFk,
|
||||
IF(tp.quantity < 0 OR t.shipped < vGraceDate, tp.quantity, 0) quantity,
|
||||
tp.ticketFk,
|
||||
p.price
|
||||
FROM ticketPackaging tp
|
||||
JOIN packaging p ON p.id = tp.packagingFk
|
||||
JOIN ticket t ON t.id = tp.ticketFk
|
||||
WHERE t.shipped BETWEEN vDateStart AND vDateEnd
|
||||
AND t.clientFk = vClient;
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.packageToInvoicePositives;
|
||||
|
||||
CREATE TEMPORARY TABLE tmp.packageToInvoicePositives
|
||||
SELECT itemFk, sum(quantity) as totalQuantity
|
||||
FROM tmp.packageToInvoice
|
||||
GROUP BY itemFk
|
||||
HAVING totalQuantity > 0;
|
||||
|
||||
SELECT COUNT(*)
|
||||
INTO vIsInvoiceable
|
||||
FROM tmp.packageToInvoicePositives;
|
||||
|
||||
IF vIsInvoiceable THEN
|
||||
|
||||
CALL ticket_add(vClient,
|
||||
vDateEnd,
|
||||
vWarehouse,
|
||||
vCompany,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
vDateEnd,
|
||||
account.myUser_getId(),
|
||||
TRUE,
|
||||
vNewTicket);
|
||||
|
||||
INSERT INTO ticketPackaging(
|
||||
ticketFk,
|
||||
packagingFk,
|
||||
quantity,
|
||||
pvp)
|
||||
SELECT vNewTicket,
|
||||
pti.packagingFk,
|
||||
- SUM(pti.quantity) AS totalQuantity,
|
||||
pti.price
|
||||
FROM tmp.packageToInvoice pti
|
||||
LEFT JOIN tmp.packageToInvoicePositives ptip ON pti.itemFk = ptip.itemFk
|
||||
WHERE ptip.itemFK IS NOT NULL
|
||||
OR vIsAllInvoiceable
|
||||
GROUP BY packagingFk
|
||||
HAVING totalQuantity;
|
||||
|
||||
INSERT INTO sale(
|
||||
ticketFk,
|
||||
itemFk,
|
||||
concept,
|
||||
quantity,
|
||||
price
|
||||
)
|
||||
SELECT vNewTicket,
|
||||
pti.itemFk,
|
||||
i.name as concept,
|
||||
sum(pti.quantity) as totalQuantity,
|
||||
pti.price
|
||||
FROM tmp.packageToInvoice pti
|
||||
JOIN item i ON i.id = pti.itemFk
|
||||
LEFT JOIN tmp.packageToInvoicePositives ptip ON pti.itemFk = ptip.itemFk
|
||||
WHERE ptip.itemFK IS NOT NULL
|
||||
OR vIsAllInvoiceable
|
||||
GROUP BY pti.itemFk
|
||||
HAVING totalQuantity;
|
||||
|
||||
INSERT INTO saleComponent(saleFk, componentFk, value)
|
||||
SELECT id, vComponentCost, price
|
||||
FROM sale
|
||||
WHERE ticketFk = vNewTicket;
|
||||
|
||||
END IF;
|
||||
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -34,7 +34,7 @@ BEGIN
|
|||
ticketFk INT(11),
|
||||
saleFk INT(11),
|
||||
isFreezed INTEGER(1) DEFAULT 0,
|
||||
risk DECIMAL(10,2) DEFAULT 0,
|
||||
risk DECIMAL(10,1) DEFAULT 0,
|
||||
hasHighRisk TINYINT(1) DEFAULT 0,
|
||||
hasTicketRequest INTEGER(1) DEFAULT 0,
|
||||
itemShortage VARCHAR(255),
|
||||
|
|
|
@ -28,5 +28,9 @@ mainLabel:BEGIN
|
|||
UPDATE `client` c
|
||||
SET c.salesPersonFk = null
|
||||
WHERE c.salesPersonFk = vUserId;
|
||||
|
||||
UPDATE locker l
|
||||
SET l.workerFk = NULL
|
||||
WHERE l.workerFk = vUserId;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -6,7 +6,6 @@ AS SELECT `s`.`id` AS `Id_Proveedor`,
|
|||
`s`.`account` AS `cuenta`,
|
||||
`s`.`countryFk` AS `pais_id`,
|
||||
`s`.`nif` AS `NIF`,
|
||||
`s`.`isFarmer` AS `Agricola`,
|
||||
`s`.`phone` AS `Telefono`,
|
||||
`s`.`retAccount` AS `cuentaret`,
|
||||
`s`.`commission` AS `ComisionProveedor`,
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
CREATE OR REPLACE PROCEDURE `vn`.`balance_create`() BEGIN END;
|
||||
CREATE OR REPLACE PROCEDURE `vn`.`buy_recalcPricesByEntry`() BEGIN END;
|
||||
CREATE OR REPLACE PROCEDURE `vn`.`buy_recalcPricesByBuy`() BEGIN END;
|
||||
|
||||
GRANT EXECUTE ON PROCEDURE vn.balance_create TO `financialBoss`, `hrBoss`;
|
||||
GRANT EXECUTE ON PROCEDURE vn.buy_recalcPricesByEntry TO `buyer`, `claimManager`, `employee`;
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
ALTER TABLE vn.country
|
||||
ADD IF NOT EXISTS viesCode varchar(2) DEFAULT NULL NULL AFTER code;
|
||||
|
||||
UPDATE IGNORE vn.country
|
||||
SET viesCode = 'FR'
|
||||
WHERE code = 'MC'; -- Mónaco
|
|
@ -0,0 +1,60 @@
|
|||
-- Eliminar locker
|
||||
ALTER TABLE `vn`.`worker` DROP COLUMN `locker`;
|
||||
|
||||
CREATE TABLE `vn`.`locker` (
|
||||
`id` int(100) auto_increment,
|
||||
`code` varchar(10) DEFAULT NULL,
|
||||
`gender` ENUM('M','F') DEFAULT NULL,
|
||||
`workerFk` int(10) unsigned DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `code` (`code`),
|
||||
UNIQUE KEY `workerFk` (`workerFk`),
|
||||
CONSTRAINT `locker_ibfk_1` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
|
||||
|
||||
ALTER TABLE `vn`.`workerLog`
|
||||
MODIFY COLUMN changedModel enum('Worker','Calendar','WorkerTimeControlMail','Business','WorkerDms','WorkerTimeControl', 'Locker') NOT NULL DEFAULT 'Worker';
|
||||
|
||||
-- Insertar taquillas disponibles para hombres (1A - 73A / 1B - 73B)
|
||||
INSERT INTO `vn`.`locker` (code, gender, workerFk) VALUES
|
||||
('1A', 'M', NULL), ('2A', 'M', NULL), ('3A', 'M', NULL), ('4A', 'M', NULL), ('5A', 'M', NULL),
|
||||
('6A', 'M', NULL), ('7A', 'M', NULL), ('8A', 'M', NULL), ('9A', 'M', NULL), ('10A', 'M', NULL),
|
||||
('11A', 'M', NULL), ('12A', 'M', NULL), ('13A', 'M', NULL), ('14A', 'M', NULL), ('15A', 'M', NULL),
|
||||
('16A', 'M', NULL), ('17A', 'M', NULL), ('18A', 'M', NULL), ('19A', 'M', NULL), ('20A', 'M', NULL),
|
||||
('21A', 'M', NULL), ('22A', 'M', NULL), ('23A', 'M', NULL), ('24A', 'M', NULL), ('25A', 'M', NULL),
|
||||
('26A', 'M', NULL), ('27A', 'M', NULL), ('28A', 'M', NULL), ('29A', 'M', NULL), ('30A', 'M', NULL),
|
||||
('31A', 'M', NULL), ('32A', 'M', NULL), ('33A', 'M', NULL), ('34A', 'M', NULL), ('35A', 'M', NULL),
|
||||
('36A', 'M', NULL), ('37A', 'M', NULL), ('38A', 'M', NULL), ('39A', 'M', NULL), ('40A', 'M', NULL),
|
||||
('41A', 'M', NULL), ('42A', 'M', NULL), ('43A', 'M', NULL), ('44A', 'M', NULL), ('45A', 'M', NULL),
|
||||
('46A', 'M', NULL), ('47A', 'M', NULL), ('48A', 'M', NULL), ('49A', 'M', NULL), ('50A', 'M', NULL),
|
||||
('51A', 'M', NULL), ('52A', 'M', NULL), ('53A', 'M', NULL), ('54A', 'M', NULL), ('55A', 'M', NULL),
|
||||
('56A', 'M', NULL), ('57A', 'M', NULL), ('58A', 'M', NULL), ('59A', 'M', NULL), ('60A', 'M', NULL),
|
||||
('61A', 'M', NULL), ('62A', 'M', NULL), ('63A', 'M', NULL), ('64A', 'M', NULL), ('65A', 'M', NULL),
|
||||
('66A', 'M', NULL), ('67A', 'M', NULL), ('68A', 'M', NULL), ('69A', 'M', NULL), ('70A', 'M', NULL),
|
||||
('71A', 'M', NULL), ('72A', 'M', NULL), ('73A', 'M', NULL),
|
||||
('1B', 'M', NULL), ('2B', 'M', NULL), ('3B', 'M', NULL), ('4B', 'M', NULL), ('5B', 'M', NULL),
|
||||
('6B', 'M', NULL), ('7B', 'M', NULL), ('8B', 'M', NULL), ('9B', 'M', NULL), ('10B', 'M', NULL),
|
||||
('11B', 'M', NULL), ('12B', 'M', NULL), ('13B', 'M', NULL), ('14B', 'M', NULL), ('15B', 'M', NULL),
|
||||
('16B', 'M', NULL), ('17B', 'M', NULL), ('18B', 'M', NULL), ('19B', 'M', NULL), ('20B', 'M', NULL),
|
||||
('21B', 'M', NULL), ('22B', 'M', NULL), ('23B', 'M', NULL), ('24B', 'M', NULL), ('25B', 'M', NULL),
|
||||
('26B', 'M', NULL), ('27B', 'M', NULL), ('28B', 'M', NULL), ('29B', 'M', NULL), ('30B', 'M', NULL),
|
||||
('31B', 'M', NULL), ('32B', 'M', NULL), ('33B', 'M', NULL), ('34B', 'M', NULL), ('35B', 'M', NULL),
|
||||
('36B', 'M', NULL), ('37B', 'M', NULL), ('38B', 'M', NULL), ('39B', 'M', NULL), ('40B', 'M', NULL),
|
||||
('41B', 'M', NULL), ('42B', 'M', NULL), ('43B', 'M', NULL), ('44B', 'M', NULL), ('45B', 'M', NULL),
|
||||
('46B', 'M', NULL), ('47B', 'M', NULL), ('48B', 'M', NULL), ('49B', 'M', NULL), ('50B', 'M', NULL),
|
||||
('51B', 'M', NULL), ('52B', 'M', NULL), ('53B', 'M', NULL), ('54B', 'M', NULL), ('55B', 'M', NULL),
|
||||
('56B', 'M', NULL), ('57B', 'M', NULL), ('58B', 'M', NULL), ('59B', 'M', NULL), ('60B', 'M', NULL),
|
||||
('61B', 'M', NULL), ('62B', 'M', NULL), ('63B', 'M', NULL), ('64B', 'M', NULL), ('65B', 'M', NULL),
|
||||
('66B', 'M', NULL), ('67B', 'M', NULL), ('68B', 'M', NULL), ('69B', 'M', NULL), ('70B', 'M', NULL),
|
||||
('71B', 'M', NULL), ('72B', 'M', NULL), ('73B', 'M', NULL);
|
||||
|
||||
-- Insertar taquillas disponibles para mujeres (200A - 217A / 200B - 217B)
|
||||
INSERT INTO `vn`.`locker` (code, gender, workerFk) VALUES
|
||||
('200A', 'F', NULL), ('201A', 'F', NULL), ('202A', 'F', NULL), ('203A', 'F', NULL), ('204A', 'F', NULL),
|
||||
('205A', 'F', NULL), ('206A', 'F', NULL), ('207A', 'F', NULL), ('208A', 'F', NULL), ('209A', 'F', NULL),
|
||||
('210A', 'F', NULL), ('211A', 'F', NULL), ('212A', 'F', NULL), ('213A', 'F', NULL), ('214A', 'F', NULL),
|
||||
('215A', 'F', NULL), ('216A', 'F', NULL), ('217A', 'F', NULL),
|
||||
('200B', 'F', NULL), ('201B', 'F', NULL), ('202B', 'F', NULL), ('203B', 'F', NULL), ('204B', 'F', NULL),
|
||||
('205B', 'F', NULL), ('206B', 'F', NULL), ('207B', 'F', NULL), ('208B', 'F', NULL), ('209B', 'F', NULL),
|
||||
('210B', 'F', NULL), ('211B', 'F', NULL), ('212B', 'F', NULL), ('213B', 'F', NULL), ('214B', 'F', NULL),
|
||||
('215B', 'F', NULL), ('216B', 'F', NULL), ('217B', 'F', NULL);
|
|
@ -0,0 +1,6 @@
|
|||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES ('Locker', '__get__codes', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Locker', '*', '*', 'ALLOW', 'ROLE', 'hr'),
|
||||
('Locker', '*', '*', 'ALLOW', 'ROLE', 'productionBoss'),
|
||||
('Worker', '__get__locker', 'READ', 'ALLOW', 'ROLE', 'hr'),
|
||||
('Worker', '__get__locker', 'READ', 'ALLOW', 'ROLE', 'productionBoss');
|
|
@ -1,2 +0,0 @@
|
|||
-- Place your SQL code here
|
||||
ALTER TABLE vn.productionConfig ADD defaultSectorFk INT UNSIGNED DEFAULT 37 NOT NULL COMMENT 'Default sector';
|
|
@ -0,0 +1,5 @@
|
|||
-- Place your SQL code here
|
||||
ALTER TABLE vn.packaging
|
||||
MODIFY COLUMN height decimal(10,2) DEFAULT NULL NULL,
|
||||
MODIFY COLUMN `depth` decimal(10,2) DEFAULT NULL NULL,
|
||||
MODIFY COLUMN width decimal(10,2) DEFAULT NULL NULL;
|
|
@ -0,0 +1,3 @@
|
|||
ALTER TABLE vn.invoiceInConfig CHANGE sageWithholdingFk sageFarmerWithholdingFk smallint(6) NOT NULL;
|
||||
ALTER TABLE vn.supplier CHANGE isFarmer isFarmer__ tinyint(1) DEFAULT 0 NOT NULL COMMENT 'refs #7345 @deprecated 2024-05-10 - Utilizar withholdingSageFk';
|
||||
ALTER TABLE vn.supplier MODIFY COLUMN isFarmer__ tinyint(1) DEFAULT 0 NOT NULL COMMENT 'refs #7345 @deprecated 2024-05-10 - Utilizar withholdingSageFk';
|
|
@ -0,0 +1,3 @@
|
|||
ALTER TABLE vn.item
|
||||
MODIFY nonRecycledPlastic DECIMAL(10,2) DEFAULT NULL NULL,
|
||||
MODIFY recycledPlastic DECIMAL(10,2) DEFAULT NULL NULL;
|
|
@ -25,7 +25,6 @@ describe('Worker basic data path', () => {
|
|||
await page.overwrite(selectors.workerBasicData.name, 'David C.');
|
||||
await page.overwrite(selectors.workerBasicData.surname, 'H.');
|
||||
await page.overwrite(selectors.workerBasicData.phone, '444332211');
|
||||
await page.overwrite(selectors.workerBasicData.locker, '1');
|
||||
await page.click(selectors.workerBasicData.saveButton);
|
||||
|
||||
const message = await page.waitForSnackbar();
|
||||
|
@ -37,6 +36,5 @@ describe('Worker basic data path', () => {
|
|||
expect(await page.waitToGetProperty(selectors.workerBasicData.name, 'value')).toEqual('David C.');
|
||||
expect(await page.waitToGetProperty(selectors.workerBasicData.surname, 'value')).toEqual('H.');
|
||||
expect(await page.waitToGetProperty(selectors.workerBasicData.phone, 'value')).toEqual('444332211');
|
||||
expect(await page.waitToGetProperty(selectors.workerBasicData.locker, 'value')).toEqual('1');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -6,6 +6,7 @@ const log = require('fancy-log');
|
|||
const Myt = require('@verdnatura/myt/myt');
|
||||
const Run = require('@verdnatura/myt/myt-run');
|
||||
const Start = require('@verdnatura/myt/myt-start');
|
||||
const watchDatabaseChanges = require('./db/dbWatcher');
|
||||
|
||||
// Configuration
|
||||
|
||||
|
@ -245,6 +246,7 @@ routes.description = 'Merges all module routes file into one file';
|
|||
function watch(done) {
|
||||
gulp.watch(routeFiles, gulp.series(routes));
|
||||
gulp.watch(localeFiles, gulp.series(locales));
|
||||
watchDatabaseChanges();
|
||||
done();
|
||||
}
|
||||
watch.description = `Watches for changes in routes and locale files`;
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
"sageWithholding": {
|
||||
"type": "belongsTo",
|
||||
"model": "SageWithholding",
|
||||
"foreignKey": "sageWithholdingFk"
|
||||
"foreignKey": "sageFarmerWithholdingFk"
|
||||
}
|
||||
},
|
||||
"acls": [{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<vn-crud-model
|
||||
url="InvoiceInConfigs"
|
||||
data="$ctrl.config"
|
||||
filter="{fields: ['sageWithholdingFk']}"
|
||||
filter="{fields: ['sageFarmerWithholdingFk']}"
|
||||
id-value="1"
|
||||
auto-load="true">
|
||||
</vn-crud-model>
|
||||
|
|
|
@ -112,7 +112,7 @@ class Controller extends Descriptor {
|
|||
}
|
||||
|
||||
isAgricultural() {
|
||||
return this.invoiceIn.supplier.sageWithholdingFk == this.config[0].sageWithholdingFk;
|
||||
return this.invoiceIn.supplier.sageWithholdingFk == this.config[0].sageFarmerWithholdingFk;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,6 @@ module.exports = Self => {
|
|||
try {
|
||||
await Self.makePdf(id, options);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
throw new UserError('Error while generating PDF', 'pdfError');
|
||||
}
|
||||
|
||||
|
|
|
@ -36,6 +36,11 @@ module.exports = Self => {
|
|||
type: 'number',
|
||||
required: true
|
||||
},
|
||||
{
|
||||
arg: 'checked',
|
||||
type: 'boolean',
|
||||
required: true
|
||||
},
|
||||
],
|
||||
returns: {
|
||||
type: 'boolean',
|
||||
|
@ -51,6 +56,7 @@ module.exports = Self => {
|
|||
const models = Self.app.models;
|
||||
const myOptions = {userId: ctx.req.accessToken.userId};
|
||||
const {id, refFk, newClientFk, cplusRectificationTypeFk, siiTypeInvoiceOutFk, invoiceCorrectionTypeFk} = ctx.args;
|
||||
const checked = ctx.args.checked;
|
||||
let tx;
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
@ -96,9 +102,10 @@ module.exports = Self => {
|
|||
|
||||
await models.Ticket.invoiceTickets(ctx, refundTicketIds, invoiceCorrection, myOptions);
|
||||
|
||||
const [invoiceId] = await models.Ticket.invoiceTicketsAndPdf(ctx, clonedTicketIds, null, myOptions);
|
||||
|
||||
return invoiceId;
|
||||
if (!checked) {
|
||||
const [invoiceId] = await models.Ticket.invoiceTicketsAndPdf(ctx, clonedTicketIds, null, myOptions);
|
||||
return invoiceId;
|
||||
}
|
||||
} catch (e) {
|
||||
if (tx) await tx.rollback();
|
||||
throw e;
|
||||
|
|
|
@ -1,15 +1,3 @@
|
|||
<vn-crud-model
|
||||
auto-load="true"
|
||||
url="CplusRectificationTypes"
|
||||
data="cplusRectificationTypes"
|
||||
order="description">
|
||||
</vn-crud-model>
|
||||
<vn-crud-model
|
||||
auto-load="true"
|
||||
url="SiiTypeInvoiceOuts"
|
||||
data="siiTypeInvoiceOuts"
|
||||
where="{code: {like: 'R%'}}">
|
||||
</vn-crud-model>
|
||||
<vn-crud-model
|
||||
auto-load="true"
|
||||
url="InvoiceCorrectionTypes"
|
||||
|
@ -211,14 +199,14 @@
|
|||
vn-one
|
||||
vn-id="cplusRectificationType"
|
||||
required="true"
|
||||
data="cplusRectificationTypes"
|
||||
data="$ctrl.cplusRectificationTypes"
|
||||
show-field="description"
|
||||
value-field="id"
|
||||
ng-model="$ctrl.cplusRectificationType"
|
||||
search-function="{or: [{id: $search}, {description: {like: '%'+ $search +'%'}}]}"
|
||||
label="Rectificative type">
|
||||
<tpl-item>
|
||||
{{::description}}
|
||||
{{ ::description}}
|
||||
</tpl-item>
|
||||
</vn-autocomplete>
|
||||
</vn-horizontal>
|
||||
|
@ -226,7 +214,7 @@
|
|||
<vn-autocomplete
|
||||
vn-one
|
||||
vn-id="siiTypeInvoiceOut"
|
||||
data="siiTypeInvoiceOuts"
|
||||
data="$ctrl.siiTypeInvoiceOuts"
|
||||
show-field="description"
|
||||
value-field="id"
|
||||
fields="['id','code','description']"
|
||||
|
@ -248,6 +236,14 @@
|
|||
label="Type">
|
||||
</vn-autocomplete>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-check
|
||||
ng-model="$ctrl.isChecked"
|
||||
label="destinationClient"
|
||||
info="transferInvoiceInfo"
|
||||
/>
|
||||
</vn-check>
|
||||
</vn-horizontal>
|
||||
</section>
|
||||
</tpl-body>
|
||||
<tpl-buttons>
|
||||
|
|
|
@ -7,6 +7,7 @@ class Controller extends Section {
|
|||
super($element, $);
|
||||
this.vnReport = vnReport;
|
||||
this.vnEmail = vnEmail;
|
||||
this.checked = true;
|
||||
}
|
||||
|
||||
get invoiceOut() {
|
||||
|
@ -23,6 +24,26 @@ class Controller extends Section {
|
|||
return this.aclService.hasAny(['invoicing']);
|
||||
}
|
||||
|
||||
get isChecked() {
|
||||
return this.checked;
|
||||
}
|
||||
|
||||
set isChecked(value) {
|
||||
this.checked = value;
|
||||
}
|
||||
|
||||
$onInit() {
|
||||
this.$http.get(`CplusRectificationTypes`, {filter: {order: 'description'}})
|
||||
.then(res => {
|
||||
this.cplusRectificationTypes = res.data;
|
||||
this.cplusRectificationType = res.data.filter(type => type.description == 'I – Por diferencias')[0].id;
|
||||
});
|
||||
this.$http.get(`SiiTypeInvoiceOuts`, {filter: {where: {code: {like: 'R%'}}}})
|
||||
.then(res => {
|
||||
this.siiTypeInvoiceOuts = res.data;
|
||||
this.siiTypeInvoiceOut = res.data.filter(type => type.code == 'R4')[0].id;
|
||||
});
|
||||
}
|
||||
loadData() {
|
||||
const filter = {
|
||||
include: [
|
||||
|
@ -34,7 +55,7 @@ class Controller extends Section {
|
|||
}, {
|
||||
relation: 'client',
|
||||
scope: {
|
||||
fields: ['id', 'name', 'email']
|
||||
fields: ['id', 'name', 'email', 'hasToInvoiceByAddress']
|
||||
}
|
||||
}
|
||||
]
|
||||
|
@ -136,12 +157,24 @@ class Controller extends Section {
|
|||
newClientFk: this.clientId,
|
||||
cplusRectificationTypeFk: this.cplusRectificationType,
|
||||
siiTypeInvoiceOutFk: this.siiTypeInvoiceOut,
|
||||
invoiceCorrectionTypeFk: this.invoiceCorrectionType
|
||||
invoiceCorrectionTypeFk: this.invoiceCorrectionType,
|
||||
checked: this.checked
|
||||
};
|
||||
this.$http.post(`InvoiceOuts/transferInvoice`, params).then(res => {
|
||||
const invoiceId = res.data;
|
||||
this.vnApp.showSuccess(this.$t('Transferred invoice'));
|
||||
this.$state.go('invoiceOut.card.summary', {id: invoiceId});
|
||||
|
||||
this.$http.get(`Clients/${this.clientId}`).then(response => {
|
||||
const clientData = response.data;
|
||||
const hasToInvoiceByAddress = clientData.hasToInvoiceByAddress;
|
||||
|
||||
if (this.checked && hasToInvoiceByAddress) {
|
||||
if (!window.confirm(this.$t('confirmTransferInvoice')))
|
||||
return;
|
||||
}
|
||||
|
||||
this.$http.post(`InvoiceOuts/transferInvoice`, params).then(res => {
|
||||
const invoiceId = res.data;
|
||||
this.vnApp.showSuccess(this.$t('Transferred invoice'));
|
||||
this.$state.go('invoiceOut.card.summary', {id: invoiceId});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
The following refund tickets have been created: "The following refund tickets have been created: {{ticketIds}}"
|
||||
Transfer invoice to...: Transfer invoice to...
|
||||
Cplus Type: Cplus Type
|
||||
Cplus Type: Cplus Type
|
||||
transferInvoice: Transfer Invoice
|
||||
destinationClient: Bill destination client
|
||||
transferInvoiceInfo: New tickets from the destination customer will be generated in the default consignee.
|
||||
confirmTransferInvoice: Destination customer has marked to bill by consignee, do you want to continue?
|
|
@ -24,3 +24,7 @@ Refund...: Abono...
|
|||
Transfer invoice to...: Transferir factura a...
|
||||
Rectificative type: Tipo rectificativa
|
||||
Transferred invoice: Factura transferida
|
||||
transferInvoice: Transferir factura
|
||||
destinationClient: Facturar cliente destino
|
||||
transferInvoiceInfo: Los nuevos tickets del cliente destino serán generados en el consignatario por defecto.
|
||||
confirmTransferInvoice: El cliente destino tiene marcado facturar por consignatario, ¿desea continuar?
|
|
@ -19,6 +19,9 @@ module.exports = Self => {
|
|||
type: 'number',
|
||||
required: true,
|
||||
description: 'The requested item quantity',
|
||||
}, {
|
||||
arg: 'attenderFk',
|
||||
type: 'number'
|
||||
}],
|
||||
returns: {
|
||||
type: 'object',
|
||||
|
@ -73,12 +76,14 @@ module.exports = Self => {
|
|||
ticketFk: request.ticketFk,
|
||||
itemFk: ctx.args.itemFk,
|
||||
quantity: ctx.args.quantity,
|
||||
attenderFk: ctx.args.attenderFk,
|
||||
concept: item.name
|
||||
}, myOptions);
|
||||
await request.updateAttributes({
|
||||
saleFk: sale.id,
|
||||
itemFk: sale.itemFk,
|
||||
isOk: true
|
||||
isOk: true,
|
||||
attenderFk: sale.attenderFk,
|
||||
}, myOptions);
|
||||
|
||||
const query = `CALL vn.sale_calculateComponent(?, NULL)`;
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
const moment = require('moment');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('resendWeeklyHourEmail', {
|
||||
description: 'Send the records for the week of the date provided',
|
||||
|
@ -31,7 +33,8 @@ module.exports = Self => {
|
|||
Object.assign(myOptions, options);
|
||||
|
||||
const yearNumber = dated.getFullYear();
|
||||
const weekNumber = getWeekNumber(dated);
|
||||
const weekNumber = moment(dated).isoWeek();
|
||||
|
||||
const workerTimeControlMail = await models.WorkerTimeControlMail.findOne({
|
||||
where: {
|
||||
workerFk: workerId,
|
||||
|
@ -54,15 +57,4 @@ module.exports = Self => {
|
|||
|
||||
return false;
|
||||
};
|
||||
|
||||
function getWeekNumber(date) {
|
||||
const tempDate = new Date(date);
|
||||
let dayOfWeek = tempDate.getDay();
|
||||
dayOfWeek = (dayOfWeek === 0) ? 7 : dayOfWeek;
|
||||
const firstDayOfWeek = new Date(tempDate.getFullYear(), tempDate.getMonth(), tempDate.getDate() - (dayOfWeek - 1));
|
||||
const firstDayOfYear = new Date(tempDate.getFullYear(), 0, 1);
|
||||
const differenceInMilliseconds = firstDayOfWeek.getTime() - firstDayOfYear.getTime();
|
||||
const weekNumber = Math.floor(differenceInMilliseconds / (1000 * 60 * 60 * 24 * 7)) + 1;
|
||||
return weekNumber;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -121,6 +121,9 @@
|
|||
},
|
||||
"Operator": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"Locker": {
|
||||
"dataSource": "vn"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
module.exports = Self => {
|
||||
Self.observe('before save', async ctx => {
|
||||
const models = Self.app.models;
|
||||
const changes = ctx.data || ctx.instance;
|
||||
const instance = ctx.currentInstance;
|
||||
|
||||
const workerFk = changes?.workerFk || instance?.workerFk;
|
||||
if (workerFk) {
|
||||
const locker = await models.Locker.findOne({
|
||||
where: {workerFk}
|
||||
}, ctx.options);
|
||||
|
||||
if (locker) {
|
||||
await Self.rawSql(
|
||||
'UPDATE locker SET workerFk = NULL where workerFk = ?',
|
||||
[workerFk],
|
||||
ctx.options);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"name": "Locker",
|
||||
"base": "VnModel",
|
||||
"description": "Worker's locker",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "locker"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"code": {
|
||||
"type": "string"
|
||||
},
|
||||
"gender": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"scopes": {
|
||||
"codes": {
|
||||
"fields": ["id","code"]
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
const {models} = require('vn-loopback/server/server');
|
||||
|
||||
describe('locker model ', () => {
|
||||
const productionBossId = 50;
|
||||
const hrBuyerId = 124;
|
||||
const hrId = 37;
|
||||
const jessicaJonesId = 1110;
|
||||
const bruceBannerId = 1109;
|
||||
const lockerMaleId = 1;
|
||||
const lockerFemaleId = 147;
|
||||
let ctx;
|
||||
let options;
|
||||
let tx;
|
||||
|
||||
beforeEach(async() => {
|
||||
ctx = {
|
||||
req: {
|
||||
accessToken: {userId: hrId},
|
||||
headers: {origin: 'http://localhost'}
|
||||
},
|
||||
};
|
||||
options = {transaction: tx};
|
||||
tx = await models.Locker.beginTransaction({});
|
||||
options.transaction = tx;
|
||||
});
|
||||
|
||||
afterEach(async() => {
|
||||
await tx.rollback();
|
||||
});
|
||||
|
||||
it('should allocate a locker', async() => {
|
||||
ctx.req.accessToken.userId = productionBossId;
|
||||
|
||||
const locker = await models.Locker.findById(lockerMaleId, null, options);
|
||||
await locker.updateAttributes({workerFk: bruceBannerId}, options);
|
||||
|
||||
expect(locker.workerFk).toEqual(bruceBannerId);
|
||||
});
|
||||
|
||||
it('should take away a locker', async() => {
|
||||
ctx.req.accessToken.userId = hrBuyerId;
|
||||
const locker = await models.Locker.findById(lockerFemaleId, null, options);
|
||||
await locker.updateAttributes({workerFk: null}, options);
|
||||
|
||||
expect(locker.workerFk).toEqual(null);
|
||||
});
|
||||
|
||||
it('should change a locker', async() => {
|
||||
const locker = await models.Locker.findById(148, null, options);
|
||||
await locker.updateAttributes({workerFk: jessicaJonesId}, options);
|
||||
const oldLocker = await models.Locker.findById(lockerFemaleId, null, options);
|
||||
|
||||
expect(locker.workerFk).toEqual(jessicaJonesId);
|
||||
expect(oldLocker.workerFk).toEqual(null);
|
||||
});
|
||||
});
|
|
@ -21,10 +21,6 @@ module.exports = Self => {
|
|||
require('../methods/worker/isAuthorized')(Self);
|
||||
require('../methods/worker/setPassword')(Self);
|
||||
|
||||
Self.validatesUniquenessOf('locker', {
|
||||
message: 'This locker has already been assigned'
|
||||
});
|
||||
|
||||
Self.validateAsync('fi', tinIsValid, {
|
||||
message: 'Invalid TIN'
|
||||
});
|
||||
|
|
|
@ -48,9 +48,6 @@
|
|||
"code": {
|
||||
"type" : "string"
|
||||
},
|
||||
"locker": {
|
||||
"type" : "number"
|
||||
},
|
||||
"fi": {
|
||||
"type" : "string"
|
||||
},
|
||||
|
@ -60,6 +57,9 @@
|
|||
"isF11Allowed": {
|
||||
"type" : "boolean"
|
||||
},
|
||||
"sex": {
|
||||
"type" : "string"
|
||||
},
|
||||
"isFreelance": {
|
||||
"type" : "boolean"
|
||||
}
|
||||
|
@ -94,6 +94,20 @@
|
|||
"type": "hasMany",
|
||||
"model": "WorkerTeamCollegues",
|
||||
"foreignKey": "workerFk"
|
||||
},
|
||||
"locker": {
|
||||
"type": "hasMany",
|
||||
"model": "Locker",
|
||||
"foreignKey": "workerFk"
|
||||
}
|
||||
}
|
||||
},
|
||||
"acls":[
|
||||
{
|
||||
"property": "__get__locker",
|
||||
"accessType": "READ",
|
||||
"permission": "ALLOW",
|
||||
"principalType": "ROLE",
|
||||
"principalId": "$owner"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -75,11 +75,6 @@
|
|||
ng-model="$ctrl.worker.SSN"
|
||||
rule>
|
||||
</vn-textfield>
|
||||
<vn-input-number
|
||||
min="0"
|
||||
label="Locker"
|
||||
ng-model="$ctrl.worker.locker">
|
||||
</vn-input-number>
|
||||
</vn-horizontal>
|
||||
</vn-vertical>
|
||||
</vn-card>
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
"loopback-context": "^3.5.2",
|
||||
"loopback-datasource-juggler": "3.36.1",
|
||||
"md5": "^2.2.1",
|
||||
"moment": "^2.30.1",
|
||||
"mysql": "2.18.1",
|
||||
"node-ssh": "^11.0.0",
|
||||
"object.pick": "^1.3.0",
|
||||
|
@ -113,7 +114,8 @@
|
|||
"test:e2e": "node e2e/tests.js",
|
||||
"test:front": "jest --watch",
|
||||
"back": "nodemon --inspect -w modules ./node_modules/gulp/bin/gulp.js back",
|
||||
"lint": "eslint ./ --cache --ignore-pattern .gitignore"
|
||||
"lint": "eslint ./ --cache --ignore-pattern .gitignore",
|
||||
"watch:db": "node ./db/dbWatcher.js"
|
||||
},
|
||||
"jest": {
|
||||
"projects": [
|
||||
|
|
|
@ -83,6 +83,9 @@ dependencies:
|
|||
md5:
|
||||
specifier: ^2.2.1
|
||||
version: 2.3.0
|
||||
moment:
|
||||
specifier: ^2.30.1
|
||||
version: 2.30.1
|
||||
mysql:
|
||||
specifier: 2.18.1
|
||||
version: 2.18.1
|
||||
|
@ -10202,6 +10205,10 @@ packages:
|
|||
to-iso-string: 0.0.2
|
||||
dev: false
|
||||
|
||||
/moment@2.30.1:
|
||||
resolution: {integrity: sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how==}
|
||||
dev: false
|
||||
|
||||
/ms@0.7.1:
|
||||
resolution: {integrity: sha512-lRLiIR9fSNpnP6TC4v8+4OU7oStC01esuNowdQ34L+Gk8e5Puoc88IqJ+XAY/B3Mn2ZKis8l8HX90oU8ivzUHg==}
|
||||
dev: false
|
||||
|
|
Loading…
Reference in New Issue