#7663 setWeight #2817
|
@ -0,0 +1,29 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('killSession', {
|
||||
description: 'Kill session',
|
||||
accepts: [{
|
||||
arg: 'userId',
|
||||
type: 'integer',
|
||||
description: 'The user id',
|
||||
required: true,
|
||||
}, {
|
||||
arg: 'created',
|
||||
type: 'date',
|
||||
description: 'The created time',
|
||||
required: true,
|
||||
}],
|
||||
accessType: 'WRITE',
|
||||
http: {
|
||||
path: `/killSession`,
|
||||
verb: 'POST'
|
||||
}
|
||||
});
|
||||
|
||||
Self.killSession = async function(ctx, userId, created) {
|
||||
await Self.app.models.VnUser.userSecurity(ctx, ctx.req.accessToken.userId);
|
||||
const tokens = await Self.app.models.AccessToken.find({where: {userId, created}});
|
||||
if (!tokens?.length) return;
|
||||
for (const token of tokens)
|
||||
await Self.app.models.AccessToken.deleteById(token.id);
|
||||
};
|
||||
};
|
|
@ -175,6 +175,9 @@
|
|||
"ViaexpressConfig": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"VnToken": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"VnUser": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
const vnModel = require('vn-loopback/common/models/vn-model');
|
||||
module.exports = function(Self) {
|
||||
vnModel(Self);
|
||||
require('../methods/vn-token/killSession')(Self);
|
||||
};
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"name": "VnToken",
|
||||
"base": "AccessToken",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "salix.AccessToken"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"created": {
|
||||
"type": "date"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"user": {
|
||||
"type": "belongsTo",
|
||||
"model": "VnUser",
|
||||
"foreignKey": "userId"
|
||||
}
|
||||
},
|
||||
"hidden": ["id"]
|
||||
}
|
|
@ -25,6 +25,9 @@
|
|||
"isManaged": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"isDestiny": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"countryFk": {
|
||||
"type": "number"
|
||||
}
|
||||
|
|
|
@ -108,6 +108,7 @@ INSERT INTO `vn`.`worker`(`id`,`code`, `firstName`, `lastName`, `bossFk`)
|
|||
UPDATE `vn`.`worker` SET bossFk = NULL WHERE id = 20;
|
||||
UPDATE `vn`.`worker` SET bossFk = 20 WHERE id = 1 OR id = 9;
|
||||
UPDATE `vn`.`worker` SET bossFk = 19 WHERE id = 18;
|
||||
UPDATE `vn`.`worker` SET bossFk = 50 WHERE id = 49;
|
||||
|
||||
DELETE FROM `vn`.`worker` WHERE firstName ='customer';
|
||||
|
||||
|
@ -3970,4 +3971,4 @@ VALUES
|
|||
|
||||
INSERT IGNORE INTO ormConfig
|
||||
SET id =1,
|
||||
selectLimit = 1000;
|
||||
selectLimit = 1000;
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `cache`.`available_refresh`(OUT `vCalc` INT, IN `vRefresh` INT, IN `vWarehouse` INT, IN `vDated` DATE)
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `cache`.`available_refresh`(
|
||||
OUT `vCalc` INT,
|
||||
`vRefresh` INT,
|
||||
`vWarehouse` INT,
|
||||
`vDated` DATE
|
||||
)
|
||||
proc: BEGIN
|
||||
DECLARE vStartDate DATE;
|
||||
DECLARE vReserveDate DATETIME;
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `cache`.`available_updateItem`(
|
||||
`vItem` INT,
|
||||
`vWarehouse` INT,
|
||||
`vDated` DATE,
|
||||
`vQuantity` INT
|
||||
)
|
||||
BEGIN
|
||||
/**
|
||||
* Immediately deduct/add an amount from the available cache (if exists).
|
||||
*
|
||||
* @param vItem The item id
|
||||
* @param vWarehouse The warehouse id
|
||||
* @param vDated Available cache date
|
||||
* @param vQuantity The amount to be deducted from the cache
|
||||
*/
|
||||
DECLARE vCalc INT;
|
||||
|
||||
SELECT id INTO vCalc
|
||||
FROM cache_calc
|
||||
WHERE cacheName = 'available'
|
||||
AND params = CONCAT_WS('/', vWarehouse, vDated);
|
||||
|
||||
IF vCalc IS NOT NULL THEN
|
||||
UPDATE available
|
||||
SET available = available - vQuantity
|
||||
WHERE calc_id = vCalc
|
||||
AND item_id = vItem;
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -4,7 +4,7 @@ proc: BEGIN
|
|||
/**
|
||||
* Crea o actualiza la cache con la última compra y fecha de cada
|
||||
* artículo hasta ayer. Para obtener la última compra hasta una fecha
|
||||
* determinada utilizar el procedimiento vn.buyUltimate().
|
||||
* determinada utilizar el procedimiento vn.buy_getUltimate().
|
||||
*
|
||||
* @param vRefresh %TRUE para forzar el recálculo de la cache
|
||||
*/
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`order_addItem`(
|
||||
vSelf INT,
|
||||
vWarehouse INT,
|
||||
vItem INT,
|
||||
vWarehouse INT,
|
||||
vItem INT,
|
||||
vAmount INT)
|
||||
BEGIN
|
||||
/**
|
||||
|
@ -37,7 +37,7 @@ BEGIN
|
|||
ROLLBACK;
|
||||
RESIGNAL;
|
||||
END;
|
||||
|
||||
|
||||
CALL order_calcCatalogFromItem(vSelf, vItem);
|
||||
START TRANSACTION;
|
||||
|
||||
|
@ -47,11 +47,15 @@ BEGIN
|
|||
FROM tmp.zoneGetShipped
|
||||
WHERE warehouseFk = vWarehouse;
|
||||
|
||||
SELECT IFNULL(available, 0) INTO vAvailable
|
||||
SELECT available INTO vAvailable
|
||||
FROM tmp.ticketLot
|
||||
WHERE warehouseFk = vWarehouse
|
||||
AND itemFk = vItem;
|
||||
|
||||
IF vAvailable IS NULL THEN
|
||||
SET vAvailable = 0;
|
||||
END IF;
|
||||
|
||||
IF vAmount > vAvailable THEN
|
||||
CALL util.throw ('ORDER_ROW_UNAVAILABLE');
|
||||
END IF;
|
||||
|
@ -102,6 +106,8 @@ BEGIN
|
|||
amount = vAdd,
|
||||
price = vPrice;
|
||||
|
||||
CALL cache.available_updateItem(vItem, vWarehouse, vShipment, vAdd);
|
||||
|
||||
SET vRow = LAST_INSERT_ID();
|
||||
|
||||
INSERT INTO orderRowComponent (rowFk, componentFk, price)
|
||||
|
@ -121,6 +127,6 @@ BEGIN
|
|||
END IF;
|
||||
|
||||
COMMIT;
|
||||
CALL vn.ticketCalculatePurge;
|
||||
CALL vn.ticketCalculatePurge;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`buyUltimate`(
|
||||
vWarehouseFk SMALLINT,
|
||||
vDated DATE
|
||||
)
|
||||
BEGIN
|
||||
/**
|
||||
* @deprecated Usar buy_getUltimate
|
||||
* Calcula las últimas compras realizadas hasta una fecha.
|
||||
*
|
||||
* @param vItemFk Id del artículo
|
||||
* @param vWarehouseFk Id del almacén
|
||||
* @param vDated Compras hasta fecha
|
||||
* @return tmp.buyUltimate
|
||||
*/
|
||||
CALL buy_getUltimate(NULL, vWarehouseFk, vDated);
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,20 +0,0 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`buyUltimateFromInterval`(
|
||||
vWarehouseFk SMALLINT,
|
||||
vStarted DATE,
|
||||
vEnded DATE
|
||||
)
|
||||
BEGIN
|
||||
/**
|
||||
* @deprecated Usar buy_getUltimateFromInterval
|
||||
* Calcula las últimas compras realizadas
|
||||
* desde un rango de fechas.
|
||||
*
|
||||
* @param vWarehouseFk Id del almacén si es NULL se actualizan todos
|
||||
* @param vStarted Fecha inicial
|
||||
* @param vEnded Fecha fin
|
||||
* @return tmp.buyUltimateFromInterval
|
||||
*/
|
||||
CALL vn.buy_getUltimateFromInterval(NULL, vWarehouseFk, vStarted, vEnded);
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -6,9 +6,10 @@ BEGIN
|
|||
*
|
||||
* @param tmp.buysToCheck(id as INT).
|
||||
*/
|
||||
DECLARE hasVolumetricAgency INT;
|
||||
DECLARE vHasVolumetricAgency INT;
|
||||
DECLARE vItemFk INT;
|
||||
|
||||
SELECT a.hasWeightVolumetric INTO hasVolumetricAgency
|
||||
SELECT a.hasWeightVolumetric, i.id INTO vHasVolumetricAgency, vItemFk
|
||||
FROM entry e
|
||||
JOIN travel t ON t.id = e.travelFk
|
||||
JOIN agencyMode a ON a.id = t.agencyModeFk
|
||||
|
@ -19,10 +20,10 @@ BEGIN
|
|||
AND a.hasWeightVolumetric
|
||||
LIMIT 1;
|
||||
|
||||
DROP TEMPORARY TABLE tmp.buysToCheck;
|
||||
DROP TEMPORARY TABLE tmp.buysToCheck;
|
||||
|
||||
IF hasVolumetricAgency THEN
|
||||
CALL util.throw('Item lacks size/weight in purchase line at agency');
|
||||
END IF;
|
||||
IF vHasVolumetricAgency THEN
|
||||
CALL util.throw(CONCAT('Missing size/weight in buy line at agency, item: ', vItemFk));
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
DELIMITER ;
|
|
@ -17,6 +17,7 @@ BEGIN
|
|||
DECLARE vHasDailyInvoice BOOL;
|
||||
DECLARE vWithPackage BOOL;
|
||||
DECLARE vHasToInvoice BOOL;
|
||||
DECLARE vSerial VARCHAR(2);
|
||||
|
||||
DECLARE cur CURSOR FOR
|
||||
SELECT ticketFk FROM tmp.ticket_close;
|
||||
|
@ -83,14 +84,17 @@ BEGIN
|
|||
GROUP BY e.freightItemFk);
|
||||
|
||||
IF(vHasDailyInvoice) AND vHasToInvoice THEN
|
||||
SELECT invoiceSerial(vClientFk, vCompanyFk, 'quick') INTO vSerial;
|
||||
IF vSerial IS NULL THEN
|
||||
CALL util.throw('Cannot booking without a serial');
|
||||
END IF;
|
||||
|
||||
-- Facturacion rapida
|
||||
CALL ticket_setState(vCurTicketFk, 'DELIVERED');
|
||||
-- Facturar si está contabilizado
|
||||
|
||||
IF vIsTaxDataChecked THEN
|
||||
CALL invoiceOut_newFromClient(
|
||||
vClientFk,
|
||||
(SELECT invoiceSerial(vClientFk, vCompanyFk, 'multiple')),
|
||||
vSerial,
|
||||
vShipped,
|
||||
vCompanyFk,
|
||||
NULL,
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
UPDATE `salix`.`ACL`
|
||||
SET accessType='READ'
|
||||
WHERE model = 'ACL';
|
||||
|
||||
UPDATE `salix`.`ACL`
|
||||
SET principalId='developerBoss'
|
||||
WHERE model = 'AccessToken';
|
||||
|
||||
INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId)
|
||||
VALUES
|
||||
('VnToken', '*', 'READ', 'ALLOW', 'ROLE', 'developer'),
|
||||
('VnToken', 'killSession', '*', 'ALLOW', 'ROLE', 'developer'),
|
||||
('ACL', '*', 'WRITE', 'ALLOW', 'ROLE', 'developerBoss');
|
|
@ -0,0 +1 @@
|
|||
ALTER TABLE vn.parking ADD COLUMN floor VARCHAR(5) DEFAULT NULL AFTER row;
|
|
@ -0,0 +1,129 @@
|
|||
|
||||
use vn;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `material` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(50) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `name_UNIQUE` (`name`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
|
||||
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Abedul');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Acacia');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Acero');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Acero Galvanizado');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Acetato');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Acrílico');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Alambre');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Algodón');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Aluminio');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Antracita');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Arcilla');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Bambú');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Banano');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Canneté');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Cartón');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Cartulina');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Celofán');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Cemento');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Cera');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Cerámica');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Chapa');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Chenilla');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Cloruro de polivinilo');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Cobre');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Corcho');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Cordel');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Cotton');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Cotton Chess');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Cristal');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Cubo Asa');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Cuerda');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Cuero');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Doble Raso');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Doble Velvet');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Eco Glass');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Encaje');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Esparto');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Espuma');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Felpa');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Fibra');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Fibra de Coco');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Fibra de Vidrio y Resina');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Fieltro');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Foam');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Gamuza');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Gasa');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Glass');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Goma');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Grafito');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Hierro');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Hoja Carbono');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Hoja de Mirto');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Hormigón');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Jute');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Kraft');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Lana');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Látex');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Latrix');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Lienzo');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Lino');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Lurex');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Madera');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Metacrilato');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Metal');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Mimbre');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Musgo');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Nonwoven');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Nylon');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Organza');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Paja');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Pana');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Papel');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Paperweb');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Paulownia');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Peluche');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Piedra');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Pizarra');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Plástico');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Poliestireno');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Polipropileno');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Poliresina');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Polyester');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Porcelana');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Puntilla');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('PVC');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Rafia');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Rama');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Raso');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Rattan');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Rayon');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Reciclable');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Red');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Resina');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Roca');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Rope');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Saco');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Salim');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Seagrass');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Silicona');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Sisal');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Tejido');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Tela');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Terciopelo');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Terracota');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Textil');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Titanio');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Tul');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Velvet');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Vidrio');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Yute');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Zinc');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Base de goma');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Base de madera');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Plumas');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Protección Uva');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Purpurina');
|
||||
|
||||
UPDATE vn.tag SET isFree=0,sourceTable='material' WHERE name= 'Material';
|
||||
UPDATE vn.tag SET isFree=0,sourceTable='material' WHERE name='Material secundario';
|
|
@ -0,0 +1,4 @@
|
|||
-- Place your SQL code here
|
||||
INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId)
|
||||
VALUES ('Worker', '__get__descriptor', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Worker', 'findById', 'READ', 'ALLOW', 'ROLE', '$subordinate');
|
|
@ -0,0 +1,19 @@
|
|||
INSERT INTO hedera.message (code,description)
|
||||
VALUES ('ORDER_ROW_UNAVAILABLE','The ordered quantity exceeds the available');
|
||||
INSERT INTO hedera.message (code,description)
|
||||
VALUES ('AMOUNT_NOT_MATCH_GROUPING','The quantity ordered does not match the grouping');
|
||||
|
||||
INSERT INTO hedera.messageI18n (code,lang,description)
|
||||
VALUES ('ORDER_ROW_UNAVAILABLE','es','La cantidad pedida excede el disponible');
|
||||
INSERT INTO hedera.messageI18n (code,lang,description)
|
||||
VALUES ('AMOUNT_NOT_MATCH_GROUPING','es','La cantidad pedida no coincide con el agrupado');
|
||||
|
||||
INSERT INTO hedera.messageI18n (code,lang,description)
|
||||
VALUES ('ORDER_ROW_UNAVAILABLE','fr','La quantité demandée dépasse ce qui est disponible');
|
||||
INSERT INTO hedera.messageI18n (code,lang,description)
|
||||
VALUES ('AMOUNT_NOT_MATCH_GROUPING','fr','La quantité commandée ne correspond pas au regroupement');
|
||||
|
||||
INSERT INTO hedera.messageI18n (code,lang,description)
|
||||
VALUES ('ORDER_ROW_UNAVAILABLE','pt','A quantidade de entrega excede a disponibilidade');
|
||||
INSERT INTO hedera.messageI18n (code,lang,description)
|
||||
VALUES ('AMOUNT_NOT_MATCH_GROUPING','pt','A quantidade solicitada não corresponde ao agrupamento');
|
|
@ -1,79 +0,0 @@
|
|||
import selectors from '../../helpers/selectors.js';
|
||||
import getBrowser from '../../helpers/puppeteer';
|
||||
|
||||
describe('Supplier summary & descriptor path', () => {
|
||||
let browser;
|
||||
let page;
|
||||
|
||||
beforeAll(async() => {
|
||||
browser = await getBrowser();
|
||||
page = browser.page;
|
||||
await page.loginAndModule('administrative', 'supplier');
|
||||
await page.accessToSearchResult('1');
|
||||
});
|
||||
|
||||
afterAll(async() => {
|
||||
await browser.close();
|
||||
});
|
||||
|
||||
// summary
|
||||
it('should reach the second entry summary section', async() => {
|
||||
await page.waitForState('supplier.card.summary');
|
||||
});
|
||||
|
||||
it(`should confirm there's data on the summary header`, async() => {
|
||||
const result = await page.waitToGetProperty(selectors.supplierSummary.header, 'innerText');
|
||||
|
||||
expect(result).toContain('PLANTS SL - 1');
|
||||
});
|
||||
|
||||
it(`should confirm there's data on the summary basic data`, async() => {
|
||||
const result = await page.waitToGetProperty(selectors.supplierSummary.basicDataId, 'innerText');
|
||||
|
||||
expect(result).toContain('Id 1');
|
||||
});
|
||||
|
||||
it(`should confirm there's data on the summary fiscal address`, async() => {
|
||||
const result = await page.waitToGetProperty(selectors.supplierSummary.fiscalAddressTaxNumber, 'innerText');
|
||||
|
||||
expect(result).toContain('Tax number 06089160W');
|
||||
});
|
||||
|
||||
it(`should confirm there's data on the summary fiscal pay method`, async() => {
|
||||
const result = await page.waitToGetProperty(selectors.supplierSummary.billingDataPayMethod, 'innerText');
|
||||
|
||||
expect(result).toContain('Pay method PayMethod one');
|
||||
});
|
||||
|
||||
// descriptor
|
||||
it(`should confirm there's data on the descriptor`, async() => {
|
||||
const result = await page.waitToGetProperty(selectors.supplierDescriptor.alias, 'innerText');
|
||||
|
||||
expect(result).toContain('Plants nick');
|
||||
});
|
||||
|
||||
it(`should navigate to the supplier's client summary using the icon client button`, async() => {
|
||||
await page.waitToClick(selectors.supplierDescriptor.clientButton);
|
||||
await page.waitForState('client.card.summary');
|
||||
});
|
||||
|
||||
it(`should navigate back to the supplier`, async() => {
|
||||
await page.waitToClick(selectors.globalItems.homeButton);
|
||||
await page.waitForState('home');
|
||||
await page.selectModule('supplier');
|
||||
await page.accessToSearchResult('1');
|
||||
await page.waitForState('supplier.card.summary');
|
||||
});
|
||||
|
||||
it(`should navigate back to suppliers but a different one this time`, async() => {
|
||||
await page.waitToClick(selectors.globalItems.homeButton);
|
||||
await page.waitForState('home');
|
||||
await page.selectModule('supplier');
|
||||
await page.accessToSearchResult('2');
|
||||
await page.waitForState('supplier.card.summary');
|
||||
});
|
||||
|
||||
it(`should check the client button isn't present since this supplier should not be a client`, async() => {
|
||||
await page.waitForSelector(selectors.supplierDescriptor.clientButton, {visible: false});
|
||||
});
|
||||
});
|
|
@ -1,67 +0,0 @@
|
|||
import selectors from '../../helpers/selectors.js';
|
||||
import getBrowser from '../../helpers/puppeteer';
|
||||
|
||||
describe('Supplier basic data path', () => {
|
||||
let browser;
|
||||
let page;
|
||||
|
||||
beforeAll(async() => {
|
||||
browser = await getBrowser();
|
||||
page = browser.page;
|
||||
await page.loginAndModule('financial', 'supplier');
|
||||
await page.accessToSearchResult('1');
|
||||
await page.accessToSection('supplier.card.basicData');
|
||||
});
|
||||
|
||||
afterAll(async() => {
|
||||
await browser.close();
|
||||
});
|
||||
|
||||
it('should edit the basic data', async() => {
|
||||
await page.clearInput(selectors.supplierBasicData.alias);
|
||||
await page.write(selectors.supplierBasicData.alias, 'Plants Nick SL');
|
||||
await page.waitToClick(selectors.supplierBasicData.isReal);
|
||||
await page.waitToClick(selectors.supplierBasicData.isActive);
|
||||
await page.waitToClick(selectors.supplierBasicData.isPayMethodChecked);
|
||||
await page.write(selectors.supplierBasicData.notes, 'Some notes');
|
||||
|
||||
await page.waitToClick(selectors.supplierBasicData.saveButton);
|
||||
const message = await page.waitForSnackbar();
|
||||
|
||||
expect(message.text).toContain('Data saved!');
|
||||
});
|
||||
|
||||
it('should reload the section', async() => {
|
||||
await page.reloadSection('supplier.card.basicData');
|
||||
});
|
||||
|
||||
it('should check the alias was edited', async() => {
|
||||
const result = await page.waitToGetProperty(selectors.supplierBasicData.alias, 'value');
|
||||
|
||||
expect(result).toEqual('Plants Nick SL');
|
||||
});
|
||||
|
||||
it('should check the isReal checkbox is now checked', async() => {
|
||||
const result = await page.checkboxState(selectors.supplierBasicData.isReal);
|
||||
|
||||
expect(result).toBe('checked');
|
||||
});
|
||||
|
||||
it('should check the isActive checkbox is now unchecked', async() => {
|
||||
const result = await page.checkboxState(selectors.supplierBasicData.isActive);
|
||||
|
||||
expect(result).toBe('unchecked');
|
||||
});
|
||||
|
||||
it('should check the isPayMethodChecked checkbox is now unchecked', async() => {
|
||||
const result = await page.checkboxState(selectors.supplierBasicData.isPayMethodChecked);
|
||||
|
||||
expect(result).toBe('unchecked');
|
||||
});
|
||||
|
||||
it('should check the notes were edited', async() => {
|
||||
const result = await page.waitToGetProperty(selectors.supplierBasicData.notes, 'value');
|
||||
|
||||
expect(result).toEqual('Some notes');
|
||||
});
|
||||
});
|
|
@ -1,56 +0,0 @@
|
|||
import getBrowser from '../../helpers/puppeteer';
|
||||
|
||||
describe('Supplier fiscal data path', () => {
|
||||
let browser;
|
||||
let page;
|
||||
|
||||
beforeAll(async() => {
|
||||
browser = await getBrowser();
|
||||
page = browser.page;
|
||||
await page.loginAndModule('administrative', 'supplier');
|
||||
await page.accessToSearchResult('2');
|
||||
});
|
||||
|
||||
afterAll(async() => {
|
||||
await browser.close();
|
||||
});
|
||||
|
||||
it('should attempt to edit the fiscal data and check data iss saved', async() => {
|
||||
await page.accessToSection('supplier.card.fiscalData');
|
||||
|
||||
const form = 'vn-supplier-fiscal-data form';
|
||||
const values = {
|
||||
province: null,
|
||||
country: null,
|
||||
postcode: null,
|
||||
city: 'Valencia',
|
||||
socialName: 'FARMER KING SL',
|
||||
taxNumber: '12345678Z',
|
||||
account: '0123456789',
|
||||
sageWithholding: 'retencion estimacion objetiva',
|
||||
sageTaxType: 'operaciones no sujetas'
|
||||
};
|
||||
|
||||
const errorMessage = await page.sendForm(form, {
|
||||
taxNumber: 'Wrong tax number'
|
||||
});
|
||||
const message = await page.sendForm(form, values);
|
||||
|
||||
await page.reloadSection('supplier.card.fiscalData');
|
||||
const formValues = await page.fetchForm(form, Object.keys(values));
|
||||
|
||||
expect(errorMessage.text).toContain('Invalid Tax number');
|
||||
expect(message.isSuccess).toBeTrue();
|
||||
expect(formValues).toEqual({
|
||||
province: 'Province one',
|
||||
country: 'España',
|
||||
postcode: '46000',
|
||||
city: 'Valencia',
|
||||
socialName: 'FARMER KING SL',
|
||||
taxNumber: '12345678Z',
|
||||
account: '0123456789',
|
||||
sageWithholding: 'RETENCION ESTIMACION OBJETIVA',
|
||||
sageTaxType: 'Operaciones no sujetas'
|
||||
});
|
||||
});
|
||||
});
|
|
@ -1,52 +0,0 @@
|
|||
import selectors from '../../helpers/selectors.js';
|
||||
import getBrowser from '../../helpers/puppeteer';
|
||||
|
||||
describe('Supplier billing data path', () => {
|
||||
let browser;
|
||||
let page;
|
||||
|
||||
beforeAll(async() => {
|
||||
browser = await getBrowser();
|
||||
page = browser.page;
|
||||
await page.loginAndModule('administrative', 'supplier');
|
||||
await page.accessToSearchResult('442');
|
||||
await page.accessToSection('supplier.card.billingData');
|
||||
});
|
||||
|
||||
afterAll(async() => {
|
||||
await browser.close();
|
||||
});
|
||||
|
||||
it('should edit the billing data', async() => {
|
||||
await page.autocompleteSearch(selectors.supplierBillingData.payMethod, 'PayMethod with IBAN');
|
||||
await page.autocompleteSearch(selectors.supplierBillingData.payDem, '10');
|
||||
await page.clearInput(selectors.supplierBillingData.payDay);
|
||||
await page.write(selectors.supplierBillingData.payDay, '19');
|
||||
await page.waitToClick(selectors.supplierBillingData.saveButton);
|
||||
const message = await page.waitForSnackbar();
|
||||
|
||||
expect(message.text).toContain('Data saved!');
|
||||
});
|
||||
|
||||
it('should reload the section', async() => {
|
||||
await page.reloadSection('supplier.card.billingData');
|
||||
});
|
||||
|
||||
it('should check the pay method was edited', async() => {
|
||||
const result = await page.waitToGetProperty(selectors.supplierBillingData.payMethod, 'value');
|
||||
|
||||
expect(result).toEqual('PayMethod with IBAN');
|
||||
});
|
||||
|
||||
it('should check the payDem was edited', async() => {
|
||||
const result = await page.waitToGetProperty(selectors.supplierBillingData.payDem, 'value');
|
||||
|
||||
expect(result).toEqual('10');
|
||||
});
|
||||
|
||||
it('should check the pay day was edited', async() => {
|
||||
const result = await page.waitToGetProperty(selectors.supplierBillingData.payDay, 'value');
|
||||
|
||||
expect(result).toEqual('19');
|
||||
});
|
||||
});
|
|
@ -1,79 +0,0 @@
|
|||
import selectors from '../../helpers/selectors.js';
|
||||
import getBrowser from '../../helpers/puppeteer';
|
||||
|
||||
describe('Supplier address path', () => {
|
||||
let browser;
|
||||
let page;
|
||||
|
||||
beforeAll(async() => {
|
||||
browser = await getBrowser();
|
||||
page = browser.page;
|
||||
await page.loginAndModule('employee', 'supplier');
|
||||
await page.accessToSearchResult('1');
|
||||
await page.accessToSection('supplier.card.address.index');
|
||||
});
|
||||
|
||||
afterAll(async() => {
|
||||
await browser.close();
|
||||
});
|
||||
|
||||
it('should count the addresses before creating one', async() => {
|
||||
const count = await page.countElement(selectors.supplierAddress.anyAddress);
|
||||
|
||||
expect(count).toEqual(2);
|
||||
});
|
||||
|
||||
it('should open the new address form by clicking the add button', async() => {
|
||||
await page.waitToClick(selectors.supplierAddress.newAddress);
|
||||
await page.waitForState('supplier.card.address.create');
|
||||
});
|
||||
|
||||
it('should create a new address', async() => {
|
||||
await page.write(selectors.supplierAddress.newNickname, 'Darkest dungeon');
|
||||
await page.write(selectors.supplierAddress.newStreet, 'Wayne manor');
|
||||
await page.write(selectors.supplierAddress.newPostcode, '46000');
|
||||
await page.write(selectors.supplierAddress.newCity, 'Valencia');
|
||||
await page.autocompleteSearch(selectors.supplierAddress.newProvince, 'Province one');
|
||||
await page.write(selectors.supplierAddress.newPhone, '888888888');
|
||||
await page.write(selectors.supplierAddress.newMobile, '444444444');
|
||||
await page.waitToClick(selectors.supplierAddress.saveButton);
|
||||
const message = await page.waitForSnackbar();
|
||||
|
||||
expect(message.text).toContain('Data saved!');
|
||||
});
|
||||
|
||||
it('should have been redirected to the addresses index', async() => {
|
||||
await page.waitForState('supplier.card.address.index');
|
||||
});
|
||||
|
||||
it('should count the addresses and find one more now', async() => {
|
||||
const count = await page.countElement(selectors.supplierAddress.anyAddress);
|
||||
|
||||
expect(count).toEqual(3);
|
||||
});
|
||||
|
||||
it('should open the edit address form by clicking the new address', async() => {
|
||||
await page.waitToClick(selectors.supplierAddress.thirdAddress);
|
||||
await page.waitForState('supplier.card.address.edit');
|
||||
});
|
||||
|
||||
it('should edit the address', async() => {
|
||||
await page.overwrite(selectors.supplierAddress.editNickname, 'Wayne manor');
|
||||
await page.overwrite(selectors.supplierAddress.editStreet, '1007 Mountain Drive');
|
||||
await page.overwrite(selectors.supplierAddress.editPostcode, '46000');
|
||||
await page.overwrite(selectors.supplierAddress.editCity, 'Valencia');
|
||||
await page.autocompleteSearch(selectors.supplierAddress.editProvince, 'Province one');
|
||||
await page.overwrite(selectors.supplierAddress.editPhone, '777777777');
|
||||
await page.overwrite(selectors.supplierAddress.editMobile, '555555555');
|
||||
await page.waitToClick(selectors.supplierAddress.saveButton);
|
||||
const message = await page.waitForSnackbar();
|
||||
|
||||
expect(message.text).toContain('Data saved!');
|
||||
});
|
||||
|
||||
it('should check the address has now the expected data', async() => {
|
||||
let thirdAddress = await page.waitToGetProperty(selectors.supplierAddress.thirdAddress, 'innerText');
|
||||
|
||||
expect(thirdAddress).toContain('Wayne manor');
|
||||
});
|
||||
});
|
|
@ -1,89 +0,0 @@
|
|||
import selectors from '../../helpers/selectors.js';
|
||||
import getBrowser from '../../helpers/puppeteer';
|
||||
|
||||
describe('Supplier contact path', () => {
|
||||
let browser;
|
||||
let page;
|
||||
|
||||
beforeAll(async() => {
|
||||
browser = await getBrowser();
|
||||
page = browser.page;
|
||||
await page.loginAndModule('administrative', 'supplier');
|
||||
await page.accessToSearchResult('1');
|
||||
await page.accessToSection('supplier.card.contact');
|
||||
});
|
||||
|
||||
afterAll(async() => {
|
||||
await browser.close();
|
||||
});
|
||||
|
||||
it('should create a new contact', async() => {
|
||||
await page.waitToClick(selectors.supplierContact.addNewContact);
|
||||
await page.write(selectors.supplierContact.thirdContactName, 'The tester');
|
||||
await page.write(selectors.supplierContact.thirdContactPhone, '99 999 99 99');
|
||||
await page.write(selectors.supplierContact.thirdContactMobile, '555 55 55 55');
|
||||
await page.write(selectors.supplierContact.thirdContactEmail, 'testing@puppeteer.com');
|
||||
await page.write(selectors.supplierContact.thirdContactNotes, 'the end to end integration tester');
|
||||
await page.waitToClick(selectors.supplierContact.saveButton);
|
||||
const message = await page.waitForSnackbar();
|
||||
|
||||
expect(message.text).toContain('Data saved!');
|
||||
});
|
||||
|
||||
it(`should reload the section and count the contacts`, async() => {
|
||||
await page.reloadSection('supplier.card.contact');
|
||||
const result = await page.countElement(selectors.supplierContact.anyContact);
|
||||
|
||||
expect(result).toEqual(3);
|
||||
});
|
||||
|
||||
it(`should check the new contact name was saved correctly`, async() => {
|
||||
const result = await page.waitToGetProperty(selectors.supplierContact.thirdContactName, 'value');
|
||||
|
||||
expect(result).toContain('The tester');
|
||||
});
|
||||
|
||||
it(`should check the new contact phone was saved correctly`, async() => {
|
||||
const result = await page.waitToGetProperty(selectors.supplierContact.thirdContactPhone, 'value');
|
||||
|
||||
expect(result).toContain('99 999 99 99');
|
||||
});
|
||||
|
||||
it(`should check the new contact mobile was saved correctly`, async() => {
|
||||
const result = await page.waitToGetProperty(selectors.supplierContact.thirdContactMobile, 'value');
|
||||
|
||||
expect(result).toContain('555 55 55 55');
|
||||
});
|
||||
|
||||
it(`should check the new contact email was saved correctly`, async() => {
|
||||
const result = await page.waitToGetProperty(selectors.supplierContact.thirdContactEmail, 'value');
|
||||
|
||||
expect(result).toContain('testing@puppeteer.com');
|
||||
});
|
||||
|
||||
it(`should check the new contact note was saved correctly`, async() => {
|
||||
await page.waitForTextInField(selectors.supplierContact.thirdContactNotes, 'the end to end integration tester');
|
||||
const result = await page.waitToGetProperty(selectors.supplierContact.thirdContactNotes, 'value');
|
||||
|
||||
expect(result).toContain('the end to end integration tester');
|
||||
});
|
||||
|
||||
it(`should remove the created contact`, async() => {
|
||||
await page.waitToClick(selectors.supplierContact.thirdContactDeleteButton, 'value');
|
||||
const result = await page.countElement(selectors.supplierContact.anyContact);
|
||||
|
||||
expect(result).toEqual(2);
|
||||
|
||||
await page.waitToClick(selectors.supplierContact.saveButton);
|
||||
const message = await page.waitForSnackbar();
|
||||
|
||||
expect(message.text).toContain('Data saved!');
|
||||
});
|
||||
|
||||
it(`should reload the section and count the amount of contacts went back to 2`, async() => {
|
||||
await page.reloadSection('supplier.card.contact');
|
||||
const result = await page.countElement(selectors.supplierContact.anyContact);
|
||||
|
||||
expect(result).toEqual(2);
|
||||
});
|
||||
});
|
|
@ -0,0 +1,12 @@
|
|||
const UserError = require('vn-loopback/util/user-error');
|
||||
|
||||
module.exports = async function(app) {
|
||||
const models = app.models;
|
||||
|
||||
models.VnRole.registerResolver('$subordinate', async(role, ctx) => {
|
||||
Object.assign(ctx, {req: {accessToken: {userId: ctx.accessToken.userId}}});
|
||||
|
||||
const isSubordinate = await models.Worker.isSubordinate(ctx, +ctx.modelId);
|
||||
if (!isSubordinate) throw new UserError(`You don't have enough privileges`);
|
||||
});
|
||||
};
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/**
|
||||
* Flattens an array of objects by converting each object into a flat structure.
|
||||
*
|
||||
|
|
|
@ -320,7 +320,8 @@ module.exports = Self => {
|
|||
|
||||
// Credit management changes
|
||||
|
||||
if (changes?.rating >= 0 || changes?.recommendedCredit >= 0)
|
||||
if ((changes?.rating != null && changes.rating >= 0)
|
||||
|| (changes?.recommendedCredit != null && changes.recommendedCredit >= 0))
|
||||
await Self.changeCreditManagement(ctx, finalState, changes);
|
||||
|
||||
const oldInstance = {};
|
||||
|
|
|
@ -23,6 +23,7 @@ class Controller extends Dialog {
|
|||
}
|
||||
|
||||
set clientFk(value) {
|
||||
if (!value) return;
|
||||
this.receipt.clientFk = value;
|
||||
|
||||
const filter = {
|
||||
|
@ -32,6 +33,7 @@ class Controller extends Dialog {
|
|||
}
|
||||
};
|
||||
|
||||
this.getAmountPaid();
|
||||
this.$http.get(`Clients/findOne`, {filter})
|
||||
.then(res => {
|
||||
this.receipt.email = res.data.email;
|
||||
|
@ -50,7 +52,6 @@ class Controller extends Dialog {
|
|||
|
||||
set companyFk(value) {
|
||||
this.receipt.companyFk = value;
|
||||
this.getAmountPaid();
|
||||
}
|
||||
|
||||
set description(value) {
|
||||
|
@ -152,7 +153,7 @@ class Controller extends Dialog {
|
|||
getAmountPaid() {
|
||||
const filter = {
|
||||
where: {
|
||||
clientFk: this.$params.id,
|
||||
clientFk: this.$params.id ?? this.clientFk,
|
||||
companyFk: this.receipt.companyFk
|
||||
}
|
||||
};
|
||||
|
@ -210,8 +211,8 @@ ngModule.vnComponent('vnClientBalanceCreate', {
|
|||
payed: '<?',
|
||||
bankFk: '<?',
|
||||
amountPaid: '<?',
|
||||
clientFk: '<?',
|
||||
companyFk: '<?',
|
||||
description: '<?',
|
||||
clientFk: '<?'
|
||||
}
|
||||
});
|
||||
|
|
|
@ -9,6 +9,11 @@ module.exports = Self => {
|
|||
required: true,
|
||||
description: 'Issued invoice id'
|
||||
},
|
||||
{
|
||||
arg: 'withWarehouse',
|
||||
type: 'boolean',
|
||||
required: true
|
||||
},
|
||||
{
|
||||
arg: 'cplusRectificationTypeFk',
|
||||
type: 'number',
|
||||
|
@ -38,6 +43,7 @@ module.exports = Self => {
|
|||
Self.refundAndInvoice = async(
|
||||
ctx,
|
||||
id,
|
||||
withWarehouse,
|
||||
cplusRectificationTypeFk,
|
||||
siiTypeInvoiceOutFk,
|
||||
invoiceCorrectionTypeFk,
|
||||
|
@ -59,7 +65,7 @@ module.exports = Self => {
|
|||
try {
|
||||
const originalInvoice = await models.InvoiceOut.findById(id, myOptions);
|
||||
|
||||
const refundedTickets = await Self.refund(ctx, originalInvoice.ref, false, myOptions);
|
||||
const refundedTickets = await Self.refund(ctx, originalInvoice.ref, withWarehouse, myOptions);
|
||||
|
||||
const invoiceCorrection = {
|
||||
correctedFk: id,
|
||||
|
|
|
@ -14,14 +14,16 @@ describe('InvoiceOut refundAndInvoice()', () => {
|
|||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({active: activeCtx});
|
||||
});
|
||||
|
||||
it('should refund an invoice and create a new invoice', async() => {
|
||||
it('should refund an invoice and create a new invoice with warehouse', async() => {
|
||||
const tx = await models.InvoiceOut.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
const withWarehouse = true;
|
||||
|
||||
try {
|
||||
const result = await models.InvoiceOut.refundAndInvoice(
|
||||
ctx,
|
||||
id,
|
||||
withWarehouse,
|
||||
cplusRectificationTypeFk,
|
||||
siiTypeInvoiceOutFk,
|
||||
invoiceCorrectionTypeFk,
|
||||
|
@ -32,7 +34,40 @@ describe('InvoiceOut refundAndInvoice()', () => {
|
|||
expect(result.refundId).toBeDefined();
|
||||
|
||||
const invoicesAfter = await models.InvoiceOut.find({where: {id: result.refundId}}, options);
|
||||
const ticketsAfter = await models.Ticket.find({where: {refFk: 'R10100001'}}, options);
|
||||
const ticketsAfter = await models.Ticket.find(
|
||||
{where: {refFk: 'R10100001', warehouse: {neq: null}}}, options);
|
||||
|
||||
expect(invoicesAfter.length).toBeGreaterThan(0);
|
||||
expect(ticketsAfter.length).toBeGreaterThan(0);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
|
||||
it('should refund an invoice and create a new invoice with warehouse null', async() => {
|
||||
const tx = await models.InvoiceOut.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
const withWarehouse = false;
|
||||
|
||||
try {
|
||||
const result = await models.InvoiceOut.refundAndInvoice(
|
||||
ctx,
|
||||
id,
|
||||
withWarehouse,
|
||||
cplusRectificationTypeFk,
|
||||
siiTypeInvoiceOutFk,
|
||||
invoiceCorrectionTypeFk,
|
||||
options
|
||||
);
|
||||
|
||||
expect(result).toBeDefined();
|
||||
expect(result.refundId).toBeDefined();
|
||||
|
||||
const invoicesAfter = await models.InvoiceOut.find({where: {id: result.refundId}}, options);
|
||||
const ticketsAfter = await models.Ticket.find({where: {refFk: 'R10100001', warehouse: null}}, options);
|
||||
|
||||
expect(invoicesAfter.length).toBeGreaterThan(0);
|
||||
expect(ticketsAfter.length).toBeGreaterThan(0);
|
||||
|
|
|
@ -75,6 +75,7 @@ module.exports = Self => {
|
|||
await Self.refundAndInvoice(
|
||||
ctx,
|
||||
id,
|
||||
false,
|
||||
cplusRectificationTypeFk,
|
||||
siiTypeInvoiceOutFk,
|
||||
invoiceCorrectionTypeFk,
|
||||
|
|
|
@ -128,6 +128,9 @@ module.exports = Self => {
|
|||
return {[param]: value};
|
||||
}
|
||||
});
|
||||
if (ctx.req.query?.showBadDates === 'true')
|
||||
where['fp.started'] = {gte: Date.vnNew()};
|
||||
|
||||
filter = mergeFilters(filter, {where});
|
||||
|
||||
const stmts = [];
|
||||
|
@ -136,6 +139,7 @@ module.exports = Self => {
|
|||
SELECT DISTINCT fp.id,
|
||||
fp.itemFk,
|
||||
fp.warehouseFk,
|
||||
w.name warehouseName,
|
||||
fp.rate2,
|
||||
fp.rate3,
|
||||
fp.started,
|
||||
|
@ -159,6 +163,7 @@ module.exports = Self => {
|
|||
FROM priceFixed fp
|
||||
JOIN item i ON i.id = fp.itemFk
|
||||
JOIN itemType it ON it.id = i.typeFk
|
||||
JOIN warehouse w ON fp.warehouseFk = w.id
|
||||
`);
|
||||
|
||||
if (ctx.args.tags) {
|
||||
|
@ -184,7 +189,6 @@ module.exports = Self => {
|
|||
}
|
||||
|
||||
stmt.merge(conn.makeSuffix(filter));
|
||||
|
||||
const fixedPriceIndex = stmts.push(stmt) - 1;
|
||||
const sql = ParameterizedSQL.join(stmts, ';');
|
||||
const result = await conn.executeStmt(sql, myOptions);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('item getVisibleAvailable()', () => {
|
||||
it('should check available visible for today', async() => {
|
||||
it('should check available visible for tomorrow', async() => {
|
||||
const tx = await models.Item.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
|
||||
|
@ -9,6 +9,7 @@ describe('item getVisibleAvailable()', () => {
|
|||
const itemFk = 1;
|
||||
const warehouseFk = 1;
|
||||
const dated = Date.vnNew();
|
||||
dated.setDate(dated.getDate() + 1);
|
||||
|
||||
const result = await models.Item.getVisibleAvailable(itemFk, warehouseFk, dated, options);
|
||||
|
||||
|
|
|
@ -285,7 +285,7 @@ module.exports = Self => {
|
|||
if (hasProblems === true) {
|
||||
whereProblems = {or: [
|
||||
{'tp.isFreezed': true},
|
||||
{'tp.risk': {lt: 0}},
|
||||
{'tp.hasRisk': true},
|
||||
{'tp.hasTicketRequest': true},
|
||||
{'tp.hasComponentLack': true},
|
||||
{'tp.isTaxDataChecked': false},
|
||||
|
@ -295,7 +295,7 @@ module.exports = Self => {
|
|||
} else if (hasProblems === false) {
|
||||
whereProblems = {and: [
|
||||
{'tp.isFreezed': false},
|
||||
{'tp.risk': 0},
|
||||
{'tp.hasRisk': false},
|
||||
{'tp.hasTicketRequest': false},
|
||||
{'tp.hasComponentLack': false},
|
||||
{'tp.isTaxDataChecked': true},
|
||||
|
|
|
@ -1,86 +0,0 @@
|
|||
<vn-crud-model
|
||||
vn-id="model"
|
||||
url="SupplierAccounts"
|
||||
fields="['id', 'supplierFk', 'iban', 'bankEntityFk', 'beneficiary']"
|
||||
link="{supplierFk: $ctrl.$params.id}"
|
||||
include="$ctrl.include"
|
||||
data="$ctrl.supplierAccounts"
|
||||
auto-load="true">
|
||||
</vn-crud-model>
|
||||
<vn-watcher
|
||||
vn-id="watcher"
|
||||
data="$ctrl.supplierAccounts"
|
||||
form="form">
|
||||
</vn-watcher>
|
||||
<form name="form" ng-submit="$ctrl.onSubmit()" class="vn-w-lg">
|
||||
<vn-card class="vn-pa-lg">
|
||||
<vn-horizontal ng-repeat="supplierAccount in $ctrl.supplierAccounts">
|
||||
<vn-textfield
|
||||
label="Iban"
|
||||
ng-model="supplierAccount.iban"
|
||||
on-change="supplierAccount.bankEntityFk = supplierAccount.iban.slice(4,8)"
|
||||
rule>
|
||||
</vn-textfield>
|
||||
<vn-autocomplete
|
||||
label="Bank entity"
|
||||
ng-model="supplierAccount.bankEntityFk"
|
||||
url="BankEntities"
|
||||
fields="['name']"
|
||||
initial-data="supplierAccount.bankEntityFk"
|
||||
search-function="{or: [{bic: {like: $search +'%'}}, {name: {like: '%'+ $search +'%'}}]}"
|
||||
value-field="id"
|
||||
show-field="bic"
|
||||
rule>
|
||||
<tpl-item>{{bic}} {{name}}</tpl-item>
|
||||
<append>
|
||||
<vn-icon-button
|
||||
vn-auto
|
||||
icon="add_circle"
|
||||
vn-click-stop="bankEntity.show({index: $index})"
|
||||
vn-tooltip="New bank entity">
|
||||
</vn-icon-button>
|
||||
</append>
|
||||
</vn-autocomplete>
|
||||
<vn-textfield
|
||||
label="Beneficiary"
|
||||
ng-model="supplierAccount.beneficiary"
|
||||
info="Beneficiary information">
|
||||
</vn-textfield>
|
||||
<vn-none>
|
||||
<vn-icon-button
|
||||
vn-tooltip="Remove account"
|
||||
icon="delete"
|
||||
ng-click="model.remove($index)"
|
||||
tabindex="-1">
|
||||
</vn-icon-button>
|
||||
</vn-none>
|
||||
</vn-horizontal>
|
||||
<vn-one>
|
||||
<vn-icon-button
|
||||
vn-bind="+"
|
||||
vn-tooltip="Add account"
|
||||
icon="add_circle"
|
||||
ng-click="$ctrl.add()">
|
||||
</vn-icon-button>
|
||||
</vn-one>
|
||||
</vn-card>
|
||||
<vn-button-bar>
|
||||
<vn-submit
|
||||
disabled="!watcher.dataChanged()"
|
||||
label="Save">
|
||||
</vn-submit>
|
||||
</vn-button-bar>
|
||||
</form>
|
||||
|
||||
<!-- New bankentity dialog -->
|
||||
<vn-new-bank-entity
|
||||
vn-id="bankEntity"
|
||||
on-accept="$ctrl.onAccept($data)">
|
||||
</vn-new-bank-entity>
|
||||
|
||||
<vn-confirm
|
||||
class="edit"
|
||||
vn-id="payMethodToTransfer"
|
||||
on-accept="$ctrl.setWireTransfer()"
|
||||
message="Do you want to change the pay method to wire transfer?">
|
||||
</vn-confirm>
|
|
@ -1,66 +0,0 @@
|
|||
import ngModule from '../module';
|
||||
import Section from 'salix/components/section';
|
||||
|
||||
class Controller extends Section {
|
||||
constructor($element, $) {
|
||||
super($element, $);
|
||||
this.include = {
|
||||
relation: 'bankEntity',
|
||||
scope: {
|
||||
fields: ['countryFk', 'id', 'name', 'bic']
|
||||
}
|
||||
};
|
||||
const filter = {
|
||||
where: {code: 'wireTransfer'}
|
||||
};
|
||||
|
||||
this.$http.get(`payMethods/findOne`, {filter})
|
||||
.then(res => {
|
||||
this.wireTransferFk = res.data.id;
|
||||
});
|
||||
}
|
||||
|
||||
add() {
|
||||
this.$.model.insert({
|
||||
supplierFk: this.$params.id
|
||||
});
|
||||
}
|
||||
|
||||
onAccept(data) {
|
||||
const accounts = this.supplierAccounts;
|
||||
const targetAccount = accounts[data.index];
|
||||
targetAccount.bankEntityFk = data.id;
|
||||
}
|
||||
|
||||
onSubmit() {
|
||||
this.$.watcher.check();
|
||||
return this.$.model.save()
|
||||
.then(() => {
|
||||
this.$.watcher.notifySaved();
|
||||
this.$.watcher.updateOriginalData();
|
||||
return this.card.reload();
|
||||
})
|
||||
.then(() => {
|
||||
if (this.supplier.payMethodFk != this.wireTransferFk)
|
||||
this.$.payMethodToTransfer.show();
|
||||
});
|
||||
}
|
||||
|
||||
setWireTransfer() {
|
||||
const params = {
|
||||
id: this.$params.id,
|
||||
payMethodFk: this.wireTransferFk
|
||||
};
|
||||
const query = `Suppliers/${this.$params.id}`;
|
||||
return this.$http.patch(query, params)
|
||||
.then(() => this.$.watcher.notifySaved());
|
||||
}
|
||||
}
|
||||
|
||||
ngModule.vnComponent('vnSupplierAccount', {
|
||||
template: require('./index.html'),
|
||||
controller: Controller,
|
||||
require: {
|
||||
card: '^vnSupplierCard'
|
||||
}
|
||||
});
|
|
@ -1,98 +0,0 @@
|
|||
import './index.js';
|
||||
import watcher from 'core/mocks/watcher';
|
||||
import crudModel from 'core/mocks/crud-model';
|
||||
|
||||
describe('Supplier Component vnSupplierAccount', () => {
|
||||
let $scope;
|
||||
let controller;
|
||||
let $httpBackend;
|
||||
|
||||
beforeEach(ngModule('supplier'));
|
||||
|
||||
beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => {
|
||||
$httpBackend = _$httpBackend_;
|
||||
$scope = $rootScope.$new();
|
||||
$scope.model = crudModel;
|
||||
$scope.watcher = watcher;
|
||||
|
||||
$scope.bankEntity = {
|
||||
open: () => {}
|
||||
};
|
||||
|
||||
const $element = angular.element('<vn-supplier-account></vn-supplier-account>');
|
||||
controller = $componentController('vnSupplierAccount', {$element, $scope});
|
||||
controller.supplierAccount = {
|
||||
supplierFk: 442,
|
||||
name: 'Verdnatura'
|
||||
};
|
||||
}));
|
||||
|
||||
describe('onAccept()', () => {
|
||||
it('should set the created bank entity id into the target account', () => {
|
||||
controller.supplierAccounts = [{}, {}, {}];
|
||||
|
||||
const data = {
|
||||
id: 999,
|
||||
index: 1
|
||||
};
|
||||
|
||||
controller.onAccept(data);
|
||||
|
||||
const targetAccount = controller.supplierAccounts[data.index];
|
||||
|
||||
expect(targetAccount.bankEntityFk).toEqual(data.id);
|
||||
});
|
||||
});
|
||||
|
||||
describe('onSubmit()', () => {
|
||||
it(`should reload the card`, done => {
|
||||
controller.card = {reload: () => {}};
|
||||
controller.$.payMethodToTransfer = {show: () => {}};
|
||||
jest.spyOn(controller.$.payMethodToTransfer, 'show');
|
||||
jest.spyOn(controller.$.model, 'save').mockReturnValue(new Promise(resolve => {
|
||||
return resolve({
|
||||
id: 1234
|
||||
});
|
||||
}));
|
||||
jest.spyOn(controller.card, 'reload').mockReturnValue(new Promise(resolve => {
|
||||
return resolve({
|
||||
id: 1234
|
||||
});
|
||||
}));
|
||||
|
||||
controller.wireTransferFk = 'a';
|
||||
controller.supplier = {payMethodFk: 'b'};
|
||||
controller.onSubmit().then(() => {
|
||||
expect(controller.card.reload).toHaveBeenCalledWith();
|
||||
expect(controller.$.payMethodToTransfer.show).toHaveBeenCalled();
|
||||
done();
|
||||
}).catch(done.fail);
|
||||
});
|
||||
});
|
||||
|
||||
describe('setWireTransfer()', () => {
|
||||
it(`should make HTTP PATCH request to set wire transfer and call notifySaved`, () => {
|
||||
const supplierId = 1;
|
||||
const params = {
|
||||
id: supplierId,
|
||||
payMethodFk: 2
|
||||
};
|
||||
const response = {
|
||||
data: {id: 2}
|
||||
};
|
||||
const uri = 'payMethods/findOne?filter=%7B%22where%22:%7B%22code%22:%22wireTransfer%22%7D%7D';
|
||||
jest.spyOn($scope.watcher, 'notifySaved');
|
||||
|
||||
controller.$params.id = supplierId;
|
||||
controller.wireTransferFk = 2;
|
||||
controller.supplier = {payMethodFk: 1};
|
||||
$httpBackend.expectGET(uri).respond(response);
|
||||
$httpBackend.expectPATCH(`Suppliers/${supplierId}`, params).respond();
|
||||
controller.setWireTransfer();
|
||||
$httpBackend.flush();
|
||||
|
||||
expect($scope.watcher.notifySaved).toHaveBeenCalledWith();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -1 +0,0 @@
|
|||
Beneficiary information: Name of the bank account holder if different from the provider
|
|
@ -1,6 +0,0 @@
|
|||
Bank entity: Entidad bancaria
|
||||
swift: Swift BIC
|
||||
Add account: Añadir cuenta
|
||||
Beneficiary: Beneficiario
|
||||
Beneficiary information: Nombre del titular de la cuenta bancaria en caso de ser diferente del proveedor
|
||||
Do you want to change the pay method to wire transfer?: ¿Quieres modificar la forma de pago a transferencia?
|
|
@ -1,109 +0,0 @@
|
|||
<vn-watcher
|
||||
vn-id="watcher"
|
||||
url="SupplierAddresses"
|
||||
id-field="id"
|
||||
data="$ctrl.address"
|
||||
params="$ctrl.address"
|
||||
insert-mode="true"
|
||||
form="form">
|
||||
</vn-watcher>
|
||||
<vn-crud-model
|
||||
auto-load="true"
|
||||
url="Provinces/location"
|
||||
data="provincesLocation"
|
||||
order="id">
|
||||
</vn-crud-model>
|
||||
<form name="form" ng-submit="$ctrl.onSubmit()" class="vn-w-md">
|
||||
<vn-card class="vn-pa-lg">
|
||||
<vn-horizontal>
|
||||
<vn-textfield
|
||||
vn-one
|
||||
label="Name"
|
||||
ng-model="$ctrl.address.nickname"
|
||||
rule
|
||||
vn-focus>
|
||||
</vn-textfield>
|
||||
<vn-textfield
|
||||
vn-one
|
||||
label="Street address"
|
||||
ng-model="$ctrl.address.street"
|
||||
rule>
|
||||
</vn-textfield>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-datalist vn-one
|
||||
label="Postcode"
|
||||
ng-model="$ctrl.address.postalCode"
|
||||
selection="$ctrl.postcode"
|
||||
url="Postcodes/location"
|
||||
fields="['code','townFk']"
|
||||
order="code, townFk"
|
||||
value-field="code"
|
||||
show-field="code"
|
||||
rule>
|
||||
<tpl-item>
|
||||
{{code}} - {{town.name}} ({{town.province.name}},
|
||||
{{town.province.country.name}})
|
||||
</tpl-item>
|
||||
<append>
|
||||
<vn-icon-button
|
||||
icon="add_circle"
|
||||
vn-tooltip="New postcode"
|
||||
ng-click="postcode.open()"
|
||||
vn-acl="deliveryAssistant"
|
||||
vn-acl-action="remove">
|
||||
</vn-icon-button>
|
||||
</append>
|
||||
</vn-datalist>
|
||||
<vn-datalist vn-id="town" vn-one
|
||||
label="City"
|
||||
ng-model="$ctrl.address.city"
|
||||
selection="$ctrl.town"
|
||||
url="Towns/location"
|
||||
fields="['id', 'name', 'provinceFk']"
|
||||
show-field="name"
|
||||
value-field="name">
|
||||
<tpl-item>
|
||||
{{name}}, {{province.name}}
|
||||
({{province.country.name}})
|
||||
</tpl-item>
|
||||
</vn-datalist>
|
||||
<vn-autocomplete vn-id="province" vn-one
|
||||
label="Province"
|
||||
ng-model="$ctrl.address.provinceFk"
|
||||
data="provincesLocation"
|
||||
fields="['id', 'name', 'countryFk']"
|
||||
show-field="name"
|
||||
value-field="id"
|
||||
rule>
|
||||
<tpl-item>{{name}} ({{country.name}})</tpl-item>
|
||||
</vn-autocomplete>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-textfield
|
||||
vn-one
|
||||
label="Phone"
|
||||
ng-model="$ctrl.address.phone"
|
||||
rule>
|
||||
</vn-textfield>
|
||||
<vn-textfield
|
||||
vn-one
|
||||
label="Mobile"
|
||||
ng-model="$ctrl.address.mobile"
|
||||
rule>
|
||||
</vn-textfield>
|
||||
</vn-horizontal>
|
||||
</vn-card>
|
||||
<vn-button-bar>
|
||||
<vn-submit label="Save"></vn-submit>
|
||||
<vn-button
|
||||
label="Cancel"
|
||||
ui-sref="supplier.card.address.index">
|
||||
</vn-button>
|
||||
</vn-button-bar>
|
||||
</form>
|
||||
|
||||
<!-- New postcode dialog -->
|
||||
<vn-geo-postcode vn-id="postcode"
|
||||
on-response="$ctrl.onResponse($response)">
|
||||
</vn-geo-postcode>
|
|
@ -1,74 +0,0 @@
|
|||
import ngModule from '../../module';
|
||||
import Section from 'salix/components/section';
|
||||
|
||||
export default class Controller extends Section {
|
||||
constructor($element, $) {
|
||||
super($element, $);
|
||||
|
||||
this.address = {
|
||||
supplierFk: this.$params.id
|
||||
};
|
||||
}
|
||||
|
||||
onSubmit() {
|
||||
this.$.watcher.submit().then(res => {
|
||||
this.$state.go('supplier.card.address.index');
|
||||
});
|
||||
}
|
||||
|
||||
get town() {
|
||||
return this._town;
|
||||
}
|
||||
|
||||
// Town auto complete
|
||||
set town(selection) {
|
||||
this._town = selection;
|
||||
|
||||
if (!selection) return;
|
||||
|
||||
const province = selection.province;
|
||||
const postcodes = selection.postcodes;
|
||||
|
||||
if (!this.address.provinceFk)
|
||||
this.address.provinceFk = province.id;
|
||||
|
||||
if (postcodes.length === 1)
|
||||
this.address.postalCode = postcodes[0].code;
|
||||
}
|
||||
|
||||
get postcode() {
|
||||
return this._postcode;
|
||||
}
|
||||
|
||||
// Postcode auto complete
|
||||
set postcode(selection) {
|
||||
this._postcode = selection;
|
||||
|
||||
if (!selection) return;
|
||||
|
||||
const town = selection.town;
|
||||
const province = town.province;
|
||||
|
||||
if (!this.address.city)
|
||||
this.address.city = town.name;
|
||||
|
||||
if (!this.address.provinceFk)
|
||||
this.address.provinceFk = province.id;
|
||||
}
|
||||
|
||||
onResponse(response) {
|
||||
this.address.postalCode = response.code;
|
||||
this.address.city = response.city;
|
||||
this.address.provinceFk = response.provinceFk;
|
||||
}
|
||||
}
|
||||
|
||||
Controller.$inject = ['$element', '$scope'];
|
||||
|
||||
ngModule.vnComponent('vnSupplierAddressCreate', {
|
||||
template: require('./index.html'),
|
||||
controller: Controller,
|
||||
bindings: {
|
||||
supplier: '<'
|
||||
}
|
||||
});
|
|
@ -1,102 +0,0 @@
|
|||
import './index';
|
||||
import watcher from 'core/mocks/watcher';
|
||||
|
||||
describe('Supplier', () => {
|
||||
describe('Component vnSupplierAddressCreate', () => {
|
||||
let $scope;
|
||||
let controller;
|
||||
let $element;
|
||||
let $state;
|
||||
|
||||
beforeEach(ngModule('supplier'));
|
||||
|
||||
beforeEach(inject(($componentController, $rootScope, _$state_) => {
|
||||
$scope = $rootScope.$new();
|
||||
$state = _$state_;
|
||||
$state.params.id = '1234';
|
||||
$element = angular.element('<vn-supplier-address-create></vn-supplier-address-create>');
|
||||
controller = $componentController('vnSupplierAddressCreate', {$element, $scope});
|
||||
controller.$.watcher = watcher;
|
||||
controller.$.watcher.submit = () => {
|
||||
return {
|
||||
then: callback => {
|
||||
callback({data: {id: 124}});
|
||||
}
|
||||
};
|
||||
};
|
||||
controller.supplier = {id: 1};
|
||||
}));
|
||||
|
||||
describe('onSubmit()', () => {
|
||||
it('should perform a PATCH and then redirect to the main section', () => {
|
||||
jest.spyOn(controller.$state, 'go');
|
||||
controller.onSubmit();
|
||||
|
||||
expect(controller.$state.go).toHaveBeenCalledWith('supplier.card.address.index');
|
||||
});
|
||||
});
|
||||
|
||||
describe('town() setter', () => {
|
||||
it(`should set provinceFk property`, () => {
|
||||
controller.town = {
|
||||
provinceFk: 1,
|
||||
code: 46001,
|
||||
province: {
|
||||
id: 1,
|
||||
name: 'New york',
|
||||
country: {
|
||||
id: 2,
|
||||
name: 'USA'
|
||||
}
|
||||
},
|
||||
postcodes: []
|
||||
};
|
||||
|
||||
expect(controller.address.provinceFk).toEqual(1);
|
||||
});
|
||||
|
||||
it(`should set provinceFk property and fill the postalCode if there's just one`, () => {
|
||||
controller.town = {
|
||||
provinceFk: 1,
|
||||
code: 46001,
|
||||
province: {
|
||||
id: 1,
|
||||
name: 'New york',
|
||||
country: {
|
||||
id: 2,
|
||||
name: 'USA'
|
||||
}
|
||||
},
|
||||
postcodes: [{code: '46001'}]
|
||||
};
|
||||
|
||||
expect(controller.address.provinceFk).toEqual(1);
|
||||
expect(controller.address.postalCode).toEqual('46001');
|
||||
});
|
||||
});
|
||||
|
||||
describe('postcode() setter', () => {
|
||||
it(`should set the town and province properties`, () => {
|
||||
controller.postcode = {
|
||||
townFk: 1,
|
||||
code: 46001,
|
||||
town: {
|
||||
id: 1,
|
||||
name: 'New York',
|
||||
province: {
|
||||
id: 1,
|
||||
name: 'New york',
|
||||
country: {
|
||||
id: 2,
|
||||
name: 'USA'
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
expect(controller.address.city).toEqual('New York');
|
||||
expect(controller.address.provinceFk).toEqual(1);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
|
@ -1,104 +0,0 @@
|
|||
|
||||
<mg-ajax
|
||||
path="SupplierAddresses/{{edit.params.addressId}}"
|
||||
actions="$ctrl.address = edit.model"
|
||||
options="mgEdit">
|
||||
</mg-ajax>
|
||||
<vn-watcher
|
||||
vn-id="watcher"
|
||||
url="SupplierAddresses"
|
||||
id-field="id"
|
||||
data="$ctrl.address"
|
||||
form="form">
|
||||
</vn-watcher>
|
||||
<form name="form" ng-submit="$ctrl.onSubmit()" class="vn-w-md">
|
||||
<vn-card class="vn-pa-lg">
|
||||
<vn-horizontal>
|
||||
<vn-textfield
|
||||
vn-one
|
||||
label="Name"
|
||||
ng-model="$ctrl.address.nickname"
|
||||
rule
|
||||
vn-focus>
|
||||
</vn-textfield>
|
||||
<vn-textfield
|
||||
vn-one
|
||||
label="Street"
|
||||
ng-model="$ctrl.address.street"
|
||||
rule>
|
||||
</vn-textfield>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-datalist vn-one
|
||||
label="Postcode"
|
||||
ng-model="$ctrl.address.postalCode"
|
||||
selection="$ctrl.postcode"
|
||||
url="Postcodes/location"
|
||||
fields="['code','townFk']"
|
||||
order="code, townFk"
|
||||
value-field="code"
|
||||
show-field="code"
|
||||
rule>
|
||||
<tpl-item>
|
||||
{{code}} - {{town.name}} ({{town.province.name}},
|
||||
{{town.province.country.name}})
|
||||
</tpl-item>
|
||||
<append>
|
||||
<vn-icon-button
|
||||
icon="add_circle"
|
||||
vn-tooltip="New postcode"
|
||||
ng-click="postcode.open()"
|
||||
vn-acl="deliveryAssistant"
|
||||
vn-acl-action="remove">
|
||||
</vn-icon-button>
|
||||
</append>
|
||||
</vn-datalist>
|
||||
<vn-datalist vn-id="town" vn-one
|
||||
label="City"
|
||||
ng-model="$ctrl.address.city"
|
||||
selection="$ctrl.town"
|
||||
url="Towns/location"
|
||||
fields="['id', 'name', 'provinceFk']"
|
||||
show-field="name"
|
||||
value-field="name">
|
||||
<tpl-item>
|
||||
{{name}}, {{province.name}}
|
||||
({{province.country.name}})
|
||||
</tpl-item>
|
||||
</vn-datalist>
|
||||
<vn-autocomplete vn-id="province" vn-one
|
||||
label="Province"
|
||||
ng-model="$ctrl.address.provinceFk"
|
||||
url="Provinces/location"
|
||||
fields="['id', 'name', 'countryFk']"
|
||||
show-field="name"
|
||||
value-field="id"
|
||||
rule>
|
||||
<tpl-item>{{name}} ({{country.name}})</tpl-item>
|
||||
</vn-autocomplete>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-textfield
|
||||
vn-one
|
||||
label="Phone"
|
||||
ng-model="$ctrl.address.phone"
|
||||
rule>
|
||||
</vn-textfield>
|
||||
<vn-textfield
|
||||
vn-one
|
||||
label="Mobile"
|
||||
ng-model="$ctrl.address.mobile"
|
||||
rule>
|
||||
</vn-textfield>
|
||||
</vn-horizontal>
|
||||
</vn-card>
|
||||
<vn-button-bar>
|
||||
<vn-submit label="Save"></vn-submit>
|
||||
<vn-button label="Cancel" ui-sref="supplier.card.address.index"></vn-button>
|
||||
</vn-button-bar>
|
||||
</form>
|
||||
|
||||
<!-- New postcode dialog -->
|
||||
<vn-geo-postcode vn-id="postcode"
|
||||
on-response="$ctrl.onResponse($response)">
|
||||
</vn-geo-postcode>
|
|
@ -1,62 +0,0 @@
|
|||
import ngModule from '../../module';
|
||||
import Section from 'salix/components/section';
|
||||
|
||||
export default class Controller extends Section {
|
||||
onSubmit() {
|
||||
this.$.watcher.submit()
|
||||
.then(() => this.$state.go('supplier.card.address.index'));
|
||||
}
|
||||
|
||||
get town() {
|
||||
return this._town;
|
||||
}
|
||||
|
||||
// Town auto complete
|
||||
set town(selection) {
|
||||
const oldValue = this._town;
|
||||
this._town = selection;
|
||||
|
||||
if (!selection || !oldValue) return;
|
||||
|
||||
const province = selection.province;
|
||||
const postcodes = selection.postcodes;
|
||||
|
||||
if (!this.address.provinceFk)
|
||||
this.address.provinceFk = province.id;
|
||||
|
||||
if (!this.address.postalCode && postcodes.length === 1)
|
||||
this.address.postalCode = postcodes[0].code;
|
||||
}
|
||||
|
||||
get postcode() {
|
||||
return this._postcode;
|
||||
}
|
||||
|
||||
// Postcode auto complete
|
||||
set postcode(selection) {
|
||||
const oldValue = this._postcode;
|
||||
this._postcode = selection;
|
||||
|
||||
if (!selection || !oldValue) return;
|
||||
|
||||
const town = selection.town;
|
||||
const province = town.province;
|
||||
|
||||
if (!this.address.city)
|
||||
this.address.city = town.name;
|
||||
|
||||
if (!this.address.provinceFk)
|
||||
this.address.provinceFk = province.id;
|
||||
}
|
||||
|
||||
onResponse(response) {
|
||||
this.address.postalCode = response.code;
|
||||
this.address.city = response.city;
|
||||
this.address.provinceFk = response.provinceFk;
|
||||
}
|
||||
}
|
||||
|
||||
ngModule.vnComponent('vnSupplierAddressEdit', {
|
||||
template: require('./index.html'),
|
||||
controller: Controller
|
||||
});
|
|
@ -1,39 +0,0 @@
|
|||
import './index';
|
||||
import watcher from 'core/mocks/watcher';
|
||||
|
||||
describe('Supplier', () => {
|
||||
describe('Component vnSupplierAddressEdit', () => {
|
||||
let $scope;
|
||||
let controller;
|
||||
let $element;
|
||||
let $state;
|
||||
|
||||
beforeEach(ngModule('supplier'));
|
||||
|
||||
beforeEach(inject(($componentController, $rootScope, _$state_) => {
|
||||
$scope = $rootScope.$new();
|
||||
$state = _$state_;
|
||||
$state.params.addressId = '1';
|
||||
$element = angular.element('<vn-supplier-address-edit></vn-supplier-address-edit>');
|
||||
controller = $componentController('vnSupplierAddressEdit', {$element, $scope});
|
||||
controller.address = {id: 1};
|
||||
controller.$.watcher = watcher;
|
||||
controller.$.watcher.submit = () => {
|
||||
return {
|
||||
then: callback => {
|
||||
callback({data: {id: 124}});
|
||||
}
|
||||
};
|
||||
};
|
||||
}));
|
||||
|
||||
describe('onSubmit()', () => {
|
||||
it('should perform a PATCH and then redirect to the main section', () => {
|
||||
jest.spyOn(controller.$state, 'go');
|
||||
controller.onSubmit();
|
||||
|
||||
expect(controller.$state.go).toHaveBeenCalledWith('supplier.card.address.index');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
|
@ -1,64 +0,0 @@
|
|||
<vn-crud-model
|
||||
vn-id="model"
|
||||
url="Suppliers/{{$ctrl.$params.id}}/addresses"
|
||||
filter="$ctrl.filter"
|
||||
limit="10"
|
||||
data="$ctrl.addresses"
|
||||
auto-load="true">
|
||||
</vn-crud-model>
|
||||
<vn-portal slot="topbar">
|
||||
<vn-searchbar
|
||||
placeholder="Search by address"
|
||||
info="You can search by address id or name"
|
||||
model="model"
|
||||
expr-builder="$ctrl.exprBuilder(param, value)"
|
||||
auto-state="false">
|
||||
</vn-searchbar>
|
||||
</vn-portal>
|
||||
<vn-data-viewer
|
||||
model="model"
|
||||
class="vn-w-md">
|
||||
<vn-card class="vn-pa-md">
|
||||
<div
|
||||
ng-repeat="address in $ctrl.addresses"
|
||||
class="address">
|
||||
<a
|
||||
ui-sref="supplier.card.address.edit({addressId: {{::address.id}}})"
|
||||
class="vn-pa-sm border-solid border-radius"
|
||||
translate-attr="{title: 'Edit address'}">
|
||||
<vn-one
|
||||
style="overflow: hidden; min-width: 14em;">
|
||||
<div class="ellipsize"><b>{{::address.nickname}} - #{{::address.id}}</b></div>
|
||||
<div class="ellipsize" name="street">{{::address.street}}</div>
|
||||
<div class="ellipsize">
|
||||
<span ng-show="::address.postalCode">{{::address.postalCode}} -</span>
|
||||
<span ng-show="::address.city">{{::address.city}},</span>
|
||||
{{::address.province.name}}
|
||||
</div>
|
||||
<div class="ellipsize">
|
||||
{{::address.phone}}<span ng-if="::address.mobile">, </span>
|
||||
{{::address.mobile}}
|
||||
</div>
|
||||
</vn-one>
|
||||
<vn-vertical
|
||||
vn-one
|
||||
ng-if="address.observations.length"
|
||||
class="vn-hide-narrow vn-px-md border-solid-left"
|
||||
style="height: 6em; overflow: auto;">
|
||||
<vn-one ng-repeat="observation in address.observations track by $index" ng-class="{'vn-pt-sm': $index}">
|
||||
<b>{{::observation.observationType.description}}:</b>
|
||||
<span>{{::observation.description}}</span>
|
||||
</vn-one>
|
||||
</vn-vertical>
|
||||
</a>
|
||||
</div>
|
||||
</vn-card>
|
||||
</vn-data-viewer>
|
||||
<vn-float-button
|
||||
vn-bind="+"
|
||||
fixed-bottom-right
|
||||
vn-tooltip="New address"
|
||||
ui-sref="supplier.card.address.create"
|
||||
icon="add"
|
||||
label="Add">
|
||||
</vn-float-button>
|
|
@ -1,46 +0,0 @@
|
|||
import ngModule from '../../module';
|
||||
import Section from 'salix/components/section';
|
||||
import './style.scss';
|
||||
|
||||
class Controller extends Section {
|
||||
constructor($element, $) {
|
||||
super($element, $);
|
||||
this.filter = {
|
||||
fields: [
|
||||
'id',
|
||||
'nickname',
|
||||
'street',
|
||||
'city',
|
||||
'provinceFk',
|
||||
'phone',
|
||||
'mobile',
|
||||
'postalCode'
|
||||
],
|
||||
order: ['nickname ASC'],
|
||||
include: [{
|
||||
relation: 'province',
|
||||
scope: {
|
||||
fields: ['id', 'name']
|
||||
}
|
||||
}]
|
||||
};
|
||||
}
|
||||
|
||||
exprBuilder(param, value) {
|
||||
switch (param) {
|
||||
case 'search':
|
||||
return /^\d+$/.test(value)
|
||||
? {id: value}
|
||||
: {nickname: {like: `%${value}%`}};
|
||||
}
|
||||
}
|
||||
}
|
||||
Controller.$inject = ['$element', '$scope'];
|
||||
|
||||
ngModule.vnComponent('vnSupplierAddressIndex', {
|
||||
template: require('./index.html'),
|
||||
controller: Controller,
|
||||
bindings: {
|
||||
supplier: '<'
|
||||
}
|
||||
});
|
|
@ -1,34 +0,0 @@
|
|||
import './index';
|
||||
|
||||
describe('Supplier', () => {
|
||||
describe('Component vnSupplierAddressIndex', () => {
|
||||
let controller;
|
||||
let $scope;
|
||||
let $stateParams;
|
||||
|
||||
beforeEach(ngModule('supplier'));
|
||||
|
||||
beforeEach(inject(($componentController, $rootScope, _$stateParams_) => {
|
||||
$stateParams = _$stateParams_;
|
||||
$stateParams.id = 1;
|
||||
$scope = $rootScope.$new();
|
||||
const $element = angular.element('<vn-supplier-address-index></vn-supplier-address-index>');
|
||||
controller = $componentController('vnSupplierAddressIndex', {$element, $scope});
|
||||
controller.supplier = {id: 1};
|
||||
}));
|
||||
|
||||
describe('exprBuilder()', () => {
|
||||
it('should return a filter based on a search by id', () => {
|
||||
const filter = controller.exprBuilder('search', '123');
|
||||
|
||||
expect(filter).toEqual({id: '123'});
|
||||
});
|
||||
|
||||
it('should return a filter based on a search by name', () => {
|
||||
const filter = controller.exprBuilder('search', 'Arkham Chemicals');
|
||||
|
||||
expect(filter).toEqual({nickname: {like: '%Arkham Chemicals%'}});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
|
@ -1,21 +0,0 @@
|
|||
@import "variables";
|
||||
@import "./effects";
|
||||
|
||||
vn-supplier-address-index {
|
||||
.address {
|
||||
padding-bottom: $spacing-md;
|
||||
|
||||
&:last-child {
|
||||
padding-bottom: 0;
|
||||
}
|
||||
& > a {
|
||||
@extend %clickable;
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
color: inherit;
|
||||
overflow: hidden;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
# Index
|
||||
Search by address: Buscar por dirección
|
||||
You can search by address id or name: Puedes buscar por el id o nombre de la dirección
|
||||
|
||||
# Create
|
||||
Street address: Dirección postal
|
||||
Postcode: Código postal
|
||||
Town/City: Ciudad
|
||||
Province: Provincia
|
||||
Phone: Teléfono
|
||||
Mobile: Móvil
|
||||
|
||||
# Common
|
||||
Fiscal name: Nombre fiscal
|
||||
Street: Dirección fiscal
|
||||
Addresses: Direcciones
|
||||
New address: Nueva dirección
|
||||
Edit address: Editar dirección
|
|
@ -1,77 +0,0 @@
|
|||
<vn-watcher
|
||||
vn-id="watcher"
|
||||
url="SupplierAgencyTerms"
|
||||
primary-key="agencyFk"
|
||||
data="$ctrl.supplierAgencyTerm"
|
||||
insert-mode="true"
|
||||
form="form">
|
||||
</vn-watcher>
|
||||
<vn-crud-model
|
||||
auto-load="true"
|
||||
url="Suppliers/freeAgencies"
|
||||
data="$ctrl.agencies">
|
||||
</vn-crud-model>
|
||||
<form name="form" ng-submit="$ctrl.onSubmit()" class="vn-w-md">
|
||||
<vn-card class="vn-pa-lg">
|
||||
<vn-horizontal>
|
||||
<vn-autocomplete vn-one
|
||||
label="Agency"
|
||||
ng-model="$ctrl.supplierAgencyTerm.agencyFk"
|
||||
data="$ctrl.agencies"
|
||||
show-field="name"
|
||||
value-field="id"
|
||||
rule>
|
||||
</vn-autocomplete>
|
||||
<vn-input-number
|
||||
type="number"
|
||||
label="Minimum M3"
|
||||
ng-model="$ctrl.supplierAgencyTerm.minimumM3"
|
||||
step="0.01"
|
||||
rule>
|
||||
</vn-input-number>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-input-number
|
||||
type="number"
|
||||
label="Package Price"
|
||||
ng-model="$ctrl.supplierAgencyTerm.packagePrice"
|
||||
rule>
|
||||
</vn-input-number>
|
||||
<vn-input-number
|
||||
type="number"
|
||||
label="Km Price"
|
||||
ng-model="$ctrl.supplierAgencyTerm.kmPrice"
|
||||
step="0.01"
|
||||
rule>
|
||||
</vn-input-number>
|
||||
<vn-input-number
|
||||
type="number"
|
||||
label="M3 Price"
|
||||
ng-model="$ctrl.supplierAgencyTerm.m3Price"
|
||||
step="0.01"
|
||||
rule>
|
||||
</vn-input-number>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-input-number
|
||||
type="number"
|
||||
label="Route Price"
|
||||
ng-model="$ctrl.supplierAgencyTerm.routePrice"
|
||||
rule>
|
||||
</vn-input-number>
|
||||
<vn-input-number
|
||||
type="number"
|
||||
label="Minimum Km"
|
||||
ng-model="$ctrl.supplierAgencyTerm.minimumKm"
|
||||
rule>
|
||||
</vn-input-number>
|
||||
</vn-horizontal>
|
||||
</vn-card>
|
||||
<vn-button-bar>
|
||||
<vn-submit label="Save"></vn-submit>
|
||||
<vn-button
|
||||
label="Cancel"
|
||||
ui-sref="supplier.card.agencyTerm.index">
|
||||
</vn-button>
|
||||
</vn-button-bar>
|
||||
</form>
|
|
@ -1,26 +0,0 @@
|
|||
import ngModule from '../../module';
|
||||
import Section from 'salix/components/section';
|
||||
|
||||
export default class Controller extends Section {
|
||||
constructor($element, $) {
|
||||
super($element, $);
|
||||
|
||||
this.supplierAgencyTerm = {
|
||||
supplierFk: this.$params.id
|
||||
};
|
||||
}
|
||||
|
||||
onSubmit() {
|
||||
this.$.watcher.submit().then(res => {
|
||||
this.$state.go('supplier.card.agencyTerm.index');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
ngModule.vnComponent('vnSupplierAgencyTermCreate', {
|
||||
template: require('./index.html'),
|
||||
controller: Controller,
|
||||
bindings: {
|
||||
supplier: '<'
|
||||
}
|
||||
});
|
|
@ -1,28 +0,0 @@
|
|||
import './index';
|
||||
import watcher from 'core/mocks/watcher';
|
||||
|
||||
describe('Supplier', () => {
|
||||
describe('Component vnSupplierAddressCreate', () => {
|
||||
let $scope;
|
||||
let controller;
|
||||
let $element;
|
||||
|
||||
beforeEach(ngModule('supplier'));
|
||||
|
||||
beforeEach(inject(($componentController, $rootScope, _$state_) => {
|
||||
$scope = $rootScope.$new();
|
||||
$scope.watcher = watcher;
|
||||
$element = angular.element('<vn-supplier-agency-term-create></vn-supplier-agency-term-create>');
|
||||
controller = $componentController('vnSupplierAgencyTermCreate', {$element, $scope});
|
||||
}));
|
||||
|
||||
describe('onSubmit()', () => {
|
||||
it(`should redirect to 'supplier.card.agencyTerm.index' state`, () => {
|
||||
jest.spyOn(controller.$state, 'go');
|
||||
controller.onSubmit();
|
||||
|
||||
expect(controller.$state.go).toHaveBeenCalledWith('supplier.card.agencyTerm.index');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
|
@ -1,91 +0,0 @@
|
|||
<vn-crud-model
|
||||
vn-id="model"
|
||||
url="SupplierAgencyTerms"
|
||||
link="{supplierFk: $ctrl.$params.id}"
|
||||
primary-key="agencyFk"
|
||||
filter="$ctrl.filter"
|
||||
data="$ctrl.supplierAgencyTerms"
|
||||
auto-load="true">
|
||||
</vn-crud-model>
|
||||
<vn-watcher
|
||||
vn-id="watcher"
|
||||
data="$ctrl.supplierAgencyTerms"
|
||||
form="form">
|
||||
</vn-watcher>
|
||||
<form name="form" ng-submit="$ctrl.onSubmit()" class="vn-w-lg">
|
||||
<vn-card class="vn-pa-lg">
|
||||
<vn-horizontal ng-repeat="supplierAgencyTerm in $ctrl.supplierAgencyTerms">
|
||||
<vn-textfield
|
||||
disabled="true"
|
||||
vn-id="agency"
|
||||
label="Agency"
|
||||
ng-model="supplierAgencyTerm.agency.name"
|
||||
rule>
|
||||
</vn-textfield>
|
||||
<vn-input-number
|
||||
type="number"
|
||||
step="0.01"
|
||||
label="Minimum M3"
|
||||
ng-model="supplierAgencyTerm.minimumM3"
|
||||
rule>
|
||||
</vn-input-number>
|
||||
<vn-input-number
|
||||
type="number"
|
||||
step="0.01"
|
||||
label="Package Price"
|
||||
ng-model="supplierAgencyTerm.packagePrice"
|
||||
rule>
|
||||
</vn-input-number>
|
||||
<vn-input-number
|
||||
type="number"
|
||||
step="0.01"
|
||||
label="Km Price"
|
||||
ng-model="supplierAgencyTerm.kmPrice"
|
||||
rule>
|
||||
</vn-input-number>
|
||||
<vn-input-number
|
||||
type="number"
|
||||
step="0.01"
|
||||
label="M3 Price"
|
||||
ng-model="supplierAgencyTerm.m3Price"
|
||||
rule>
|
||||
</vn-input-number>
|
||||
<vn-input-number
|
||||
type="number"
|
||||
step="0.01"
|
||||
label="Route Price"
|
||||
ng-model="supplierAgencyTerm.routePrice"
|
||||
rule>
|
||||
</vn-input-number>
|
||||
<vn-input-number
|
||||
type="number"
|
||||
step="0.01"
|
||||
label="Minimum Km"
|
||||
ng-model="supplierAgencyTerm.minimumKm"
|
||||
rule>
|
||||
</vn-input-number>
|
||||
<vn-none>
|
||||
<vn-icon-button
|
||||
vn-tooltip="Remove row"
|
||||
icon="delete"
|
||||
ng-click="model.remove($index)"
|
||||
tabindex="-1">
|
||||
</vn-icon-button>
|
||||
</vn-none>
|
||||
</vn-horizontal>
|
||||
</vn-card>
|
||||
<vn-button-bar>
|
||||
<vn-submit
|
||||
disabled="!watcher.dataChanged()"
|
||||
label="Save">
|
||||
</vn-submit>
|
||||
</vn-button-bar>
|
||||
</form>
|
||||
<vn-float-button
|
||||
vn-bind="+"
|
||||
fixed-bottom-right
|
||||
vn-tooltip="Add row"
|
||||
ui-sref="supplier.card.agencyTerm.create"
|
||||
icon="add"
|
||||
label="Add">
|
||||
</vn-float-button>
|
|
@ -1,36 +0,0 @@
|
|||
import ngModule from '../../module';
|
||||
import Section from 'salix/components/section';
|
||||
|
||||
class Controller extends Section {
|
||||
constructor($element, $) {
|
||||
super($element, $);
|
||||
this.filter = {
|
||||
include:
|
||||
{relation: 'agency',
|
||||
scope: {
|
||||
fields: ['id', 'name']
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
add() {
|
||||
this.$.model.insert({});
|
||||
}
|
||||
|
||||
onSubmit() {
|
||||
this.$.watcher.check();
|
||||
this.$.model.save().then(() => {
|
||||
this.$.watcher.notifySaved();
|
||||
this.$.watcher.updateOriginalData();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
ngModule.vnComponent('vnSupplierAgencyTermIndex', {
|
||||
template: require('./index.html'),
|
||||
controller: Controller,
|
||||
bindings: {
|
||||
supplier: '<'
|
||||
}
|
||||
});
|
|
@ -1,37 +0,0 @@
|
|||
import './index';
|
||||
import watcher from 'core/mocks/watcher';
|
||||
import crudModel from 'core/mocks/crud-model';
|
||||
|
||||
describe('Supplier', () => {
|
||||
describe('Component vnSupplierAddressCreate', () => {
|
||||
let $scope;
|
||||
let controller;
|
||||
let $element;
|
||||
|
||||
beforeEach(ngModule('supplier'));
|
||||
|
||||
beforeEach(inject(($componentController, $rootScope, _$state_) => {
|
||||
$scope = $rootScope.$new();
|
||||
$scope.model = crudModel;
|
||||
$scope.watcher = watcher;
|
||||
$element = angular.element('<vn-supplier-agency-term-index></vn-supplier-agency-term-index>');
|
||||
controller = $componentController('vnSupplierAgencyTermIndex', {$element, $scope});
|
||||
}));
|
||||
|
||||
describe('onSubmit()', () => {
|
||||
it('should make HTTP POST request to save values', () => {
|
||||
jest.spyOn($scope.watcher, 'check');
|
||||
jest.spyOn($scope.watcher, 'notifySaved');
|
||||
jest.spyOn($scope.watcher, 'updateOriginalData');
|
||||
jest.spyOn($scope.model, 'save');
|
||||
|
||||
controller.onSubmit();
|
||||
|
||||
expect($scope.model.save).toHaveBeenCalledWith();
|
||||
expect($scope.watcher.updateOriginalData).toHaveBeenCalledWith();
|
||||
expect($scope.watcher.check).toHaveBeenCalledWith();
|
||||
expect($scope.watcher.notifySaved).toHaveBeenCalledWith();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
|
@ -1,9 +0,0 @@
|
|||
Minimum M3: M3 minimos
|
||||
Package Price: Precio bulto
|
||||
Km Price: Precio Km
|
||||
M3 Price: Precio M3
|
||||
Route Price: Precio ruta
|
||||
Minimum Km: Km minimos
|
||||
Remove row: Eliminar fila
|
||||
Add row: Añadir fila
|
||||
New autonomous: Nuevo autónomo
|
|
@ -1,62 +0,0 @@
|
|||
<mg-ajax path="Suppliers/{{patch.params.id}}" options="vnPatch"></mg-ajax>
|
||||
<vn-watcher
|
||||
vn-id="watcher"
|
||||
data="$ctrl.supplier"
|
||||
form="form"
|
||||
save="patch">
|
||||
</vn-watcher>
|
||||
<form name="form" ng-submit="watcher.submit()" class="vn-w-md">
|
||||
<vn-card class="vn-pa-lg">
|
||||
<vn-horizontal>
|
||||
<vn-textfield
|
||||
vn-one
|
||||
label="Alias"
|
||||
ng-model="$ctrl.supplier.nickname"
|
||||
rule
|
||||
vn-focus>
|
||||
</vn-textfield>
|
||||
<vn-worker-autocomplete
|
||||
vn-one
|
||||
ng-model="$ctrl.supplier.workerFk"
|
||||
show-field="nickname"
|
||||
label="Responsible"
|
||||
info="Responsible for approving invoices">
|
||||
</vn-worker-autocomplete>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-check
|
||||
label="Verified"
|
||||
ng-model="$ctrl.supplier.isReal">
|
||||
</vn-check>
|
||||
<vn-check
|
||||
label="Active"
|
||||
ng-model="$ctrl.supplier.isActive">
|
||||
</vn-check>
|
||||
<vn-check
|
||||
label="PayMethodChecked"
|
||||
ng-model="$ctrl.supplier.isPayMethodChecked"
|
||||
vn-acl="financial">
|
||||
</vn-check>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-textarea
|
||||
vn-one
|
||||
label="Notes"
|
||||
ng-model="$ctrl.supplier.note"
|
||||
rule>
|
||||
</vn-textarea>
|
||||
</vn-horizontal>
|
||||
</vn-card>
|
||||
<vn-button-bar>
|
||||
<vn-submit
|
||||
disabled="!watcher.dataChanged()"
|
||||
label="Save">
|
||||
</vn-submit>
|
||||
<vn-button
|
||||
class="cancel"
|
||||
label="Undo changes"
|
||||
disabled="!watcher.dataChanged()"
|
||||
ng-click="watcher.loadOriginalData()">
|
||||
</vn-button>
|
||||
</vn-button-bar>
|
||||
</form>
|
|
@ -1,10 +0,0 @@
|
|||
import ngModule from '../module';
|
||||
import Section from 'salix/components/section';
|
||||
|
||||
ngModule.vnComponent('vnSupplierBasicData', {
|
||||
template: require('./index.html'),
|
||||
controller: Section,
|
||||
bindings: {
|
||||
supplier: '<'
|
||||
}
|
||||
});
|
|
@ -1,5 +0,0 @@
|
|||
Notes: Notas
|
||||
Active: Activo
|
||||
Verified: Verificado
|
||||
PayMethodChecked: Método de pago validado
|
||||
Responsible for approving invoices: Responsable de aprobar las facturas
|
|
@ -1,66 +0,0 @@
|
|||
<mg-ajax path="Suppliers/{{patch.params.id}}" options="vnPatch"></mg-ajax>
|
||||
<vn-watcher
|
||||
vn-id="watcher"
|
||||
data="$ctrl.supplier"
|
||||
form="form"
|
||||
save="patch">
|
||||
</vn-watcher>
|
||||
<vn-crud-model
|
||||
auto-load="true"
|
||||
url="PayMethods"
|
||||
data="paymethods">
|
||||
</vn-crud-model>
|
||||
<vn-crud-model
|
||||
auto-load="true"
|
||||
url="PayDems"
|
||||
data="paydems">
|
||||
</vn-crud-model>
|
||||
<form name="form" ng-submit="$ctrl.onSubmit()" class="vn-w-md">
|
||||
<vn-card class="vn-pa-lg">
|
||||
<vn-horizontal>
|
||||
<vn-autocomplete
|
||||
vn-one
|
||||
label="Billing data"
|
||||
vn-acl="salesAssistant"
|
||||
ng-model="$ctrl.supplier.payMethodFk"
|
||||
data="paymethods"
|
||||
fields="['isIbanRequiredForSuppliers']"
|
||||
initial-data="$ctrl.supplier.payMethod">
|
||||
</vn-autocomplete>
|
||||
<vn-autocomplete
|
||||
vn-one
|
||||
label="Payment deadline"
|
||||
vn-acl="salesAssistant"
|
||||
ng-model="$ctrl.supplier.payDemFk"
|
||||
data="paydems"
|
||||
fields="['id', 'payDem']"
|
||||
show-field="payDem"
|
||||
initial-data="$ctrl.supplier.payDem">
|
||||
</vn-autocomplete>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-input-number
|
||||
vn-one
|
||||
min="0"
|
||||
step="1"
|
||||
label="Pay day"
|
||||
ng-model="$ctrl.supplier.payDay"
|
||||
vn-focus
|
||||
rule>
|
||||
</vn-input-number>
|
||||
</vn-horizontal>
|
||||
</vn-card>
|
||||
<vn-button-bar>
|
||||
<vn-submit
|
||||
label="Save"
|
||||
disabled="!watcher.dataChanged()"
|
||||
vn-acl="salesAssistant">
|
||||
</vn-submit>
|
||||
<vn-button
|
||||
class="cancel"
|
||||
label="Undo changes"
|
||||
disabled="!watcher.dataChanged()"
|
||||
ng-click="watcher.loadOriginalData()">
|
||||
</vn-button>
|
||||
</vn-button-bar>
|
||||
</form>
|
|
@ -1,28 +0,0 @@
|
|||
import ngModule from '../module';
|
||||
import Section from 'salix/components/section';
|
||||
|
||||
export default class Controller extends Section {
|
||||
get supplier() {
|
||||
return this._supplier;
|
||||
}
|
||||
|
||||
set supplier(value) {
|
||||
this._supplier = value;
|
||||
}
|
||||
|
||||
onSubmit() {
|
||||
this.$.watcher.submit()
|
||||
.then(() => this.card.reload());
|
||||
}
|
||||
}
|
||||
|
||||
ngModule.vnComponent('vnSupplierBillingData', {
|
||||
template: require('./index.html'),
|
||||
controller: Controller,
|
||||
bindings: {
|
||||
supplier: '<'
|
||||
},
|
||||
require: {
|
||||
card: '^vnSupplierCard'
|
||||
}
|
||||
});
|
|
@ -1 +0,0 @@
|
|||
Pay day: Dia de pago
|
|
@ -1,5 +0,0 @@
|
|||
<vn-portal slot="menu">
|
||||
<vn-supplier-descriptor supplier="$ctrl.supplier"></vn-supplier-descriptor>
|
||||
<vn-left-menu source="card"></vn-left-menu>
|
||||
</vn-portal>
|
||||
<ui-view></ui-view>
|
|
@ -1,48 +0,0 @@
|
|||
import ngModule from '../module';
|
||||
import ModuleCard from 'salix/components/module-card';
|
||||
|
||||
class Controller extends ModuleCard {
|
||||
reload() {
|
||||
let filter = {
|
||||
include: [
|
||||
{
|
||||
relation: 'province',
|
||||
scope: {
|
||||
fields: ['id', 'name']
|
||||
}
|
||||
},
|
||||
{
|
||||
relation: 'country',
|
||||
scope: {
|
||||
fields: ['id', 'name', 'code']
|
||||
}
|
||||
},
|
||||
{
|
||||
relation: 'payMethod',
|
||||
scope: {
|
||||
fields: ['id', 'name']
|
||||
}
|
||||
},
|
||||
{
|
||||
relation: 'payDem',
|
||||
scope: {
|
||||
fields: ['id', 'payDem']
|
||||
}
|
||||
},
|
||||
{
|
||||
relation: 'client',
|
||||
scope: {
|
||||
fields: ['id', 'fi']
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
return this.$http.get(`Suppliers/${this.$params.id}`, {filter})
|
||||
.then(response => this.supplier = response.data);
|
||||
}
|
||||
}
|
||||
|
||||
ngModule.vnComponent('vnSupplierCard', {
|
||||
template: require('./index.html'),
|
||||
controller: Controller
|
||||
});
|
|
@ -1,67 +0,0 @@
|
|||
<div class="search-panel">
|
||||
<form class="vn-pa-lg" ng-submit="$ctrl.onSearch()">
|
||||
<vn-horizontal>
|
||||
<vn-textfield vn-focus
|
||||
vn-one
|
||||
label="General search"
|
||||
ng-model="filter.search"
|
||||
vn-focus>
|
||||
</vn-textfield>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-textfield
|
||||
vn-one
|
||||
label="Item id"
|
||||
ng-model="filter.itemId">
|
||||
</vn-textfield>
|
||||
<vn-autocomplete
|
||||
vn-one
|
||||
ng-model="filter.buyerId"
|
||||
url="TicketRequests/getItemTypeWorker"
|
||||
search-function="{firstName: $search}"
|
||||
show-field="nickname"
|
||||
value-field="id"
|
||||
label="Buyer">
|
||||
</vn-autocomplete>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-autocomplete vn-one
|
||||
ng-model="filter.typeId"
|
||||
url="ItemTypes"
|
||||
show-field="name"
|
||||
value-field="id"
|
||||
label="Type"
|
||||
fields="['categoryFk']"
|
||||
include="'category'">
|
||||
<tpl-item>
|
||||
<div>{{name}}</div>
|
||||
<div class="text-caption text-secondary">
|
||||
{{category.name}}
|
||||
</div>
|
||||
</tpl-item>
|
||||
</vn-autocomplete>
|
||||
<vn-autocomplete vn-one
|
||||
url="ItemCategories"
|
||||
label="Category"
|
||||
show-field="name"
|
||||
value-field="id"
|
||||
ng-model="filter.categoryId">
|
||||
</vn-autocomplete>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-date-picker
|
||||
vn-one
|
||||
label="From"
|
||||
ng-model="filter.from">
|
||||
</vn-date-picker>
|
||||
<vn-date-picker
|
||||
vn-one
|
||||
label="To"
|
||||
ng-model="filter.to">
|
||||
</vn-date-picker>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal class="vn-mt-lg">
|
||||
<vn-submit label="Search"></vn-submit>
|
||||
</vn-horizontal>
|
||||
</form>
|
||||
</div>
|
|
@ -1,7 +0,0 @@
|
|||
import ngModule from '../module';
|
||||
import SearchPanel from 'core/components/searchbar/search-panel';
|
||||
|
||||
ngModule.vnComponent('vnSupplierConsumptionSearchPanel', {
|
||||
template: require('./index.html'),
|
||||
controller: SearchPanel
|
||||
});
|
|
@ -1,7 +0,0 @@
|
|||
Item id: Id artículo
|
||||
From: Desde
|
||||
To: Hasta
|
||||
Campaign: Campaña
|
||||
allSaints: Día de todos los Santos
|
||||
valentinesDay: Día de San Valentín
|
||||
mothersDay: Día de la madre
|
|
@ -1,97 +0,0 @@
|
|||
<vn-crud-model vn-id="model"
|
||||
url="Suppliers/consumption"
|
||||
link="{supplierFk: $ctrl.$params.id}"
|
||||
limit="20"
|
||||
user-params="::$ctrl.filterParams"
|
||||
data="entries"
|
||||
order="itemTypeFk, itemName, itemSize">
|
||||
</vn-crud-model>
|
||||
<vn-portal slot="topbar">
|
||||
<vn-searchbar
|
||||
panel="vn-supplier-consumption-search-panel"
|
||||
suggested-filter="$ctrl.filterParams"
|
||||
info="Search by item id or name"
|
||||
model="model"
|
||||
auto-state="false">
|
||||
</vn-searchbar>
|
||||
</vn-portal>
|
||||
<vn-data-viewer model="model">
|
||||
<vn-card class="vn-pa-lg vn-w-lg">
|
||||
<section class="header">
|
||||
<vn-tool-bar class="vn-mb-md">
|
||||
<vn-button disabled="!model.userParams.from || !model.userParams.to"
|
||||
icon="picture_as_pdf"
|
||||
ng-click="$ctrl.showReport()"
|
||||
vn-tooltip="Open as PDF">
|
||||
</vn-button>
|
||||
<vn-button disabled="!model.userParams.from || !model.userParams.to"
|
||||
icon="email"
|
||||
ng-click="confirm.show()"
|
||||
vn-tooltip="Send to email">
|
||||
</vn-button>
|
||||
</vn-tool-bar>
|
||||
</section>
|
||||
<vn-table model="model"
|
||||
ng-repeat="entry in entries"
|
||||
ng-if="entry.buys">
|
||||
<vn-thead>
|
||||
<vn-tr>
|
||||
<vn-th field="entryFk" expand>Entry </vn-th>
|
||||
<vn-td>{{::entry.id}}</vn-td>
|
||||
<vn-th field="data">Date</vn-th>
|
||||
<vn-td>{{::entry.shipped | date: 'dd/MM/yyyy'}}</vn-td>
|
||||
<vn-th field="invoiceNumber">Reference</vn-th>
|
||||
<vn-td vn-tooltip="{{::entry.invoiceNumber}}">{{::entry.invoiceNumber}}</vn-td>
|
||||
</vn-tr>
|
||||
</vn-thead>
|
||||
<vn-tbody>
|
||||
<vn-tr ng-repeat="buy in entry.buys">
|
||||
<vn-td expand>
|
||||
<span
|
||||
vn-click-stop="itemDescriptor.show($event, buy.id)"
|
||||
class="link">
|
||||
{{::buy.itemName}}
|
||||
</span>
|
||||
</vn-td>
|
||||
<vn-td vn-fetched-tags>
|
||||
<div>
|
||||
<vn-one></vn-one>
|
||||
<vn-one ng-if="::buy.subName">
|
||||
<h3 title="{{::buy.subName}}">{{::buy.subName}}</h3>
|
||||
</vn-one>
|
||||
</div>
|
||||
<vn-fetched-tags
|
||||
max-length="6"
|
||||
item="::buy"
|
||||
tabindex="-1">
|
||||
</vn-fetched-tags>
|
||||
</vn-td>
|
||||
<vn-td number>{{::buy.quantity | dashIfEmpty}}</vn-td>
|
||||
<vn-td number>{{::buy.price | dashIfEmpty}}</vn-td>
|
||||
<vn-td number>{{::buy.total | dashIfEmpty}}</vn-td>
|
||||
<vn-td></vn-td>
|
||||
</vn-tr>
|
||||
</vn-tbody>
|
||||
<vn-tfoot>
|
||||
<vn-tr>
|
||||
<vn-td>
|
||||
<vn-label-value
|
||||
label="Total entry"
|
||||
value="{{$ctrl.getTotal(entry)}}">
|
||||
</vn-label-value>
|
||||
</vn-td>
|
||||
</vn-tr>
|
||||
</vn-tfoot>
|
||||
</vn-table>
|
||||
</vn-card>
|
||||
</vn-data-viewer>
|
||||
<vn-confirm
|
||||
vn-id="confirm"
|
||||
question="Please, confirm"
|
||||
message="The consumption report will be sent"
|
||||
on-accept="$ctrl.sendEmail()">
|
||||
</vn-confirm>
|
||||
<vn-item-descriptor-popover
|
||||
vn-id="item-descriptor"
|
||||
warehouse-fk="$ctrl.vnConfig.warehouseFk">
|
||||
</vn-item-descriptor-popover>
|
|
@ -1,88 +0,0 @@
|
|||
import ngModule from '../module';
|
||||
import Section from 'salix/components/section';
|
||||
|
||||
class Controller extends Section {
|
||||
constructor($element, $, vnReport, vnEmail) {
|
||||
super($element, $);
|
||||
this.vnReport = vnReport;
|
||||
this.vnEmail = vnEmail;
|
||||
|
||||
this.setDefaultFilter();
|
||||
}
|
||||
|
||||
setDefaultFilter() {
|
||||
const minDate = Date.vnNew();
|
||||
minDate.setHours(0, 0, 0, 0);
|
||||
minDate.setMonth(minDate.getMonth() - 2);
|
||||
|
||||
const maxDate = Date.vnNew();
|
||||
maxDate.setHours(23, 59, 59, 59);
|
||||
|
||||
this.filterParams = {
|
||||
from: minDate,
|
||||
to: maxDate
|
||||
};
|
||||
}
|
||||
|
||||
get reportParams() {
|
||||
const userParams = this.$.model.userParams;
|
||||
return Object.assign({
|
||||
authorization: this.vnToken.token,
|
||||
recipientId: this.supplier.id
|
||||
}, userParams);
|
||||
}
|
||||
|
||||
showReport() {
|
||||
const path = `Suppliers/${this.supplier.id}/campaign-metrics-pdf`;
|
||||
this.vnReport.show(path, this.reportParams);
|
||||
}
|
||||
|
||||
sendEmail() {
|
||||
const params = {
|
||||
filter: {
|
||||
where: {
|
||||
supplierFk: this.$params.id,
|
||||
email: {neq: null}
|
||||
},
|
||||
limit: 1
|
||||
}
|
||||
};
|
||||
this.$http.get('SupplierContacts', params).then(({data}) => {
|
||||
if (data.length) {
|
||||
const contact = data[0];
|
||||
const params = Object.assign({
|
||||
recipient: contact.email
|
||||
}, this.reportParams);
|
||||
|
||||
const path = `Suppliers/${this.supplier.id}/campaign-metrics-email`;
|
||||
this.vnEmail.send(path, params);
|
||||
} else {
|
||||
const message = this.$t(`This supplier doesn't have a contact with an email address`);
|
||||
this.vnApp.showError(message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
getTotal(entry) {
|
||||
if (entry.buys) {
|
||||
let total = 0;
|
||||
for (let buy of entry.buys)
|
||||
total += buy.total;
|
||||
|
||||
return total;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Controller.$inject = ['$element', '$scope', 'vnReport', 'vnEmail'];
|
||||
|
||||
ngModule.vnComponent('vnSupplierConsumption', {
|
||||
template: require('./index.html'),
|
||||
controller: Controller,
|
||||
bindings: {
|
||||
supplier: '<'
|
||||
},
|
||||
require: {
|
||||
card: '^vnSupplierCard'
|
||||
}
|
||||
});
|
|
@ -1,110 +0,0 @@
|
|||
import './index.js';
|
||||
import crudModel from 'core/mocks/crud-model';
|
||||
|
||||
describe('Supplier', () => {
|
||||
describe('Component vnSupplierConsumption', () => {
|
||||
let $scope;
|
||||
let controller;
|
||||
let $httpParamSerializer;
|
||||
let $httpBackend;
|
||||
const supplierId = 2;
|
||||
|
||||
beforeEach(ngModule('supplier'));
|
||||
|
||||
beforeEach(inject(($componentController, $rootScope, _$httpParamSerializer_, _$httpBackend_) => {
|
||||
$scope = $rootScope.$new();
|
||||
$httpParamSerializer = _$httpParamSerializer_;
|
||||
$httpBackend = _$httpBackend_;
|
||||
const $element = angular.element('<vn-supplier-consumption></vn-supplier-consumption');
|
||||
controller = $componentController('vnSupplierConsumption', {$element, $scope});
|
||||
controller.$.model = crudModel;
|
||||
controller.$params = {id: supplierId};
|
||||
controller.supplier = {
|
||||
id: supplierId
|
||||
};
|
||||
}));
|
||||
|
||||
describe('showReport()', () => {
|
||||
it('should call the window.open function', () => {
|
||||
jest.spyOn(window, 'open').mockReturnThis();
|
||||
|
||||
const now = Date.vnNew();
|
||||
controller.$.model.userParams = {
|
||||
from: now,
|
||||
to: now
|
||||
};
|
||||
|
||||
controller.showReport();
|
||||
|
||||
const expectedParams = {
|
||||
recipientId: 2,
|
||||
from: now,
|
||||
to: now
|
||||
};
|
||||
const serializedParams = $httpParamSerializer(expectedParams);
|
||||
const path = `api/Suppliers/${supplierId}/campaign-metrics-pdf?${serializedParams}`;
|
||||
|
||||
expect(window.open).toHaveBeenCalledWith(path);
|
||||
});
|
||||
});
|
||||
|
||||
describe('sendEmail()', () => {
|
||||
it('should throw an error', () => {
|
||||
jest.spyOn(controller.vnApp, 'showError');
|
||||
|
||||
const expectedParams = {
|
||||
filter: {
|
||||
where: {
|
||||
supplierFk: supplierId,
|
||||
email: {neq: null}
|
||||
},
|
||||
limit: 1
|
||||
}
|
||||
};
|
||||
const serializedParams = $httpParamSerializer(expectedParams);
|
||||
$httpBackend.expectGET(`SupplierContacts?${serializedParams}`).respond({});
|
||||
controller.sendEmail();
|
||||
$httpBackend.flush();
|
||||
|
||||
expect(controller.vnApp.showError)
|
||||
.toHaveBeenCalledWith(`This supplier doesn't have a contact with an email address`);
|
||||
});
|
||||
|
||||
it('should make a GET query sending the report', () => {
|
||||
let serializedParams;
|
||||
const params = {
|
||||
filter: {
|
||||
where: {
|
||||
supplierFk: supplierId,
|
||||
email: {neq: null}
|
||||
},
|
||||
limit: 1
|
||||
}
|
||||
};
|
||||
serializedParams = $httpParamSerializer(params);
|
||||
$httpBackend.whenGET(`SupplierContacts?${serializedParams}`).respond([
|
||||
{id: 1, email: 'batman@gothamcity.com'}
|
||||
]);
|
||||
|
||||
const now = Date.vnNew();
|
||||
controller.$.model.userParams = {
|
||||
from: now,
|
||||
to: now
|
||||
};
|
||||
const expectedParams = {
|
||||
recipient: 'batman@gothamcity.com',
|
||||
from: now,
|
||||
to: now
|
||||
};
|
||||
|
||||
serializedParams = $httpParamSerializer(expectedParams);
|
||||
const path = `Suppliers/${supplierId}/campaign-metrics-email`;
|
||||
|
||||
$httpBackend.expect('POST', path).respond({});
|
||||
controller.sendEmail();
|
||||
$httpBackend.flush();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
Total entry: Total entrada
|
||||
This supplier doesn't have a contact with an email address: Este proveedor no tiene ningún contacto con una dirección de email
|
|
@ -1,84 +0,0 @@
|
|||
<vn-crud-model
|
||||
vn-id="model"
|
||||
url="SupplierContacts"
|
||||
link="{supplierFk: $ctrl.$params.id}"
|
||||
data="contacts"
|
||||
auto-load="true">
|
||||
</vn-crud-model>
|
||||
<vn-watcher
|
||||
vn-id="watcher"
|
||||
data="contacts"
|
||||
form="form">
|
||||
</vn-watcher>
|
||||
<form name="form" ng-submit="$ctrl.onSubmit()" class="vn-w-lg">
|
||||
<vn-card class="vn-pa-lg">
|
||||
<div ng-repeat="contact in contacts" class="contact">
|
||||
<vn-vertical>
|
||||
<vn-horizontal>
|
||||
<vn-textfield
|
||||
vn-one
|
||||
label="Name"
|
||||
ng-model="contact.name"
|
||||
rule="SupplierContact">
|
||||
</vn-textfield>
|
||||
<vn-textfield
|
||||
vn-one
|
||||
label="Phone"
|
||||
ng-model="contact.phone"
|
||||
rule="SupplierContact">
|
||||
</vn-textfield>
|
||||
<vn-textfield
|
||||
vn-one
|
||||
label="Mobile"
|
||||
ng-model="contact.mobile"
|
||||
rule="SupplierContact">
|
||||
</vn-textfield>
|
||||
<vn-textfield
|
||||
vn-two
|
||||
label="Email"
|
||||
ng-model="contact.email"
|
||||
rule="SupplierContact">
|
||||
</vn-textfield>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-textfield
|
||||
vn-one
|
||||
label="Notes"
|
||||
ng-model="contact.observation"
|
||||
rule="SupplierContact"
|
||||
title="{{contact.observation}}">
|
||||
</vn-textfield>
|
||||
<vn-none>
|
||||
<vn-icon-button
|
||||
vn-tooltip="Remove contact"
|
||||
icon="delete"
|
||||
tabindex="-1"
|
||||
ng-click="model.remove($index)">
|
||||
</vn-icon-button>
|
||||
</vn-none>
|
||||
</vn-horizontal>
|
||||
</vn-vertical>
|
||||
</div>
|
||||
<vn-one>
|
||||
<vn-icon-button
|
||||
vn-bind="+"
|
||||
vn-tooltip="Add contact"
|
||||
icon="add_circle"
|
||||
ng-click="$ctrl.add()">
|
||||
</vn-icon-button>
|
||||
</vn-one>
|
||||
</vn-card>
|
||||
<vn-button-bar>
|
||||
<vn-submit
|
||||
disabled="!watcher.dataChanged()"
|
||||
label="Save">
|
||||
</vn-submit>
|
||||
<!-- # #2680 Undo changes button bugs -->
|
||||
<!-- <vn-button
|
||||
class="cancel"
|
||||
label="Undo changes"
|
||||
disabled="!watcher.dataChanged()"
|
||||
ng-click="watcher.loadOriginalData()">
|
||||
</vn-button> -->
|
||||
</vn-button-bar>
|
||||
</form>
|
|
@ -1,27 +0,0 @@
|
|||
import ngModule from '../module';
|
||||
import './style.scss';
|
||||
import Section from 'salix/components/section';
|
||||
|
||||
class Controller extends Section {
|
||||
add() {
|
||||
this.$.model.insert({
|
||||
supplierFk: this.supplier.id
|
||||
});
|
||||
}
|
||||
|
||||
onSubmit() {
|
||||
this.$.watcher.check();
|
||||
this.$.model.save().then(() => {
|
||||
this.$.watcher.notifySaved();
|
||||
this.$.watcher.updateOriginalData();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
ngModule.vnComponent('vnSupplierContact', {
|
||||
template: require('./index.html'),
|
||||
controller: Controller,
|
||||
bindings: {
|
||||
supplier: '<'
|
||||
}
|
||||
});
|
|
@ -1,10 +0,0 @@
|
|||
@import "variables";
|
||||
|
||||
|
||||
.contact {
|
||||
max-width: $width-lg;
|
||||
margin-bottom: 10px;
|
||||
padding-right: 10px;
|
||||
padding-left: 10px;
|
||||
border: 1px solid $color-spacer;
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
<vn-watcher
|
||||
vn-id="watcher"
|
||||
url="Suppliers/newSupplier"
|
||||
data="$ctrl.supplier"
|
||||
params="$ctrl.supplier"
|
||||
insert-mode="true"
|
||||
form="form">
|
||||
</vn-watcher>
|
||||
<form name="form" ng-submit="$ctrl.onSubmit()" class="vn-w-md">
|
||||
<vn-card class="vn-pa-lg">
|
||||
<vn-horizontal>
|
||||
<vn-textfield
|
||||
label="Supplier name"
|
||||
ng-model="$ctrl.supplier.name"
|
||||
vn-focus
|
||||
ng-keyup="$ctrl.supplier.name = $ctrl.supplier.name.toUpperCase()">
|
||||
</vn-textfield>
|
||||
</vn-horizontal>
|
||||
</vn-card>
|
||||
<vn-button-bar>
|
||||
<vn-submit
|
||||
label="Create">
|
||||
</vn-submit>
|
||||
<vn-button
|
||||
class="cancel"
|
||||
label="Cancel"
|
||||
ui-sref="supplier.index">
|
||||
</vn-button>
|
||||
</vn-button-bar>
|
||||
</form>
|
|
@ -1,23 +0,0 @@
|
|||
import ngModule from '../module';
|
||||
import Section from 'salix/components/section';
|
||||
|
||||
class Controller extends Section {
|
||||
constructor($element, $) {
|
||||
super($element, $);
|
||||
}
|
||||
|
||||
onSubmit() {
|
||||
this.$.watcher.submit().then(
|
||||
json => {
|
||||
this.$state.go(`supplier.card.fiscalData`, {id: json.data.id});
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Controller.$inject = ['$element', '$scope'];
|
||||
|
||||
ngModule.vnComponent('vnSupplierCreate', {
|
||||
template: require('./index.html'),
|
||||
controller: Controller
|
||||
});
|
|
@ -1,3 +0,0 @@
|
|||
<slot-descriptor>
|
||||
<vn-supplier-descriptor></vn-supplier-descriptor>
|
||||
</slot-descriptor>
|
|
@ -1,9 +0,0 @@
|
|||
import ngModule from '../module';
|
||||
import DescriptorPopover from 'salix/components/descriptor-popover';
|
||||
|
||||
class Controller extends DescriptorPopover {}
|
||||
|
||||
ngModule.vnComponent('vnSupplierDescriptorPopover', {
|
||||
slotTemplate: require('./index.html'),
|
||||
controller: Controller
|
||||
});
|
|
@ -1,66 +0,0 @@
|
|||
<vn-descriptor-content
|
||||
module="supplier"
|
||||
description="$ctrl.supplier.name"
|
||||
summary="$ctrl.$.summary">
|
||||
<slot-body>
|
||||
<div class="attributes">
|
||||
<vn-label-value label="Tax number"
|
||||
value="{{$ctrl.supplier.nif}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value label="Alias"
|
||||
value="{{$ctrl.supplier.nickname}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value label="Pay method"
|
||||
value="{{$ctrl.supplier.payMethod.name}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value label="Payment deadline"
|
||||
value="{{$ctrl.supplier.payDem.payDem}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value label="Pay day"
|
||||
value="{{$ctrl.supplier.payDay}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value label="Account"
|
||||
value="{{$ctrl.supplier.account}}">
|
||||
</vn-label-value>
|
||||
</div>
|
||||
<div class="icons">
|
||||
<vn-icon
|
||||
vn-tooltip="Inactive supplier"
|
||||
icon="icon-disabled"
|
||||
ng-if="$ctrl.supplier.isActive == false">
|
||||
</vn-icon>
|
||||
<vn-icon
|
||||
vn-tooltip="Unverified supplier"
|
||||
icon="icon-supplierfalse"
|
||||
ng-if="$ctrl.supplier.isReal == false">
|
||||
</vn-icon>
|
||||
</div>
|
||||
<div class="quicklinks">
|
||||
<div ng-transclude="btnOne">
|
||||
<vn-quick-link
|
||||
tooltip="All entries with current supplier"
|
||||
state="['entry.index', {q: $ctrl.entryFilter}]"
|
||||
icon="icon-entry">
|
||||
</vn-quick-link>
|
||||
</div>
|
||||
<div ng-transclude="btnTwo">
|
||||
<vn-quick-link
|
||||
ng-if="$ctrl.supplier.client.fi"
|
||||
tooltip="Go to client"
|
||||
state="['client.card.summary', {id: $ctrl.supplier.client.id}]"
|
||||
icon="person">
|
||||
</vn-quick-link>
|
||||
</div>
|
||||
<div ng-transclude="btnThree">
|
||||
<vn-quick-link
|
||||
tooltip="Create invoiceIn"
|
||||
state="['invoiceIn.create', {supplierFk: $ctrl.id}]"
|
||||
icon="icon-invoice-in-create">
|
||||
</vn-quick-link>
|
||||
</div>
|
||||
</div>
|
||||
</slot-body>
|
||||
</vn-descriptor-content>
|
||||
<vn-popup vn-id="summary">
|
||||
<vn-supplier-summary supplier="$ctrl.supplier"></vn-supplier-summary>
|
||||
</vn-popup>
|
|
@ -1,80 +0,0 @@
|
|||
import ngModule from '../module';
|
||||
import Descriptor from 'salix/components/descriptor';
|
||||
|
||||
class Controller extends Descriptor {
|
||||
get supplier() {
|
||||
return this.entity;
|
||||
}
|
||||
|
||||
set supplier(value) {
|
||||
this.entity = value;
|
||||
}
|
||||
|
||||
get entryFilter() {
|
||||
if (!this.supplier) return null;
|
||||
|
||||
const date = Date.vnNew();
|
||||
date.setHours(0, 0, 0, 0);
|
||||
|
||||
const from = new Date(date.getTime());
|
||||
from.setDate(from.getDate() - 10);
|
||||
|
||||
const to = new Date(date.getTime());
|
||||
to.setDate(to.getDate() + 10);
|
||||
|
||||
return JSON.stringify({
|
||||
supplierFk: this.id,
|
||||
from,
|
||||
to
|
||||
});
|
||||
}
|
||||
|
||||
loadData() {
|
||||
const filter = {
|
||||
fields: [
|
||||
'id',
|
||||
'name',
|
||||
'nickname',
|
||||
'nif',
|
||||
'payMethodFk',
|
||||
'payDemFk',
|
||||
'payDay',
|
||||
'isActive',
|
||||
'isReal',
|
||||
'isTrucker',
|
||||
'account'
|
||||
],
|
||||
include: [
|
||||
{
|
||||
relation: 'payMethod',
|
||||
scope: {
|
||||
fields: ['id', 'name']
|
||||
}
|
||||
},
|
||||
{
|
||||
relation: 'payDem',
|
||||
scope: {
|
||||
fields: ['id', 'payDem']
|
||||
}
|
||||
},
|
||||
{
|
||||
relation: 'client',
|
||||
scope: {
|
||||
fields: ['id', 'fi']
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
return this.getData(`Suppliers/${this.id}`, {filter})
|
||||
.then(res => this.supplier = res.data);
|
||||
}
|
||||
}
|
||||
|
||||
ngModule.vnComponent('vnSupplierDescriptor', {
|
||||
template: require('./index.html'),
|
||||
controller: Controller,
|
||||
bindings: {
|
||||
supplier: '<'
|
||||
}
|
||||
});
|
|
@ -1,65 +0,0 @@
|
|||
import './index.js';
|
||||
|
||||
describe('Supplier Component vnSupplierDescriptor', () => {
|
||||
let $httpBackend;
|
||||
let controller;
|
||||
let $httpParamSerializer;
|
||||
const supplier = {id: 1};
|
||||
|
||||
beforeEach(ngModule('supplier'));
|
||||
|
||||
beforeEach(inject(($componentController, _$httpBackend_, _$httpParamSerializer_) => {
|
||||
$httpBackend = _$httpBackend_;
|
||||
$httpParamSerializer = _$httpParamSerializer_;
|
||||
controller = $componentController('vnSupplierDescriptor', {$element: null}, {supplier});
|
||||
}));
|
||||
|
||||
describe('loadData()', () => {
|
||||
it('should perform ask for the supplier', () => {
|
||||
const filter = {
|
||||
fields: [
|
||||
'id',
|
||||
'name',
|
||||
'nickname',
|
||||
'nif',
|
||||
'payMethodFk',
|
||||
'payDemFk',
|
||||
'payDay',
|
||||
'isActive',
|
||||
'isReal',
|
||||
'isTrucker',
|
||||
'account'
|
||||
],
|
||||
include: [
|
||||
{
|
||||
relation: 'payMethod',
|
||||
scope: {
|
||||
fields: ['id', 'name']
|
||||
}
|
||||
},
|
||||
{
|
||||
relation: 'payDem',
|
||||
scope: {
|
||||
fields: ['id', 'payDem']
|
||||
}
|
||||
},
|
||||
{
|
||||
relation: 'client',
|
||||
scope: {
|
||||
fields: ['id', 'fi']
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
const serializedParams = $httpParamSerializer({filter});
|
||||
let query = `Suppliers/${controller.supplier.id}?${serializedParams}`;
|
||||
jest.spyOn(controller, 'getData');
|
||||
|
||||
$httpBackend.expect('GET', query).respond({id: 1});
|
||||
controller.loadData();
|
||||
$httpBackend.flush();
|
||||
|
||||
expect(controller.getData).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
});
|
|
@ -1,8 +0,0 @@
|
|||
Tax number: NIF / CIF
|
||||
All entries with current supplier: Todas las entradas con el proveedor actual
|
||||
Go to client: Ir al cliente
|
||||
Verified supplier: Proveedor verificado
|
||||
Unverified supplier: Proveedor no verificado
|
||||
Inactive supplier: Proveedor inactivo
|
||||
Create invoiceIn: Crear factura recibida
|
||||
Supplier name: Razón social
|
|
@ -1,237 +0,0 @@
|
|||
<mg-ajax path="Suppliers/{{patch.params.id}}/updateFiscalData" options="vnPatch"></mg-ajax>
|
||||
<vn-watcher
|
||||
vn-id="watcher"
|
||||
data="$ctrl.supplier"
|
||||
id-field="id"
|
||||
form="form"
|
||||
save="patch">
|
||||
</vn-watcher>
|
||||
<vn-crud-model
|
||||
auto-load="true"
|
||||
url="Provinces/location"
|
||||
data="provincesLocation"
|
||||
order="name">
|
||||
</vn-crud-model>
|
||||
<vn-crud-model
|
||||
auto-load="true"
|
||||
url="Countries"
|
||||
data="countries"
|
||||
order="name">
|
||||
</vn-crud-model>
|
||||
<vn-crud-model
|
||||
auto-load="true"
|
||||
url="SageTaxTypes"
|
||||
data="sageTaxTypes"
|
||||
order="vat">
|
||||
</vn-crud-model>
|
||||
<vn-crud-model
|
||||
auto-load="true"
|
||||
url="SageWithholdings"
|
||||
data="sageWithholdings"
|
||||
order="withholding">
|
||||
</vn-crud-model>
|
||||
<vn-crud-model
|
||||
auto-load="true"
|
||||
url="SupplierActivities"
|
||||
data="supplierActivities">
|
||||
</vn-crud-model>
|
||||
<form name="form" vn-http-submit="watcher.submit()" class="vn-w-md">
|
||||
<vn-card class="vn-pa-lg">
|
||||
<vn-horizontal>
|
||||
<vn-textfield
|
||||
vn-two
|
||||
vn-focus
|
||||
label="Social name"
|
||||
vn-name="socialName"
|
||||
ng-model="$ctrl.supplier.name"
|
||||
info="Only letters, numbers and spaces can be used"
|
||||
required="true"
|
||||
rule>
|
||||
</vn-textfield>
|
||||
<vn-textfield
|
||||
vn-one
|
||||
label="Tax number"
|
||||
vn-name="taxNumber"
|
||||
ng-model="$ctrl.supplier.nif"
|
||||
required="true"
|
||||
rule>
|
||||
</vn-textfield>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-textfield
|
||||
vn-one
|
||||
label="Account"
|
||||
vn-name="account"
|
||||
ng-model="$ctrl.supplier.account"
|
||||
insertable="true"
|
||||
max-length="10"
|
||||
rule>
|
||||
</vn-textfield>
|
||||
<vn-autocomplete
|
||||
vn-one
|
||||
label="Sage tax type"
|
||||
vn-name="sageTaxType"
|
||||
ng-model="$ctrl.supplier.sageTaxTypeFk"
|
||||
data="sageTaxTypes"
|
||||
show-field="vat"
|
||||
value-field="id"
|
||||
rule>
|
||||
</vn-autocomplete>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-autocomplete
|
||||
vn-one
|
||||
label="Sage withholding"
|
||||
vn-name="sageWithholding"
|
||||
ng-model="$ctrl.supplier.sageWithholdingFk"
|
||||
data="sageWithholdings"
|
||||
show-field="withholding"
|
||||
value-field="id"
|
||||
rule>
|
||||
</vn-autocomplete>
|
||||
<vn-autocomplete
|
||||
vn-one
|
||||
label="Sage transaction type"
|
||||
vn-name="sageTransactionType"
|
||||
ng-model="$ctrl.supplier.sageTransactionTypeFk"
|
||||
url="SageTransactionTypes"
|
||||
show-field="transaction"
|
||||
value-field="id"
|
||||
search-function="{or: [{id: $search}, {transaction: {like: '%'+ $search +'%'}}]}"
|
||||
order="transaction"
|
||||
rule>
|
||||
<tpl-item>{{id}}: {{transaction}}</tpl-item>
|
||||
</vn-autocomplete>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-autocomplete
|
||||
vn-one
|
||||
label="Supplier activity"
|
||||
vn-name="supplierActivity"
|
||||
ng-model="$ctrl.supplier.supplierActivityFk"
|
||||
data="supplierActivities"
|
||||
show-field="name"
|
||||
value-field="code"
|
||||
rule>
|
||||
</vn-autocomplete>
|
||||
<vn-textfield
|
||||
vn-one
|
||||
label="Healt register"
|
||||
ng-model="$ctrl.supplier.healthRegister"
|
||||
rule>
|
||||
</vn-textfield>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-textfield
|
||||
vn-one
|
||||
label="Street"
|
||||
ng-model="$ctrl.supplier.street"
|
||||
rule
|
||||
vn-focus>
|
||||
</vn-textfield>
|
||||
<vn-datalist
|
||||
vn-one
|
||||
label="Postcode"
|
||||
vn-name="postcode"
|
||||
ng-model="$ctrl.supplier.postCode"
|
||||
selection="$ctrl.postcode"
|
||||
url="Postcodes/location"
|
||||
fields="['code','townFk']"
|
||||
order="code, townFk"
|
||||
value-field="code"
|
||||
show-field="code"
|
||||
rule>
|
||||
<tpl-item>
|
||||
{{code}} - {{town.name}} ({{town.province.name}},
|
||||
{{town.province.country.name}})
|
||||
</tpl-item>
|
||||
<append>
|
||||
<vn-icon-button
|
||||
icon="add_circle"
|
||||
vn-tooltip="New postcode"
|
||||
ng-click="postcode.open()"
|
||||
vn-acl="deliveryAssistant"
|
||||
vn-acl-action="remove">
|
||||
</vn-icon-button>
|
||||
</append>
|
||||
</vn-datalist>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-datalist
|
||||
vn-one
|
||||
vn-id="town"
|
||||
label="City"
|
||||
vn-name="city"
|
||||
ng-model="$ctrl.supplier.city"
|
||||
selection="$ctrl.town"
|
||||
url="Towns/location"
|
||||
fields="['id', 'name', 'provinceFk']"
|
||||
show-field="name"
|
||||
value-field="name"
|
||||
required="true"
|
||||
rule>
|
||||
<tpl-item>
|
||||
{{name}}, {{province.name}}
|
||||
({{province.country.name}})
|
||||
</tpl-item>
|
||||
</vn-datalist>
|
||||
<vn-autocomplete
|
||||
vn-one
|
||||
vn-id="province"
|
||||
label="Province"
|
||||
vn-name="province"
|
||||
ng-model="$ctrl.supplier.provinceFk"
|
||||
selection="$ctrl.province"
|
||||
data="provincesLocation"
|
||||
fields="['id', 'name', 'countryFk']"
|
||||
show-field="name"
|
||||
value-field="id"
|
||||
rule>
|
||||
<tpl-item>{{name}} ({{country.name}})</tpl-item>
|
||||
</vn-autocomplete>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-autocomplete
|
||||
vn-two
|
||||
vn-id="country"
|
||||
label="Country"
|
||||
vn-name="country"
|
||||
ng-model="$ctrl.supplier.countryFk"
|
||||
data="countries"
|
||||
show-field="name"
|
||||
value-field="id"
|
||||
rule>
|
||||
</vn-autocomplete>
|
||||
<vn-two class="vn-pl-xs">
|
||||
<vn-check
|
||||
label="Trucker"
|
||||
ng-model="$ctrl.supplier.isTrucker">
|
||||
</vn-check>
|
||||
<vn-check
|
||||
class="vn-ml-lg"
|
||||
label="Vies"
|
||||
info="When activating it, do not enter the country code in the ID field."
|
||||
ng-model="$ctrl.supplier.isVies"
|
||||
>
|
||||
</vn-check>
|
||||
</vn-two>
|
||||
</vn-horizontal>
|
||||
</vn-card>
|
||||
<vn-button-bar>
|
||||
<vn-submit
|
||||
disabled="!watcher.dataChanged()"
|
||||
label="Save">
|
||||
</vn-submit>
|
||||
<vn-button
|
||||
class="cancel"
|
||||
label="Undo changes"
|
||||
disabled="!watcher.dataChanged()"
|
||||
ng-click="watcher.loadOriginalData()">
|
||||
</vn-button>
|
||||
</vn-button-bar>
|
||||
</form>
|
||||
<!-- New postcode dialog -->
|
||||
<vn-geo-postcode
|
||||
vn-id="postcode"
|
||||
on-response="$ctrl.onResponse($response)">
|
||||
</vn-geo-postcode>
|
|
@ -1,86 +0,0 @@
|
|||
import ngModule from '../module';
|
||||
import Section from 'salix/components/section';
|
||||
|
||||
export default class Controller extends Section {
|
||||
get province() {
|
||||
return this._province;
|
||||
}
|
||||
|
||||
// Province auto complete
|
||||
set province(selection) {
|
||||
const oldValue = this._province;
|
||||
this._province = selection;
|
||||
|
||||
if (!selection || !oldValue) return;
|
||||
|
||||
const country = selection.country;
|
||||
|
||||
if (!this.supplier.countryFk)
|
||||
this.supplier.countryFk = country.id;
|
||||
}
|
||||
|
||||
get town() {
|
||||
return this._town;
|
||||
}
|
||||
|
||||
// Town auto complete
|
||||
set town(selection) {
|
||||
const oldValue = this._town;
|
||||
this._town = selection;
|
||||
|
||||
if (!selection || !oldValue) return;
|
||||
|
||||
const province = selection.province;
|
||||
const country = province.country;
|
||||
const postcodes = selection.postcodes;
|
||||
|
||||
if (!this.supplier.provinceFk)
|
||||
this.supplier.provinceFk = province.id;
|
||||
|
||||
if (!this.supplier.countryFk)
|
||||
this.supplier.countryFk = country.id;
|
||||
|
||||
if (!this.supplier.postCode && postcodes.length === 1)
|
||||
this.supplier.postCode = postcodes[0].code;
|
||||
}
|
||||
|
||||
get postcode() {
|
||||
return this._postcode;
|
||||
}
|
||||
|
||||
// Postcode auto complete
|
||||
set postcode(selection) {
|
||||
const oldValue = this._postcode;
|
||||
this._postcode = selection;
|
||||
|
||||
if (!selection || !oldValue) return;
|
||||
|
||||
const town = selection.town;
|
||||
const province = town.province;
|
||||
const country = province.country;
|
||||
|
||||
if (!this.supplier.city)
|
||||
this.supplier.city = town.name;
|
||||
|
||||
if (!this.supplier.provinceFk)
|
||||
this.supplier.provinceFk = province.id;
|
||||
|
||||
if (!this.supplier.countryFk)
|
||||
this.supplier.countryFk = country.id;
|
||||
}
|
||||
|
||||
onResponse(response) {
|
||||
this.supplier.postCode = response.code;
|
||||
this.supplier.city = response.city;
|
||||
this.supplier.provinceFk = response.provinceFk;
|
||||
this.supplier.countryFk = response.countryFk;
|
||||
}
|
||||
}
|
||||
|
||||
ngModule.vnComponent('vnSupplierFiscalData', {
|
||||
template: require('./index.html'),
|
||||
controller: Controller,
|
||||
bindings: {
|
||||
supplier: '<'
|
||||
}
|
||||
});
|
|
@ -1,109 +0,0 @@
|
|||
import './index';
|
||||
import watcher from 'core/mocks/watcher';
|
||||
|
||||
describe('Supplier', () => {
|
||||
describe('Component vnSupplierFiscalData', () => {
|
||||
let $scope;
|
||||
let $element;
|
||||
let controller;
|
||||
|
||||
beforeEach(ngModule('supplier'));
|
||||
|
||||
beforeEach(inject(($componentController, $rootScope) => {
|
||||
$scope = $rootScope.$new();
|
||||
$scope.watcher = watcher;
|
||||
$scope.watcher.orgData = {id: 1};
|
||||
$element = angular.element('<vn-supplier-fiscal-data></supplier-fiscal-data>');
|
||||
controller = $componentController('vnSupplierFiscalData', {$element, $scope});
|
||||
controller.card = {reload: () => {}};
|
||||
controller.supplier = {
|
||||
id: 1,
|
||||
name: 'Batman'
|
||||
};
|
||||
|
||||
controller._province = {};
|
||||
controller._town = {};
|
||||
controller._postcode = {};
|
||||
}));
|
||||
|
||||
describe('province() setter', () => {
|
||||
it(`should set countryFk property`, () => {
|
||||
controller.supplier.countryFk = null;
|
||||
controller.province = {
|
||||
id: 1,
|
||||
name: 'New york',
|
||||
country: {
|
||||
id: 2,
|
||||
name: 'USA'
|
||||
}
|
||||
};
|
||||
|
||||
expect(controller.supplier.countryFk).toEqual(2);
|
||||
});
|
||||
});
|
||||
|
||||
describe('town() setter', () => {
|
||||
it(`should set provinceFk property`, () => {
|
||||
controller.town = {
|
||||
provinceFk: 1,
|
||||
code: 46001,
|
||||
province: {
|
||||
id: 1,
|
||||
name: 'New york',
|
||||
country: {
|
||||
id: 2,
|
||||
name: 'USA'
|
||||
}
|
||||
},
|
||||
postcodes: []
|
||||
};
|
||||
|
||||
expect(controller.supplier.provinceFk).toEqual(1);
|
||||
});
|
||||
|
||||
it(`should set provinceFk property and fill the postalCode if there's just one`, () => {
|
||||
controller.town = {
|
||||
provinceFk: 1,
|
||||
code: 46001,
|
||||
province: {
|
||||
id: 1,
|
||||
name: 'New york',
|
||||
country: {
|
||||
id: 2,
|
||||
name: 'USA'
|
||||
}
|
||||
},
|
||||
postcodes: [{code: '46001'}]
|
||||
};
|
||||
|
||||
expect(controller.supplier.provinceFk).toEqual(1);
|
||||
expect(controller.supplier.postCode).toEqual('46001');
|
||||
});
|
||||
});
|
||||
|
||||
describe('postcode() setter', () => {
|
||||
it(`should set the town, provinceFk and contryFk properties`, () => {
|
||||
controller.postcode = {
|
||||
townFk: 1,
|
||||
code: 46001,
|
||||
town: {
|
||||
id: 1,
|
||||
name: 'New York',
|
||||
province: {
|
||||
id: 1,
|
||||
name: 'New york',
|
||||
country: {
|
||||
id: 2,
|
||||
name: 'USA'
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
expect(controller.supplier.city).toEqual('New York');
|
||||
expect(controller.supplier.provinceFk).toEqual(1);
|
||||
expect(controller.supplier.countryFk).toEqual(2);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
|
@ -1,8 +0,0 @@
|
|||
Sage tax type: Tipo de impuesto Sage
|
||||
Sage transaction type: Tipo de transacción Sage
|
||||
Sage withholding: Retención Sage
|
||||
Supplier activity: Actividad proveedor
|
||||
Healt register: Pasaporte sanitario
|
||||
Trucker: Transportista
|
||||
When activating it, do not enter the country code in the ID field.: Al activarlo, no informar el código del país en el campo nif
|
||||
The first two values are letters.: Los dos primeros valores son letras
|
|
@ -1,23 +1,3 @@
|
|||
export * from './module';
|
||||
|
||||
import './main';
|
||||
import './card';
|
||||
import './descriptor';
|
||||
import './descriptor-popover';
|
||||
import './index/';
|
||||
import './search-panel';
|
||||
import './summary';
|
||||
import './basic-data';
|
||||
import './fiscal-data';
|
||||
import './account';
|
||||
import './contact';
|
||||
import './log';
|
||||
import './consumption';
|
||||
import './consumption-search-panel';
|
||||
import './billing-data';
|
||||
import './address/index';
|
||||
import './address/create';
|
||||
import './address/edit';
|
||||
import './agency-term/index';
|
||||
import './agency-term/create';
|
||||
import './create/index';
|
||||
|
|
|
@ -1,64 +0,0 @@
|
|||
|
||||
<vn-auto-search
|
||||
model="model">
|
||||
</vn-auto-search>
|
||||
<vn-data-viewer
|
||||
model="model"
|
||||
class="vn-w-sm">
|
||||
<vn-card>
|
||||
<div class="vn-list separated">
|
||||
<a
|
||||
ng-repeat="supplier in model.data track by supplier.id"
|
||||
ui-sref="supplier.card.summary(::{id: supplier.id})"
|
||||
translate-attr="{title: 'View supplier'}"
|
||||
class="vn-item search-result">
|
||||
<vn-item-section>
|
||||
<h6>{{::supplier.socialName}}</h6>
|
||||
<vn-label-value
|
||||
label="Id"
|
||||
value="{{::supplier.id}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value
|
||||
label="Tax number"
|
||||
value="{{::supplier.nif}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value
|
||||
label="Alias"
|
||||
value="{{::supplier.alias}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value
|
||||
label="Pay method"
|
||||
value="{{::supplier.payMethod}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value
|
||||
label="Payment deadline"
|
||||
value="{{::supplier.payDem}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value
|
||||
label="Pay day"
|
||||
value="{{::supplier.payDay}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value
|
||||
label="Account"
|
||||
value="{{::supplier.account}}">
|
||||
</vn-label-value>
|
||||
</vn-item-section>
|
||||
<vn-item-section side>
|
||||
<vn-icon-button
|
||||
ng-click="$ctrl.openSummary(supplier, $event)"
|
||||
vn-tooltip="Preview"
|
||||
icon="preview">
|
||||
</vn-icon-button>
|
||||
</vn-item-section>
|
||||
</a>
|
||||
</div>
|
||||
</vn-card>
|
||||
</vn-data-viewer>
|
||||
<vn-popup vn-id="dialog-summary-supplier">
|
||||
<vn-supplier-summary
|
||||
supplier="$ctrl.supplierSelected">
|
||||
</vn-supplier-summary>
|
||||
</vn-popup>
|
||||
<a vn-acl-action="remove" vn-acl="administrative" ui-sref="supplier.create" vn-tooltip="New supplier" vn-bind="+" fixed-bottom-right>
|
||||
<vn-float-button icon="add"></vn-float-button>
|
||||
</a>
|
|
@ -1,18 +0,0 @@
|
|||
import ngModule from '../module';
|
||||
import Section from 'salix/components/section';
|
||||
|
||||
export default class Controller extends Section {
|
||||
openSummary(supplier, event) {
|
||||
if (event.defaultPrevented) return;
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
this.supplierSelected = supplier;
|
||||
this.$.dialogSummarySupplier.show();
|
||||
}
|
||||
}
|
||||
|
||||
ngModule.vnComponent('vnSupplierIndex', {
|
||||
template: require('./index.html'),
|
||||
controller: Controller
|
||||
});
|
|
@ -1,6 +0,0 @@
|
|||
Payment deadline: Plazo de pago
|
||||
Pay day: Dia de pago
|
||||
Account: Cuenta
|
||||
Pay method: Metodo de pago
|
||||
Tax number: Nif
|
||||
New supplier: Nuevo proveedor
|
|
@ -1 +0,0 @@
|
|||
<vn-log url="SupplierLogs" origin-id="$ctrl.$params.id"></vn-log>
|
|
@ -1,7 +0,0 @@
|
|||
import ngModule from '../module';
|
||||
import Section from 'salix/components/section';
|
||||
|
||||
ngModule.vnComponent('vnSupplierLog', {
|
||||
template: require('./index.html'),
|
||||
controller: Section,
|
||||
});
|
|
@ -1,17 +0,0 @@
|
|||
<vn-crud-model
|
||||
vn-id="model"
|
||||
url="Suppliers/filter"
|
||||
limit="20">
|
||||
</vn-crud-model>
|
||||
<vn-portal slot="topbar">
|
||||
<vn-searchbar
|
||||
vn-focus
|
||||
panel="vn-supplier-search-panel"
|
||||
info="Search suppliers by id, name or alias"
|
||||
model="model">
|
||||
</vn-searchbar>
|
||||
</vn-portal>
|
||||
<vn-portal slot="menu">
|
||||
<vn-left-menu></vn-left-menu>
|
||||
</vn-portal>
|
||||
<ui-view></ui-view>
|
|
@ -1,7 +1,15 @@
|
|||
import ngModule from '../module';
|
||||
import ModuleMain from 'salix/components/module-main';
|
||||
|
||||
export default class Supplier extends ModuleMain {}
|
||||
export default class Supplier extends ModuleMain {
|
||||
constructor($element, $) {
|
||||
super($element, $);
|
||||
}
|
||||
async $onInit() {
|
||||
this.$state.go('home');
|
||||
window.location.href = await this.vnApp.getUrl(`supplier/`);
|
||||
}
|
||||
}
|
||||
|
||||
ngModule.vnComponent('vnSupplier', {
|
||||
controller: Supplier,
|
||||
|
|
|
@ -36,146 +36,6 @@
|
|||
"state": "supplier.index",
|
||||
"component": "vn-supplier-index",
|
||||
"description": "Suppliers"
|
||||
},
|
||||
{
|
||||
"url": "/:id",
|
||||
"state": "supplier.card",
|
||||
"abstract": true,
|
||||
"component": "vn-supplier-card"
|
||||
},
|
||||
{
|
||||
"url": "/summary",
|
||||
"state": "supplier.card.summary",
|
||||
"component": "vn-supplier-summary",
|
||||
"description": "Summary",
|
||||
"params": {
|
||||
"supplier": "$ctrl.supplier"
|
||||
}
|
||||
},
|
||||
{
|
||||
"url": "/create",
|
||||
"state": "supplier.create",
|
||||
"component": "vn-supplier-create",
|
||||
"acl": ["administrative"],
|
||||
"description": "New supplier"
|
||||
},
|
||||
{
|
||||
"url": "/basic-data",
|
||||
"state": "supplier.card.basicData",
|
||||
"component": "vn-supplier-basic-data",
|
||||
"description": "Basic data",
|
||||
"acl": ["administrative"],
|
||||
"params": {
|
||||
"supplier": "$ctrl.supplier"
|
||||
}
|
||||
},
|
||||
{
|
||||
"url": "/fiscal-data",
|
||||
"state": "supplier.card.fiscalData",
|
||||
"component": "vn-supplier-fiscal-data",
|
||||
"description": "Fiscal data",
|
||||
"params": {
|
||||
"supplier": "$ctrl.supplier"
|
||||
},
|
||||
"acl": ["administrative"]
|
||||
},
|
||||
{
|
||||
"url" : "/log",
|
||||
"state": "supplier.card.log",
|
||||
"component": "vn-supplier-log",
|
||||
"description": "Log"
|
||||
},
|
||||
{
|
||||
"url": "/contact",
|
||||
"state": "supplier.card.contact",
|
||||
"component": "vn-supplier-contact",
|
||||
"description": "Contacts",
|
||||
"params": {
|
||||
"supplier": "$ctrl.supplier"
|
||||
}
|
||||
},
|
||||
{
|
||||
"url": "/agency-term",
|
||||
"state": "supplier.card.agencyTerm",
|
||||
"component": "ui-view",
|
||||
"abstract": true
|
||||
},
|
||||
{
|
||||
"url": "/index",
|
||||
"state": "supplier.card.agencyTerm.index",
|
||||
"component": "vn-supplier-agency-term-index",
|
||||
"description": "Agency Agreement",
|
||||
"params": {
|
||||
"supplier": "$ctrl.supplier"
|
||||
}
|
||||
},
|
||||
{
|
||||
"url": "/create",
|
||||
"state": "supplier.card.agencyTerm.create",
|
||||
"component": "vn-supplier-agency-term-create",
|
||||
"description": "New autonomous",
|
||||
"params": {
|
||||
"supplier": "$ctrl.supplier"
|
||||
}
|
||||
},
|
||||
{
|
||||
"url": "/consumption?q",
|
||||
"state": "supplier.card.consumption",
|
||||
"component": "vn-supplier-consumption",
|
||||
"description": "Consumption",
|
||||
"params": {
|
||||
"supplier": "$ctrl.supplier"
|
||||
}
|
||||
},
|
||||
{
|
||||
"url": "/billing-data",
|
||||
"state": "supplier.card.billingData",
|
||||
"component": "vn-supplier-billing-data",
|
||||
"description": "Billing data",
|
||||
"params": {
|
||||
"supplier": "$ctrl.supplier"
|
||||
},
|
||||
"acl": ["administrative"]
|
||||
},
|
||||
{
|
||||
"url": "/account",
|
||||
"state": "supplier.card.account",
|
||||
"component": "vn-supplier-account",
|
||||
"description": "Accounts",
|
||||
"params": {
|
||||
"supplier": "$ctrl.supplier"
|
||||
},
|
||||
"acl": ["administrative"]
|
||||
},
|
||||
{
|
||||
"url": "/address",
|
||||
"state": "supplier.card.address",
|
||||
"component": "ui-view",
|
||||
"abstract": true
|
||||
},
|
||||
{
|
||||
"url": "/index?q",
|
||||
"state": "supplier.card.address.index",
|
||||
"component": "vn-supplier-address-index",
|
||||
"description": "Addresses",
|
||||
"params": {
|
||||
"supplier": "$ctrl.supplier"
|
||||
}
|
||||
},
|
||||
{
|
||||
"url": "/create",
|
||||
"state": "supplier.card.address.create",
|
||||
"component": "vn-supplier-address-create",
|
||||
"description": "New address",
|
||||
"params": {
|
||||
"supplier": "$ctrl.supplier"
|
||||
}
|
||||
},
|
||||
{
|
||||
"url": "/:addressId/edit",
|
||||
"state": "supplier.card.address.edit",
|
||||
"component": "vn-supplier-address-edit",
|
||||
"description": "Edit address"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,46 +0,0 @@
|
|||
<div class="search-panel">
|
||||
<form ng-submit="$ctrl.onSearch()">
|
||||
<vn-horizontal>
|
||||
<vn-textfield
|
||||
vn-one
|
||||
label="General search"
|
||||
ng-model="filter.search"
|
||||
info="Search suppliers by id, name or alias"
|
||||
vn-focus>
|
||||
</vn-textfield>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-textfield
|
||||
vn-one
|
||||
label="Alias"
|
||||
ng-model="filter.nickname">
|
||||
</vn-textfield>
|
||||
<vn-textfield
|
||||
vn-one
|
||||
label="Tax number"
|
||||
ng-model="filter.nif">
|
||||
</vn-textfield>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-autocomplete
|
||||
vn-one
|
||||
label="Province"
|
||||
ng-model="filter.provinceFk"
|
||||
url="Provinces"
|
||||
show-field="name"
|
||||
value-field="id">
|
||||
</vn-autocomplete>
|
||||
<vn-autocomplete
|
||||
vn-one
|
||||
label="Country"
|
||||
ng-model="filter.countryFk"
|
||||
url="countries"
|
||||
show-field="name"
|
||||
value-field="id">
|
||||
</vn-autocomplete>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal class="vn-mt-lg">
|
||||
<vn-submit label="Search"></vn-submit>
|
||||
</vn-horizontal>
|
||||
</form>
|
||||
</div>
|
|
@ -1,7 +0,0 @@
|
|||
import ngModule from '../module';
|
||||
import SearchPanel from 'core/components/searchbar/search-panel';
|
||||
|
||||
ngModule.vnComponent('vnSupplierSearchPanel', {
|
||||
template: require('./index.html'),
|
||||
controller: SearchPanel
|
||||
});
|
|
@ -1,4 +0,0 @@
|
|||
Province: Provincia
|
||||
Country: País
|
||||
Tax number: NIF / CIF
|
||||
Search suppliers by id, name or alias: Busca proveedores por id, nombre o alias
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue