2510-client-address-create-test #418
|
@ -110,13 +110,15 @@ BEGIN
|
|||
SELECT `name` FROM `user` WHERE id = OLD.id;
|
||||
END$$
|
||||
|
||||
CREATE TRIGGER role_beforeInsert
|
||||
DROP TRIGGER IF EXISTS account.role_beforeInsert$$
|
||||
CREATE DEFINER=`root`@`%` TRIGGER role_beforeInsert
|
||||
BEFORE INSERT ON `role` FOR EACH ROW
|
||||
BEGIN
|
||||
CALL role_checkName(NEW.`name`);
|
||||
END$$
|
||||
END
|
||||
|
||||
CREATE TRIGGER role_beforeUpdate
|
||||
DROP TRIGGER IF EXISTS account.role_beforeUpdate$$
|
||||
CREATE DEFINER=`root`@`%` TRIGGER role_beforeUpdate
|
||||
BEFORE UPDATE ON `role` FOR EACH ROW
|
||||
BEGIN
|
||||
IF !(NEW.`name` <=> OLD.`name`) THEN
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
DROP PROCEDURE IF EXISTS account.role_checkName;
|
||||
|
||||
DELIMITER $$
|
||||
CREATE PROCEDURE account.role_checkName(vRoleName VARCHAR(255))
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE account.role_checkName(vRoleName VARCHAR(255))
|
||||
BEGIN
|
||||
/**
|
||||
* Checks that role name meets the necessary syntax requirements, otherwise it
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
UPDATE `salix`.`ACL` SET `principalId` = 'deliveryBoss' WHERE (`id` = '194');
|
||||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES ('Town', '*', 'WRITE', 'ALLOW', 'ROLE', 'deliveryBoss');
|
||||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES ('Province', '*', 'WRITE', 'ALLOW', 'ROLE', 'deliveryBoss');
|
File diff suppressed because one or more lines are too long
|
@ -400,12 +400,13 @@ INSERT INTO `vn`.`clientObservation`(`id`, `clientFk`, `workerFk`, `text`, `crea
|
|||
(9, 109, 18, 'HULK SMASH! ...', CURDATE()),
|
||||
(10, 110, 18, 'They say everyone is born a hero. But if you let it, life will push you over the line until you are the villain.', CURDATE());
|
||||
|
||||
INSERT INTO `vn`.`observationType`(`id`,`description`)
|
||||
INSERT INTO `vn`.`observationType`(`id`,`description`, `code`)
|
||||
VALUES
|
||||
(1,'observation one'),
|
||||
(2,'observation two'),
|
||||
(3,'observation three'),
|
||||
(4,'comercial');
|
||||
(1, 'observation one', 'observation one'),
|
||||
(2, 'observation two', 'observation two'),
|
||||
(3, 'observation three', 'observation three'),
|
||||
(4, 'comercial', 'salesPerson'),
|
||||
(5, 'delivery', 'delivery');
|
||||
|
||||
INSERT INTO `vn`.`addressObservation`(`id`,`addressFk`,`observationTypeFk`,`description`)
|
||||
VALUES
|
||||
|
@ -2116,4 +2117,18 @@ INSERT INTO `vn`.`tabletDepartment`(`tabletFk`, `departmentFk`)
|
|||
(1, 23),
|
||||
(2, 1);
|
||||
|
||||
INSERT INTO `vn`.`campaign`(`code`, `dated`)
|
||||
VALUES
|
||||
('valentinesDay', CONCAT(YEAR(CURDATE()), '-02-14')),
|
||||
('valentinesDay', CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -1 YEAR)), '-02-14')),
|
||||
('valentinesDay', CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -2 YEAR)), '-02-14')),
|
||||
('valentinesDay', CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -3 YEAR)), '-02-14')),
|
||||
('mothersDay', CONCAT(YEAR(CURDATE()), '-05-05')),
|
||||
('mothersDay', CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -1 YEAR)), '-05-05')),
|
||||
('mothersDay', CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -2 YEAR)), '-05-05')),
|
||||
('mothersDay', CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -3 YEAR)), '-05-05')),
|
||||
('allSaints', CONCAT(YEAR(CURDATE()), '-11-01')),
|
||||
('allSaints', CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -1 YEAR)), '-11-01')),
|
||||
('allSaints', CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -2 YEAR)), '-11-01')),
|
||||
('allSaints', CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -3 YEAR)), '-11-01'));
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -82,3 +82,10 @@ TABLES=(
|
|||
workcenter
|
||||
)
|
||||
dump_tables ${TABLES[@]}
|
||||
|
||||
TABLES=(
|
||||
sage
|
||||
TiposIva
|
||||
TiposTransacciones
|
||||
)
|
||||
dump_tables ${TABLES[@]}
|
|
@ -9,6 +9,7 @@ SCHEMAS=(
|
|||
nst
|
||||
pbx
|
||||
postgresql
|
||||
sage
|
||||
salix
|
||||
stock
|
||||
util
|
||||
|
|
|
@ -42,13 +42,24 @@ export default {
|
|||
taxNumber: 'vn-client-create vn-textfield[ng-model="$ctrl.client.fi"]',
|
||||
socialName: 'vn-client-create vn-textfield[ng-model="$ctrl.client.socialName"]',
|
||||
street: 'vn-client-create vn-textfield[ng-model="$ctrl.client.street"]',
|
||||
addPostCode: 'vn-client-create vn-datalist[ng-model="$ctrl.client.postcode"] vn-icon-button[icon="add_circle"]',
|
||||
addProvince: 'vn-autocomplete[ng-model="$ctrl.location.provinceFk"] vn-icon-button[icon="add_circle"]',
|
||||
addCity: 'vn-autocomplete[ng-model="$ctrl.location.townFk"] vn-icon-button[icon="add_circle"]',
|
||||
newProvinceName: 'vn-textfield[ng-model="$ctrl.province.name"]',
|
||||
newCityName: 'vn-textfield[ng-model="$ctrl.city.name"]',
|
||||
newCityProvince: 'vn-autocomplete[ng-model="$ctrl.city.provinceFk"]',
|
||||
newPostcode: 'vn-textfield[ng-model="$ctrl.location.code"]',
|
||||
postcode: 'vn-client-create vn-datalist[ng-model="$ctrl.client.postcode"]',
|
||||
city: 'vn-client-create vn-datalist[ng-model="$ctrl.client.city"]',
|
||||
province: 'vn-client-create vn-autocomplete[ng-model="$ctrl.client.provinceFk"]',
|
||||
province: 'vn-autocomplete[ng-model="$ctrl.client.provinceFk"]',
|
||||
country: 'vn-client-create vn-autocomplete[ng-model="$ctrl.client.countryFk"]',
|
||||
dialogCountry: 'vn-autocomplete[ng-model="$ctrl.province.countryFk"]',
|
||||
userName: 'vn-client-create vn-textfield[ng-model="$ctrl.client.userName"]',
|
||||
email: 'vn-client-create vn-textfield[ng-model="$ctrl.client.email"]',
|
||||
salesPerson: 'vn-client-create vn-autocomplete[ng-model="$ctrl.client.salesPersonFk"]',
|
||||
saveNewProvicenButton: '#saveProvince',
|
||||
saveNewCityButton: '#saveCity',
|
||||
saveNewPoscode: '#savePostcode',
|
||||
createButton: 'vn-client-create button[type=submit]'
|
||||
},
|
||||
clientDescriptor: {
|
||||
|
|
|
@ -8,7 +8,7 @@ describe('Client create path', () => {
|
|||
beforeAll(async() => {
|
||||
browser = await getBrowser();
|
||||
page = browser.page;
|
||||
await page.loginAndModule('employee', 'client');
|
||||
await page.loginAndModule(' deliveryBoss', 'client');
|
||||
});
|
||||
|
||||
afterAll(async() => {
|
||||
|
@ -45,14 +45,40 @@ describe('Client create path', () => {
|
|||
expect(message.text).toBe('Some fields are invalid');
|
||||
});
|
||||
|
||||
it(`should create a new province`, async() => {
|
||||
await page.waitToClick(selectors.createClientView.addPostCode);
|
||||
await page.waitToClick(selectors.createClientView.addProvince);
|
||||
await page.write(selectors.createClientView.newProvinceName, 'Massachusetts');
|
||||
await page.autocompleteSearch(selectors.createClientView.dialogCountry, 'España');
|
||||
await page.waitToClick(selectors.createClientView.saveNewProvicenButton);
|
||||
const message = await page.waitForSnackbar();
|
||||
|
||||
expect(message.text).toBe('The province has been created');
|
||||
});
|
||||
|
||||
it(`should create a new city`, async() => {
|
||||
await page.waitToClick(selectors.createClientView.addCity);
|
||||
await page.write(selectors.createClientView.newCityName, 'Boston');
|
||||
await page.autocompleteSearch(selectors.createClientView.newCityProvince, 'Massachusetts');
|
||||
await page.waitToClick(selectors.createClientView.saveNewCityButton);
|
||||
const message = await page.waitForSnackbar();
|
||||
|
||||
expect(message.text).toBe('The city has been created');
|
||||
});
|
||||
|
||||
it(`should create a new post code`, async() => {
|
||||
await page.write(selectors.createClientView.newPostcode, '61616');
|
||||
await page.waitToClick(selectors.createClientView.saveNewPoscode);
|
||||
|
||||
const message = await page.waitForSnackbar();
|
||||
|
||||
expect(message.text).toBe('The postcode has been created. You can save the data now');
|
||||
});
|
||||
|
||||
it(`should attempt to create a new user with all it's data but wrong email`, async() => {
|
||||
await page.write(selectors.createClientView.name, 'Carol Danvers');
|
||||
await page.write(selectors.createClientView.socialName, 'AVG tax');
|
||||
await page.write(selectors.createClientView.street, 'Many places');
|
||||
await page.autocompleteSearch(selectors.createClientView.country, 'España');
|
||||
await page.autocompleteSearch(selectors.createClientView.province, 'Province one');
|
||||
await page.write(selectors.createClientView.city, 'Valencia');
|
||||
await page.write(selectors.createClientView.postcode, '46000');
|
||||
await page.clearInput(selectors.createClientView.email);
|
||||
await page.write(selectors.createClientView.email, 'incorrect email format');
|
||||
await page.waitToClick(selectors.createClientView.createButton);
|
||||
|
@ -82,14 +108,14 @@ describe('Client create path', () => {
|
|||
const clientCountry = await page
|
||||
.waitToGetProperty(selectors.createClientView.country, 'value');
|
||||
|
||||
expect(clientCity).toEqual('Valencia');
|
||||
expect(clientProvince).toContain('Province one');
|
||||
expect(clientCity).toEqual('Boston');
|
||||
expect(clientProvince).toContain('Massachusetts');
|
||||
expect(clientCountry).toEqual('España');
|
||||
});
|
||||
|
||||
it(`should create a new user with all correct data`, async() => {
|
||||
await page.clearInput(selectors.createClientView.postcode);
|
||||
await page.write(selectors.createClientView.postcode, '46000');
|
||||
await page.write(selectors.createClientView.postcode, '61616');
|
||||
await page.waitToClick(selectors.createClientView.createButton);
|
||||
const message = await page.waitForSnackbar();
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ describe('Worker calendar path', () => {
|
|||
expect(result).toContain(' 5 ');
|
||||
});
|
||||
|
||||
it('should set two days as holidays on the calendar', async() => {
|
||||
it('should set two days as holidays on the calendar and check the total holidays increased by 1.5', async() => {
|
||||
await page.waitToClick(selectors.workerCalendar.holidays);
|
||||
await page.waitFor(reasonableTimeBetweenClicks);
|
||||
await page.waitToClick(selectors.workerCalendar.januaryThirtyFirst);
|
||||
|
@ -51,9 +51,7 @@ describe('Worker calendar path', () => {
|
|||
await page.waitFor(reasonableTimeBetweenClicks);
|
||||
await page.waitToClick(selectors.workerCalendar.mayEighth);
|
||||
await page.waitFor(reasonableTimeBetweenClicks);
|
||||
});
|
||||
|
||||
it('should check the total holidays increased by 1.5', async() => {
|
||||
const result = await page.waitToGetProperty(selectors.workerCalendar.totalHolidaysUsed, 'innerText');
|
||||
|
||||
expect(result).toContain(' 6.5 ');
|
||||
|
|
|
@ -26,7 +26,9 @@ describe('Entry create path', () => {
|
|||
await page.autocompleteSearch(selectors.entryIndex.newEntryCompany, 'ORN');
|
||||
|
||||
await page.waitToClick(selectors.entryIndex.saveNewEntry);
|
||||
await page.waitFor(500);
|
||||
await page.waitForNavigation({
|
||||
waitUntil: 'load',
|
||||
});
|
||||
await page.waitForState('entry.card.basicData');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -57,12 +57,12 @@
|
|||
"The postcode doesn't exist. Please enter a correct one": "The postcode doesn't exist. Please enter a correct one",
|
||||
"Can't create stowaway for this ticket": "Can't create stowaway for this ticket",
|
||||
"Swift / BIC can't be empty": "Swift / BIC can't be empty",
|
||||
"MESSAGE_BOUGHT_UNITS": "Bought {{quantity}} units of {{concept}} (#{{itemId}}) for the ticket id [#{{ticketId}}]({{{url}}})",
|
||||
"MESSAGE_INSURANCE_CHANGE": "I have changed the insurence credit of client [{{clientName}} (#{{clientId}})]({{{url}}}) to *{{credit}} €*",
|
||||
"MESSAGE_CHANGED_PAYMETHOD": "I have changed the pay method for client [{{clientName}} (#{{clientId}})]({{{url}}})",
|
||||
"Sent units from ticket": "I sent *{{quantity}}* units of [{{concept}} (#{{itemId}})]({{{itemUrl}}}) to *\"{{nickname}}\"* coming from ticket id [#{{ticketId}}]({{{ticketUrl}}})",
|
||||
"Claim will be picked": "The product from the claim (#{{claimId}})]({{{claimUrl}}}) from the client *{{clientName}}* will be picked",
|
||||
"This ticket is not an stowaway anymore": "The ticket id [#{{ticketId}}]({{{ticketUrl}}}) is not an stowaway anymore",
|
||||
"MESSAGE_BOUGHT_UNITS": "Bought {{quantity}} units of {{concept}} ({{itemId}}) for the ticket id [{{ticketId}}]({{{url}}})",
|
||||
"MESSAGE_INSURANCE_CHANGE": "I have changed the insurence credit of client [{{clientName}} ({{clientId}})]({{{url}}}) to *{{credit}} €*",
|
||||
"MESSAGE_CHANGED_PAYMETHOD": "I have changed the pay method for client [{{clientName}} ({{clientId}})]({{{url}}})",
|
||||
"Sent units from ticket": "I sent *{{quantity}}* units of [{{concept}} ({{itemId}})]({{{itemUrl}}}) to *\"{{nickname}}\"* coming from ticket id [{{ticketId}}]({{{ticketUrl}}})",
|
||||
"Claim will be picked": "The product from the claim ({{claimId}})]({{{claimUrl}}}) from the client *{{clientName}}* will be picked",
|
||||
"This ticket is not an stowaway anymore": "The ticket id [{{ticketId}}]({{{ticketUrl}}}) is not an stowaway anymore",
|
||||
"Customs agent is required for a non UEE member": "Customs agent is required for a non UEE member",
|
||||
"Incoterms is required for a non UEE member": "Incoterms is required for a non UEE member",
|
||||
"Client checked as validated despite of duplication": "Client checked as validated despite of duplication from client id {{clientId}}",
|
||||
|
@ -70,6 +70,7 @@
|
|||
"NOT_ZONE_WITH_THIS_PARAMETERS": "There's no zone available for this day",
|
||||
"Created absence": "The worker <strong>{{author}}</strong> has added an absence of type '{{absenceType}}' to <a href='{{{workerUrl}}}'><strong>{{employee}}</strong></a> for day {{dated}}.",
|
||||
"Deleted absence": "The worker <strong>{{author}}</strong> has deleted an absence of type '{{absenceType}}' to <a href='{{{workerUrl}}}'><strong>{{employee}}</strong></a> for day {{dated}}.",
|
||||
"I have deleted the ticket id": "I have deleted the ticket id [#{{id}}]({{{url}}})",
|
||||
"I have restored the ticket id": "I have restored the ticket id [#{{id}}]({{{url}}})"
|
||||
"I have deleted the ticket id": "I have deleted the ticket id [{{id}}]({{{url}}})",
|
||||
"I have restored the ticket id": "I have restored the ticket id [{{id}}]({{{url}}})",
|
||||
"Changed this data from the ticket": "I have changed the data from the ticket [{{ticketId}}]({{{ticketUrl}}}): ```{{{changes}}}```"
|
||||
}
|
|
@ -121,12 +121,12 @@
|
|||
"Swift / BIC can't be empty": "Swift / BIC no puede estar vacío",
|
||||
"Customs agent is required for a non UEE member": "El agente de aduanas es requerido para los clientes extracomunitarios",
|
||||
"Incoterms is required for a non UEE member": "El incoterms es requerido para los clientes extracomunitarios",
|
||||
"MESSAGE_BOUGHT_UNITS": "Se ha comprado {{quantity}} unidades de {{concept}} (#{{itemId}}) para el ticket id [#{{ticketId}}]({{{url}}})",
|
||||
"MESSAGE_BOUGHT_UNITS": "Se ha comprado {{quantity}} unidades de {{concept}} (#{{itemId}}) para el ticket id [{{ticketId}}]({{{url}}})",
|
||||
"MESSAGE_INSURANCE_CHANGE": "He cambiado el crédito asegurado del cliente [{{clientName}} (#{{clientId}})]({{{url}}}) a *{{credit}} €*",
|
||||
"MESSAGE_CHANGED_PAYMETHOD": "He cambiado la forma de pago del cliente [{{clientName}} (#{{clientId}})]({{{url}}})",
|
||||
"Sent units from ticket": "Envio *{{quantity}}* unidades de [{{concept}} (#{{itemId}})]({{{itemUrl}}}) a *\"{{nickname}}\"* provenientes del ticket id [#{{ticketId}}]({{{ticketUrl}}})",
|
||||
"Sent units from ticket": "Envio *{{quantity}}* unidades de [{{concept}} (#{{itemId}})]({{{itemUrl}}}) a *\"{{nickname}}\"* provenientes del ticket id [{{ticketId}}]({{{ticketUrl}}})",
|
||||
"Claim will be picked": "Se recogerá el género de la reclamación (#{{claimId}})]({{{claimUrl}}}) del cliente *{{clientName}}*",
|
||||
"This ticket is not an stowaway anymore": "El ticket id [#{{ticketId}}]({{{ticketUrl}}}) ha dejado de ser un polizón",
|
||||
"This ticket is not an stowaway anymore": "El ticket id [{{ticketId}}]({{{ticketUrl}}}) ha dejado de ser un polizón",
|
||||
"Client checked as validated despite of duplication": "Cliente comprobado a pesar de que existe el cliente id {{clientId}}",
|
||||
"ORDER_ROW_UNAVAILABLE": "No hay disponibilidad de este producto",
|
||||
"Distance must be lesser than 1000": "La distancia debe ser inferior a 1000",
|
||||
|
@ -146,7 +146,8 @@
|
|||
"Absence change notification on the labour calendar": "Notificacion de cambio de ausencia en el calendario laboral",
|
||||
"Created absence": "El empleado <strong>{{author}}</strong> ha añadido una ausencia de tipo '{{absenceType}}' a <a href='{{{workerUrl}}}'><strong>{{employee}}</strong></a> para el día {{dated}}.",
|
||||
"Deleted absence": "El empleado <strong>{{author}}</strong> ha eliminado una ausencia de tipo '{{absenceType}}' a <a href='{{{workerUrl}}}'><strong>{{employee}}</strong></a> del día {{dated}}.",
|
||||
"I have deleted the ticket id": "He eliminado el ticket id [#{{id}}]({{{url}}})",
|
||||
"I have restored the ticket id": "He restaurado el ticket id [#{{id}}]({{{url}}})",
|
||||
"You can only restore a ticket within the first hour after deletion": "Únicamente puedes restaurar el ticket dentro de la primera hora después de su eliminación"
|
||||
"I have deleted the ticket id": "He eliminado el ticket id [{{id}}]({{{url}}})",
|
||||
"I have restored the ticket id": "He restaurado el ticket id [{{id}}]({{{url}}})",
|
||||
"You can only restore a ticket within the first hour after deletion": "Únicamente puedes restaurar el ticket dentro de la primera hora después de su eliminación",
|
||||
"Changed this data from the ticket": "He cambiado estos datos del ticket [{{ticketId}}]({{{ticketUrl}}}): ```{{{changes}}}```"
|
||||
}
|
|
@ -7,7 +7,7 @@ describe('Client activeWorkersWithRole', () => {
|
|||
|
||||
let isSalesPerson = await app.models.Account.hasRole(result[0].id, 'salesPerson');
|
||||
|
||||
expect(result.length).toEqual(16);
|
||||
expect(result.length).toEqual(17);
|
||||
expect(isSalesPerson).toBeTruthy();
|
||||
});
|
||||
|
||||
|
|
|
@ -104,7 +104,7 @@ describe('Address createAddress', () => {
|
|||
|
||||
address = await app.models.Client.createAddress(ctx, clientFk);
|
||||
|
||||
expect(address.__data).toEqual(jasmine.objectContaining(ctx.args));
|
||||
expect(address).toEqual(jasmine.objectContaining(ctx.args));
|
||||
// restores
|
||||
const client = await app.models.Client.findById(clientFk);
|
||||
await client.updateAttributes({defaultAddressFk: 1});
|
||||
|
|
|
@ -6,7 +6,7 @@ describe('Client listWorkers', () => {
|
|||
.then(result => {
|
||||
let amountOfEmployees = Object.keys(result).length;
|
||||
|
||||
expect(amountOfEmployees).toEqual(51);
|
||||
expect(amountOfEmployees).toEqual(53);
|
||||
done();
|
||||
})
|
||||
.catch(done.fail);
|
||||
|
|
|
@ -15,6 +15,10 @@
|
|||
"description": {
|
||||
"type": "String",
|
||||
"required": true
|
||||
},
|
||||
"code": {
|
||||
"type": "String",
|
||||
"required": true
|
||||
}
|
||||
},
|
||||
"acls": [
|
||||
|
|
|
@ -153,9 +153,9 @@
|
|||
</form>
|
||||
|
||||
<!-- New postcode dialog -->
|
||||
<vn-client-postcode vn-id="postcode"
|
||||
<vn-geo-postcode vn-id="postcode"
|
||||
on-response="$ctrl.onResponse($response)">
|
||||
</vn-client-postcode>
|
||||
</vn-geo-postcode>
|
||||
|
||||
<!-- Create custom agent dialog -->
|
||||
<vn-dialog class="edit"
|
||||
|
|
|
@ -74,6 +74,8 @@ export default class Controller extends Section {
|
|||
|
||||
onResponse(response) {
|
||||
this.address.postalCode = response.code;
|
||||
this.address.city = response.city;
|
||||
this.address.provinceFk = response.provinceFk;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -191,9 +191,9 @@
|
|||
</form>
|
||||
|
||||
<!-- New postcode dialog -->
|
||||
<vn-client-postcode vn-id="postcode"
|
||||
<vn-geo-postcode vn-id="postcode"
|
||||
on-response="$ctrl.onResponse($response)">
|
||||
</vn-client-postcode>
|
||||
</vn-geo-postcode>
|
||||
|
||||
<!-- Create custom agent dialog -->
|
||||
<vn-dialog class="edit"
|
||||
|
|
|
@ -78,6 +78,8 @@ export default class Controller extends Section {
|
|||
|
||||
onResponse(response) {
|
||||
this.address.postalCode = response.code;
|
||||
this.address.city = response.city;
|
||||
this.address.provinceFk = response.provinceFk;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,12 +5,6 @@
|
|||
insert-mode="true"
|
||||
form="form">
|
||||
</vn-watcher>
|
||||
<vn-crud-model
|
||||
auto-load="true"
|
||||
url="Towns/location"
|
||||
data="townLocations"
|
||||
order="name">
|
||||
</vn-crud-model>
|
||||
<form name="form" vn-http-submit="$ctrl.onSubmit()" class="vn-w-md">
|
||||
<vn-card class="vn-pa-lg">
|
||||
<vn-horizontal>
|
||||
|
@ -82,7 +76,7 @@
|
|||
label="City"
|
||||
ng-model="$ctrl.client.city"
|
||||
selection="$ctrl.town"
|
||||
data="townsLocation"
|
||||
url="Towns/location"
|
||||
fields="['id', 'name', 'provinceFk']"
|
||||
value-field="name">
|
||||
<tpl-item>
|
||||
|
@ -136,7 +130,7 @@
|
|||
</vn-button-bar>
|
||||
</form>
|
||||
<!-- New postcode dialog -->
|
||||
<vn-client-postcode
|
||||
<vn-geo-postcode
|
||||
vn-id="postcode"
|
||||
on-response="$ctrl.onResponse($response)">
|
||||
</vn-client-postcode>
|
||||
</vn-geo-postcode>
|
|
@ -81,6 +81,9 @@ export default class Controller extends Section {
|
|||
|
||||
onResponse(response) {
|
||||
this.client.postcode = response.code;
|
||||
this.client.city = response.city;
|
||||
this.client.provinceFk = response.provinceFk;
|
||||
this.client.countryFk = response.countryFk;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -173,7 +173,7 @@
|
|||
on-accept="$ctrl.onAcceptDuplication()">
|
||||
</vn-confirm>
|
||||
<!-- New postcode dialog -->
|
||||
<vn-client-postcode
|
||||
<vn-geo-postcode
|
||||
vn-id="postcode"
|
||||
on-response="$ctrl.onResponse($response)">
|
||||
</vn-client-postcode>
|
||||
</vn-geo-postcode>
|
|
@ -159,6 +159,9 @@ export default class Controller extends Section {
|
|||
|
||||
onResponse(response) {
|
||||
this.client.postcode = response.code;
|
||||
this.client.city = response.city;
|
||||
this.client.provinceFk = response.provinceFk;
|
||||
this.client.countryFk = response.countryFk;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -37,6 +37,8 @@ import './web-payment';
|
|||
import './log';
|
||||
import './sms';
|
||||
import './postcode';
|
||||
import './postcode/province';
|
||||
import './postcode/city';
|
||||
import './dms/index';
|
||||
import './dms/create';
|
||||
import './dms/edit';
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
<vn-dialog class="edit"
|
||||
vn-id="cityDialog"
|
||||
on-open="$ctrl.onOpen()"
|
||||
on-accept="$ctrl.onAccept()"
|
||||
message="New city">
|
||||
<tpl-body>
|
||||
<p translate>Please, ensure you put the correct data!</p>
|
||||
<vn-horizontal>
|
||||
<vn-textfield vn-one
|
||||
vn-focus
|
||||
ng-model="$ctrl.city.name"
|
||||
label="Name">
|
||||
</vn-textfield>
|
||||
<vn-autocomplete vn-one
|
||||
ng-model="$ctrl.city.provinceFk"
|
||||
url="Provinces"
|
||||
show-field="name"
|
||||
value-field="id"
|
||||
label="Province">
|
||||
</vn-autocomplete>
|
||||
</vn-horizontal>
|
||||
</tpl-body>
|
||||
<tpl-buttons>
|
||||
<input type="button" response="cancel" translate-attr="{value: 'Cancel'}"/>
|
||||
<button id="saveCity" response="accept" translate>Save</button>
|
||||
</tpl-buttons>
|
||||
</vn-dialog>
|
|
@ -0,0 +1,37 @@
|
|||
import ngModule from '../../module';
|
||||
import Component from 'core/lib/component';
|
||||
|
||||
class Controller extends Component { // Comprobar funcionamiento añadir ciudad
|
||||
open($event) {
|
||||
if ($event.defaultPrevented) return;
|
||||
|
||||
this.$.cityDialog.show();
|
||||
$event.preventDefault();
|
||||
}
|
||||
|
||||
onAccept() {
|
||||
try {
|
||||
if (!this.city.name)
|
||||
throw new Error(`The city name can't be empty`);
|
||||
if (!this.city.provinceFk)
|
||||
throw new Error(`The province can't be empty`);
|
||||
|
||||
this.$http.patch(`towns`, this.city).then(res => {
|
||||
this.vnApp.showMessage(this.$t('The city has been created'));
|
||||
this.emit('response', {$response: res.data});
|
||||
});
|
||||
} catch (e) {
|
||||
this.vnApp.showError(this.$t(e.message));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
ngModule.vnComponent('vnGeoCity', {
|
||||
template: require('./index.html'),
|
||||
controller: Controller,
|
||||
bindings: {
|
||||
data: '<',
|
||||
}
|
||||
});
|
|
@ -0,0 +1,34 @@
|
|||
import './index';
|
||||
|
||||
describe('Client', () => {
|
||||
describe('Component vnGeoCity', () => {
|
||||
let controller;
|
||||
let $httpBackend;
|
||||
let $scope;
|
||||
|
||||
beforeEach(ngModule('client'));
|
||||
|
||||
beforeEach(inject(($componentController, _$httpBackend_, $rootScope) => {
|
||||
$httpBackend = _$httpBackend_;
|
||||
$scope = $rootScope.$new();
|
||||
const $element = angular.element('<vn-dialog></vn-dialog>');
|
||||
controller = $componentController('vnGeoCity', {$element, $scope});
|
||||
controller.client = {id: 101};
|
||||
}));
|
||||
|
||||
describe('onAccept()', () => {
|
||||
it('should perform a POST query and show a success snackbar', () => {
|
||||
let params = {name: 'Gotham City', provinceFk: 1};
|
||||
controller.city = {name: 'Gotham City', provinceFk: 1};
|
||||
|
||||
jest.spyOn(controller.vnApp, 'showMessage');
|
||||
$httpBackend.expect('PATCH', `towns`, params).respond(200, params);
|
||||
|
||||
controller.onAccept();
|
||||
$httpBackend.flush();
|
||||
|
||||
expect(controller.vnApp.showMessage).toHaveBeenCalledWith('The city has been created');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
|
@ -11,7 +11,7 @@
|
|||
vn-focus
|
||||
vn-id="postcode"
|
||||
label="Postcode"
|
||||
ng-model="$ctrl.data.code"
|
||||
ng-model="$ctrl.location.code"
|
||||
required="true">
|
||||
</vn-textfield>
|
||||
<vn-autocomplete vn-one
|
||||
|
@ -19,23 +19,39 @@
|
|||
url="Towns/location"
|
||||
show-field="name"
|
||||
value-field="id"
|
||||
ng-model="$ctrl.data.townFk"
|
||||
ng-model="$ctrl.location.townFk"
|
||||
selection="$ctrl.townSelection"
|
||||
required="true">
|
||||
<append>
|
||||
<vn-icon-button
|
||||
icon="add_circle"
|
||||
vn-tooltip="New city"
|
||||
ng-click="city.open($event)"
|
||||
vn-acl="deliveryBoss"
|
||||
vn-acl-action="remove">
|
||||
</vn-icon-button>
|
||||
</append>
|
||||
</vn-autocomplete>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-autocomplete vn-one
|
||||
disabled="true"
|
||||
ng-model="$ctrl.data.provinceFk"
|
||||
ng-model="$ctrl.location.provinceFk"
|
||||
url="Provinces"
|
||||
show-field="name"
|
||||
value-field="id"
|
||||
label="Province">
|
||||
<append>
|
||||
<vn-icon-button
|
||||
icon="add_circle"
|
||||
vn-tooltip="New province"
|
||||
ng-click="province.open($event)"
|
||||
vn-acl="deliveryBoss"
|
||||
vn-acl-action="remove">
|
||||
</vn-icon-button>
|
||||
</append>
|
||||
</vn-autocomplete>
|
||||
<vn-autocomplete vn-one
|
||||
disabled="true"
|
||||
ng-model="$ctrl.data.countryFk"
|
||||
ng-model="$ctrl.location.countryFk"
|
||||
url="Countries"
|
||||
show-field="country"
|
||||
value-field="id"
|
||||
|
@ -45,6 +61,16 @@
|
|||
</tpl-body>
|
||||
<tpl-buttons>
|
||||
<input type="button" response="cancel" translate-attr="{value: 'Cancel'}"/>
|
||||
<button response="accept" translate>Save</button>
|
||||
<button id= "savePostcode" response="accept" translate>Save</button>
|
||||
</tpl-buttons>
|
||||
</vn-dialog>
|
||||
</vn-dialog>
|
||||
<!-- New province dialog -->
|
||||
<vn-geo-province
|
||||
vn-id="province"
|
||||
on-response="$ctrl.onProvinceResponse($response)">
|
||||
</vn-geo-province>
|
||||
<!-- New city dialog -->
|
||||
<vn-geo-city
|
||||
vn-id="city"
|
||||
on-response="$ctrl.onCityResponse($response)">
|
||||
</vn-geo-city>
|
|
@ -15,8 +15,9 @@ class Controller extends Component {
|
|||
const province = selection.province;
|
||||
const country = province.country;
|
||||
|
||||
this.data.provinceFk = province.id;
|
||||
this.data.countryFk = country.id;
|
||||
this.location.city = selection.name;
|
||||
this.location.provinceFk = province.id;
|
||||
this.location.countryFk = country.id;
|
||||
}
|
||||
|
||||
open() {
|
||||
|
@ -24,19 +25,35 @@ class Controller extends Component {
|
|||
}
|
||||
|
||||
onOpen() {
|
||||
this.location = {};
|
||||
this.$.postcode.focus();
|
||||
}
|
||||
|
||||
onProvinceResponse(response) {
|
||||
this.location.provinceFk = response.id;
|
||||
this.location.countryFk = response.countryFk;
|
||||
}
|
||||
|
||||
onCityResponse(response) {
|
||||
this.location.townFk = response.id;
|
||||
this.location.provinceFk = response.provinceFk;
|
||||
this.location.countryFk = response.countryFk;
|
||||
}
|
||||
|
||||
onAccept() {
|
||||
try {
|
||||
if (!this.data.code)
|
||||
if (!this.location.code)
|
||||
throw new Error(`The postcode can't be empty`);
|
||||
if (!this.data.townFk)
|
||||
if (!this.location.townFk)
|
||||
throw new Error(`The town can't be empty`);
|
||||
if (!this.location.provinceFk)
|
||||
throw new Error(`The province can't be empty`);
|
||||
if (!this.location.provinceFk)
|
||||
throw new Error(`The country can't be empty`);
|
||||
|
||||
this.$http.patch(`postcodes`, this.data).then(res => {
|
||||
this.vnApp.showMessage(this.$t('The postcode has been saved'));
|
||||
this.emit('response', {$response: res.data});
|
||||
this.$http.patch(`postcodes`, this.location).then(() => {
|
||||
this.vnApp.showMessage(this.$t('The postcode has been created. You can save the data now'));
|
||||
this.emit('response', {$response: this.location});
|
||||
});
|
||||
} catch (e) {
|
||||
this.vnApp.showError(this.$t(e.message));
|
||||
|
@ -46,7 +63,7 @@ class Controller extends Component {
|
|||
}
|
||||
}
|
||||
|
||||
ngModule.vnComponent('vnClientPostcode', {
|
||||
ngModule.vnComponent('vnGeoPostcode', {
|
||||
template: require('./index.html'),
|
||||
controller: Controller,
|
||||
bindings: {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import './index';
|
||||
|
||||
describe('Client', () => {
|
||||
describe('Component vnClientPostcode', () => {
|
||||
describe('Component vnGeoPostcode', () => {
|
||||
let controller;
|
||||
let $httpBackend;
|
||||
let $scope;
|
||||
|
@ -12,14 +12,14 @@ describe('Client', () => {
|
|||
$httpBackend = _$httpBackend_;
|
||||
$scope = $rootScope.$new();
|
||||
const $element = angular.element('<vn-dialog></vn-dialog>');
|
||||
controller = $componentController('vnClientPostcode', {$element, $scope});
|
||||
controller = $componentController('vnGeoPostcode', {$element, $scope});
|
||||
controller.client = {id: 101};
|
||||
}));
|
||||
|
||||
describe('onAccept()', () => {
|
||||
it('should perform a POST query and show a success snackbar', () => {
|
||||
let params = {townFk: 1, provinceFk: 1, countryFk: 1, code: '46460'};
|
||||
controller.data = {townFk: 1, provinceFk: 1, countryFk: 1, code: '46460'};
|
||||
controller.location = {townFk: 1, provinceFk: 1, countryFk: 1, code: '46460'};
|
||||
|
||||
jest.spyOn(controller.vnApp, 'showMessage');
|
||||
$httpBackend.expect('PATCH', `postcodes`, params).respond(200, params);
|
||||
|
@ -27,7 +27,7 @@ describe('Client', () => {
|
|||
controller.onAccept();
|
||||
$httpBackend.flush();
|
||||
|
||||
expect(controller.vnApp.showMessage).toHaveBeenCalledWith('The postcode has been saved');
|
||||
expect(controller.vnApp.showMessage).toHaveBeenCalledWith('The postcode has been created. You can save the data now');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
New postcode: Nuevo código postal
|
||||
New city: Nueva ciudad
|
||||
New province: Nueva provincia
|
||||
Please, ensure you put the correct data!: ¡Por favor, asegúrate de poner los datos correctos!
|
||||
The postcode can't be empty: El código postal no puede quedar vacío
|
||||
The town can't be empty: La población no puede quedar vacía
|
||||
The postcode has been saved: El código postal ha sido guardado
|
||||
The province can't be empty: La provincia no puede quedar vacía
|
||||
The country can't be empty: El país no puede quedar vacío
|
||||
The postcode has been created. You can save the data now: Se ha creado el código postal. Ahora puedes guardar los datos
|
||||
The city has been created: Se ha creado la ciudad
|
||||
The province has been created: Se ha creado la provincia
|
|
@ -0,0 +1,27 @@
|
|||
<vn-dialog class="edit"
|
||||
vn-id="provinceDialog"
|
||||
on-open="$ctrl.onOpen()"
|
||||
on-accept="$ctrl.onAccept()"
|
||||
message="New province">
|
||||
<tpl-body>
|
||||
<p translate>Please, ensure you put the correct data!</p>
|
||||
<vn-horizontal>
|
||||
<vn-textfield vn-one
|
||||
vn-focus
|
||||
ng-model="$ctrl.province.name"
|
||||
label="Name">
|
||||
</vn-textfield>
|
||||
<vn-autocomplete vn-one
|
||||
ng-model="$ctrl.province.countryFk"
|
||||
url="Countries"
|
||||
show-field="country"
|
||||
value-field="id"
|
||||
label="Country">
|
||||
</vn-autocomplete>
|
||||
</vn-horizontal>
|
||||
</tpl-body>
|
||||
<tpl-buttons>
|
||||
<input type="button" response="cancel" translate-attr="{value: 'Cancel'}"/>
|
||||
<button id="saveProvince" response="accept" translate>Save</button>
|
||||
</tpl-buttons>
|
||||
</vn-dialog>
|
|
@ -0,0 +1,37 @@
|
|||
import ngModule from '../../module';
|
||||
import Component from 'core/lib/component';
|
||||
|
||||
class Controller extends Component {
|
||||
open($event) {
|
||||
if ($event.defaultPrevented) return;
|
||||
|
||||
this.$.provinceDialog.show();
|
||||
$event.preventDefault();
|
||||
}
|
||||
|
||||
onAccept() {
|
||||
try {
|
||||
if (!this.province.name)
|
||||
throw new Error(`The province name can't be empty`);
|
||||
if (!this.province.countryFk)
|
||||
throw new Error(`The country can't be empty`);
|
||||
|
||||
this.$http.patch(`provinces`, this.province).then(res => {
|
||||
this.vnApp.showMessage(this.$t('The province has been created'));
|
||||
this.emit('response', {$response: res.data});
|
||||
});
|
||||
} catch (e) {
|
||||
this.vnApp.showError(this.$t(e.message));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
ngModule.vnComponent('vnGeoProvince', {
|
||||
template: require('./index.html'),
|
||||
controller: Controller,
|
||||
bindings: {
|
||||
data: '<',
|
||||
}
|
||||
});
|
|
@ -0,0 +1,34 @@
|
|||
import './index';
|
||||
|
||||
describe('Client', () => {
|
||||
describe('Component vnGeoProvince', () => {
|
||||
let controller;
|
||||
let $httpBackend;
|
||||
let $scope;
|
||||
|
||||
beforeEach(ngModule('client'));
|
||||
|
||||
beforeEach(inject(($componentController, _$httpBackend_, $rootScope) => {
|
||||
$httpBackend = _$httpBackend_;
|
||||
$scope = $rootScope.$new();
|
||||
const $element = angular.element('<vn-dialog></vn-dialog>');
|
||||
controller = $componentController('vnGeoProvince', {$element, $scope});
|
||||
controller.client = {id: 101};
|
||||
}));
|
||||
|
||||
describe('onAccept()', () => {
|
||||
it('should perform a POST query and show a success snackbar', () => {
|
||||
let params = {name: 'New Jersey', countryFk: 1};
|
||||
controller.province = {name: 'New Jersey', countryFk: 1};
|
||||
|
||||
jest.spyOn(controller.vnApp, 'showMessage');
|
||||
$httpBackend.expect('PATCH', `provinces`, params).respond(200, params);
|
||||
|
||||
controller.onAccept();
|
||||
$httpBackend.flush();
|
||||
|
||||
expect(controller.vnApp.showMessage).toHaveBeenCalledWith('The province has been created');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
|
@ -1,6 +1,6 @@
|
|||
@import "variables";
|
||||
|
||||
vn-client-postcode {
|
||||
vn-geo-postcode {
|
||||
vn-dialog {
|
||||
p {
|
||||
color: $color-alert
|
||||
|
|
|
@ -76,6 +76,7 @@ module.exports = Self => {
|
|||
companyFk, shipped, landed, isDeleted, option) => {
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
const models = Self.app.models;
|
||||
const $t = ctx.req.__; // $translate
|
||||
const isEditable = await models.Ticket.isEditable(ctx, id);
|
||||
|
||||
if (!isEditable)
|
||||
|
@ -97,40 +98,22 @@ module.exports = Self => {
|
|||
'warehouseFk', 'companyFk', 'shipped', 'landed', 'isDeleted'],
|
||||
include: [
|
||||
{
|
||||
relation: 'address',
|
||||
relation: 'client',
|
||||
scope: {
|
||||
include: {
|
||||
relation: 'observations',
|
||||
scope: {
|
||||
where: {observationTypeFk: observationTypeDelivery.id},
|
||||
include: {
|
||||
relation: 'observationType'
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
fields: 'salesPersonFk'
|
||||
}
|
||||
}]
|
||||
});
|
||||
const updatedTicket = Object.assign({}, ctx.args);
|
||||
delete updatedTicket.ctx;
|
||||
delete updatedTicket.option;
|
||||
|
||||
// Force unroute
|
||||
const hasToBeUnrouted = true;
|
||||
const propertiesChange = diff(originalTicket, updatedTicket);
|
||||
const changedProperties = diff(originalTicket, updatedTicket);
|
||||
|
||||
let logRecord = {
|
||||
originFk: id,
|
||||
userFk: userId,
|
||||
action: 'update',
|
||||
changedModel: 'Ticket',
|
||||
changedModelId: id,
|
||||
oldInstance: originalTicket,
|
||||
newInstance: propertiesChange
|
||||
};
|
||||
|
||||
let query = 'CALL vn.ticket_componentMakeUpdate(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)';
|
||||
let res = await Self.rawSql(query, [
|
||||
const query = 'CALL vn.ticket_componentMakeUpdate(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)';
|
||||
const res = await Self.rawSql(query, [
|
||||
id,
|
||||
clientFk,
|
||||
agencyModeFk,
|
||||
|
@ -155,7 +138,20 @@ module.exports = Self => {
|
|||
if (ticketObservation)
|
||||
await ticketObservation.destroy();
|
||||
|
||||
const [observation] = originalTicket.address().observations();
|
||||
const address = await models.Address.findOne({
|
||||
where: {id: addressFk},
|
||||
include: {
|
||||
relation: 'observations',
|
||||
scope: {
|
||||
where: {observationTypeFk: observationTypeDelivery.id},
|
||||
include: {
|
||||
relation: 'observationType'
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
const [observation] = address.observations();
|
||||
if (observation) {
|
||||
await models.TicketObservation.upsert({
|
||||
ticketFk: id,
|
||||
|
@ -164,7 +160,46 @@ module.exports = Self => {
|
|||
});
|
||||
}
|
||||
}
|
||||
await models.TicketLog.create(logRecord);
|
||||
|
||||
await models.TicketLog.create({
|
||||
originFk: id,
|
||||
userFk: userId,
|
||||
action: 'update',
|
||||
changedModel: 'Ticket',
|
||||
changedModelId: id,
|
||||
oldInstance: originalTicket,
|
||||
newInstance: changedProperties
|
||||
});
|
||||
|
||||
const salesPersonId = originalTicket.client().salesPersonFk;
|
||||
if (salesPersonId) {
|
||||
const origin = ctx.req.headers.origin;
|
||||
|
||||
let changesMade = '';
|
||||
for (let change in changedProperties) {
|
||||
let value = changedProperties[change];
|
||||
if (value instanceof Date) {
|
||||
value = new Intl.DateTimeFormat('es', {
|
||||
year: '2-digit',
|
||||
month: '2-digit',
|
||||
day: '2-digit',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
second: '2-digit'
|
||||
}).format(value);
|
||||
}
|
||||
|
||||
changesMade += `${change}: ${value}\r\n`;
|
||||
}
|
||||
|
||||
const message = $t('Changed this data from the ticket', {
|
||||
ticketId: id,
|
||||
ticketUrl: `${origin}/#!/ticket/${id}/summary`,
|
||||
changes: changesMade
|
||||
});
|
||||
await models.Chat.sendCheckingPresence(ctx, salesPersonId, message);
|
||||
}
|
||||
|
||||
return res;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -47,7 +47,14 @@ describe('ticket componentUpdate()', () => {
|
|||
let ctx = {
|
||||
args: {clientFk: clientID,
|
||||
agencyModeFk: agencyModeID},
|
||||
req: {accessToken: {userId: userID}}};
|
||||
req: {
|
||||
accessToken: {userId: userID},
|
||||
headers: {origin: 'http://localhost'},
|
||||
__: (value, params) => {
|
||||
return params.nickname;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
await app.models.Ticket.componentUpdate(ctx, ticketID, clientID, agencyModeID, addressID,
|
||||
zoneID, warehouseID, companyID, shipped, landed, isDeleted, option);
|
||||
|
|
|
@ -56,8 +56,16 @@ class Controller extends Component {
|
|||
set warehouseId(value) {
|
||||
if (value != this.ticket.warehouseFk) {
|
||||
this.ticket.warehouseFk = value;
|
||||
this.ticket.agencyModeFk = null;
|
||||
this.ticket.zoneFk = null;
|
||||
|
||||
this.getShipped({
|
||||
landed: this.ticket.landed,
|
||||
addressFk: this.ticket.addressFk,
|
||||
agencyModeFk: this.ticket.agencyModeFk,
|
||||
warehouseFk: value
|
||||
}).then(() => {
|
||||
if (this.zoneId == null)
|
||||
this.ticket.agencyModeFk = null;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -177,8 +185,8 @@ class Controller extends Component {
|
|||
);
|
||||
}
|
||||
|
||||
let query = `tickets/${this.ticket.id}/priceDifference`;
|
||||
let params = {
|
||||
const query = `tickets/${this.ticket.id}/priceDifference`;
|
||||
const params = {
|
||||
landed: this.ticket.landed,
|
||||
addressId: this.ticket.addressFk,
|
||||
agencyModeId: this.ticket.agencyModeFk,
|
||||
|
@ -202,9 +210,13 @@ class Controller extends Component {
|
|||
* Returns a landing date
|
||||
*/
|
||||
getLanded(params) {
|
||||
const validParams = this.shipped && this.addressId
|
||||
&& this.agencyModeId && this.warehouseId;
|
||||
if (!validParams) return this.$q.resolve();
|
||||
|
||||
this.ticket.zoneFk = null;
|
||||
const query = `Agencies/getLanded`;
|
||||
this.$http.get(query, {params}).then(res => {
|
||||
return this.$http.get(query, {params}).then(res => {
|
||||
if (res.data) {
|
||||
this.ticket.zoneFk = res.data.zoneFk;
|
||||
this.ticket.landed = res.data.landed;
|
||||
|
@ -221,9 +233,13 @@ class Controller extends Component {
|
|||
* Returns a shipment date
|
||||
*/
|
||||
getShipped(params) {
|
||||
const validParams = this.landed && this.addressId
|
||||
&& this.agencyModeId && this.warehouseId;
|
||||
if (!validParams) return this.$q.resolve();
|
||||
|
||||
this.ticket.zoneFk = null;
|
||||
const query = `Agencies/getShipped`;
|
||||
this.$http.get(query, {params}).then(res => {
|
||||
return this.$http.get(query, {params}).then(res => {
|
||||
if (res.data) {
|
||||
this.ticket.zoneFk = res.data.zoneFk;
|
||||
this.ticket.landed = params.landed;
|
||||
|
|
|
@ -323,6 +323,7 @@ describe('Ticket', () => {
|
|||
warehouseFk: 1
|
||||
};
|
||||
const serializedParams = $httpParamSerializer(params);
|
||||
controller.ticket.shipped = shipped;
|
||||
|
||||
$httpBackend.expect('GET', `Agencies/getLanded?${serializedParams}`).respond(200, expectedResult);
|
||||
controller.getLanded(params);
|
||||
|
@ -344,6 +345,7 @@ describe('Ticket', () => {
|
|||
warehouseFk: 1
|
||||
};
|
||||
const serializedParams = $httpParamSerializer(params);
|
||||
controller.ticket.landed = landed;
|
||||
|
||||
$httpBackend.expect('GET', `Agencies/getShipped?${serializedParams}`).respond(200, expectedResult);
|
||||
controller.getShipped(params);
|
||||
|
|
|
@ -37,9 +37,12 @@ module.exports = Self => {
|
|||
Self.getLanded = async(ctx, shipped, addressFk, agencyModeFk, warehouseFk) => {
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
const models = Self.app.models;
|
||||
const isProductionBoss = await models.Account.hasRole(userId, 'productionBoss');
|
||||
const roles = await models.Account.getRoles(userId);
|
||||
const canSeeExpired = roles.filter(role =>
|
||||
role == 'productionBoss' || role == 'administrative'
|
||||
);
|
||||
let showExpired = false;
|
||||
if (isProductionBoss) showExpired = true;
|
||||
if (canSeeExpired.length) showExpired = true;
|
||||
|
||||
let stmts = [];
|
||||
stmts.push(new ParameterizedSQL(
|
||||
|
|
|
@ -32,9 +32,12 @@ module.exports = Self => {
|
|||
&& where.agencyModeFk && where.warehouseFk;
|
||||
|
||||
if (filterByAvailability) {
|
||||
const isProductionBoss = await models.Account.hasRole(userId, 'productionBoss');
|
||||
const roles = await models.Account.getRoles(userId);
|
||||
const canSeeExpired = roles.filter(role =>
|
||||
role == 'productionBoss' || role == 'administrative'
|
||||
);
|
||||
let showExpired = false;
|
||||
if (isProductionBoss) showExpired = true;
|
||||
if (canSeeExpired.length) showExpired = true;
|
||||
|
||||
stmt = new ParameterizedSQL(`CALL vn.zone_getLanded(?, ?, ?, ?, ?)`, [
|
||||
where.shipped,
|
||||
|
|
|
@ -3,6 +3,7 @@ const Component = require(`${appPath}/core/component`);
|
|||
const reportHeader = new Component('report-header');
|
||||
const reportFooter = new Component('report-footer');
|
||||
const md5 = require('md5');
|
||||
const fs = require('fs-extra');
|
||||
|
||||
module.exports = {
|
||||
name: 'delivery-note',
|
||||
|
@ -24,11 +25,14 @@ module.exports = {
|
|||
},
|
||||
computed: {
|
||||
dmsPath() {
|
||||
const pathHash = md5(this.signature.id.toString()).substring(0, 3);
|
||||
const hostPath = `file:///${config.storage.root}/${pathHash}`;
|
||||
if (!this.signature) return;
|
||||
|
||||
if (this.signature && this.signature.id)
|
||||
return `${hostPath}/${this.signature.id}.png`;
|
||||
const hash = md5(this.signature.id.toString()).substring(0, 3);
|
||||
const file = `${config.storage.root}/${hash}/${this.signature.id}.png`;
|
||||
const src = fs.readFileSync(file);
|
||||
const base64 = Buffer.from(src, 'utf8').toString('base64');
|
||||
|
||||
return `data:image/png;base64, ${base64}`;
|
||||
},
|
||||
serviceTotal() {
|
||||
let total = 0.00;
|
||||
|
|
Loading…
Reference in New Issue