3448-worker_calendar-payedHolidays #846

Merged
carlosjr merged 11 commits from 3448-worker_calendar-payedHolidays into dev 2022-01-17 09:09:46 +00:00
27 changed files with 3210 additions and 24012 deletions
Showing only changes of commit e850fdaf4e - Show all commits

View File

@ -120,7 +120,7 @@ module.exports = Self => {
} }
const defaultOptions = { const defaultOptions = {
body: params form: params
}; };
if (options) Object.assign(defaultOptions, options); if (options) Object.assign(defaultOptions, options);

View File

@ -0,0 +1,5 @@
ALTER TABLE `vn`.`smsConfig` ADD apiKey varchar(50) NULL;
ALTER TABLE `vn`.`smsConfig` CHANGE `user` user__ varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL;
ALTER TABLE `vn`.`smsConfig` CHANGE password password__ varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL;
ALTER TABLE `vn`.`sms` MODIFY COLUMN statusCode smallint(9) DEFAULT 0 NULL;
ALTER TABLE `vn`.`sms` MODIFY COLUMN status varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT 'OK' NULL;

View File

@ -0,0 +1,7 @@
UPDATE `vn`.`smsConfig`
SET `uri` = 'https://api.gateway360.com/api/3.0/sms/send'
WHERE `id` = 1;
UPDATE `vn`.`smsConfig`
SET `apiKey` = '5715476da95b46d686a5a255e6459523'
WHERE `id` = 1;

View File

