This commit is contained in:
parent
f0447c18ae
commit
d3441fa1b3
|
@ -0,0 +1,47 @@
|
||||||
|
DROP procedure IF EXISTS `vn`.`zoneGetLanded`;
|
||||||
|
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`zoneGetLanded`(vShipped DATE, vAddressFk INT, vAgencyModeFk INT, vWarehouseFk INT)
|
||||||
|
BEGIN
|
||||||
|
/**
|
||||||
|
* Devuelve una tabla temporal con el dia de recepcion para vShipped.
|
||||||
|
*
|
||||||
|
* @param vShipped Fecha de preparacion de mercancia
|
||||||
|
* @param vAddressFk Id de consignatario, %NULL para recogida
|
||||||
|
* @param vAgencyModeFk Id agencia
|
||||||
|
* @table tmp.zoneGetLanded Datos de recepción
|
||||||
|
*/
|
||||||
|
DECLARE vPostalCode varchar(10);
|
||||||
|
|
||||||
|
SELECT postalCode INTO vPostalCode
|
||||||
|
FROM address WHERE id = vAddressFk;
|
||||||
|
|
||||||
|
DROP TEMPORARY TABLE IF EXISTS tmp.zoneGetLanded;
|
||||||
|
CREATE TEMPORARY TABLE tmp.zoneGetLanded
|
||||||
|
ENGINE = MEMORY
|
||||||
|
SELECT
|
||||||
|
id zoneFk,
|
||||||
|
vShipped shipped,
|
||||||
|
delivered landed,
|
||||||
|
vWarehouseFk warehouseFk,
|
||||||
|
agencyModeFk,
|
||||||
|
isIncluded
|
||||||
|
FROM (
|
||||||
|
SELECT zi.isIncluded, zc.delivered, z.id, z.agencyModeFk
|
||||||
|
FROM vn.zoneGeo zgSon
|
||||||
|
JOIN vn.zoneGeo zgFather ON zgSon.lft BETWEEN zgFather.lft AND zgFather.rgt
|
||||||
|
JOIN zoneIncluded zi ON zi.geoFk = zgFather.id
|
||||||
|
JOIN zone z ON z.id = zi.zoneFk
|
||||||
|
JOIN zoneCalendar zc ON zc.zoneFk = z.id
|
||||||
|
WHERE zgSon.`name` LIKE vPostalCode
|
||||||
|
AND zc.delivered = TIMESTAMPADD(DAY,z.travelingDays, vShipped)
|
||||||
|
AND IF(vShipped = CURDATE(), hour(now()) < hour(z.`hour`),TRUE)
|
||||||
|
AND z.agencyModeFk = vAgencyModeFk
|
||||||
|
AND z.warehouseFk = vWarehouseFk
|
||||||
|
ORDER BY zgFather.depth DESC) t
|
||||||
|
GROUP BY zoneFk
|
||||||
|
HAVING isIncluded > 0
|
||||||
|
LIMIT 1;
|
||||||
|
END$$
|
||||||
|
|
||||||
|
DELIMITER ;
|
|
@ -0,0 +1,47 @@
|
||||||
|
DROP procedure IF EXISTS `vn`.`zoneGetShipped`;
|
||||||
|
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`zoneGetShipped`(vLanded DATE, vAddressFk INT, vAgencyModeFk INT, vWarehouseFk INT)
|
||||||
|
BEGIN
|
||||||
|
/**
|
||||||
|
* Devuelve la mínima fecha de envía para cada warehouse
|
||||||
|
*
|
||||||
|
* @param vLanded La fecha de recepcion
|
||||||
|
* @param vAddressFk Id del consignatario
|
||||||
|
* @param vAgencyModeFk Id de la agencia
|
||||||
|
* @return tmp.zoneGetShipped
|
||||||
|
*/
|
||||||
|
|
||||||
|
DECLARE vPostalCode varchar(10);
|
||||||
|
|
||||||
|
SELECT postalCode INTO vPostalCode
|
||||||
|
FROM address WHERE id = vAddressFk;
|
||||||
|
|
||||||
|
SELECT * FROM (
|
||||||
|
SELECT * FROM (
|
||||||
|
SELECT z.id zoneFk,
|
||||||
|
TIMESTAMPADD(DAY,-z.travelingDays, vLanded) shipped,
|
||||||
|
vLanded landed,
|
||||||
|
vWarehouseFk warehouseFk,
|
||||||
|
z.agencyModeFk,
|
||||||
|
zi.isIncluded
|
||||||
|
FROM zoneGeo zgSon
|
||||||
|
JOIN zoneGeo zgFather ON zgSon.lft BETWEEN zgFather.lft AND zgFather.rgt
|
||||||
|
JOIN zoneIncluded zi ON zi.geoFk = zgFather.id
|
||||||
|
JOIN zone z ON z.id = zi.zoneFk
|
||||||
|
JOIN zoneCalendar zc ON zc.zoneFk = z.id
|
||||||
|
WHERE zgSon.`name` LIKE vPostalCode
|
||||||
|
AND zc.delivered = vLanded
|
||||||
|
AND z.agencyModeFk = vAgencyModeFk
|
||||||
|
AND z.warehouseFk = vWarehouseFk
|
||||||
|
AND IF(TIMESTAMPADD(DAY,-z.travelingDays, vLanded) = CURDATE(), hour(now()) < hour(z.`hour`),TRUE)
|
||||||
|
ORDER BY z.id, zgFather.depth DESC, isIncluded DESC) t
|
||||||
|
GROUP BY zoneFk
|
||||||
|
HAVING isIncluded > 0
|
||||||
|
ORDER BY shipped)
|
||||||
|
t
|
||||||
|
GROUP BY agencyModeFk;
|
||||||
|
END$$
|
||||||
|
|
||||||
|
DELIMITER ;
|
||||||
|
|
|
@ -91,9 +91,9 @@ module.exports = Self => {
|
||||||
|
|
||||||
const isProductionBoss = await models.Account.hasRole(userId, 'productionBoss');
|
const isProductionBoss = await models.Account.hasRole(userId, 'productionBoss');
|
||||||
if (!isProductionBoss) {
|
if (!isProductionBoss) {
|
||||||
const zone = await models.Agency.getShipped(landed, addressId, agencyModeId, warehouseId);
|
const zoneShipped = await models.Agency.getShipped(landed, addressId, agencyModeId, warehouseId);
|
||||||
|
|
||||||
if (zone.id != zoneId)
|
if (!zoneShipped || zoneShipped.zoneFk != zoneId)
|
||||||
throw new UserError(`You don't have privileges to change the zone`);
|
throw new UserError(`You don't have privileges to change the zone`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,9 +61,9 @@ module.exports = Self => {
|
||||||
|
|
||||||
const isProductionBoss = await models.Account.hasRole(userId, 'productionBoss');
|
const isProductionBoss = await models.Account.hasRole(userId, 'productionBoss');
|
||||||
if (!isProductionBoss) {
|
if (!isProductionBoss) {
|
||||||
const zone = await models.Agency.getShipped(landed, addressId, agencyModeId, warehouseId);
|
const zoneShipped = await models.Agency.getShipped(landed, addressId, agencyModeId, warehouseId);
|
||||||
|
|
||||||
if (!zone || zone.id != zoneId)
|
if (!zoneShipped || zoneShipped.zoneFk != zoneId)
|
||||||
throw new UserError(`You don't have privileges to change the zone`);
|
throw new UserError(`You don't have privileges to change the zone`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,6 +86,7 @@ module.exports = Self => {
|
||||||
|
|
||||||
const map = new Map();
|
const map = new Map();
|
||||||
|
|
||||||
|
// Sale price component, one per sale
|
||||||
difComponents.forEach(difComponent => {
|
difComponents.forEach(difComponent => {
|
||||||
map.set(difComponent.saleFk, difComponent);
|
map.set(difComponent.saleFk, difComponent);
|
||||||
});
|
});
|
||||||
|
|
|
@ -46,10 +46,15 @@ class Controller {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
set warehouseId(id) {
|
set warehouseId(value) {
|
||||||
if (id != this.ticket.warehouseFk) {
|
if (value != this.ticket.warehouseFk) {
|
||||||
this.ticket.warehouseFk = id;
|
this.ticket.warehouseFk = value;
|
||||||
this.onChangeWarehouse(id);
|
this.getShipped({
|
||||||
|
landed: this.ticket.landed,
|
||||||
|
addressFk: this.ticket.addressFk,
|
||||||
|
agencyModeFk: this.ticket.agencyModeFk,
|
||||||
|
warehouseFk: value
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +68,12 @@ class Controller {
|
||||||
|
|
||||||
set shipped(value) {
|
set shipped(value) {
|
||||||
this.ticket.shipped = value;
|
this.ticket.shipped = value;
|
||||||
this.onChangeShipped(value);
|
this.getLanded({
|
||||||
|
shipped: value,
|
||||||
|
addressFk: this.ticket.addressFk,
|
||||||
|
agencyModeFk: this.ticket.agencyModeFk,
|
||||||
|
warehouseFk: this.ticket.warehouseFk
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
get landed() {
|
get landed() {
|
||||||
|
@ -75,7 +85,12 @@ class Controller {
|
||||||
|
|
||||||
set landed(value) {
|
set landed(value) {
|
||||||
this.ticket.landed = value;
|
this.ticket.landed = value;
|
||||||
this.onChangeLanded(value);
|
this.getShipped({
|
||||||
|
landed: value,
|
||||||
|
addressFk: this.ticket.addressFk,
|
||||||
|
agencyModeFk: this.ticket.agencyModeFk,
|
||||||
|
warehouseFk: this.ticket.warehouseFk
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
get agencyModeId() {
|
get agencyModeId() {
|
||||||
|
@ -85,10 +100,15 @@ class Controller {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
set agencyModeId(id) {
|
set agencyModeId(value) {
|
||||||
if (id != this.ticket.agencyModeFk) {
|
if (value != this.ticket.agencyModeFk) {
|
||||||
this.ticket.agencyModeFk = id;
|
this.ticket.agencyModeFk = value;
|
||||||
this.onChangeAgencyMode(id);
|
this.getShipped({
|
||||||
|
landed: this.ticket.landed,
|
||||||
|
addressFk: this.ticket.addressFk,
|
||||||
|
agencyModeFk: value,
|
||||||
|
warehouseFk: this.ticket.warehouseFk
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,10 +119,10 @@ class Controller {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
set zoneId(id) {
|
set zoneId(value) {
|
||||||
if (id != this.ticket.zoneFk) {
|
if (value != this.ticket.zoneFk) {
|
||||||
this.ticket.zoneFk = id;
|
this.ticket.zoneFk = value;
|
||||||
this.onChangeZone(id);
|
this.onChangeZone(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,50 +155,6 @@ class Controller {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
onChangeShipped(shipped) {
|
|
||||||
let params = {
|
|
||||||
shipped: shipped,
|
|
||||||
addressFk: this.ticket.addressFk,
|
|
||||||
agencyModeFk: this.ticket.agencyModeFk,
|
|
||||||
warehouseFk: this.ticket.warehouseFk
|
|
||||||
};
|
|
||||||
this.ticket.zoneFk = null;
|
|
||||||
|
|
||||||
let query = `/api/Agencies/getLanded`;
|
|
||||||
this.$http.get(query, {params}).then(res => {
|
|
||||||
if (res.data && res.data.landed) {
|
|
||||||
this.ticket.zoneFk = res.data.zoneFk;
|
|
||||||
this.ticket.landed = res.data.landed;
|
|
||||||
} else {
|
|
||||||
return this.vnApp.showError(
|
|
||||||
this.$translate.instant(`No delivery zone available for this shipping date`)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
onChangeLanded(landed) {
|
|
||||||
let params = {
|
|
||||||
landed: landed,
|
|
||||||
addressFk: this.ticket.addressFk,
|
|
||||||
agencyModeFk: this.ticket.agencyModeFk,
|
|
||||||
warehouseFk: this.ticket.warehouseFk
|
|
||||||
};
|
|
||||||
this.ticket.zoneFk = null;
|
|
||||||
|
|
||||||
let query = `/api/Agencies/getShipped`;
|
|
||||||
this.$http.get(query, {params}).then(res => {
|
|
||||||
if (res.data) {
|
|
||||||
this.ticket.zoneFk = res.data.id;
|
|
||||||
this.ticket.shipped = res.data.shipped;
|
|
||||||
} else {
|
|
||||||
return this.vnApp.showError(
|
|
||||||
this.$translate.instant(`No delivery zone available for this landing date`)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Gets an agency from an specified zone
|
* Gets an agency from an specified zone
|
||||||
*/
|
*/
|
||||||
|
@ -193,56 +169,6 @@ class Controller {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Gets a zone from an agency
|
|
||||||
*/
|
|
||||||
onChangeAgencyMode(agencyModeId) {
|
|
||||||
let params = {
|
|
||||||
landed: this.ticket.landed,
|
|
||||||
addressFk: this.ticket.addressFk,
|
|
||||||
agencyModeFk: agencyModeId,
|
|
||||||
warehouseFk: this.ticket.warehouseFk
|
|
||||||
};
|
|
||||||
|
|
||||||
this.ticket.zoneFk = null;
|
|
||||||
let query = `/api/Agencies/getShipped`;
|
|
||||||
this.$http.get(query, {params}).then(res => {
|
|
||||||
if (res.data)
|
|
||||||
this.ticket.zoneFk = res.data.id;
|
|
||||||
|
|
||||||
if (!res.data) {
|
|
||||||
this.vnApp.showMessage(
|
|
||||||
this.$translate.instant('No delivery zone available for this parameters')
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Gets a zone from an agency
|
|
||||||
*/
|
|
||||||
onChangeWarehouse(warehouseId) {
|
|
||||||
let params = {
|
|
||||||
landed: this.ticket.landed,
|
|
||||||
addressFk: this.ticket.addressFk,
|
|
||||||
agencyModeFk: this.ticket.agencyModeFk,
|
|
||||||
warehouseFk: warehouseId
|
|
||||||
};
|
|
||||||
|
|
||||||
this.ticket.zoneFk = null;
|
|
||||||
let query = `/api/Agencies/getShipped`;
|
|
||||||
this.$http.get(query, {params}).then(res => {
|
|
||||||
if (res.data)
|
|
||||||
this.ticket.zoneFk = res.data.id;
|
|
||||||
|
|
||||||
if (!res.data) {
|
|
||||||
this.vnApp.showMessage(
|
|
||||||
this.$translate.instant('No delivery zone available for this parameters')
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async onStepChange() {
|
async onStepChange() {
|
||||||
if (this.isFormInvalid()) {
|
if (this.isFormInvalid()) {
|
||||||
return this.vnApp.showError(
|
return this.vnApp.showError(
|
||||||
|
@ -275,16 +201,40 @@ class Controller {
|
||||||
* Returns a landing date
|
* Returns a landing date
|
||||||
*/
|
*/
|
||||||
getLanded(params) {
|
getLanded(params) {
|
||||||
let query = `/api/Agencies/getLanded`;
|
this.ticket.zoneFk = null;
|
||||||
return this.$http.get(query, {params});
|
const query = `/api/Agencies/getLanded`;
|
||||||
|
this.$http.get(query, {params}).then(res => {
|
||||||
|
if (res.data) {
|
||||||
|
this.ticket.zoneFk = res.data.zoneFk;
|
||||||
|
this.ticket.landed = res.data.landed;
|
||||||
|
this.ticket.agencyModeFk = res.data.agencyModeFk;
|
||||||
|
this.ticket.warehouseFk = res.data.warehouseFk;
|
||||||
|
} else {
|
||||||
|
return this.vnApp.showError(
|
||||||
|
this.$translate.instant(`No delivery zone available for this landing date`)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Returns a shipment date
|
* Returns a shipment date
|
||||||
*/
|
*/
|
||||||
getShipped(params) {
|
getShipped(params) {
|
||||||
let query = `/api/Agencies/getShipped`;
|
this.ticket.zoneFk = null;
|
||||||
return this.$http.get(query, {params});
|
const query = `/api/Agencies/getShipped`;
|
||||||
|
this.$http.get(query, {params}).then(res => {
|
||||||
|
if (res.data) {
|
||||||
|
this.ticket.zoneFk = res.data.zoneFk;
|
||||||
|
this.ticket.shipped = res.data.shipped;
|
||||||
|
this.ticket.agencyModeFk = res.data.agencyModeFk;
|
||||||
|
this.ticket.warehouseFk = res.data.warehouseFk;
|
||||||
|
} else {
|
||||||
|
return this.vnApp.showError(
|
||||||
|
this.$translate.instant(`No delivery zone available for this landing date`)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
isFormInvalid() {
|
isFormInvalid() {
|
||||||
|
|
|
@ -5,16 +5,18 @@ describe('Ticket', () => {
|
||||||
let $state;
|
let $state;
|
||||||
let controller;
|
let controller;
|
||||||
let $httpBackend;
|
let $httpBackend;
|
||||||
let $httpParamSerializer;
|
|
||||||
|
|
||||||
|
|
||||||
beforeEach(ngModule('ticket'));
|
beforeEach(ngModule('ticket'));
|
||||||
|
|
||||||
beforeEach(angular.mock.inject(($componentController, _$state_, _$httpBackend_, _$httpParamSerializer_) => {
|
beforeEach(angular.mock.inject(($componentController, _$state_, _$httpBackend_) => {
|
||||||
$state = _$state_;
|
$state = _$state_;
|
||||||
$httpBackend = _$httpBackend_;
|
$httpBackend = _$httpBackend_;
|
||||||
$httpParamSerializer = _$httpParamSerializer_;
|
|
||||||
controller = $componentController('vnTicketBasicDataStepOne', {$state});
|
controller = $componentController('vnTicketBasicDataStepOne', {$state});
|
||||||
|
controller.ticket = {
|
||||||
|
addressFk: 121,
|
||||||
|
agencyModeFk: 7,
|
||||||
|
warehouseFk: 1
|
||||||
|
};
|
||||||
}));
|
}));
|
||||||
|
|
||||||
describe('ticket() setter', () => {
|
describe('ticket() setter', () => {
|
||||||
|
@ -44,44 +46,70 @@ describe('Ticket', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('shipped() setter', () => {
|
describe('shipped() setter', () => {
|
||||||
it('should set shipped property and call onChangeShipped() method ', () => {
|
it('should set shipped property and call getLanded() method ', () => {
|
||||||
let shipped = new Date();
|
spyOn(controller, 'getLanded');
|
||||||
spyOn(controller, 'onChangeShipped');
|
const shipped = new Date();
|
||||||
controller.ticket = {id: 1};
|
const spectedResult = {
|
||||||
|
shipped: shipped,
|
||||||
|
addressFk: 121,
|
||||||
|
agencyModeFk: 7,
|
||||||
|
warehouseFk: 1
|
||||||
|
};
|
||||||
controller.shipped = shipped;
|
controller.shipped = shipped;
|
||||||
|
|
||||||
expect(controller.onChangeShipped).toHaveBeenCalledWith(shipped);
|
|
||||||
|
expect(controller.getLanded).toHaveBeenCalledWith(spectedResult);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('landed() setter', () => {
|
describe('landed() setter', () => {
|
||||||
it('should set landed property and call onChangeLanded() method ', () => {
|
it('should set shipped property and call getShipped() method ', () => {
|
||||||
let landed = new Date();
|
spyOn(controller, 'getShipped');
|
||||||
spyOn(controller, 'onChangeLanded');
|
const landed = new Date();
|
||||||
controller.ticket = {id: 1};
|
const spectedResult = {
|
||||||
|
landed: landed,
|
||||||
|
addressFk: 121,
|
||||||
|
agencyModeFk: 7,
|
||||||
|
warehouseFk: 1
|
||||||
|
};
|
||||||
controller.landed = landed;
|
controller.landed = landed;
|
||||||
|
|
||||||
expect(controller.onChangeLanded).toHaveBeenCalledWith(landed);
|
|
||||||
|
expect(controller.getShipped).toHaveBeenCalledWith(spectedResult);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('agencyModeId() setter', () => {
|
describe('agencyModeId() setter', () => {
|
||||||
it('should set agencyModeId property and call onChangeAgencyMode() method', () => {
|
it('should set agencyModeId property and call onChangeAgencyMode() method', () => {
|
||||||
|
spyOn(controller, 'getShipped');
|
||||||
|
const landed = new Date();
|
||||||
const agencyModeId = 8;
|
const agencyModeId = 8;
|
||||||
spyOn(controller, 'onChangeAgencyMode');
|
const spectedResult = {
|
||||||
controller.ticket = {id: 1};
|
landed: landed,
|
||||||
|
addressFk: 121,
|
||||||
|
agencyModeFk: agencyModeId,
|
||||||
|
warehouseFk: 1
|
||||||
|
};
|
||||||
|
controller.ticket.landed = landed;
|
||||||
controller.agencyModeId = 8;
|
controller.agencyModeId = 8;
|
||||||
|
|
||||||
expect(controller.onChangeAgencyMode).toHaveBeenCalledWith(agencyModeId);
|
expect(controller.getShipped).toHaveBeenCalledWith(spectedResult);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should do nothing if attempting to set the same agencyMode id', () => {
|
it('should do nothing if attempting to set the same agencyMode id', () => {
|
||||||
spyOn(controller, 'onChangeAgencyMode');
|
spyOn(controller, 'getShipped');
|
||||||
const agencyModeId = 8;
|
const landed = new Date();
|
||||||
controller.ticket = {agencyModeFk: agencyModeId};
|
const agencyModeId = 7;
|
||||||
controller.agencyModeId = agencyModeId;
|
const spectedResult = {
|
||||||
|
landed: landed,
|
||||||
|
addressFk: 121,
|
||||||
|
agencyModeFk: agencyModeId,
|
||||||
|
warehouseFk: 1
|
||||||
|
};
|
||||||
|
controller.ticket.landed = landed;
|
||||||
|
controller.agencyModeId = 7;
|
||||||
|
|
||||||
expect(controller.onChangeAgencyMode).not.toHaveBeenCalledWith();
|
expect(controller.getShipped).not.toHaveBeenCalledWith(spectedResult);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -134,59 +162,6 @@ describe('Ticket', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('onChangeShipped()', () => {
|
|
||||||
it('should return an available landing date', async() => {
|
|
||||||
let shipped = new Date();
|
|
||||||
|
|
||||||
controller._ticket = {
|
|
||||||
id: 1,
|
|
||||||
shipped: shipped,
|
|
||||||
addressFk: 121,
|
|
||||||
agencyModeFk: 2,
|
|
||||||
warehouseFk: 1
|
|
||||||
};
|
|
||||||
let params = {
|
|
||||||
shipped: shipped,
|
|
||||||
addressFk: 121,
|
|
||||||
agencyModeFk: 2,
|
|
||||||
warehouseFk: 1
|
|
||||||
};
|
|
||||||
|
|
||||||
let serializedParams = $httpParamSerializer(params);
|
|
||||||
$httpBackend.when('GET', `/api/Agencies/getLanded?${serializedParams}`).respond(200);
|
|
||||||
$httpBackend.expect('GET', `/api/Agencies/getLanded?${serializedParams}`);
|
|
||||||
|
|
||||||
controller.onChangeShipped(shipped);
|
|
||||||
$httpBackend.flush();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('onChangeLanded()', () => {
|
|
||||||
it('should return an available shipment date', async() => {
|
|
||||||
let landed = new Date();
|
|
||||||
controller._ticket = {
|
|
||||||
id: 1,
|
|
||||||
landed: landed,
|
|
||||||
addressFk: 121,
|
|
||||||
agencyModeFk: 2,
|
|
||||||
warehouseFk: 1
|
|
||||||
};
|
|
||||||
let params = {
|
|
||||||
landed: landed,
|
|
||||||
addressFk: 121,
|
|
||||||
agencyModeFk: 2,
|
|
||||||
warehouseFk: 1
|
|
||||||
};
|
|
||||||
|
|
||||||
let serializedParams = $httpParamSerializer(params);
|
|
||||||
$httpBackend.when('GET', `/api/Agencies/getShipped?${serializedParams}`).respond(200);
|
|
||||||
$httpBackend.expect('GET', `/api/Agencies/getShipped?${serializedParams}`);
|
|
||||||
|
|
||||||
controller.onChangeLanded(landed);
|
|
||||||
$httpBackend.flush();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('onChangeZone()', () => {
|
describe('onChangeZone()', () => {
|
||||||
it('should return an available zone', async() => {
|
it('should return an available zone', async() => {
|
||||||
const zoneId = 5;
|
const zoneId = 5;
|
||||||
|
@ -206,61 +181,60 @@ describe('Ticket', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('onChangeAgencyMode()', () => {
|
|
||||||
it('should return an available agency', async() => {
|
|
||||||
const landed = new Date();
|
|
||||||
const agencyModeId = 7;
|
|
||||||
controller._ticket = {
|
|
||||||
id: 1,
|
|
||||||
landed: landed,
|
|
||||||
addressFk: 121,
|
|
||||||
agencyModeFk: agencyModeId,
|
|
||||||
warehouseFk: 1
|
|
||||||
};
|
|
||||||
let params = {
|
|
||||||
landed: landed,
|
|
||||||
addressFk: 121,
|
|
||||||
agencyModeFk: agencyModeId,
|
|
||||||
warehouseFk: 1
|
|
||||||
};
|
|
||||||
|
|
||||||
let serializedParams = $httpParamSerializer(params);
|
/* it('should return an available agency', async() => {
|
||||||
$httpBackend.when('GET', `/api/Agencies/getShipped?${serializedParams}`).respond(200);
|
const landed = new Date();
|
||||||
$httpBackend.expect('GET', `/api/Agencies/getShipped?${serializedParams}`);
|
const agencyModeId = 7;
|
||||||
|
controller._ticket = {
|
||||||
|
id: 1,
|
||||||
|
landed: landed,
|
||||||
|
addressFk: 121,
|
||||||
|
agencyModeFk: agencyModeId,
|
||||||
|
warehouseFk: 1
|
||||||
|
};
|
||||||
|
let params = {
|
||||||
|
landed: landed,
|
||||||
|
addressFk: 121,
|
||||||
|
agencyModeFk: agencyModeId,
|
||||||
|
warehouseFk: 1
|
||||||
|
};
|
||||||
|
|
||||||
controller.onChangeAgencyMode(agencyModeId);
|
let serializedParams = $httpParamSerializer(params);
|
||||||
$httpBackend.flush();
|
$httpBackend.when('GET', `/api/Agencies/getShipped?${serializedParams}`).respond(200);
|
||||||
});
|
$httpBackend.expect('GET', `/api/Agencies/getShipped?${serializedParams}`);
|
||||||
|
|
||||||
it('should throw a user error', async() => {
|
controller.onChangeAgencyMode(agencyModeId);
|
||||||
spyOn(controller.vnApp, 'showMessage');
|
$httpBackend.flush();
|
||||||
const landed = new Date();
|
|
||||||
const agencyModeId = 7;
|
|
||||||
controller._ticket = {
|
|
||||||
id: 1,
|
|
||||||
landed: landed,
|
|
||||||
addressFk: 121,
|
|
||||||
agencyModeFk: agencyModeId,
|
|
||||||
warehouseFk: 1
|
|
||||||
};
|
|
||||||
let params = {
|
|
||||||
landed: landed,
|
|
||||||
addressFk: 121,
|
|
||||||
agencyModeFk: agencyModeId,
|
|
||||||
warehouseFk: 1
|
|
||||||
};
|
|
||||||
|
|
||||||
let serializedParams = $httpParamSerializer(params);
|
|
||||||
$httpBackend.when('GET', `/api/Agencies/getShipped?${serializedParams}`).respond(null);
|
|
||||||
$httpBackend.expect('GET', `/api/Agencies/getShipped?${serializedParams}`);
|
|
||||||
|
|
||||||
controller.onChangeAgencyMode(agencyModeId);
|
|
||||||
$httpBackend.flush();
|
|
||||||
|
|
||||||
expect(controller.vnApp.showMessage).toHaveBeenCalledWith('No delivery zone available for this parameters');
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should throw a user error', async() => {
|
||||||
|
spyOn(controller.vnApp, 'showMessage');
|
||||||
|
const landed = new Date();
|
||||||
|
const agencyModeId = 7;
|
||||||
|
controller._ticket = {
|
||||||
|
id: 1,
|
||||||
|
landed: landed,
|
||||||
|
addressFk: 121,
|
||||||
|
agencyModeFk: agencyModeId,
|
||||||
|
warehouseFk: 1
|
||||||
|
};
|
||||||
|
let params = {
|
||||||
|
landed: landed,
|
||||||
|
addressFk: 121,
|
||||||
|
agencyModeFk: agencyModeId,
|
||||||
|
warehouseFk: 1
|
||||||
|
};
|
||||||
|
|
||||||
|
let serializedParams = $httpParamSerializer(params);
|
||||||
|
$httpBackend.when('GET', `/api/Agencies/getShipped?${serializedParams}`).respond(null);
|
||||||
|
$httpBackend.expect('GET', `/api/Agencies/getShipped?${serializedParams}`);
|
||||||
|
|
||||||
|
controller.onChangeAgencyMode(agencyModeId);
|
||||||
|
$httpBackend.flush();
|
||||||
|
|
||||||
|
expect(controller.vnApp.showMessage).toHaveBeenCalledWith('No delivery zone available for this parameters');
|
||||||
|
}); */
|
||||||
|
|
||||||
describe('isFormInvalid()', () => {
|
describe('isFormInvalid()', () => {
|
||||||
it('should check if all form fields are valid', () => {
|
it('should check if all form fields are valid', () => {
|
||||||
controller.ticket = {
|
controller.ticket = {
|
||||||
|
|
|
@ -15,7 +15,7 @@ module.exports = {
|
||||||
sections: {
|
sections: {
|
||||||
agency: {
|
agency: {
|
||||||
description: `Para agilizar tu recogida, por favor, pónte en contacto con la oficina de integrados. <br/>
|
description: `Para agilizar tu recogida, por favor, pónte en contacto con la oficina de integrados. <br/>
|
||||||
Tlf: 96 166 77 88 - Ana Gómez (Ext. 2113) <em>(agomezf@integra2.es)</em> `
|
Tlf: 96 166 77 88 - Ana Gómez (Ext. 2133) <em>(agomezf@integra2.es)</em> `
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue