refs #5652 feat:itemTrash_new
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
7c6e3d3fc5
commit
022d3d08e6
|
@ -0,0 +1,20 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethod('getAddress', {
|
||||
description: 'Get all activated address last year ',
|
||||
accessType: 'READ',
|
||||
returns: {
|
||||
type: 'Object',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/getAddress`,
|
||||
verb: 'GET'
|
||||
}
|
||||
});
|
||||
|
||||
Self.getAddress = async() => {
|
||||
const query = `CALL vn.address_getLosesLastYear()`;
|
||||
const [result] = await Self.rawSql(query);
|
||||
return result;
|
||||
};
|
||||
};
|
|
@ -0,0 +1,10 @@
|
|||
const {models} = require('vn-loopback/server/server');
|
||||
|
||||
describe('getAddress()', () => {
|
||||
fit('return list of address last year', async() => {
|
||||
let response = await models.Collection.getAddress();
|
||||
|
||||
expect(response.length).toBeGreaterThan(0);
|
||||
expect(response[0].addressFk).toEqual(1);
|
||||
});
|
||||
});
|
|
@ -4,4 +4,5 @@ module.exports = Self => {
|
|||
require('../methods/collection/getSectors')(Self);
|
||||
require('../methods/collection/setSaleQuantity')(Self);
|
||||
require('../methods/collection/previousLabel')(Self);
|
||||
require('../methods/collection/getAddress')(Self);
|
||||
};
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
|
||||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`address_getLosesLastYear`()
|
||||
BEGIN
|
||||
SELECT t.addressFk , a.nickname, c.name
|
||||
FROM ticket t
|
||||
JOIN address a ON a.id = t.addressFk
|
||||
JOIN client c ON a.clientFk = c.id
|
||||
WHERE c.typeFk = 'loses'
|
||||
AND a.isactive = 1
|
||||
AND t.created >= (CURRENT_DATE() - INTERVAL 1 YEAR)
|
||||
GROUP BY t.addressFk;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
|
||||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_setVisibleDiscard`(
|
||||
vItemFk INT,
|
||||
vWarehouseFk INT,
|
||||
vQuantity INT,
|
||||
vAddressFk INT)
|
||||
|
||||
BEGIN
|
||||
DECLARE vTicketFk INT;
|
||||
DECLARE vClientFk INT;
|
||||
DECLARE vCompanyVnlFk INT;
|
||||
DECLARE vCalc INT;
|
||||
|
||||
SELECT barcodeToItem(vItemFk) INTO vItemFk;
|
||||
|
||||
SELECT companyDefaultFk INTO vCompanyVnlFk
|
||||
FROM ticketConfig ;
|
||||
|
||||
SELECT c.id INTO vClientFk
|
||||
FROM client c
|
||||
JOIN address a ON a.clientFk = c.id
|
||||
WHERE a.id = vAddressFk;
|
||||
|
||||
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,' ', getWorkerCode(), ' ', 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 ;
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
|
||||
ALTER TABLE `vn`.`ticketConfig` ADD companyDefaultFk int(10) unsigned DEFAULT 442 NOT NULL COMMENT 'Compañía por defecto para crear ticket';
|
||||
|
||||
ALTER TABLE `vn`.`ticketConfig` ADD CONSTRAINT ticketConfig_FK FOREIGN KEY (companyDefaultFk) REFERENCES vn.company(id) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- Se desactivan por utilizarse muy poco
|
||||
|
||||
UPDATE vn.address
|
||||
SET isDefaultAddress = 0,
|
||||
isActive = 0
|
||||
WHERE id IN (6,47);
|
||||
|
||||
INSERT INTO `salix`.`ACL` (id, model, property, accessType, permission, principalType, principalId) VALUES(698, 'Item', 'setVisibleDiscard', 'WRITE', 'ALLOW', 'ROLE', 'employee');
|
|
@ -2958,3 +2958,12 @@ INSERT INTO `vn`.`invoiceInSerial` (`code`, `description`, `cplusTerIdNifFk`, `t
|
|||
INSERT INTO `hedera`.`imageConfig` (`id`, `maxSize`, `useXsendfile`, `url`)
|
||||
VALUES
|
||||
(1, 0, 0, 'marvel.com');
|
||||
|
||||
--fixtures for getaddressLastYear
|
||||
UPDATE vn.client
|
||||
SET typeFk='loses'
|
||||
WHERE id=1101;
|
||||
|
||||
UPDATE vn.ticket
|
||||
SET created='2023-08-01 00:00:00'
|
||||
WHERE id=6;
|
|
@ -0,0 +1,37 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('setVisibleDiscard', {
|
||||
description: 'Change visible for item',
|
||||
accessType: 'WRITE',
|
||||
accepts: [{
|
||||
arg: 'itemFk',
|
||||
type: 'Number',
|
||||
required: false,
|
||||
description: 'The item id'
|
||||
}, {
|
||||
arg: 'warehouseFk',
|
||||
type: 'Number',
|
||||
required: true,
|
||||
description: 'The warehouse of item'
|
||||
}, {
|
||||
arg: 'quantity',
|
||||
type: 'Number',
|
||||
required: true,
|
||||
description: 'The quantity to modify'
|
||||
},
|
||||
{
|
||||
arg: 'addressFk',
|
||||
type: 'Number',
|
||||
required: true,
|
||||
description: 'The address id'
|
||||
}],
|
||||
http: {
|
||||
path: `/setVisibleDiscard`,
|
||||
verb: 'POST'
|
||||
}
|
||||
});
|
||||
|
||||
Self.setVisibleDiscard = async(ctx, itemFk, warehouseFk, quantity, addressFk) => {
|
||||
const query = `CALL vn.item_setVisibleDiscard(?, ?, ?, ?)`;
|
||||
await Self.rawSql(query, [itemFk, warehouseFk, quantity, addressFk]);
|
||||
};
|
||||
};
|
|
@ -16,6 +16,7 @@ module.exports = Self => {
|
|||
require('../methods/item/createIntrastat')(Self);
|
||||
require('../methods/item/buyerWasteEmail')(Self);
|
||||
require('../methods/item/labelPdf')(Self);
|
||||
require('../methods/item/setVisibleDiscard')(Self);
|
||||
|
||||
Self.validatesPresenceOf('originFk', {message: 'Cannot be blank'});
|
||||
|
||||
|
|
Loading…
Reference in New Issue