@ -1906,9 +1906,9 @@ INSERT INTO `postgresql`.`calendar_employee` (`business_id`, `calendar_state_id`
(1107, 1, IF(MONTH(CURDATE()) >= 1 AND DAY(CURDATE()) > 20, DATE_ADD(CURDATE(), INTERVAL -14 DAY), DATE_ADD(CURDATE(), INTERVAL 9 DAY))), (1107, 1, IF(MONTH(CURDATE()) >= 1 AND DAY(CURDATE()) > 20, DATE_ADD(CURDATE(), INTERVAL -14 DAY), DATE_ADD(CURDATE(), INTERVAL 9 DAY))),
(1107, 2, IF(MONTH(CURDATE()) >= 1 AND DAY(CURDATE()) > 20, DATE_ADD(CURDATE(), INTERVAL -15 DAY), DATE_ADD(CURDATE(), INTERVAL 7 DAY))); (1107, 2, IF(MONTH(CURDATE()) >= 1 AND DAY(CURDATE()) > 20, DATE_ADD(CURDATE(), INTERVAL -15 DAY), DATE_ADD(CURDATE(), INTERVAL 7 DAY)));
INSERT INTO `vn`.`smsConfig` (`id`, `uri`, `title`) INSERT INTO `vn`.`smsConfig` (`id`, `uri`, `title`, `apiKey`)
VALUES VALUES
('1', 'https://websms.xtratelecom.es/api_php/server.wsdl', 'Verdnatura'); ('1', 'https://api.gateway360.com/api/3.0/sms/send', 'Verdnatura', '5715476da95b46d686a5a255e6459523');
INSERT INTO `vn`.`sharingClient`(`id`, `workerFk`, `started`, `ended`, `clientFk`) INSERT INTO `vn`.`sharingClient`(`id`, `workerFk`, `started`, `ended`, `clientFk`)
VALUES VALUES

View File

@ -23,371 +23,408 @@
-moz-osx-font-smoothing: grayscale; -moz-osx-font-smoothing: grayscale;
} }
.icon-100:before { .icon-isTooLittle:before {
content: "\e976"; content: "\e91b";
} }
.icon-account:before { .icon-frozen:before {
content: "\e900"; content: "\e900";
} }
.icon-actions:before { .icon-Person:before {
content: "\e901"; content: "\e901";
} }
.icon-addperson:before { .icon-handmadeArtificial:before {
content: "\e902"; content: "\e902";
} }
.icon-agency:before { .icon-fruit:before {
content: "\e903"; content: "\e903";
} }
.icon-albaran:before { .icon-funeral:before {
content: "\e904"; content: "\e904";
} }
.icon-anonymous:before { .icon-treatments:before {
content: "\e905"; content: "\e905";
} }
.icon-apps:before { .icon-preserved:before {
content: "\e906"; content: "\e906";
} }
.icon-artificial:before { .icon-greenery:before {
content: "\e907"; content: "\e907";
} }
.icon-attach:before { .icon-plant:before {
content: "\e908"; content: "\e908";
} }
.icon-barcode:before { .icon-handmade:before {
content: "\e909"; content: "\e909";
} }
.icon-basket:before { .icon-accessory:before {
content: "\e90a"; content: "\e90a";
} }
.icon-basketadd:before { .icon-artificial:before {
content: "\e90b"; content: "\e90b";
} }
.icon-bin:before { .icon-flower:before {
content: "\e90c"; content: "\e90c";
} }
.icon-botanical:before { .icon-fixedPrice:before {
content: "\e90d"; content: "\e90d";
} }
.icon-bucket:before { .icon-addperson:before {
content: "\e90e"; content: "\e90e";
} }
.icon-buscaman:before { .icon-supplierfalse:before {
content: "\e90f"; content: "\e90f";
} }
.icon-buyrequest:before { .icon-invoice-out:before {
content: "\e910"; content: "\e910";
} }
.icon-calc_volum .path1:before { .icon-invoice-in:before {
content: "\e911"; content: "\e911";
}
.icon-invoice-in-create:before {
content: "\e912";
}
.icon-basketadd:before {
content: "\e913";
}
.icon-basket:before {
content: "\e914";
}
.icon-calc_volum .path1:before {
content: "\e915";
color: rgb(0, 0, 0); color: rgb(0, 0, 0);
} }
.icon-calc_volum .path2:before { .icon-calc_volum .path2:before {
content: "\e912"; content: "\e916";
margin-left: -1em; margin-left: -1em;
color: rgb(0, 0, 0); color: rgb(0, 0, 0);
} }
.icon-calc_volum .path3:before { .icon-calc_volum .path3:before {
content: "\e913"; content: "\e917";
margin-left: -1em; margin-left: -1em;
color: rgb(0, 0, 0); color: rgb(0, 0, 0);
} }
.icon-calc_volum .path4:before { .icon-calc_volum .path4:before {
content: "\e914"; content: "\e918";
margin-left: -1em; margin-left: -1em;
color: rgb(0, 0, 0); color: rgb(0, 0, 0);
} }
.icon-calc_volum .path5:before { .icon-calc_volum .path5:before {
content: "\e915"; content: "\e919";
margin-left: -1em; margin-left: -1em;
color: rgb(0, 0, 0); color: rgb(0, 0, 0);
} }
.icon-calc_volum .path6:before { .icon-calc_volum .path6:before {
content: "\e916"; content: "\e91a";
margin-left: -1em; margin-left: -1em;
color: rgb(255, 255, 255); color: rgb(255, 255, 255);
} }
.icon-calendar:before { .icon-deliveryprices:before {
content: "\e917";
}
.icon-catalog:before {
content: "\e918";
}
.icon-claims:before {
content: "\e919";
}
.icon-client:before {
content: "\e91a";
}
.icon-clone:before {
content: "\e91b";
}
.icon-columnadd:before {
content: "\e91c"; content: "\e91c";
} }
.icon-columndelete:before { .icon-onlinepayment:before {
content: "\e91d"; content: "\e91d";
} }
.icon-accessory:before { .icon-risk:before {
content: "\e91e"; content: "\e91e";
} }
.icon-components:before { .icon-noweb:before {
content: "\e91f"; content: "\e91f";
} }
.icon-handmade:before { .icon-no036:before {
content: "\e920"; content: "\e920";
} }
.icon-consignatarios:before { .icon-inactive:before {
content: "\e921"; content: "\e921";
} }
.icon-control:before { .icon-unavailable:before {
content: "\e922"; content: "\e922";
} }
.icon-credit:before { .icon-invoice-01:before {
content: "\e923"; content: "\e923";
} }
.icon-deletedTicket:before {
content: "\e924";
}
.icon-deleteline:before {
content: "\e925";
}
.icon-delivery:before {
content: "\e926";
}
.icon-deliveryprices:before {
content: "\e927";
}
.icon-details:before {
content: "\e928";
}
.icon-dfiscales:before {
content: "\e929";
}
.icon-doc:before {
content: "\e92a";
}
.icon-entry:before {
content: "\e92b";
}
.icon-exit:before {
content: "\e92c";
}
.icon-eye:before {
content: "\e92d";
}
.icon-fixedPrice:before {
content: "\e92e";
}
.icon-flower:before {
content: "\e92f";
}
.icon-frozen:before {
content: "\e930";
}
.icon-fruit:before {
content: "\e931";
}
.icon-funeral:before {
content: "\e932";
}
.icon-greuge:before {
content: "\e933";
}
.icon-grid:before {
content: "\e934";
}
.icon-handmadeArtificial:before {
content: "\e935";
}
.icon-headercol:before {
content: "\e936";
}
.icon-history:before {
content: "\e937";
}
.icon-disabled:before {
content: "\e938";
}
.icon-info:before {
content: "\e939";
}
.icon-inventory:before {
content: "\e93a";
}
.icon-invoice:before { .icon-invoice:before {
content: "\e93b"; content: "\e924";
} color: #5f5f5f;
.icon-invoice-in:before {
content: "\e93c";
}
.icon-invoice-in-create:before {
content: "\e93d";
}
.icon-invoice-out:before {
content: "\e93e";
}
.icon-item:before {
content: "\e93f";
}
.icon-languaje:before {
content: "\e940";
}
.icon-lines:before {
content: "\e941";
}
.icon-linesprepaired:before {
content: "\e942";
}
.icon-logout:before {
content: "\e943";
}
.icon-mana:before {
content: "\e944";
}
.icon-mandatory:before {
content: "\e945";
}
.icon-net:before {
content: "\e946";
}
.icon-niche:before {
content: "\e947";
}
.icon-no036:before {
content: "\e948";
}
.icon-notes:before {
content: "\e949";
}
.icon-noweb:before {
content: "\e94a";
}
.icon-onlinepayment:before {
content: "\e94b";
}
.icon-package:before {
content: "\e94c";
}
.icon-payment:before {
content: "\e94d";
}
.icon-pbx:before {
content: "\e94e";
}
.icon-Person:before {
content: "\e94f";
}
.icon-pets:before {
content: "\e950";
}
.icon-photo:before {
content: "\e951";
}
.icon-plant:before {
content: "\e952";
}
.icon-stowaway:before {
content: "\e953";
}
.icon-preserved:before {
content: "\e954";
}
.icon-recovery:before {
content: "\e955";
}
.icon-regentry:before {
content: "\e956";
}
.icon-reserve:before {
content: "\e957";
}
.icon-revision:before {
content: "\e958";
}
.icon-risk:before {
content: "\e959";
}
.icon-services:before {
content: "\e95a";
}
.icon-settings:before {
content: "\e95b";
}
.icon-shipment-01 .path1:before {
content: "\e95c";
color: rgb(225, 225, 225);
}
.icon-shipment-01 .path2:before {
content: "\e95d";
margin-left: -1em;
color: rgb(0, 0, 0);
}
.icon-sign:before {
content: "\e95e";
}
.icon-sms:before {
content: "\e95f";
}
.icon-solclaim:before {
content: "\e960";
}
.icon-solunion:before {
content: "\e961";
}
.icon-splitline:before {
content: "\e962";
}
.icon-splur:before {
content: "\e963";
} }
.icon-supplier:before { .icon-supplier:before {
content: "\e965"; content: "\e925";
} }
.icon-supplierfalse:before { .icon-client2:before {
content: "\e966"; content: "\e926";
} }
.icon-tags:before { .icon-supplier2:before {
content: "\e967"; content: "\e927";
} }
.icon-tax:before { .icon-client:before {
content: "\e968"; content: "\e928";
} }
.icon-thermometer:before { .icon-shipment-01:before {
content: "\e969"; content: "\e929";
color: #000;
} }
.icon-ticket:before { .icon-inventory:before {
content: "\e96a"; content: "\e92b";
}
.icon-traceability:before {
content: "\e96b";
}
.icon-transaction:before {
content: "\e96c";
}
.icon-treatments:before {
content: "\e96d";
}
.icon-unavailable:before {
content: "\e96e";
}
.icon-greenery:before {
content: "\e96f";
}
.icon-volume:before {
content: "\e970";
}
.icon-wand:before {
content: "\e971";
}
.icon-web:before {
content: "\e972";
}
.icon-wiki:before {
content: "\e973";
}
.icon-worker:before {
content: "\e974";
} }
.icon-zone:before { .icon-zone:before {
content: "\e92c";
}
.icon-wiki:before {
content: "\e92d";
}
.icon-attach:before {
content: "\e92e";
}
.icon-zone2:before {
content: "\e92f";
}
.icon-anonymous:before {
content: "\e930";
}
.icon-net:before {
content: "\e931";
}
.icon-buyrequest:before {
content: "\e932";
}
.icon-thermometer:before {
content: "\e933";
}
.icon-entry:before {
content: "\e934";
}
.icon-deletedTicket:before {
content: "\e935";
}
.icon-deliveryprices-01:before {
content: "\e936";
}
.icon-catalog:before {
content: "\e937";
}
.icon-agency:before {
content: "\e938";
}
.icon-delivery:before {
content: "\e939";
}
.icon-wand:before {
content: "\e93a";
}
.icon-buscaman:before {
content: "\e93b";
}
.icon-pbx:before {
content: "\e93c";
}
.icon-calendar:before {
content: "\e93d";
}
.icon-splitline:before {
content: "\e93e";
}
.icon-consignatarios:before {
content: "\e93f";
}
.icon-tax:before {
content: "\e940";
}
.icon-notes:before {
content: "\e941";
}
.icon-lines:before {
content: "\e942";
}
.icon-languaje:before {
content: "\e943";
}
.icon-greuge:before {
content: "\e944";
}
.icon-credit:before {
content: "\e945";
}
.icon-components:before {
content: "\e946";
}
.icon-pets:before {
content: "\e947";
}
.icon-linesprepaired:before {
content: "\e948";
}
.icon-control:before {
content: "\e949";
}
.icon-revision:before {
content: "\e94a";
}
.icon-newinvoices:before {
content: "\e94b";
}
.icon-services:before {
content: "\e94c";
}
.icon-newalbaran:before {
content: "\e94d";
}
.icon-solunion:before {
content: "\e94e";
}
.icon-stowaway:before {
content: "\e94f";
}
.icon-exit:before {
content: "\e950";
}
.icon-apps:before {
content: "\e951";
}
.icon-info:before {
content: "\e952";
}
.icon-columndelete:before {
content: "\e953";
}
.icon-columnadd:before {
content: "\e954";
}
.icon-deleteline:before {
content: "\e955";
}
.icon-item:before {
content: "\e956";
}
.icon-worker:before {
content: "\e957";
}
.icon-headercol:before {
content: "\e958";
}
.icon-reserva:before {
content: "\e959";
}
.icon-100:before {
content: "\e95a";
}
.icon-noweb1:before {
content: "\e95b";
}
.icon-settings1:before {
content: "\e95c";
}
.icon-sign:before {
content: "\e95d";
}
.icon-polizon:before {
content: "\e95e";
}
.icon-solclaim:before {
content: "\e95f";
}
.icon-actions:before {
content: "\e960";
}
.icon-details:before {
content: "\e961";
}
.icon-traceability:before {
content: "\e962";
}
.icon-claims:before {
content: "\e963";
}
.icon-regentry:before {
content: "\e964";
}
.icon-regentry-1:before {
content: "\e965";
}
.icon-transaction:before {
content: "\e966";
}
.icon-history:before {
content: "\e968";
}
.icon-entry:before {
content: "\e969";
}
.icon-mana:before {
content: "\e96a";
}
.icon-ticket:before {
content: "\e96b";
}
.icon-niche:before {
content: "\e96c";
}
.icon-tags:before {
content: "\e96d";
}
.icon-volume:before {
content: "\e96e";
}
.icon-bin:before {
content: "\e96f";
}
.icon-splur:before {
content: "\e970";
}
.icon-barcode:before {
content: "\e971";
}
.icon-botanical:before {
content: "\e972";
}
.icon-clone:before {
content: "\e973";
}
.icon-photo:before {
content: "\e974";
}
.icon-sms:before {
content: "\e975"; content: "\e975";
} }
.icon-eye:before {
content: "\e976";
}
.icon-doc:before {
content: "\e977";
}
.icon-package:before {
content: "\e978";
}
.icon-settings:before {
content: "\e979";
}
.icon-bucket:before {
content: "\e97a";
color: #000;
}
.icon-mandatory:before {
content: "\e97b";
}
.icon-recovery:before {
content: "\e97c";
}
.icon-payment:before {
content: "\e97e";
}
.icon-invoices:before {
content: "\e97f";
color: #000;
}
.icon-grid:before {
content: "\e980";
}
.icon-logout:before {
content: "\e981";
}
.icon-web:before {
content: "\e982";
}
.icon-albaran:before {
content: "\e983";
}
.icon-dfiscales:before {
content: "\e984";
}

Binary file not shown.

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 162 KiB

After

Width:  |  Height:  |  Size: 162 KiB

View File

@ -96,7 +96,7 @@
"This postcode already exists": "Este código postal ya existe", "This postcode already exists": "Este código postal ya existe",
"Concept cannot be blank": "El concepto no puede quedar en blanco", "Concept cannot be blank": "El concepto no puede quedar en blanco",
"File doesn't exists": "El archivo no existe", "File doesn't exists": "El archivo no existe",
"You don't have privileges to change the zone": "No tienes permisos para cambiar la zona", "You don't have privileges to change the zone or for these parameters there are more than one shipping options, talk to agencies": "No tienes permisos para cambiar la zona o para esos parámetros hay más de una opción de envío, hable con las agencias",
"This ticket is already on weekly tickets": "Este ticket ya está en tickets programados", "This ticket is already on weekly tickets": "Este ticket ya está en tickets programados",
"Ticket id cannot be blank": "El id de ticket no puede quedar en blanco", "Ticket id cannot be blank": "El id de ticket no puede quedar en blanco",
"Weekday cannot be blank": "El día de la semana no puede quedar en blanco", "Weekday cannot be blank": "El día de la semana no puede quedar en blanco",
@ -215,5 +215,6 @@
"You can't create a claim from a ticket delivered more than seven days ago": "No puedes crear una reclamación de un ticket entregado hace más de siete días", "You can't create a claim from a ticket delivered more than seven days ago": "No puedes crear una reclamación de un ticket entregado hace más de siete días",
"The worker has hours recorded that day": "El trabajador tiene horas fichadas ese día", "The worker has hours recorded that day": "El trabajador tiene horas fichadas ese día",
"The worker has a marked absence that day": "El trabajador tiene marcada una ausencia ese día", "The worker has a marked absence that day": "El trabajador tiene marcada una ausencia ese día",
"You can not modify is pay method checked": "No se puede modificar el campo método de pago validado" "You can not modify is pay method checked": "No se puede modificar el campo método de pago validado",
} "Can't transfer claimed sales": "No puedes transferir lineas reclamadas"
}

View File

@ -1,5 +1,4 @@
const soap = require('soap'); const got = require('got');
const xmlParser = require('xml2js').parseString;
const UserError = require('vn-loopback/util/user-error'); const UserError = require('vn-loopback/util/user-error');
module.exports = Self => { module.exports = Self => {
@ -35,57 +34,48 @@ module.exports = Self => {
Self.send = async(ctx, destinationFk, destination, message) => { Self.send = async(ctx, destinationFk, destination, message) => {
const userId = ctx.req.accessToken.userId; const userId = ctx.req.accessToken.userId;
const smsConfig = await Self.app.models.SmsConfig.findOne(); const smsConfig = await Self.app.models.SmsConfig.findOne();
const soapClient = await soap.createClientAsync(smsConfig.uri);
if (destination.length == 9) {
const spainPrefix = '0034';
destination = spainPrefix + destination;
}
const params = { const params = {
user: smsConfig.user, api_key: smsConfig.apiKey,
pass: smsConfig.password, messages: [{
src: smsConfig.title, from: smsConfig.title,
dst: destination, to: destination,
msg: message text: message
}]
}; };
let xmlResponse; let response;
let xmlResult;
let xmlParsed;
let status;
try { try {
if (process.env.NODE_ENV !== 'production') { if (process.env.NODE_ENV !== 'production')
status = { params.fake = 1;
codigo: [200],
descripcion: ['Fake response'] const jsonTest = {
}; json: params
} else { };
[xmlResponse] = await soapClient.sendSMSAsync(params); response = await got.post(smsConfig.uri, jsonTest).json();
xmlResult = xmlResponse.result.$value;
xmlParsed = await new Promise((resolve, reject) => {
xmlParser(xmlResult, (err, result) => {
if (err)
reject(err);
resolve(result);
});
});
[status] = xmlParsed['xtratelecom-sms-response'].sms;
}
} catch (e) { } catch (e) {
console.error(e); console.error(e);
} }
const statusCode = status.codigo[0]; const [result] = response.result;
const statusDescription = status.descripcion[0]; const error = result.error_id;
const newSms = { const newSms = {
senderFk: userId, senderFk: userId,
destinationFk: destinationFk || null, destinationFk: destinationFk || null,
destination: destination, destination: destination,
message: message, message: message,
statusCode: statusCode, status: error
status: statusDescription
}; };
const sms = await Self.create(newSms); const sms = await Self.create(newSms);
if (statusCode != 200) if (error)
throw new UserError(`We weren't able to send this SMS`); throw new UserError(`We weren't able to send this SMS`);
return sms; return sms;

View File

@ -1,14 +1,10 @@
const app = require('vn-loopback/server/server'); const app = require('vn-loopback/server/server');
const soap = require('soap');
describe('sms send()', () => { describe('sms send()', () => {
it('should return the expected message and status code', async() => { it('should not return status error', async() => {
const code = 200; const ctx = {req: {accessToken: {userId: 1}}};
spyOn(soap, 'createClientAsync').and.returnValue('a so fake client'); const result = await app.models.Sms.send(ctx, 1105, '123456789', 'My SMS Body');
let ctx = {req: {accessToken: {userId: 1}}};
let result = await app.models.Sms.send(ctx, 1105, 'destination', 'My SMS Body');
expect(result.statusCode).toEqual(code); expect(result.status).toBeUndefined();
expect(result.status).toContain('Fake response');
}); });
}); });

View File

@ -284,7 +284,7 @@ module.exports = Self => {
replyTo: worker.email replyTo: worker.email
}; };
await got.get(`${origin}/api/email/payment-update`, { await got.get(`${origin}/api/email/payment-update`, {
query: params searchParams: params
}); });
} }

View File

@ -16,10 +16,7 @@
"uri": { "uri": {
"type": "String" "type": "String"
}, },
"user": { "apiKey": {
"type": "String"
},
"password": {
"type": "String" "type": "String"
}, },
"title": { "title": {

View File

@ -26,8 +26,7 @@
"required": true "required": true
}, },
"statusCode": { "statusCode": {
"type": "Number", "type": "Number"
"required": true
}, },
"status": { "status": {
"type": "String" "type": "String"

View File

@ -58,7 +58,7 @@ module.exports = Self => {
}, myOptions); }, myOptions);
const response = got.stream(`${origin}/api/report/invoice`, { const response = got.stream(`${origin}/api/report/invoice`, {
query: { searchParams: {
authorization: auth.id, authorization: auth.id,
invoiceId: id invoiceId: id
} }

View File

@ -5,6 +5,7 @@ Search tickets: Buscar tickets
Delete selected elements: Eliminar los elementos seleccionados Delete selected elements: Eliminar los elementos seleccionados
All the selected elements will be deleted. Are you sure you want to continue?: Todos los elementos seleccionados serán eliminados. ¿Seguro que quieres continuar? All the selected elements will be deleted. Are you sure you want to continue?: Todos los elementos seleccionados serán eliminados. ¿Seguro que quieres continuar?
Component lack: Faltan componentes Component lack: Faltan componentes
Ticket too little: Ticket demasiado pequeño
Minimize/Maximize: Minimizar/Maximizar Minimize/Maximize: Minimizar/Maximizar
Problems: Problemas Problems: Problemas
Theoretical: Teórica Theoretical: Teórica

View File

@ -122,6 +122,12 @@
class="bright" class="bright"
icon="icon-components"> icon="icon-components">
</vn-icon> </vn-icon>
<vn-icon
ng-show="::ticket.isTooLittle"
translate-attr="{title: 'Ticket too little'}"
class="bright"
icon="icon-isTooLittle">
</vn-icon>
</td> </td>
<td> <td>
<span <span

View File

@ -10,7 +10,12 @@
], ],
"card": [] "card": []
}, },
"keybindings": [], "keybindings": [
{
"key": "m",
"state": "monitor.index"
}
],
"routes": [ "routes": [
{ {
"url": "/monitor", "url": "/monitor",

View File

@ -15,6 +15,12 @@
{"state": "order.card.line", "icon": "icon-lines"} {"state": "order.card.line", "icon": "icon-lines"}
] ]
}, },
"keybindings": [
{
"key": "o",
"state": "order.index"
}
],
"routes": [ "routes": [
{ {
"url": "/order", "url": "/order",

View File

@ -112,10 +112,19 @@ module.exports = Self => {
const isProductionBoss = await models.Account.hasRole(userId, 'productionBoss', myOptions); const isProductionBoss = await models.Account.hasRole(userId, 'productionBoss', myOptions);
if (!isProductionBoss) { if (!isProductionBoss) {
const zoneShipped = await models.Agency.getShipped(args.landed, args.addressFk, args.agencyModeFk, args.warehouseFk, myOptions); const zoneShipped = await models.Agency.getShipped(
args.landed,
args.addressFk,
args.agencyModeFk,
args.warehouseFk,
myOptions);
if (!zoneShipped || zoneShipped.zoneFk != args.zoneFk) if (!zoneShipped || zoneShipped.zoneFk != args.zoneFk) {
throw new UserError(`You don't have privileges to change the zone`); const error = `You don't have privileges to change the zone or
for these parameters there are more than one shipping options, talk to agencies`;
throw new UserError(error);
}
} }
const originalTicket = await models.Ticket.findOne({ const originalTicket = await models.Ticket.findOne({

View File

@ -81,8 +81,12 @@ module.exports = Self => {
args.warehouseId, args.warehouseId,
myOptions); myOptions);
if (!zoneShipped || zoneShipped.zoneFk != args.zoneId) if (!zoneShipped || zoneShipped.zoneFk != args.zoneId) {
throw new UserError(`You don't have privileges to change the zone`); const error = `You don't have privileges to change the zone or
for these parameters there are more than one shipping options, talk to agencies`;
throw new UserError(error);
}
} }
const items = await models.Sale.find({ const items = await models.Sale.find({

View File

@ -58,13 +58,63 @@ describe('sale transferSales()', () => {
expect(error.message).toEqual(`The sales of the receiver ticket can't be modified`); expect(error.message).toEqual(`The sales of the receiver ticket can't be modified`);
}); });
it('should transfer the sales from one ticket to a new one then send them back and delete the created ticket', async() => { it('should throw an error if any of the sales has a claim', async() => {
const tx = await models.Ticket.beginTransaction({});
let error;
try {
const options = {transaction: tx};
const ticketId = 11;
const receiverTicketId = null;
const sales = await models.Ticket.getSales(ticketId, options);
await models.Ticket.transferSales(ctx, ticketId, receiverTicketId, sales, options);
await tx.rollback();
} catch (e) {
await tx.rollback();
error = e;
}
expect(error.message).toEqual(`Can't transfer claimed sales`);
});
it('should be able to transfer claimed sales if the role is claimManager', async() => {
const tx = await models.Ticket.beginTransaction({});
let error;
try {
const options = {transaction: tx};
const claimManagerId = 72;
const myActiveCtx = {
accessToken: {userId: claimManagerId},
};
const myCtx = {req: myActiveCtx};
const ticketId = 11;
const receiverTicketId = null;
const sales = await models.Ticket.getSales(ticketId, options);
await models.Ticket.transferSales(myCtx, ticketId, receiverTicketId, sales, options);
await tx.rollback();
} catch (e) {
await tx.rollback();
error = e;
}
expect(error).toBeUndefined();
});
it('should transfer the sales from a ticket to a new one', async() => {
const tx = await models.Ticket.beginTransaction({}); const tx = await models.Ticket.beginTransaction({});
try { try {
const options = {transaction: tx}; const options = {transaction: tx};
const formerTicketId = 11; const formerTicketId = 22;
let createdTicketId = undefined; let createdTicketId = undefined;
let formerTicketSales = await models.Ticket.getSales(formerTicketId, options); let formerTicketSales = await models.Ticket.getSales(formerTicketId, options);
@ -77,23 +127,11 @@ describe('sale transferSales()', () => {
createdTicketId = createdTicket.id; createdTicketId = createdTicket.id;
formerTicketSales = await models.Ticket.getSales(formerTicketId, options); formerTicketSales = await models.Ticket.getSales(formerTicketId, options);
createdTicketSales = await models.Ticket.getSales(createdTicketId, options); let createdTicketSales = await models.Ticket.getSales(createdTicketId, options);
expect(formerTicketSales.length).toEqual(0); expect(formerTicketSales.length).toEqual(0);
expect(createdTicketSales.length).toEqual(2); expect(createdTicketSales.length).toEqual(2);
await models.Ticket.transferSales(
ctx, createdTicketId, formerTicketId, createdTicketSales, options);
formerTicketSales = await models.Ticket.getSales(formerTicketId, options);
createdTicketSales = await models.Ticket.getSales(createdTicketId, options);
createdTicket = await models.Ticket.findById(createdTicketId, null, options);
expect(createdTicket.isDeleted).toBeTruthy();
expect(formerTicketSales.length).toEqual(2);
expect(createdTicketSales.length).toEqual(0);
await tx.rollback(); await tx.rollback();
} catch (e) { } catch (e) {
await tx.rollback(); await tx.rollback();
@ -109,10 +147,9 @@ describe('sale transferSales()', () => {
try { try {
const options = {transaction: tx}; const options = {transaction: tx};
const currentTicket = await models.Ticket.findById(11, null, options); const currentTicketId = 22;
const currentTicketSales = await models.Ticket.getSales(currentTicket.id, options); const currentTicketSales = await models.Ticket.getSales(currentTicketId, options);
const currentTicketId = currentTicket.id;
const receiverTicketId = undefined; const receiverTicketId = undefined;
currentTicketSales[0].quantity = 99; currentTicketSales[0].quantity = 99;
@ -135,7 +172,7 @@ describe('sale transferSales()', () => {
try { try {
const options = {transaction: tx}; const options = {transaction: tx};
const formerTicketId = 11; const formerTicketId = 22;
let createdTicketId = undefined; let createdTicketId = undefined;
let formerTicketSales = await models.Ticket.getSales(formerTicketId, options); let formerTicketSales = await models.Ticket.getSales(formerTicketId, options);
@ -143,7 +180,7 @@ describe('sale transferSales()', () => {
const completeSaleId = formerTicketSales[1].id; const completeSaleId = formerTicketSales[1].id;
let partialSaleTotalQuantity = formerTicketSales[0].quantity; let partialSaleTotalQuantity = formerTicketSales[0].quantity;
expect(partialSaleTotalQuantity).toEqual(15); expect(partialSaleTotalQuantity).toEqual(30);
formerTicketSales[0].quantity = 1; formerTicketSales[0].quantity = 1;

View File

@ -75,6 +75,13 @@ module.exports = Self => {
for (const sale of originalSales) for (const sale of originalSales)
map.set(sale.id, sale); map.set(sale.id, sale);
const saleIds = sales.map(sale => sale.id);
const isClaimManager = await models.Account.hasRole(userId, 'claimManager');
const hasClaimedSales = await models.ClaimBeginning.findOne({where: {saleFk: {inq: saleIds}}});
if (hasClaimedSales && !isClaimManager)
throw new UserError(`Can't transfer claimed sales`);
for (const sale of sales) { for (const sale of sales) {
const originalSale = map.get(sale.id); const originalSale = map.get(sale.id);
const originalSaleData = { // <-- Loopback modifies original instance on save const originalSaleData = { // <-- Loopback modifies original instance on save

View File

@ -24,6 +24,12 @@
{"state": "worker.card.workerLog", "icon": "history"} {"state": "worker.card.workerLog", "icon": "history"}
] ]
}, },
"keybindings": [
{
"key": "w",
"state": "worker.index"
}
],
"routes": [ "routes": [
{ {
"url": "/worker", "url": "/worker",

26129
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -15,7 +15,7 @@
"bmp-js": "^0.1.0", "bmp-js": "^0.1.0",
"compression": "^1.7.3", "compression": "^1.7.3",
"fs-extra": "^5.0.0", "fs-extra": "^5.0.0",
"got": "^6.7.1", "got": "^10.7.0",
"helmet": "^3.21.2", "helmet": "^3.21.2",
"i18n": "^0.8.4", "i18n": "^0.8.4",
"image-type": "^4.1.0", "image-type": "^4.1.0",