Merge branch 'dev' into 5063-item-module-doPhoto
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
commit
ec73b512fc
|
@ -8,13 +8,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
## [2304.01] - 2023-02-09
|
## [2304.01] - 2023-02-09
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
-
|
- (Rutas) Al descargar varias facturas se comprime en un zip
|
||||||
|
- (Trabajadores -> Nuevo trabajador) Nueva sección
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
-
|
- (Entradas -> Compras) Cambiados los campos "Precio Grouping/Packing" por "PVP" y "Precio" por "Coste"
|
||||||
|
- (Artículos -> Últimas entradas) Cambiados los campos "P.P.U." y "P.P.P." por "PVP"
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
-
|
- (Artículos -> Etiquetas) Permite intercambiar la relevancia entre dos etiquetas.
|
||||||
|
- (Tickets -> Añadir pago) Eliminado "null" en las referencias
|
||||||
|
|
||||||
## [2302.01] - 2023-01-26
|
## [2302.01] - 2023-01-26
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||||
|
VALUES
|
||||||
|
('Tag', 'onSubmit', 'WRITE', 'ALLOW', 'ROLE', 'employee');
|
|
@ -0,0 +1,24 @@
|
||||||
|
UPDATE `salix`.`ACL`
|
||||||
|
SET accessType='READ'
|
||||||
|
WHERE model='Worker'
|
||||||
|
AND property='*'
|
||||||
|
AND accessType='*'
|
||||||
|
AND permission='ALLOW'
|
||||||
|
AND principalType='ROLE'
|
||||||
|
AND principalId='employee';
|
||||||
|
|
||||||
|
|
||||||
|
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||||
|
VALUES
|
||||||
|
('Worker', 'updateAttributes', 'WRITE', 'ALLOW', 'ROLE', 'hr'),
|
||||||
|
('Worker', 'createAbsence', '*', 'ALLOW', 'ROLE', 'employee'),
|
||||||
|
('Worker', 'updateAbsence', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
|
||||||
|
('Worker', 'deleteAbsence', '*', 'ALLOW', 'ROLE', 'employee'),
|
||||||
|
('Worker', 'new', 'WRITE', 'ALLOW', 'ROLE', 'hr'),
|
||||||
|
('Role', '*', 'READ', 'ALLOW', 'ROLE', 'hr');
|
||||||
|
|
||||||
|
ALTER TABLE `vn`.`workerConfig` ADD roleFk int(10) unsigned NOT NULL COMMENT 'Rol por defecto al dar de alta un trabajador nuevo';
|
||||||
|
UPDATE `vn`.`workerConfig`
|
||||||
|
SET roleFk = 1
|
||||||
|
WHERE id = 1;
|
||||||
|
|
|
@ -2629,7 +2629,7 @@ INSERT INTO `vn`.`machineWorker` (`workerFk`, `machineFk`, `inTimed`, `outTimed`
|
||||||
|
|
||||||
INSERT INTO `vn`.`zoneExclusion` (`id`, `zoneFk`, `dated`, `created`, `userFk`)
|
INSERT INTO `vn`.`zoneExclusion` (`id`, `zoneFk`, `dated`, `created`, `userFk`)
|
||||||
VALUES
|
VALUES
|
||||||
(1, 1, DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=7, 7, 14) - DAYOFWEEK(util.VN_CURDATE())) DAY), util.VN_CURDATE(), 100),
|
(1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL (IF(DAYOFWEEK(util.VN_CURDATE())<=7, 7, 14) - DAYOFWEEK(util.VN_CURDATE())) DAY), util.VN_CURDATE(), 100),
|
||||||
(2, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL (IF(DAYOFWEEK(util.VN_CURDATE())<=8, 8, 15) - DAYOFWEEK(util.VN_CURDATE())) DAY), util.VN_CURDATE(), 100);
|
(2, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL (IF(DAYOFWEEK(util.VN_CURDATE())<=8, 8, 15) - DAYOFWEEK(util.VN_CURDATE())) DAY), util.VN_CURDATE(), 100);
|
||||||
|
|
||||||
INSERT INTO `vn`.`zoneExclusionGeo` (`zoneExclusionFk`, `geoFk`)
|
INSERT INTO `vn`.`zoneExclusionGeo` (`zoneExclusionFk`, `geoFk`)
|
||||||
|
@ -2751,10 +2751,14 @@ INSERT INTO `vn`.`mdbApp` (`app`, `baselineBranchFk`, `userFk`, `locked`)
|
||||||
VALUES
|
VALUES
|
||||||
('foo', 'master', NULL, NULL),
|
('foo', 'master', NULL, NULL),
|
||||||
('bar', 'test', 9, util.VN_NOW());
|
('bar', 'test', 9, util.VN_NOW());
|
||||||
INSERT INTO `vn`.`ticketLog` (`id`, `originFk`, `userFk`, `action`, `changedModel`, `oldInstance`, `newInstance`, `changedModelId`)
|
|
||||||
VALUES
|
|
||||||
(1, 1, 9, 'insert', 'Ticket', '{}', '{"clientFk":1, "nickname": "Bat cave"}', 1);
|
|
||||||
|
|
||||||
|
INSERT INTO `vn`.`profileType` (`id`, `name`)
|
||||||
|
VALUES
|
||||||
|
(1, 'working');
|
||||||
|
|
||||||
|
INSERT INTO `vn`.`newWorkerConfig` (`id`, `street`, `provinceFk`, `companyFk`, `profileTypeFk`, `roleFk`)
|
||||||
|
VALUES
|
||||||
|
(1, 'S/ ', 1, 442, 1, 1);
|
||||||
|
|
||||||
INSERT INTO `salix`.`url` (`appName`, `environment`, `url`)
|
INSERT INTO `salix`.`url` (`appName`, `environment`, `url`)
|
||||||
VALUES
|
VALUES
|
||||||
|
@ -2765,3 +2769,7 @@ INSERT INTO `vn`.`payDemDetail` (`id`, `detail`)
|
||||||
VALUES
|
VALUES
|
||||||
(1, 1);
|
(1, 1);
|
||||||
|
|
||||||
|
INSERT INTO `vn`.`workerConfig` (`id`, `businessUpdated`, `roleFk`)
|
||||||
|
VALUES
|
||||||
|
(1, NULL, 1);
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,7 @@ export default {
|
||||||
deleteAccount: '.vn-menu [name="deleteUser"]',
|
deleteAccount: '.vn-menu [name="deleteUser"]',
|
||||||
setPassword: '.vn-menu [name="setPassword"]',
|
setPassword: '.vn-menu [name="setPassword"]',
|
||||||
activateAccount: '.vn-menu [name="enableAccount"]',
|
activateAccount: '.vn-menu [name="enableAccount"]',
|
||||||
|
disableAccount: '.vn-menu [name="disableAccount"]',
|
||||||
activateUser: '.vn-menu [name="activateUser"]',
|
activateUser: '.vn-menu [name="activateUser"]',
|
||||||
deactivateUser: '.vn-menu [name="deactivateUser"]',
|
deactivateUser: '.vn-menu [name="deactivateUser"]',
|
||||||
newPassword: 'vn-textfield[ng-model="$ctrl.newPassword"]',
|
newPassword: 'vn-textfield[ng-model="$ctrl.newPassword"]',
|
||||||
|
@ -969,6 +970,7 @@ export default {
|
||||||
confirmButton: '.vn-confirm.shown button[response="accept"]'
|
confirmButton: '.vn-confirm.shown button[response="accept"]'
|
||||||
},
|
},
|
||||||
workerSummary: {
|
workerSummary: {
|
||||||
|
summaryIcon: 'vn-worker-descriptor a[title="Go to module summary"]',
|
||||||
header: 'vn-worker-summary h5',
|
header: 'vn-worker-summary h5',
|
||||||
id: 'vn-worker-summary vn-one:nth-child(1) > vn-label-value:nth-child(3) > section > span',
|
id: 'vn-worker-summary vn-one:nth-child(1) > vn-label-value:nth-child(3) > section > span',
|
||||||
email: 'vn-worker-summary vn-one:nth-child(1) > vn-label-value:nth-child(4) > section > span',
|
email: 'vn-worker-summary vn-one:nth-child(1) > vn-label-value:nth-child(4) > section > span',
|
||||||
|
@ -1021,6 +1023,25 @@ export default {
|
||||||
furlough: 'vn-worker-calendar > vn-side-menu [name="absenceTypes"] > vn-chip:nth-child(4)',
|
furlough: 'vn-worker-calendar > vn-side-menu [name="absenceTypes"] > vn-chip:nth-child(4)',
|
||||||
halfFurlough: 'vn-worker-calendar > vn-side-menu [name="absenceTypes"] > vn-chip:nth-child(5)',
|
halfFurlough: 'vn-worker-calendar > vn-side-menu [name="absenceTypes"] > vn-chip:nth-child(5)',
|
||||||
},
|
},
|
||||||
|
workerCreate: {
|
||||||
|
newWorkerButton: 'vn-worker-index a[ui-sref="worker.create"]',
|
||||||
|
firstname: 'vn-worker-create vn-textfield[ng-model="$ctrl.worker.firstName"]',
|
||||||
|
lastname: 'vn-worker-create vn-textfield[ng-model="$ctrl.worker.lastNames"]',
|
||||||
|
birth: 'vn-worker-create vn-date-picker[ng-model="$ctrl.worker.birth"]',
|
||||||
|
fi: 'vn-worker-create vn-textfield[ng-model="$ctrl.worker.fi"]',
|
||||||
|
code: 'vn-worker-create vn-textfield[ng-model="$ctrl.worker.code"]',
|
||||||
|
phone: 'vn-worker-create vn-textfield[ng-model="$ctrl.worker.phone"]',
|
||||||
|
city: 'vn-worker-create vn-textfield[ng-model="$ctrl.worker.city"]',
|
||||||
|
postcode: 'vn-worker-create vn-datalist[ng-model="$ctrl.worker.postcode"]',
|
||||||
|
street: 'vn-worker-create vn-textfield[ng-model="$ctrl.worker.street"]',
|
||||||
|
user: 'vn-worker-create vn-textfield[ng-model="$ctrl.worker.name"]',
|
||||||
|
email: 'vn-worker-create vn-textfield[ng-model="$ctrl.worker.email"]',
|
||||||
|
boss: 'vn-worker-create vn-autocomplete[ng-model="$ctrl.worker.bossFk"]',
|
||||||
|
role: 'vn-worker-create vn-autocomplete[ng-model="$ctrl.worker.roleFk"]',
|
||||||
|
iban: 'vn-worker-create vn-textfield[ng-model="$ctrl.worker.iban"]',
|
||||||
|
switft: 'vn-worker-create vn-autocomplete[ng-model="$ctrl.worker.bankEntityFk"]',
|
||||||
|
createButton: 'vn-worker-create vn-submit[label="Create"]',
|
||||||
|
},
|
||||||
invoiceOutIndex: {
|
invoiceOutIndex: {
|
||||||
topbarSearch: 'vn-searchbar',
|
topbarSearch: 'vn-searchbar',
|
||||||
searchResult: 'vn-invoice-out-index vn-card > vn-table > div > vn-tbody > a.vn-tr',
|
searchResult: 'vn-invoice-out-index vn-card > vn-table > div > vn-tbody > a.vn-tr',
|
||||||
|
|
|
@ -23,6 +23,7 @@ describe('Worker time control path', () => {
|
||||||
|
|
||||||
it('should go to the next month, go to current month and go 1 month in the past', async() => {
|
it('should go to the next month, go to current month and go 1 month in the past', async() => {
|
||||||
let date = new Date();
|
let date = new Date();
|
||||||
|
date.setDate(1);
|
||||||
date.setMonth(date.getMonth() + 1);
|
date.setMonth(date.getMonth() + 1);
|
||||||
let month = date.toLocaleString('default', {month: 'long'});
|
let month = date.toLocaleString('default', {month: 'long'});
|
||||||
|
|
||||||
|
@ -32,6 +33,7 @@ describe('Worker time control path', () => {
|
||||||
expect(result).toContain(month);
|
expect(result).toContain(month);
|
||||||
|
|
||||||
date = new Date();
|
date = new Date();
|
||||||
|
date.setDate(1);
|
||||||
month = date.toLocaleString('default', {month: 'long'});
|
month = date.toLocaleString('default', {month: 'long'});
|
||||||
|
|
||||||
await page.click(selectors.workerTimeControl.previousMonthButton);
|
await page.click(selectors.workerTimeControl.previousMonthButton);
|
||||||
|
@ -40,6 +42,7 @@ describe('Worker time control path', () => {
|
||||||
expect(result).toContain(month);
|
expect(result).toContain(month);
|
||||||
|
|
||||||
date = new Date();
|
date = new Date();
|
||||||
|
date.setDate(1);
|
||||||
date.setMonth(date.getMonth() - 1);
|
date.setMonth(date.getMonth() - 1);
|
||||||
const timestamp = Math.round(date.getTime() / 1000);
|
const timestamp = Math.round(date.getTime() / 1000);
|
||||||
month = date.toLocaleString('default', {month: 'long'});
|
month = date.toLocaleString('default', {month: 'long'});
|
||||||
|
|
|
@ -0,0 +1,74 @@
|
||||||
|
import selectors from '../../helpers/selectors.js';
|
||||||
|
import getBrowser from '../../helpers/puppeteer';
|
||||||
|
|
||||||
|
describe('Worker create path', () => {
|
||||||
|
let browser;
|
||||||
|
let page;
|
||||||
|
let newWorker;
|
||||||
|
beforeAll(async() => {
|
||||||
|
browser = await getBrowser();
|
||||||
|
page = browser.page;
|
||||||
|
await page.loginAndModule('hr', 'worker');
|
||||||
|
await page.waitToClick(selectors.workerCreate.newWorkerButton);
|
||||||
|
await page.waitForState('worker.create');
|
||||||
|
});
|
||||||
|
|
||||||
|
afterAll(async() => {
|
||||||
|
await browser.close();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should insert default data', async() => {
|
||||||
|
await page.write(selectors.workerCreate.firstname, 'Victor');
|
||||||
|
await page.write(selectors.workerCreate.lastname, 'Von Doom');
|
||||||
|
await page.write(selectors.workerCreate.fi, '78457139E');
|
||||||
|
await page.write(selectors.workerCreate.phone, '12356789');
|
||||||
|
await page.write(selectors.workerCreate.postcode, '46680');
|
||||||
|
await page.write(selectors.workerCreate.street, 'S/ Doomstadt');
|
||||||
|
await page.write(selectors.workerCreate.email, 'doctorDoom@marvel.com');
|
||||||
|
await page.write(selectors.workerCreate.iban, 'ES9121000418450200051332');
|
||||||
|
await page.autocompleteSearch(selectors.workerCreate.switft, 'BBKKESMMMMM');
|
||||||
|
|
||||||
|
// should check for autocompleted worker code and worker user name
|
||||||
|
const workerCode = await page
|
||||||
|
.waitToGetProperty(selectors.workerCreate.code, 'value');
|
||||||
|
|
||||||
|
newWorker = await page
|
||||||
|
.waitToGetProperty(selectors.workerCreate.user, 'value');
|
||||||
|
|
||||||
|
expect(workerCode).toEqual('VVD');
|
||||||
|
expect(newWorker).toContain('victorvd');
|
||||||
|
|
||||||
|
// should fail if necessary data is void
|
||||||
|
await page.waitToClick(selectors.workerCreate.createButton);
|
||||||
|
let message = await page.waitForSnackbar();
|
||||||
|
|
||||||
|
expect(message.text).toContain('is a required argument');
|
||||||
|
|
||||||
|
// should create a new worker and go to worker basic data'
|
||||||
|
await page.pickDate(selectors.workerCreate.birth, new Date(1962, 8, 5));
|
||||||
|
await page.autocompleteSearch(selectors.workerCreate.boss, 'deliveryBoss');
|
||||||
|
await page.waitToClick(selectors.workerCreate.createButton);
|
||||||
|
message = await page.waitForSnackbar();
|
||||||
|
await page.waitForState('worker.card.basicData');
|
||||||
|
|
||||||
|
expect(message.text).toContain('Data saved!');
|
||||||
|
|
||||||
|
// 'rollback'
|
||||||
|
await page.loginAndModule('sysadmin', 'account');
|
||||||
|
await page.accessToSearchResult(newWorker);
|
||||||
|
|
||||||
|
await page.waitToClick(selectors.accountDescriptor.menuButton);
|
||||||
|
await page.waitToClick(selectors.accountDescriptor.deactivateUser);
|
||||||
|
await page.waitToClick(selectors.accountDescriptor.acceptButton);
|
||||||
|
message = await page.waitForSnackbar();
|
||||||
|
|
||||||
|
expect(message.text).toContain('User deactivated!');
|
||||||
|
|
||||||
|
await page.waitToClick(selectors.accountDescriptor.menuButton);
|
||||||
|
await page.waitToClick(selectors.accountDescriptor.disableAccount);
|
||||||
|
await page.waitToClick(selectors.accountDescriptor.acceptButton);
|
||||||
|
message = await page.waitForSnackbar();
|
||||||
|
|
||||||
|
expect(message.text).toContain('Account disabled!');
|
||||||
|
});
|
||||||
|
});
|
|
@ -87,6 +87,7 @@ ngModule.vnComponent('vnButtonMenu', {
|
||||||
selectFields: '<?',
|
selectFields: '<?',
|
||||||
initialData: '<?',
|
initialData: '<?',
|
||||||
showFilter: '<?',
|
showFilter: '<?',
|
||||||
|
fields: '<?',
|
||||||
field: '=?',
|
field: '=?',
|
||||||
url: '@?',
|
url: '@?',
|
||||||
data: '<?',
|
data: '<?',
|
||||||
|
|
|
@ -147,28 +147,17 @@ export default class CrudModel extends ModelProxy {
|
||||||
this.moreRows = null;
|
this.moreRows = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
getChanges() {
|
||||||
* Saves current changes on the server.
|
if (!this.isChanged) return null;
|
||||||
*
|
|
||||||
* @return {Promise} The save request promise
|
|
||||||
*/
|
|
||||||
save() {
|
|
||||||
if (!this.isChanged)
|
|
||||||
return this.$q.resolve();
|
|
||||||
|
|
||||||
let deletes = [];
|
const deletes = [];
|
||||||
let updates = [];
|
const updates = [];
|
||||||
let creates = [];
|
const creates = [];
|
||||||
let orgDeletes = [];
|
|
||||||
let orgUpdates = [];
|
|
||||||
let orgCreates = [];
|
|
||||||
|
|
||||||
let pk = this.primaryKey;
|
const pk = this.primaryKey;
|
||||||
|
|
||||||
for (let row of this.removed) {
|
for (let row of this.removed)
|
||||||
deletes.push(row.$orgRow[pk]);
|
deletes.push(row.$orgRow[pk]);
|
||||||
orgDeletes.push(row);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (let row of this.data) {
|
for (let row of this.data) {
|
||||||
if (row.$isNew) {
|
if (row.$isNew) {
|
||||||
|
@ -178,7 +167,6 @@ export default class CrudModel extends ModelProxy {
|
||||||
data[prop] = row[prop];
|
data[prop] = row[prop];
|
||||||
}
|
}
|
||||||
creates.push(row);
|
creates.push(row);
|
||||||
orgCreates.push(row);
|
|
||||||
} else if (row.$oldData) {
|
} else if (row.$oldData) {
|
||||||
let data = {};
|
let data = {};
|
||||||
for (let prop in row.$oldData)
|
for (let prop in row.$oldData)
|
||||||
|
@ -187,28 +175,38 @@ export default class CrudModel extends ModelProxy {
|
||||||
data,
|
data,
|
||||||
where: {[pk]: row.$orgRow[pk]}
|
where: {[pk]: row.$orgRow[pk]}
|
||||||
});
|
});
|
||||||
orgUpdates.push(row);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let changes = {deletes, updates, creates};
|
const changes = {deletes, updates, creates};
|
||||||
|
|
||||||
for (let prop in changes) {
|
for (let prop in changes) {
|
||||||
if (changes[prop].length === 0)
|
if (changes[prop].length === 0)
|
||||||
changes[prop] = undefined;
|
changes[prop] = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!changes)
|
return changes;
|
||||||
return this.$q.resolve();
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Saves current changes on the server.
|
||||||
|
*
|
||||||
|
* @return {Promise} The save request promise
|
||||||
|
*/
|
||||||
|
save() {
|
||||||
|
const pk = this.primaryKey;
|
||||||
|
const changes = this.getChanges();
|
||||||
|
if (!changes) return this.$q.resolve();
|
||||||
|
|
||||||
|
const creates = changes.creates || [];
|
||||||
let url = this.saveUrl ? this.saveUrl : `${this._url}/crud`;
|
let url = this.saveUrl ? this.saveUrl : `${this._url}/crud`;
|
||||||
return this.$http.post(url, changes)
|
return this.$http.post(url, changes)
|
||||||
.then(res => {
|
.then(res => {
|
||||||
const created = res.data;
|
const created = res.data;
|
||||||
|
|
||||||
// Apply new data to created instances
|
// Apply new data to created instances
|
||||||
for (let i = 0; i < orgCreates.length; i++) {
|
for (let i = 0; i < creates.length; i++) {
|
||||||
const row = orgCreates[i];
|
const row = creates[i];
|
||||||
row[pk] = created[i][pk];
|
row[pk] = created[i][pk];
|
||||||
|
|
||||||
for (let prop in row) {
|
for (let prop in row) {
|
||||||
|
|
|
@ -42,6 +42,7 @@ vn-log {
|
||||||
& > td.after,
|
& > td.after,
|
||||||
& > th.after {
|
& > th.after {
|
||||||
width: 40%;
|
width: 40%;
|
||||||
|
white-space: pre-line;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
Reset password: Restrablecer contraseña
|
Reset password: Restrablecer contraseña
|
||||||
New password: Nueva contraseña
|
New password: Nueva contraseña
|
||||||
Repeat password: Repetir contraseñaç
|
Repeat password: Repetir contraseña
|
||||||
Password changed!: ¡Contraseña cambiada!
|
Password changed!: ¡Contraseña cambiada!
|
||||||
Password requirements: >
|
Password requirements: >
|
||||||
La contraseña debe tener al menos {{ length }} caracteres de longitud,
|
La contraseña debe tener al menos {{ length }} caracteres de longitud,
|
||||||
|
|
|
@ -142,10 +142,13 @@
|
||||||
"You don't own the role and you can't assign it to another user": "You don't own the role and you can't assign it to another user",
|
"You don't own the role and you can't assign it to another user": "You don't own the role and you can't assign it to another user",
|
||||||
"Email verify": "Email verify",
|
"Email verify": "Email verify",
|
||||||
"Ticket merged": "Ticket [{{originId}}]({{{originFullPath}}}) ({{{originDated}}}) merged with [{{destinationId}}]({{{destinationFullPath}}}) ({{{destinationDated}}})",
|
"Ticket merged": "Ticket [{{originId}}]({{{originFullPath}}}) ({{{originDated}}}) merged with [{{destinationId}}]({{{destinationFullPath}}}) ({{{destinationDated}}})",
|
||||||
"Sale(s) blocked, please contact production": "Sale(s) blocked, please contact production",
|
|
||||||
"App locked": "App locked by user {{userId}}",
|
"App locked": "App locked by user {{userId}}",
|
||||||
"The sales of the receiver ticket can't be modified": "The sales of the receiver ticket can't be modified",
|
"The sales of the receiver ticket can't be modified": "The sales of the receiver ticket can't be modified",
|
||||||
"Receipt's bank was not found": "Receipt's bank was not found",
|
"Receipt's bank was not found": "Receipt's bank was not found",
|
||||||
"This receipt was not compensated": "This receipt was not compensated",
|
"This receipt was not compensated": "This receipt was not compensated",
|
||||||
"Client's email was not found": "Client's email was not found"
|
"Client's email was not found": "Client's email was not found",
|
||||||
|
"It is not possible to modify tracked sales": "It is not possible to modify tracked sales",
|
||||||
|
"It is not possible to modify sales that their articles are from Floramondo": "It is not possible to modify sales that their articles are from Floramondo",
|
||||||
|
"It is not possible to modify cloned sales": "It is not possible to modify cloned sales",
|
||||||
|
"Valid priorities: 1,2,3": "Valid priorities: 1,2,3"
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,7 +84,6 @@
|
||||||
"The current ticket can't be modified": "El ticket actual no puede ser modificado",
|
"The current ticket can't be modified": "El ticket actual no puede ser modificado",
|
||||||
"The current claim can't be modified": "La reclamación actual no puede ser modificada",
|
"The current claim can't be modified": "La reclamación actual no puede ser modificada",
|
||||||
"The sales of this ticket can't be modified": "Las lineas de este ticket no pueden ser modificadas",
|
"The sales of this ticket can't be modified": "Las lineas de este ticket no pueden ser modificadas",
|
||||||
"Sale(s) blocked, contact production": "Linea(s) bloqueada(s), contacte con produccion",
|
|
||||||
"Please select at least one sale": "Por favor selecciona al menos una linea",
|
"Please select at least one sale": "Por favor selecciona al menos una linea",
|
||||||
"All sales must belong to the same ticket": "Todas las lineas deben pertenecer al mismo ticket",
|
"All sales must belong to the same ticket": "Todas las lineas deben pertenecer al mismo ticket",
|
||||||
"NO_ZONE_FOR_THIS_PARAMETERS": "Para este día no hay ninguna zona configurada",
|
"NO_ZONE_FOR_THIS_PARAMETERS": "Para este día no hay ninguna zona configurada",
|
||||||
|
@ -252,9 +251,15 @@
|
||||||
"Receipt's bank was not found": "No se encontró el banco del recibo",
|
"Receipt's bank was not found": "No se encontró el banco del recibo",
|
||||||
"This receipt was not compensated": "Este recibo no ha sido compensado",
|
"This receipt was not compensated": "Este recibo no ha sido compensado",
|
||||||
"Client's email was not found": "No se encontró el email del cliente",
|
"Client's email was not found": "No se encontró el email del cliente",
|
||||||
|
"This worker code already exists": "Este codigo de trabajador ya existe",
|
||||||
|
"This personal mail already exists": "Este correo personal ya existe",
|
||||||
|
"This worker already exists": "Este trabajador ya existe",
|
||||||
"App name does not exist": "El nombre de aplicación no es válido",
|
"App name does not exist": "El nombre de aplicación no es válido",
|
||||||
"Try again": "Vuelve a intentarlo",
|
"Try again": "Vuelve a intentarlo",
|
||||||
"Aplicación bloqueada por el usuario 9": "Aplicación bloqueada por el usuario 9",
|
"Aplicación bloqueada por el usuario 9": "Aplicación bloqueada por el usuario 9",
|
||||||
"Failed to upload file": "Error al subir archivo",
|
"Failed to upload file": "Error al subir archivo",
|
||||||
"The DOCUWARE PDF document does not exists": "The DOCUWARE PDF document does not exists"
|
"The DOCUWARE PDF document does not exists": "El documento PDF Docuware no existe",
|
||||||
|
"It is not possible to modify tracked sales": "No es posible modificar líneas de pedido que se hayan empezado a preparar",
|
||||||
|
"It is not possible to modify sales that their articles are from Floramondo": "No es posible modificar líneas de pedido cuyos artículos sean de Floramondo",
|
||||||
|
"It is not possible to modify cloned sales": "No es posible modificar líneas de pedido clonadas"
|
||||||
}
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
module.exports = class NotFoundError extends Error {
|
||||||
|
constructor(message = 'Not found', code = 'NOT_FOUND', ...translateArgs) {
|
||||||
|
super(message);
|
||||||
|
this.name = 'NotFoundError';
|
||||||
|
this.statusCode = 404;
|
||||||
|
this.code = code;
|
||||||
|
this.translateArgs = translateArgs;
|
||||||
|
}
|
||||||
|
};
|
|
@ -19,10 +19,26 @@ class Controller extends ModuleCard {
|
||||||
}, {
|
}, {
|
||||||
relation: 'ticket',
|
relation: 'ticket',
|
||||||
scope: {
|
scope: {
|
||||||
fields: ['zoneFk'],
|
fields: ['zoneFk', 'addressFk'],
|
||||||
include: {
|
include: [
|
||||||
relation: 'zone'
|
{
|
||||||
|
relation: 'zone',
|
||||||
|
scope: {
|
||||||
|
fields: ['name']
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
relation: 'address',
|
||||||
|
scope: {
|
||||||
|
fields: ['provinceFk'],
|
||||||
|
include: {
|
||||||
|
relation: 'province',
|
||||||
|
scope: {
|
||||||
|
fields: ['name']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}]
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
relation: 'claimState',
|
relation: 'claimState',
|
||||||
|
|
|
@ -55,9 +55,13 @@
|
||||||
<span
|
<span
|
||||||
ng-click="zoneDescriptor.show($event, $ctrl.claim.ticket.zoneFk)"
|
ng-click="zoneDescriptor.show($event, $ctrl.claim.ticket.zoneFk)"
|
||||||
class="link">
|
class="link">
|
||||||
{{$ctrl.claim.ticket.zoneFk}}
|
{{$ctrl.claim.ticket.zone.name}}
|
||||||
</span>
|
</span>
|
||||||
</vn-label-value>
|
</vn-label-value>
|
||||||
|
<vn-label-value
|
||||||
|
label="Province"
|
||||||
|
value="{{$ctrl.claim.ticket.address.province.name}}">
|
||||||
|
</vn-label-value>
|
||||||
<vn-label-value
|
<vn-label-value
|
||||||
label="Ticket">
|
label="Ticket">
|
||||||
<span
|
<span
|
||||||
|
|
|
@ -59,13 +59,11 @@ class Controller extends Dialog {
|
||||||
|
|
||||||
if (value) {
|
if (value) {
|
||||||
const accountingType = value.accountingType;
|
const accountingType = value.accountingType;
|
||||||
if (this.originalDescription) {
|
if (accountingType.receiptDescription != null) {
|
||||||
this.receipt.description =
|
this.receipt.description = accountingType.receiptDescription;
|
||||||
`${accountingType && accountingType.receiptDescription}, ${this.originalDescription}`;
|
if (this.originalDescription) this.receipt.description += `, ${this.originalDescription}`;
|
||||||
} else {
|
} else if (this.originalDescription)
|
||||||
this.receipt.description =
|
this.receipt.description = this.originalDescription;
|
||||||
`${accountingType && accountingType.receiptDescription}`;
|
|
||||||
}
|
|
||||||
this.maxAmount = accountingType && accountingType.maxAmount;
|
this.maxAmount = accountingType && accountingType.maxAmount;
|
||||||
|
|
||||||
this.receipt.payed = new Date();
|
this.receipt.payed = new Date();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
Edit buy(s): Editar compra(s)
|
Edit buy(s): Editar compra(s)
|
||||||
Buying value: Precio
|
Buying value: Coste
|
||||||
Freight value: Porte
|
Freight value: Porte
|
||||||
Commission value: Comisión
|
Commission value: Comisión
|
||||||
Package value: Embalaje
|
Package value: Embalaje
|
||||||
|
|
|
@ -114,8 +114,7 @@
|
||||||
<th translate center field="grouping">Grouping</th>
|
<th translate center field="grouping">Grouping</th>
|
||||||
<th translate center field="buyingValue">Buying value</th>
|
<th translate center field="buyingValue">Buying value</th>
|
||||||
<th translate center field="price3">Import</th>
|
<th translate center field="price3">Import</th>
|
||||||
<th translate center expand field="price2">Grouping price</th>
|
<th translate center expand field="price">PVP</th>
|
||||||
<th translate center expand field="price3">Packing price</th>
|
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody ng-repeat="line in buys">
|
<tbody ng-repeat="line in buys">
|
||||||
|
@ -136,8 +135,7 @@
|
||||||
</vn-td>
|
</vn-td>
|
||||||
<td center title="{{::line.buyingValue | currency: 'EUR':2}}">{{::line.buyingValue | currency: 'EUR':2}}</td>
|
<td center title="{{::line.buyingValue | currency: 'EUR':2}}">{{::line.buyingValue | currency: 'EUR':2}}</td>
|
||||||
<td center title="{{::line.quantity * line.buyingValue | currency: 'EUR':2}}">{{::line.quantity * line.buyingValue | currency: 'EUR':2}}</td>
|
<td center title="{{::line.quantity * line.buyingValue | currency: 'EUR':2}}">{{::line.quantity * line.buyingValue | currency: 'EUR':2}}</td>
|
||||||
<td center title="{{::line.price2 | currency: 'EUR':2}}">{{::line.price2 | currency: 'EUR':2}}</td>
|
<td center title="Grouping / Packing">{{::line.price2 | currency: 'EUR':2 | dashIfEmpty}} / {{::line.price3 | currency: 'EUR':2 | dashIfEmpty}}</td>
|
||||||
<td center title="{{::line.price3 | currency: 'EUR':2}}">{{::line.price3 | currency: 'EUR':2}}</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="dark-row">
|
<tr class="dark-row">
|
||||||
<td shrink>
|
<td shrink>
|
||||||
|
|
|
@ -0,0 +1,81 @@
|
||||||
|
|
||||||
|
module.exports = function(Self) {
|
||||||
|
Self.remoteMethodCtx('onSubmit', {
|
||||||
|
description: 'Save model changes',
|
||||||
|
accessType: 'WRITE',
|
||||||
|
accepts: [
|
||||||
|
{
|
||||||
|
arg: 'creates',
|
||||||
|
type: ['object'],
|
||||||
|
description: 'The itemTags records to create'
|
||||||
|
}, {
|
||||||
|
arg: 'deletes',
|
||||||
|
type: ['number'],
|
||||||
|
description: 'The itemTags ids to delete'
|
||||||
|
}, {
|
||||||
|
arg: 'updates',
|
||||||
|
type: ['object'],
|
||||||
|
description: 'The itemTags records to update'
|
||||||
|
}, {
|
||||||
|
arg: 'maxPriority',
|
||||||
|
type: 'number',
|
||||||
|
description: 'The maxPriority value'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
returns: {
|
||||||
|
root: true,
|
||||||
|
type: 'object'
|
||||||
|
},
|
||||||
|
http: {
|
||||||
|
verb: 'PATCH',
|
||||||
|
path: '/onSubmit'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Self.onSubmit = async(ctx, options) => {
|
||||||
|
const models = Self.app.models;
|
||||||
|
const args = ctx.args;
|
||||||
|
let tx;
|
||||||
|
const myOptions = {};
|
||||||
|
|
||||||
|
if (typeof options == 'object')
|
||||||
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
|
if (!myOptions.transaction) {
|
||||||
|
tx = await Self.beginTransaction({});
|
||||||
|
myOptions.transaction = tx;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (args.deletes) {
|
||||||
|
for (const itemTagId of args.deletes)
|
||||||
|
await models.ItemTag.destroyById(itemTagId, myOptions);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.updates) {
|
||||||
|
for (const row of args.updates) {
|
||||||
|
if (row.data.priority) {
|
||||||
|
const itemTag = await models.ItemTag.findById(row.where.id, null, myOptions);
|
||||||
|
await itemTag.updateAttributes({
|
||||||
|
priority: row.data.priority + args.maxPriority
|
||||||
|
}, myOptions);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (const row of args.updates) {
|
||||||
|
const itemTag = await models.ItemTag.findById(row.where.id, null, myOptions);
|
||||||
|
await itemTag.updateAttributes(row.data, myOptions);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.creates) {
|
||||||
|
for (const itemTag of args.creates)
|
||||||
|
await models.ItemTag.create(itemTag, myOptions);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tx) await tx.commit();
|
||||||
|
} catch (e) {
|
||||||
|
if (tx) await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
|
@ -0,0 +1,96 @@
|
||||||
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
|
describe('tag onSubmit()', () => {
|
||||||
|
it('should delete a tag', async() => {
|
||||||
|
const tx = await models.Item.beginTransaction({});
|
||||||
|
const options = {transaction: tx};
|
||||||
|
|
||||||
|
try {
|
||||||
|
const deletes = [40];
|
||||||
|
const ctx = {
|
||||||
|
args: {
|
||||||
|
deletes: deletes
|
||||||
|
}
|
||||||
|
};
|
||||||
|
await models.Tag.onSubmit(ctx, options);
|
||||||
|
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should update a tag', async() => {
|
||||||
|
const tx = await models.Item.beginTransaction({});
|
||||||
|
const options = {transaction: tx};
|
||||||
|
|
||||||
|
try {
|
||||||
|
const updates = [{data: {value: 'Container Test'}, where: {id: 36}}];
|
||||||
|
const ctx = {
|
||||||
|
args: {
|
||||||
|
updates: updates
|
||||||
|
}
|
||||||
|
};
|
||||||
|
await models.Tag.onSubmit(ctx, options);
|
||||||
|
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create a tag', async() => {
|
||||||
|
const tx = await models.Item.beginTransaction({});
|
||||||
|
const options = {transaction: tx};
|
||||||
|
|
||||||
|
try {
|
||||||
|
const creates = [{
|
||||||
|
'itemFk': '6',
|
||||||
|
'priority': 8,
|
||||||
|
'$orgIndex': null,
|
||||||
|
'$oldData': null,
|
||||||
|
'$isNew': true,
|
||||||
|
'tagFk': 3,
|
||||||
|
'value': 'madera'
|
||||||
|
}];
|
||||||
|
const ctx = {
|
||||||
|
args: {
|
||||||
|
creates: creates
|
||||||
|
}
|
||||||
|
};
|
||||||
|
await models.Tag.onSubmit(ctx, options);
|
||||||
|
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should swap priority for two tags', async() => {
|
||||||
|
const tx = await models.Item.beginTransaction({});
|
||||||
|
const options = {transaction: tx};
|
||||||
|
|
||||||
|
try {
|
||||||
|
const updates = [
|
||||||
|
{data: {priority: 2}, where: {id: 36}},
|
||||||
|
{data: {priority: 1}, where: {id: 37}}
|
||||||
|
];
|
||||||
|
const ctx = {
|
||||||
|
args: {
|
||||||
|
updates: updates,
|
||||||
|
maxPriority: 7,
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
await models.Tag.onSubmit(ctx, options);
|
||||||
|
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
|
@ -1,3 +1,4 @@
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
require('../methods/tag/filterValue')(Self);
|
require('../methods/tag/filterValue')(Self);
|
||||||
|
require('../methods/tag/onSubmit')(Self);
|
||||||
};
|
};
|
||||||
|
|
|
@ -35,8 +35,7 @@
|
||||||
<vn-th field="warehouseFk">Warehouse</vn-th>
|
<vn-th field="warehouseFk">Warehouse</vn-th>
|
||||||
<vn-th field="landed">Landed</vn-th>
|
<vn-th field="landed">Landed</vn-th>
|
||||||
<vn-th number>Entry</vn-th>
|
<vn-th number>Entry</vn-th>
|
||||||
<vn-th number vn-tooltip="Price Per Unit">P.P.U</vn-th>
|
<vn-th vn-tooltip="Grouping / Packing">PVP</vn-th>
|
||||||
<vn-th number vn-tooltip="Price Per Package">P.P.P</vn-th>
|
|
||||||
<vn-th number class="expendable">Label</vn-th>
|
<vn-th number class="expendable">Label</vn-th>
|
||||||
<vn-th number>Packing</vn-th>
|
<vn-th number>Packing</vn-th>
|
||||||
<vn-th number>Grouping</vn-th>
|
<vn-th number>Grouping</vn-th>
|
||||||
|
@ -65,8 +64,9 @@
|
||||||
{{::entry.entryFk | dashIfEmpty}}
|
{{::entry.entryFk | dashIfEmpty}}
|
||||||
</span>
|
</span>
|
||||||
</vn-td>
|
</vn-td>
|
||||||
<vn-td number>{{::entry.price2 | dashIfEmpty}}</vn-td>
|
<vn-td title="{{::entry.price2 | currency: 'EUR':2 | dashIfEmpty}} / {{::entry.price3 | currency: 'EUR':2 | dashIfEmpty}}">
|
||||||
<vn-td number>{{::entry.price3 | dashIfEmpty}}</vn-td>
|
{{::entry.price2 | currency: 'EUR':2 | dashIfEmpty}} / {{::entry.price3 | currency: 'EUR':2 | dashIfEmpty}}
|
||||||
|
</vn-td>
|
||||||
<vn-td number class="expendable">{{entry.stickers | dashIfEmpty}}</vn-td>
|
<vn-td number class="expendable">{{entry.stickers | dashIfEmpty}}</vn-td>
|
||||||
<vn-td number>
|
<vn-td number>
|
||||||
<vn-chip translate-attr="{title: 'Packing'}" ng-class="{'message': entry.groupingMode == 2}">
|
<vn-chip translate-attr="{title: 'Packing'}" ng-class="{'message': entry.groupingMode == 2}">
|
||||||
|
@ -84,11 +84,11 @@
|
||||||
class="expendable">
|
class="expendable">
|
||||||
<span
|
<span
|
||||||
vn-tooltip="
|
vn-tooltip="
|
||||||
{{::$ctrl.$t('Cost')}}: {{::entry.buyingValue| dashIfEmpty}}<br>
|
{{::$ctrl.$t('Cost')}}: {{::entry.buyingValue | currency: 'EUR':2 | dashIfEmpty}}<br>
|
||||||
{{::$ctrl.$t('Package')}}: {{::entry.packageValue| dashIfEmpty}}<br>
|
{{::$ctrl.$t('Package')}}: {{::entry.packageValue | currency: 'EUR':2 | dashIfEmpty}}<br>
|
||||||
{{::$ctrl.$t('Freight')}}: {{::entry.freightValue| dashIfEmpty}}<br>
|
{{::$ctrl.$t('Freight')}}: {{::entry.freightValue | currency: 'EUR':2 | dashIfEmpty}}<br>
|
||||||
{{::$ctrl.$t('Comission')}}: {{::entry.comissionValue| dashIfEmpty}}">
|
{{::$ctrl.$t('Comission')}}: {{::entry.comissionValue | currency: 'EUR':2 | dashIfEmpty}}">
|
||||||
{{::entry.cost | dashIfEmpty}}
|
{{::entry.cost | currency: 'EUR':2 | dashIfEmpty}}
|
||||||
</span>
|
</span>
|
||||||
</vn-td>
|
</vn-td>
|
||||||
<vn-td number>{{::entry.weight | dashIfEmpty}}</vn-td>
|
<vn-td number>{{::entry.weight | dashIfEmpty}}</vn-td>
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
data="tags"
|
data="tags"
|
||||||
auto-load="true">
|
auto-load="true">
|
||||||
</vn-crud-model>
|
</vn-crud-model>
|
||||||
<form name="form" ng-submit="$ctrl.onSubmit()" class="vn-w-md">
|
<form name="form" class="vn-w-md">
|
||||||
<vn-card class="vn-pa-lg">
|
<vn-card class="vn-pa-lg">
|
||||||
<vn-horizontal ng-repeat="itemTag in $ctrl.itemTags">
|
<vn-horizontal ng-repeat="itemTag in $ctrl.itemTags">
|
||||||
<vn-autocomplete vn-two vn-id="tag" vn-focus
|
<vn-autocomplete vn-two vn-id="tag" vn-focus
|
||||||
|
@ -74,6 +74,7 @@
|
||||||
</vn-card>
|
</vn-card>
|
||||||
<vn-button-bar>
|
<vn-button-bar>
|
||||||
<vn-submit
|
<vn-submit
|
||||||
|
ng-click="$ctrl.onSubmit()"
|
||||||
disabled="!watcher.dataChanged()"
|
disabled="!watcher.dataChanged()"
|
||||||
label="Save">
|
label="Save">
|
||||||
</vn-submit>
|
</vn-submit>
|
||||||
|
|
|
@ -29,11 +29,17 @@ class Controller extends Section {
|
||||||
}
|
}
|
||||||
|
|
||||||
onSubmit() {
|
onSubmit() {
|
||||||
this.$.watcher.check();
|
const changes = this.$.model.getChanges();
|
||||||
this.$.model.save().then(() => {
|
const data = {
|
||||||
|
creates: changes.creates,
|
||||||
|
deletes: changes.deletes,
|
||||||
|
updates: changes.updates,
|
||||||
|
maxPriority: this.getHighestPriority()
|
||||||
|
};
|
||||||
|
this.$http.patch(`Tags/onSubmit`, data).then(() => {
|
||||||
|
this.$.model.refresh();
|
||||||
this.$.watcher.notifySaved();
|
this.$.watcher.notifySaved();
|
||||||
this.$.watcher.updateOriginalData();
|
this.$.watcher.updateOriginalData();
|
||||||
this.card.reload();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -157,7 +157,7 @@ class Controller extends Section {
|
||||||
* Apply order to model
|
* Apply order to model
|
||||||
*/
|
*/
|
||||||
applyOrder() {
|
applyOrder() {
|
||||||
if (this.typeId || this.tagGroups.length > 0)
|
if (this.typeId || this.tagGroups.length > 0 || this.itemName)
|
||||||
this.$.model.addFilter(null, {orderBy: this.getOrderBy()});
|
this.$.model.addFilter(null, {orderBy: this.getOrderBy()});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,62 @@
|
||||||
|
const JSZip = require('jszip');
|
||||||
|
|
||||||
|
module.exports = Self => {
|
||||||
|
Self.remoteMethodCtx('downloadZip', {
|
||||||
|
description: 'Download a zip file with multiple routes pdfs',
|
||||||
|
accessType: 'READ',
|
||||||
|
accepts: [
|
||||||
|
{
|
||||||
|
arg: 'id',
|
||||||
|
type: 'string',
|
||||||
|
description: 'The routes ids',
|
||||||
|
}
|
||||||
|
],
|
||||||
|
returns: [
|
||||||
|
{
|
||||||
|
arg: 'body',
|
||||||
|
type: 'file',
|
||||||
|
root: true
|
||||||
|
}, {
|
||||||
|
arg: 'Content-Type',
|
||||||
|
type: 'string',
|
||||||
|
http: {target: 'header'}
|
||||||
|
}, {
|
||||||
|
arg: 'Content-Disposition',
|
||||||
|
type: 'string',
|
||||||
|
http: {target: 'header'}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
http: {
|
||||||
|
path: '/downloadZip',
|
||||||
|
verb: 'GET'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Self.downloadZip = async function(ctx, id, options) {
|
||||||
|
const models = Self.app.models;
|
||||||
|
const myOptions = {};
|
||||||
|
const zip = new JSZip();
|
||||||
|
|
||||||
|
if (typeof options == 'object')
|
||||||
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
|
const ids = id.split(',');
|
||||||
|
for (let id of ids) {
|
||||||
|
ctx.args.id = id;
|
||||||
|
const routePdf = await models.Route.driverRoutePdf(ctx, id);
|
||||||
|
const fileName = extractFileName(routePdf[2]);
|
||||||
|
const body = routePdf[0];
|
||||||
|
|
||||||
|
zip.file(fileName, body);
|
||||||
|
}
|
||||||
|
|
||||||
|
const stream = zip.generateNodeStream({streamFiles: true});
|
||||||
|
|
||||||
|
return [stream, 'application/zip', `filename="download.zip"`];
|
||||||
|
};
|
||||||
|
|
||||||
|
function extractFileName(str) {
|
||||||
|
const matches = str.match(/"(.*?)"/);
|
||||||
|
return matches ? matches[1] : str;
|
||||||
|
}
|
||||||
|
};
|
|
@ -13,6 +13,7 @@ module.exports = Self => {
|
||||||
require('../methods/route/driverRoutePdf')(Self);
|
require('../methods/route/driverRoutePdf')(Self);
|
||||||
require('../methods/route/driverRouteEmail')(Self);
|
require('../methods/route/driverRouteEmail')(Self);
|
||||||
require('../methods/route/sendSms')(Self);
|
require('../methods/route/sendSms')(Self);
|
||||||
|
require('../methods/route/downloadZip')(Self);
|
||||||
|
|
||||||
Self.validate('kmStart', validateDistance, {
|
Self.validate('kmStart', validateDistance, {
|
||||||
message: 'Distance must be lesser than 1000'
|
message: 'Distance must be lesser than 1000'
|
||||||
|
|
|
@ -34,12 +34,22 @@ export default class Controller extends Section {
|
||||||
}
|
}
|
||||||
|
|
||||||
showRouteReport() {
|
showRouteReport() {
|
||||||
const routes = [];
|
const routesIds = [];
|
||||||
for (let route of this.checked)
|
for (let route of this.checked)
|
||||||
routes.push(route.id);
|
routesIds.push(route.id);
|
||||||
const routesId = routes.join(',');
|
const stringRoutesIds = routesIds.join(',');
|
||||||
|
|
||||||
this.vnReport.show(`Routes/${routesId}/driver-route-pdf`);
|
if (this.checked.length <= 1) {
|
||||||
|
const url = `api/Routes/${stringRoutesIds}/driver-route-pdf?access_token=${this.vnToken.token}`;
|
||||||
|
window.open(url, '_blank');
|
||||||
|
} else {
|
||||||
|
const serializedParams = this.$httpParamSerializer({
|
||||||
|
access_token: this.vnToken.token,
|
||||||
|
id: stringRoutesIds
|
||||||
|
});
|
||||||
|
const url = `api/Routes/downloadZip?${serializedParams}`;
|
||||||
|
window.open(url, '_blank');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
openClonationDialog() {
|
openClonationDialog() {
|
||||||
|
|
|
@ -44,17 +44,15 @@ describe('Component vnRouteIndex', () => {
|
||||||
|
|
||||||
describe('showRouteReport()', () => {
|
describe('showRouteReport()', () => {
|
||||||
it('should call to the vnReport show method', () => {
|
it('should call to the vnReport show method', () => {
|
||||||
controller.vnReport.show = jest.fn();
|
jest.spyOn(window, 'open').mockReturnThis();
|
||||||
|
|
||||||
const data = controller.$.model.data;
|
const data = controller.$.model.data;
|
||||||
data[0].checked = true;
|
data[0].checked = true;
|
||||||
data[2].checked = true;
|
data[2].checked = true;
|
||||||
|
|
||||||
const routeIds = '1,3';
|
|
||||||
|
|
||||||
controller.showRouteReport();
|
controller.showRouteReport();
|
||||||
|
|
||||||
expect(controller.vnReport.show).toHaveBeenCalledWith(`Routes/${routeIds}/driver-route-pdf`);
|
expect(window.open).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"module": "shelving",
|
"module": "shelving",
|
||||||
"name": "Shelvings",
|
"name": "Shelvings",
|
||||||
"icon" : "contact_support",
|
"icon" : "icon-inventory",
|
||||||
"dependencies": ["worker"],
|
"dependencies": ["worker"],
|
||||||
"validations" : true,
|
"validations" : true,
|
||||||
"menus": {
|
"menus": {
|
||||||
"main": [
|
"main": [
|
||||||
{"state": "shelving.index", "icon": "contact_support"}
|
{"state": "shelving.index", "icon": "icon-inventory"}
|
||||||
],
|
],
|
||||||
"card": [
|
"card": [
|
||||||
{"state": "shelving.card.basicData", "icon": "settings"},
|
{"state": "shelving.card.basicData", "icon": "settings"},
|
||||||
|
|
|
@ -24,36 +24,42 @@
|
||||||
</vn-textfield>
|
</vn-textfield>
|
||||||
<vn-input-number
|
<vn-input-number
|
||||||
type="number"
|
type="number"
|
||||||
|
step="0.01"
|
||||||
label="Minimum M3"
|
label="Minimum M3"
|
||||||
ng-model="supplierAgencyTerm.minimumM3"
|
ng-model="supplierAgencyTerm.minimumM3"
|
||||||
rule>
|
rule>
|
||||||
</vn-input-number>
|
</vn-input-number>
|
||||||
<vn-input-number
|
<vn-input-number
|
||||||
type="number"
|
type="number"
|
||||||
|
step="0.01"
|
||||||
label="Package Price"
|
label="Package Price"
|
||||||
ng-model="supplierAgencyTerm.packagePrice"
|
ng-model="supplierAgencyTerm.packagePrice"
|
||||||
rule>
|
rule>
|
||||||
</vn-input-number>
|
</vn-input-number>
|
||||||
<vn-input-number
|
<vn-input-number
|
||||||
type="number"
|
type="number"
|
||||||
|
step="0.01"
|
||||||
label="Km Price"
|
label="Km Price"
|
||||||
ng-model="supplierAgencyTerm.kmPrice"
|
ng-model="supplierAgencyTerm.kmPrice"
|
||||||
rule>
|
rule>
|
||||||
</vn-input-number>
|
</vn-input-number>
|
||||||
<vn-input-number
|
<vn-input-number
|
||||||
type="number"
|
type="number"
|
||||||
|
step="0.01"
|
||||||
label="M3 Price"
|
label="M3 Price"
|
||||||
ng-model="supplierAgencyTerm.m3Price"
|
ng-model="supplierAgencyTerm.m3Price"
|
||||||
rule>
|
rule>
|
||||||
</vn-input-number>
|
</vn-input-number>
|
||||||
<vn-input-number
|
<vn-input-number
|
||||||
type="number"
|
type="number"
|
||||||
|
step="0.01"
|
||||||
label="Route Price"
|
label="Route Price"
|
||||||
ng-model="supplierAgencyTerm.routePrice"
|
ng-model="supplierAgencyTerm.routePrice"
|
||||||
rule>
|
rule>
|
||||||
</vn-input-number>
|
</vn-input-number>
|
||||||
<vn-input-number
|
<vn-input-number
|
||||||
type="number"
|
type="number"
|
||||||
|
step="0.01"
|
||||||
label="Minimum Km"
|
label="Minimum Km"
|
||||||
ng-model="supplierAgencyTerm.minimumKm"
|
ng-model="supplierAgencyTerm.minimumKm"
|
||||||
rule>
|
rule>
|
||||||
|
|
|
@ -36,7 +36,7 @@ module.exports = Self => {
|
||||||
st.originalQuantity,
|
st.originalQuantity,
|
||||||
st.created,
|
st.created,
|
||||||
st.workerFk,
|
st.workerFk,
|
||||||
u.nickname userNickname,
|
u.name,
|
||||||
ste.name AS state
|
ste.name AS state
|
||||||
FROM saleTracking st
|
FROM saleTracking st
|
||||||
JOIN sale s ON s.id = st.saleFk
|
JOIN sale s ON s.id = st.saleFk
|
||||||
|
@ -48,24 +48,6 @@ module.exports = Self => {
|
||||||
|
|
||||||
const trackings = await Self.rawStmt(stmt, myOptions);
|
const trackings = await Self.rawStmt(stmt, myOptions);
|
||||||
|
|
||||||
const salesFilter = {
|
|
||||||
include: [
|
|
||||||
{
|
|
||||||
relation: 'item'
|
|
||||||
}
|
|
||||||
],
|
|
||||||
where: {ticketFk: filter.where.ticketFk}
|
|
||||||
};
|
|
||||||
|
|
||||||
const sales = await Self.app.models.Sale.find(salesFilter, myOptions);
|
|
||||||
|
|
||||||
for (const tracking of trackings) {
|
|
||||||
for (const sale of sales) {
|
|
||||||
if (tracking.itemFk == sale.itemFk)
|
|
||||||
tracking.item = sale.item();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return trackings;
|
return trackings;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -56,6 +56,13 @@ module.exports = Self => {
|
||||||
const shouldEditCloned = canEditCloned || !hasSaleCloned;
|
const shouldEditCloned = canEditCloned || !hasSaleCloned;
|
||||||
const shouldEditFloramondo = canEditFloramondo || !hasSaleFloramondo;
|
const shouldEditFloramondo = canEditFloramondo || !hasSaleFloramondo;
|
||||||
|
|
||||||
return shouldEditTracked && shouldEditCloned && shouldEditFloramondo;
|
if (!shouldEditTracked)
|
||||||
|
throw new UserError('It is not possible to modify tracked sales');
|
||||||
|
if (!shouldEditCloned)
|
||||||
|
throw new UserError('It is not possible to modify cloned sales');
|
||||||
|
if (!shouldEditFloramondo)
|
||||||
|
throw new UserError('It is not possible to modify sales that their articles are from Floramondo');
|
||||||
|
|
||||||
|
return true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -43,9 +43,7 @@ module.exports = Self => {
|
||||||
try {
|
try {
|
||||||
const saleIds = sales.map(sale => sale.id);
|
const saleIds = sales.map(sale => sale.id);
|
||||||
|
|
||||||
const canEditSales = await models.Sale.canEdit(ctx, saleIds, myOptions);
|
await models.Sale.canEdit(ctx, saleIds, myOptions);
|
||||||
if (!canEditSales)
|
|
||||||
throw new UserError(`Sale(s) blocked, please contact production`);
|
|
||||||
|
|
||||||
const ticket = await models.Ticket.findById(ticketId, {
|
const ticket = await models.Ticket.findById(ticketId, {
|
||||||
include: {
|
include: {
|
||||||
|
|
|
@ -37,9 +37,7 @@ module.exports = Self => {
|
||||||
try {
|
try {
|
||||||
const salesIds = sales.map(sale => sale.id);
|
const salesIds = sales.map(sale => sale.id);
|
||||||
|
|
||||||
const canEditSale = await models.Sale.canEdit(ctx, salesIds, myOptions);
|
await models.Sale.canEdit(ctx, salesIds, myOptions);
|
||||||
if (!canEditSale)
|
|
||||||
throw new UserError(`Sale(s) blocked, please contact production`);
|
|
||||||
|
|
||||||
const query = `
|
const query = `
|
||||||
DROP TEMPORARY TABLE IF EXISTS tmp.recalculateSales;
|
DROP TEMPORARY TABLE IF EXISTS tmp.recalculateSales;
|
||||||
|
|
|
@ -51,9 +51,7 @@ module.exports = Self => {
|
||||||
try {
|
try {
|
||||||
const salesIds = sales.map(sale => sale.id);
|
const salesIds = sales.map(sale => sale.id);
|
||||||
|
|
||||||
const canEditSale = await models.Sale.canEdit(ctx, salesIds, myOptions);
|
await models.Sale.canEdit(ctx, salesIds, myOptions);
|
||||||
if (!canEditSale)
|
|
||||||
throw new UserError(`Sale(s) blocked, please contact production`);
|
|
||||||
|
|
||||||
let changesMade = '';
|
let changesMade = '';
|
||||||
const promises = [];
|
const promises = [];
|
||||||
|
|
|
@ -50,7 +50,7 @@ describe('sale canEdit()', () => {
|
||||||
|
|
||||||
it('should return false if any of the sales has a saleTracking record', async() => {
|
it('should return false if any of the sales has a saleTracking record', async() => {
|
||||||
const tx = await models.Sale.beginTransaction({});
|
const tx = await models.Sale.beginTransaction({});
|
||||||
|
let error;
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
|
@ -59,15 +59,15 @@ describe('sale canEdit()', () => {
|
||||||
|
|
||||||
const sales = [31];
|
const sales = [31];
|
||||||
|
|
||||||
const result = await models.Sale.canEdit(ctx, sales, options);
|
await models.Sale.canEdit(ctx, sales, options);
|
||||||
|
|
||||||
expect(result).toEqual(false);
|
|
||||||
|
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
throw e;
|
error = e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
expect(error).toEqual(
|
||||||
|
new Error('It is not possible to modify tracked sales'));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -75,22 +75,22 @@ describe('sale canEdit()', () => {
|
||||||
const saleCloned = [29];
|
const saleCloned = [29];
|
||||||
it('should return false if any of the sales is cloned', async() => {
|
it('should return false if any of the sales is cloned', async() => {
|
||||||
const tx = await models.Sale.beginTransaction({});
|
const tx = await models.Sale.beginTransaction({});
|
||||||
|
let error;
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
const buyerId = 35;
|
const buyerId = 35;
|
||||||
const ctx = {req: {accessToken: {userId: buyerId}}};
|
const ctx = {req: {accessToken: {userId: buyerId}}};
|
||||||
|
|
||||||
const result = await models.Sale.canEdit(ctx, saleCloned, options);
|
await models.Sale.canEdit(ctx, saleCloned, options);
|
||||||
|
|
||||||
expect(result).toEqual(false);
|
|
||||||
|
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
throw e;
|
error = e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
expect(error).toEqual(
|
||||||
|
new Error('It is not possible to modify cloned sales'));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return true if any of the sales is cloned and has the correct role', async() => {
|
it('should return true if any of the sales is cloned and has the correct role', async() => {
|
||||||
|
@ -130,7 +130,7 @@ describe('sale canEdit()', () => {
|
||||||
it('should return false if any of the sales isFloramondo', async() => {
|
it('should return false if any of the sales isFloramondo', async() => {
|
||||||
const tx = await models.Sale.beginTransaction({});
|
const tx = await models.Sale.beginTransaction({});
|
||||||
const sales = [26];
|
const sales = [26];
|
||||||
|
let error;
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
|
@ -140,15 +140,15 @@ describe('sale canEdit()', () => {
|
||||||
const saleToEdit = await models.Sale.findById(sales[0], null, options);
|
const saleToEdit = await models.Sale.findById(sales[0], null, options);
|
||||||
await saleToEdit.updateAttribute('itemFk', 9, options);
|
await saleToEdit.updateAttribute('itemFk', 9, options);
|
||||||
|
|
||||||
const result = await models.Sale.canEdit(ctx, sales, options);
|
await models.Sale.canEdit(ctx, sales, options);
|
||||||
|
|
||||||
expect(result).toEqual(false);
|
|
||||||
|
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
throw e;
|
error = e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
expect(error).toEqual(
|
||||||
|
new Error('It is not possible to modify sales that their articles are from Floramondo'));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return true if any of the sales is of isFloramondo and has the correct role', async() => {
|
it('should return true if any of the sales is of isFloramondo and has the correct role', async() => {
|
||||||
|
|
|
@ -40,10 +40,7 @@ module.exports = Self => {
|
||||||
try {
|
try {
|
||||||
const currentLine = await models.Sale.findById(id, null, myOptions);
|
const currentLine = await models.Sale.findById(id, null, myOptions);
|
||||||
|
|
||||||
const canEditSale = await models.Sale.canEdit(ctx, [id], myOptions);
|
await models.Sale.canEdit(ctx, [id], myOptions);
|
||||||
|
|
||||||
if (!canEditSale)
|
|
||||||
throw new UserError(`Sale(s) blocked, please contact production`);
|
|
||||||
|
|
||||||
const line = await currentLine.updateAttributes({concept: newConcept}, myOptions);
|
const line = await currentLine.updateAttributes({concept: newConcept}, myOptions);
|
||||||
|
|
||||||
|
|
|
@ -66,9 +66,7 @@ module.exports = Self => {
|
||||||
|
|
||||||
const sale = await models.Sale.findById(id, filter, myOptions);
|
const sale = await models.Sale.findById(id, filter, myOptions);
|
||||||
|
|
||||||
const canEditSale = await models.Sale.canEdit(ctx, [id], myOptions);
|
await models.Sale.canEdit(ctx, [id], myOptions);
|
||||||
if (!canEditSale)
|
|
||||||
throw new UserError(`Sale(s) blocked, please contact production`);
|
|
||||||
|
|
||||||
const oldPrice = sale.price;
|
const oldPrice = sale.price;
|
||||||
const userId = ctx.req.accessToken.userId;
|
const userId = ctx.req.accessToken.userId;
|
||||||
|
|
|
@ -41,9 +41,7 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const canEditSale = await models.Sale.canEdit(ctx, [id], myOptions);
|
await models.Sale.canEdit(ctx, [id], myOptions);
|
||||||
if (!canEditSale)
|
|
||||||
throw new UserError(`Sale(s) blocked, please contact production`);
|
|
||||||
|
|
||||||
const filter = {
|
const filter = {
|
||||||
include: {
|
include: {
|
||||||
|
|
|
@ -24,7 +24,7 @@ module.exports = Self => {
|
||||||
if (typeof options == 'object')
|
if (typeof options == 'object')
|
||||||
Object.assign(myOptions, options);
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
let statesList = await models.State.find({where: filter.where}, myOptions);
|
let statesList = await models.State.find(filter, myOptions);
|
||||||
const isProduction = await models.Account.hasRole(userId, 'production', myOptions);
|
const isProduction = await models.Account.hasRole(userId, 'production', myOptions);
|
||||||
const isSalesPerson = await models.Account.hasRole(userId, 'salesPerson', myOptions);
|
const isSalesPerson = await models.Account.hasRole(userId, 'salesPerson', myOptions);
|
||||||
const isAdministrative = await models.Account.hasRole(userId, 'administrative', myOptions);
|
const isAdministrative = await models.Account.hasRole(userId, 'administrative', myOptions);
|
||||||
|
|
|
@ -31,9 +31,9 @@
|
||||||
</vn-td>
|
</vn-td>
|
||||||
<vn-td number>
|
<vn-td number>
|
||||||
<span
|
<span
|
||||||
ng-click="$ctrl.showItemDescriptor($event, sale)"
|
ng-click="itemDescriptor.show($event, sale.item.id)"
|
||||||
class="link">
|
class="link">
|
||||||
{{::sale.itemFk | zeroFill:6}}
|
{{::sale.item.id}}
|
||||||
</span>
|
</span>
|
||||||
</vn-td>
|
</vn-td>
|
||||||
<vn-td vn-fetched-tags>
|
<vn-td vn-fetched-tags>
|
||||||
|
@ -96,27 +96,23 @@
|
||||||
</vn-tr>
|
</vn-tr>
|
||||||
</vn-thead>
|
</vn-thead>
|
||||||
<vn-tbody>
|
<vn-tbody>
|
||||||
<vn-tr ng-repeat="sale in saleTrackings">
|
<vn-tr ng-repeat="saleTracking in saleTrackings">
|
||||||
<vn-td number>{{::sale.quantity}}</vn-td>
|
<vn-td number>{{::saleTracking.quantity}}</vn-td>
|
||||||
<vn-td number>{{::sale.originalQuantity}}</vn-td>
|
<vn-td number>{{::saleTracking.originalQuantity}}</vn-td>
|
||||||
<vn-td expand>
|
<vn-td expand>
|
||||||
<span
|
<span
|
||||||
class="link"
|
class="link"
|
||||||
ng-click="workerDescriptor.show($event, sale.workerFk)">
|
ng-click="workerDescriptor.show($event, saleTracking.workerFk)">
|
||||||
{{::sale.userNickname | dashIfEmpty}}
|
{{::saleTracking.name | dashIfEmpty}}
|
||||||
</span>
|
</span>
|
||||||
</vn-td>
|
</vn-td>
|
||||||
<vn-td shrink>{{::sale.state}}</vn-td>
|
<vn-td shrink>{{::saleTracking.state}}</vn-td>
|
||||||
<vn-td expand>{{::sale.created | date: 'dd/MM/yyyy HH:mm'}}</vn-td>
|
<vn-td expand>{{::saleTracking.created | date: 'dd/MM/yyyy HH:mm'}}</vn-td>
|
||||||
</vn-tr>
|
</vn-tr>
|
||||||
</vn-tbody>
|
</vn-tbody>
|
||||||
</vn-table>
|
</vn-table>
|
||||||
</vn-card>
|
</vn-card>
|
||||||
</vn-data-viewer>
|
</vn-data-viewer>
|
||||||
<vn-item-descriptor-popover
|
|
||||||
vn-id="item-descriptor"
|
|
||||||
warehouse-fk="$ctrl.ticket.warehouseFk">
|
|
||||||
</vn-item-descriptor-popover>
|
|
||||||
<vn-worker-descriptor-popover
|
<vn-worker-descriptor-popover
|
||||||
vn-id="worker-descriptor">
|
vn-id="worker-descriptor">
|
||||||
</vn-worker-descriptor-popover>
|
</vn-worker-descriptor-popover>
|
||||||
|
|
|
@ -45,14 +45,14 @@ class Controller extends Section {
|
||||||
btnThree: {
|
btnThree: {
|
||||||
icon: 'icon-transaction',
|
icon: 'icon-transaction',
|
||||||
state: `item.card.diary({
|
state: `item.card.diary({
|
||||||
id: ${sale.itemFk},
|
id: ${sale.item.id},
|
||||||
warehouseFk: ${this.ticket.warehouseFk},
|
warehouseFk: ${this.ticket.warehouseFk},
|
||||||
lineFk: ${sale.id}
|
lineFk: ${sale.id}
|
||||||
})`,
|
})`,
|
||||||
tooltip: 'Item diary'
|
tooltip: 'Item diary'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
this.$.itemDescriptor.show(event.target, sale.itemFk);
|
this.$.itemDescriptor.show(event.target, sale.item.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
chipHasSaleGroupDetail(hasSaleGroupDetail) {
|
chipHasSaleGroupDetail(hasSaleGroupDetail) {
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
disabled="!$ctrl.isEditable"
|
disabled="!$ctrl.isEditable"
|
||||||
label="State"
|
label="State"
|
||||||
value-field="code"
|
value-field="code"
|
||||||
|
fields="['id', 'name', 'alertLevel', 'code']"
|
||||||
url="States/editableStates"
|
url="States/editableStates"
|
||||||
on-change="$ctrl.changeState(value)">
|
on-change="$ctrl.changeState(value)">
|
||||||
</vn-button-menu>
|
</vn-button-menu>
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
class="message"
|
class="message"
|
||||||
label="Change state"
|
label="Change state"
|
||||||
value-field="code"
|
value-field="code"
|
||||||
|
fields="['id', 'name', 'alertLevel', 'code']"
|
||||||
url="States/editableStates"
|
url="States/editableStates"
|
||||||
on-change="$ctrl.changeState(value)">
|
on-change="$ctrl.changeState(value)">
|
||||||
</vn-button-menu>
|
</vn-button-menu>
|
||||||
|
|
|
@ -0,0 +1,256 @@
|
||||||
|
/* eslint max-len: ["error", { "code": 130 }]*/
|
||||||
|
const UserError = require('vn-loopback/util/user-error');
|
||||||
|
|
||||||
|
module.exports = Self => {
|
||||||
|
Self.remoteMethodCtx('new', {
|
||||||
|
description: 'Creates a new worker and returns the id',
|
||||||
|
accessType: 'WRITE',
|
||||||
|
accepts: [
|
||||||
|
{
|
||||||
|
arg: 'fi',
|
||||||
|
type: 'string',
|
||||||
|
description: `The worker fi`,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'name',
|
||||||
|
type: 'string',
|
||||||
|
description: `The user name`,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'firstName',
|
||||||
|
type: 'string',
|
||||||
|
description: `The worker firstname`,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'lastNames',
|
||||||
|
type: 'string',
|
||||||
|
description: `The worker lastnames`,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'email',
|
||||||
|
type: 'string',
|
||||||
|
description: `The worker email`,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'street',
|
||||||
|
type: 'string',
|
||||||
|
description: `The worker address`,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'city',
|
||||||
|
type: 'string',
|
||||||
|
description: `The worker city`,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'provinceFk',
|
||||||
|
type: 'number',
|
||||||
|
description: `The worker province`,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'iban',
|
||||||
|
type: 'string',
|
||||||
|
description: `The worker iban`,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'bankEntityFk',
|
||||||
|
type: 'number',
|
||||||
|
description: `The worker bank entity`,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'companyFk',
|
||||||
|
type: 'number',
|
||||||
|
description: `The worker company`,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'postcode',
|
||||||
|
type: 'string',
|
||||||
|
description: `The worker postcode`,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'phone',
|
||||||
|
type: 'string',
|
||||||
|
description: `The worker phone`,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'code',
|
||||||
|
type: 'string',
|
||||||
|
description: `The worker code`,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'bossFk',
|
||||||
|
type: 'number',
|
||||||
|
description: `The worker boss`,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'birth',
|
||||||
|
type: 'date',
|
||||||
|
description: `The worker birth`,
|
||||||
|
required: true,
|
||||||
|
}
|
||||||
|
],
|
||||||
|
returns: {
|
||||||
|
type: 'number',
|
||||||
|
root: true,
|
||||||
|
},
|
||||||
|
http: {
|
||||||
|
path: `/new`,
|
||||||
|
verb: 'POST',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
Self.new = async(ctx, options) => {
|
||||||
|
const models = Self.app.models;
|
||||||
|
const myOptions = {};
|
||||||
|
const args = ctx.args;
|
||||||
|
|
||||||
|
let tx;
|
||||||
|
|
||||||
|
if (typeof options == 'object') Object.assign(myOptions, options);
|
||||||
|
|
||||||
|
if (!myOptions.transaction) {
|
||||||
|
tx = await Self.beginTransaction({});
|
||||||
|
myOptions.transaction = tx;
|
||||||
|
}
|
||||||
|
|
||||||
|
let client;
|
||||||
|
|
||||||
|
try {
|
||||||
|
client = await models.Client.findOne(
|
||||||
|
{
|
||||||
|
where: {fi: args.fi},
|
||||||
|
},
|
||||||
|
myOptions
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!client) {
|
||||||
|
const nickname = args.firstName.concat(' ', args.lastNames);
|
||||||
|
const workerConfig = await models.WorkerConfig.findOne({fields: ['roleFk']});
|
||||||
|
const [randomPassword] = await models.Worker.rawSql(
|
||||||
|
'SELECT account.passwordGenerate() as password;'
|
||||||
|
);
|
||||||
|
|
||||||
|
const user = await models.Account.create(
|
||||||
|
{
|
||||||
|
name: args.name,
|
||||||
|
nickname,
|
||||||
|
password: randomPassword.password,
|
||||||
|
email: args.email,
|
||||||
|
roleFk: workerConfig.roleFk,
|
||||||
|
},
|
||||||
|
myOptions
|
||||||
|
);
|
||||||
|
|
||||||
|
await models.UserAccount.create(
|
||||||
|
{
|
||||||
|
id: user.id,
|
||||||
|
},
|
||||||
|
myOptions
|
||||||
|
);
|
||||||
|
|
||||||
|
await models.Worker.rawSql(
|
||||||
|
'CALL vn.clientCreate(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
|
||||||
|
[
|
||||||
|
args.firstName,
|
||||||
|
args.lastNames,
|
||||||
|
args.fi,
|
||||||
|
args.street,
|
||||||
|
args.postalCode,
|
||||||
|
args.city,
|
||||||
|
args.provinceFk,
|
||||||
|
args.companyFk,
|
||||||
|
args.phone,
|
||||||
|
args.email,
|
||||||
|
user.id,
|
||||||
|
],
|
||||||
|
myOptions
|
||||||
|
);
|
||||||
|
|
||||||
|
const address = await models.Address.create(
|
||||||
|
{
|
||||||
|
clientFk: user.id,
|
||||||
|
street: args.street,
|
||||||
|
city: args.city,
|
||||||
|
provinceFk: args.provinceFk,
|
||||||
|
postalCode: args.postalCode,
|
||||||
|
mobile: args.phone,
|
||||||
|
nickname: nickname,
|
||||||
|
isDefaultAddress: true,
|
||||||
|
},
|
||||||
|
myOptions
|
||||||
|
);
|
||||||
|
|
||||||
|
client = await models.Client.findById(
|
||||||
|
user.id,
|
||||||
|
{fields: ['id', 'name', 'socialName', 'street', 'city', 'iban', 'bankEntityFk', 'defaultAddressFk']},
|
||||||
|
myOptions
|
||||||
|
);
|
||||||
|
|
||||||
|
await client.updateAttributes(
|
||||||
|
{
|
||||||
|
iban: args.iban,
|
||||||
|
bankEntityFk: args.bankEntityFk,
|
||||||
|
defaultAddressFk: address.id,
|
||||||
|
},
|
||||||
|
myOptions
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const user = await models.Account.findById(client.id, null, myOptions);
|
||||||
|
await user.updateAttribute('email', args.email, myOptions);
|
||||||
|
|
||||||
|
await models.Worker.rawSql(
|
||||||
|
'CALL vn.workerCreate(?, ?, ?, ?, ?, ?, ?)',
|
||||||
|
[
|
||||||
|
args.firstName,
|
||||||
|
args.lastNames,
|
||||||
|
args.code,
|
||||||
|
args.bossFk,
|
||||||
|
client.id,
|
||||||
|
args.fi,
|
||||||
|
args.birth,
|
||||||
|
],
|
||||||
|
myOptions
|
||||||
|
);
|
||||||
|
|
||||||
|
if (tx) await tx.commit();
|
||||||
|
} catch (error) {
|
||||||
|
if (tx) await tx.rollback();
|
||||||
|
const code = error.code;
|
||||||
|
const message = error.sqlMessage;
|
||||||
|
|
||||||
|
if (code === 'ER_DUP_ENTRY' && message.includes(`for key 'mail'`))
|
||||||
|
throw new UserError(`This personal mail already exists`);
|
||||||
|
|
||||||
|
if (code === 'ER_DUP_ENTRY' && message.includes(`CodigoTrabajador_UNIQUE`))
|
||||||
|
throw new UserError(`This worker code already exists`);
|
||||||
|
|
||||||
|
if (code === 'ER_DUP_ENTRY' && message.includes(`PRIMARY`))
|
||||||
|
throw new UserError(`This worker already exists`);
|
||||||
|
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
|
||||||
|
await models.user.resetPassword({
|
||||||
|
email: args.email,
|
||||||
|
emailTemplate: 'worker-welcome',
|
||||||
|
id: client.id
|
||||||
|
});
|
||||||
|
|
||||||
|
return {id: client.id};
|
||||||
|
};
|
||||||
|
};
|
|
@ -0,0 +1,139 @@
|
||||||
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
const LoopBackContext = require('loopback-context');
|
||||||
|
|
||||||
|
describe('Worker new', () => {
|
||||||
|
beforeAll(async() => {
|
||||||
|
const activeCtx = {
|
||||||
|
accessToken: {userId: 9},
|
||||||
|
http: {
|
||||||
|
req: {
|
||||||
|
headers: {origin: 'http://localhost'}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||||
|
active: activeCtx
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
const employeeId = 1;
|
||||||
|
const defaultWorker = {
|
||||||
|
fi: '78457139E',
|
||||||
|
name: 'defaultWorker',
|
||||||
|
firstName: 'default',
|
||||||
|
lastNames: 'worker',
|
||||||
|
email: 'defaultWorker@mydomain.com',
|
||||||
|
street: 'S/ defaultWorkerStreet',
|
||||||
|
city: 'defaultWorkerCity',
|
||||||
|
provinceFk: 1,
|
||||||
|
iban: 'ES8304879798578129532677',
|
||||||
|
bankEntityFk: 128,
|
||||||
|
companyFk: 442,
|
||||||
|
postcode: '46680',
|
||||||
|
phone: '123456789',
|
||||||
|
code: 'DWW',
|
||||||
|
bossFk: 9,
|
||||||
|
birth: '2022-12-11T23:00:00.000Z'
|
||||||
|
};
|
||||||
|
|
||||||
|
it('should return error if personal mail already exists', async() => {
|
||||||
|
const user = await models.Account.findById(employeeId, {fields: ['email']});
|
||||||
|
|
||||||
|
const tx = await models.Worker.beginTransaction({});
|
||||||
|
|
||||||
|
let error;
|
||||||
|
try {
|
||||||
|
const options = {transaction: tx};
|
||||||
|
const ctx = {
|
||||||
|
args: Object.assign({}, defaultWorker, {email: user.email})
|
||||||
|
};
|
||||||
|
|
||||||
|
await models.Worker.new(ctx, options);
|
||||||
|
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
error = e;
|
||||||
|
await tx.rollback();
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(error.message).toEqual('This personal mail already exists');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return error if worker code already exists', async() => {
|
||||||
|
const worker = await models.Worker.findById(employeeId, {fields: ['code']});
|
||||||
|
|
||||||
|
const tx = await models.Worker.beginTransaction({});
|
||||||
|
|
||||||
|
let error;
|
||||||
|
try {
|
||||||
|
const options = {transaction: tx};
|
||||||
|
const ctx = {
|
||||||
|
args: Object.assign({}, defaultWorker, {code: worker.code})
|
||||||
|
};
|
||||||
|
|
||||||
|
await models.Worker.new(ctx, options);
|
||||||
|
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
error = e;
|
||||||
|
await tx.rollback();
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(error.message).toEqual('This worker code already exists');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return error if worker already exists', async() => {
|
||||||
|
const worker = await models.Client.findById(employeeId, {fields: ['fi']});
|
||||||
|
|
||||||
|
const tx = await models.Worker.beginTransaction({});
|
||||||
|
|
||||||
|
let error;
|
||||||
|
try {
|
||||||
|
const options = {transaction: tx};
|
||||||
|
const ctx = {
|
||||||
|
args: Object.assign({}, defaultWorker, {fi: worker.fi})
|
||||||
|
};
|
||||||
|
await models.Worker.new(ctx, options);
|
||||||
|
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
error = e;
|
||||||
|
await tx.rollback();
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(error.message).toEqual('This worker already exists');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create a new worker', async() => {
|
||||||
|
const newWorker = await models.Worker.new({args: defaultWorker});
|
||||||
|
|
||||||
|
await models.Worker.destroyById(newWorker.id);
|
||||||
|
await models.Address.destroyAll({clientFk: newWorker.id});
|
||||||
|
await models.Mandate.destroyAll({clientFk: newWorker.id});
|
||||||
|
await models.Client.destroyById(newWorker.id);
|
||||||
|
await models.Account.destroyById(newWorker.id);
|
||||||
|
|
||||||
|
expect(newWorker.id).toBeDefined();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create a new worker in client', async() => {
|
||||||
|
const bruceWayneId = 1101;
|
||||||
|
const client = await models.Client.findById(bruceWayneId, {fields: ['fi', 'email']});
|
||||||
|
|
||||||
|
const newWorkerData = {
|
||||||
|
args: Object.assign(
|
||||||
|
{},
|
||||||
|
defaultWorker,
|
||||||
|
{
|
||||||
|
fi: client.fi,
|
||||||
|
email: client.email
|
||||||
|
})
|
||||||
|
};
|
||||||
|
const newWorker = await models.Worker.new(newWorkerData);
|
||||||
|
|
||||||
|
await models.Worker.destroyById(newWorker.id);
|
||||||
|
|
||||||
|
expect(newWorker.id).toEqual(bruceWayneId);
|
||||||
|
});
|
||||||
|
});
|
|
@ -17,12 +17,18 @@
|
||||||
"Department": {
|
"Department": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
|
"Device": {
|
||||||
|
"dataSource": "vn"
|
||||||
|
},
|
||||||
"EducationLevel": {
|
"EducationLevel": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
"Journey": {
|
"Journey": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
|
"ProfileType":{
|
||||||
|
"dataSource": "vn"
|
||||||
|
},
|
||||||
"Time": {
|
"Time": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
|
@ -32,39 +38,42 @@
|
||||||
"WorkCenterHoliday": {
|
"WorkCenterHoliday": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
"WorkerDms": {
|
"Worker": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
"Worker": {
|
"WorkerConfig": {
|
||||||
|
"dataSource": "vn"
|
||||||
|
},
|
||||||
|
"WorkerDepartment": {
|
||||||
|
"dataSource": "vn"
|
||||||
|
},
|
||||||
|
"WorkerDisableExcluded": {
|
||||||
|
"dataSource": "vn"
|
||||||
|
},
|
||||||
|
"WorkerDms": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
"WorkerLabour": {
|
"WorkerLabour": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
|
"WorkerLog": {
|
||||||
|
"dataSource": "vn"
|
||||||
|
},
|
||||||
"WorkerMana": {
|
"WorkerMana": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
|
"WorkerMedia": {
|
||||||
|
"dataSource": "vn"
|
||||||
|
},
|
||||||
"WorkerTeam": {
|
"WorkerTeam": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
"WorkerTeamCollegues": {
|
"WorkerTeamCollegues": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
"WorkerMedia": {
|
|
||||||
"dataSource": "vn"
|
|
||||||
},
|
|
||||||
"WorkerDepartment": {
|
|
||||||
"dataSource": "vn"
|
|
||||||
},
|
|
||||||
"WorkerTimeControl": {
|
"WorkerTimeControl": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
"Device": {
|
|
||||||
"dataSource": "vn"
|
|
||||||
},
|
|
||||||
"WorkerLog": {
|
|
||||||
"dataSource": "vn"
|
|
||||||
},
|
|
||||||
"WorkerTimeControlConfig": {
|
"WorkerTimeControlConfig": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
|
@ -73,9 +82,6 @@
|
||||||
},
|
},
|
||||||
"WorkerTimeControlMail": {
|
"WorkerTimeControlMail": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
|
||||||
"WorkerDisableExcluded": {
|
|
||||||
"dataSource": "vn"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
{
|
||||||
|
"name": "ProfileType",
|
||||||
|
"base": "VnModel",
|
||||||
|
"options": {
|
||||||
|
"mysql": {
|
||||||
|
"table": "profileType"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"properties": {
|
||||||
|
"id": {
|
||||||
|
"type": "number",
|
||||||
|
"id": true,
|
||||||
|
"description": "Identifier"
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
{
|
||||||
|
"name": "WorkerConfig",
|
||||||
|
"base": "VnModel",
|
||||||
|
"options": {
|
||||||
|
"mysql": {
|
||||||
|
"table": "workerConfig"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"properties": {
|
||||||
|
"id": {
|
||||||
|
"type": "number",
|
||||||
|
"id": true,
|
||||||
|
"description": "Identifier"
|
||||||
|
},
|
||||||
|
"roleFk": {
|
||||||
|
"type": "number"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"acls": [
|
||||||
|
{
|
||||||
|
"accessType": "READ",
|
||||||
|
"principalType": "ROLE",
|
||||||
|
"principalId": "$everyone",
|
||||||
|
"permission": "ALLOW"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -13,4 +13,5 @@ module.exports = Self => {
|
||||||
require('../methods/worker/contracts')(Self);
|
require('../methods/worker/contracts')(Self);
|
||||||
require('../methods/worker/holidays')(Self);
|
require('../methods/worker/holidays')(Self);
|
||||||
require('../methods/worker/activeContract')(Self);
|
require('../methods/worker/activeContract')(Self);
|
||||||
|
require('../methods/worker/new')(Self);
|
||||||
};
|
};
|
||||||
|
|
|
@ -52,6 +52,9 @@
|
||||||
},
|
},
|
||||||
"mobileExtension": {
|
"mobileExtension": {
|
||||||
"type" : "number"
|
"type" : "number"
|
||||||
|
},
|
||||||
|
"code": {
|
||||||
|
"type" : "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"relations": {
|
"relations": {
|
||||||
|
|
|
@ -0,0 +1,194 @@
|
||||||
|
<vn-watcher
|
||||||
|
vn-id="watcher"
|
||||||
|
url="Workers/new"
|
||||||
|
data="$ctrl.worker"
|
||||||
|
insert-mode="true"
|
||||||
|
form="form">
|
||||||
|
</vn-watcher>
|
||||||
|
<form name="form" vn-http-submit="$ctrl.onSubmit()" class="vn-w-md">
|
||||||
|
<vn-card class="vn-pa-lg">
|
||||||
|
<vn-horizontal>
|
||||||
|
<vn-textfield
|
||||||
|
vn-one
|
||||||
|
label="Firstname"
|
||||||
|
ng-model="$ctrl.worker.firstName"
|
||||||
|
rule
|
||||||
|
on-change="$ctrl.generateCodeUser()"
|
||||||
|
vn-focus>
|
||||||
|
</vn-textfield>
|
||||||
|
<vn-textfield
|
||||||
|
vn-one
|
||||||
|
label="Lastname"
|
||||||
|
on-change="$ctrl.generateCodeUser()"
|
||||||
|
ng-model="$ctrl.worker.lastNames"
|
||||||
|
rule>
|
||||||
|
</vn-textfield>
|
||||||
|
<vn-date-picker
|
||||||
|
vn-one
|
||||||
|
label="Birth"
|
||||||
|
ng-model="$ctrl.worker.birth">
|
||||||
|
</vn-date-picker>
|
||||||
|
</vn-horizontal>
|
||||||
|
<vn-horizontal>
|
||||||
|
<vn-textfield
|
||||||
|
vn-one
|
||||||
|
label="Fi"
|
||||||
|
ng-model="$ctrl.worker.fi"
|
||||||
|
rule>
|
||||||
|
</vn-textfield>
|
||||||
|
<vn-textfield
|
||||||
|
vn-one
|
||||||
|
label="Code"
|
||||||
|
ng-model="$ctrl.worker.code"
|
||||||
|
maxLength="3"
|
||||||
|
on-change="$ctrl.worker.code = $ctrl.worker.code.toUpperCase()"
|
||||||
|
rule>
|
||||||
|
</vn-textfield>
|
||||||
|
<vn-textfield
|
||||||
|
vn-one
|
||||||
|
label="Phone"
|
||||||
|
ng-model="$ctrl.worker.phone"
|
||||||
|
rule>
|
||||||
|
</vn-textfield>
|
||||||
|
</vn-horizontal>
|
||||||
|
<vn-horizontal>
|
||||||
|
<vn-datalist
|
||||||
|
label="Postcode"
|
||||||
|
vn-one
|
||||||
|
ng-model="$ctrl.worker.postcode"
|
||||||
|
selection="$ctrl.postcode"
|
||||||
|
url="Postcodes/location"
|
||||||
|
fields="['code','townFk']"
|
||||||
|
order="code, townFk"
|
||||||
|
value-field="code"
|
||||||
|
show-field="code"
|
||||||
|
rule>
|
||||||
|
<tpl-item>
|
||||||
|
{{code}} - {{town.name}} ({{town.province.name}},
|
||||||
|
{{town.province.country.country}})
|
||||||
|
</tpl-item>
|
||||||
|
<append>
|
||||||
|
<vn-icon-button
|
||||||
|
icon="add_circle"
|
||||||
|
vn-tooltip="New postcode"
|
||||||
|
ng-click="postcode.open()"
|
||||||
|
vn-acl="deliveryBoss"
|
||||||
|
vn-acl-action="remove">
|
||||||
|
</vn-icon-button>
|
||||||
|
</append>
|
||||||
|
</vn-datalist>
|
||||||
|
<vn-autocomplete
|
||||||
|
vn-id="province"
|
||||||
|
label="Province"
|
||||||
|
ng-model="$ctrl.worker.provinceFk"
|
||||||
|
selection="$ctrl.province"
|
||||||
|
url="Provinces/location"
|
||||||
|
fields="['id', 'name', 'countryFk']"
|
||||||
|
rule>
|
||||||
|
<tpl-item>{{name}} ({{country.country}})</tpl-item>
|
||||||
|
</vn-autocomplete>
|
||||||
|
</vn-horizontal>
|
||||||
|
<vn-horizontal>
|
||||||
|
<vn-datalist
|
||||||
|
vn-id="town"
|
||||||
|
label="City"
|
||||||
|
ng-model="$ctrl.worker.city"
|
||||||
|
selection="$ctrl.town"
|
||||||
|
url="Towns/location"
|
||||||
|
fields="['id', 'name', 'provinceFk']"
|
||||||
|
value-field="name">
|
||||||
|
<tpl-item>
|
||||||
|
{{name}}, {{province.name}}
|
||||||
|
({{province.country.country}})
|
||||||
|
</tpl-item>
|
||||||
|
</vn-datalist>
|
||||||
|
<vn-textfield
|
||||||
|
vn-two
|
||||||
|
label="Street"
|
||||||
|
ng-model="$ctrl.worker.street"
|
||||||
|
rule>
|
||||||
|
</vn-textfield>
|
||||||
|
</vn-horizontal>
|
||||||
|
<vn-horizontal>
|
||||||
|
<vn-textfield
|
||||||
|
label="Web user"
|
||||||
|
ng-model="$ctrl.worker.name"
|
||||||
|
rule>
|
||||||
|
</vn-textfield>
|
||||||
|
<vn-textfield
|
||||||
|
label="Personal email"
|
||||||
|
ng-model="$ctrl.worker.email"
|
||||||
|
rule>
|
||||||
|
</vn-textfield>
|
||||||
|
</vn-horizontal>
|
||||||
|
<vn-horizontal>
|
||||||
|
<vn-autocomplete
|
||||||
|
vn-one
|
||||||
|
vn-id="company"
|
||||||
|
ng-model="$ctrl.worker.companyFk"
|
||||||
|
url="Companies"
|
||||||
|
show-field="code"
|
||||||
|
value-field="id"
|
||||||
|
label="Company">
|
||||||
|
</vn-autocomplete>
|
||||||
|
<vn-autocomplete
|
||||||
|
vn-one
|
||||||
|
ng-model="$ctrl.worker.bossFk"
|
||||||
|
url="Workers/activeWithInheritedRole"
|
||||||
|
show-field="nickname"
|
||||||
|
search-function="{firstName: $search}"
|
||||||
|
where="{role: 'employee'}"
|
||||||
|
label="Boss">
|
||||||
|
</vn-autocomplete>
|
||||||
|
</vn-horizontal>
|
||||||
|
<vn-horizontal>
|
||||||
|
<vn-textfield
|
||||||
|
vn-one
|
||||||
|
label="IBAN"
|
||||||
|
ng-model="$ctrl.worker.iban"
|
||||||
|
rule
|
||||||
|
on-change="$ctrl.autofillBic()">
|
||||||
|
</vn-textfield>
|
||||||
|
<vn-autocomplete
|
||||||
|
vn-one
|
||||||
|
label="Swift / BIC"
|
||||||
|
url="BankEntities"
|
||||||
|
ng-model="$ctrl.worker.bankEntityFk"
|
||||||
|
fields="['name']"
|
||||||
|
initial-data="$ctrl.worker.bankEntityFk"
|
||||||
|
on-change="$ctrl.autofillBic()"
|
||||||
|
search-function="{or: [{bic: {like: $search +'%'}}, {name: {like: '%'+ $search +'%'}}]}"
|
||||||
|
value-field="id"
|
||||||
|
show-field="bic"
|
||||||
|
vn-acl="salesAssistant, hr"
|
||||||
|
disabled="$ctrl.ibanCountry == 'ES'">
|
||||||
|
<tpl-item>{{bic}} {{name}}</tpl-item>
|
||||||
|
<append>
|
||||||
|
<vn-icon-button
|
||||||
|
vn-auto
|
||||||
|
icon="add_circle"
|
||||||
|
vn-click-stop="bankEntity.show({countryFk: $ctrl.worker.countryFk})"
|
||||||
|
vn-tooltip="New bank entity"
|
||||||
|
vn-acl="salesAssistant, hr">
|
||||||
|
</vn-icon-button>
|
||||||
|
</append>
|
||||||
|
</vn-autocomplete>
|
||||||
|
</vn-horizontal>
|
||||||
|
</vn-card>
|
||||||
|
<vn-button-bar>
|
||||||
|
<vn-submit
|
||||||
|
disabled="!watcher.dataChanged()"
|
||||||
|
label="Create">
|
||||||
|
</vn-submit>
|
||||||
|
<vn-button
|
||||||
|
class="cancel"
|
||||||
|
label="Cancel"
|
||||||
|
ui-sref="worker.index">
|
||||||
|
</vn-button>
|
||||||
|
</vn-button-bar>
|
||||||
|
</form>
|
||||||
|
<!-- New postcode dialog -->
|
||||||
|
<vn-geo-postcode
|
||||||
|
vn-id="postcode"
|
||||||
|
on-response="$ctrl.onResponse($response)">
|
||||||
|
</vn-geo-postcode>
|
|
@ -0,0 +1,127 @@
|
||||||
|
import ngModule from '../module';
|
||||||
|
import Section from 'salix/components/section';
|
||||||
|
|
||||||
|
export default class Controller extends Section {
|
||||||
|
constructor($element, $) {
|
||||||
|
super($element, $);
|
||||||
|
this.worker = {companyFk: this.vnConfig.user.companyFk};
|
||||||
|
}
|
||||||
|
|
||||||
|
onSubmit() {
|
||||||
|
return this.$.watcher.submit().then(json => {
|
||||||
|
this.$state.go('worker.card.basicData', {id: json.data.id});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
autofillBic() {
|
||||||
|
if (!this.worker || !this.worker.iban) return;
|
||||||
|
|
||||||
|
let bankEntityId = parseInt(this.worker.iban.substr(4, 4));
|
||||||
|
let filter = {where: {id: bankEntityId}};
|
||||||
|
|
||||||
|
if (this.ibanCountry != 'ES') return;
|
||||||
|
|
||||||
|
this.$http.get(`BankEntities`, {filter}).then(response => {
|
||||||
|
const hasData = response.data && response.data[0];
|
||||||
|
|
||||||
|
if (hasData)
|
||||||
|
this.worker.bankEntityFk = response.data[0].id;
|
||||||
|
else if (!hasData)
|
||||||
|
this.worker.bankEntityFk = null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
generateCodeUser() {
|
||||||
|
if (!this.worker.firstName || !this.worker.lastNames) return;
|
||||||
|
|
||||||
|
const totalName = this.worker.firstName.concat(' ' + this.worker.lastNames).toLowerCase();
|
||||||
|
const totalNameArray = totalName.split(' ');
|
||||||
|
let newCode = '';
|
||||||
|
|
||||||
|
for (let part of totalNameArray)
|
||||||
|
newCode += part.charAt(0);
|
||||||
|
|
||||||
|
this.worker.code = newCode.toUpperCase().slice(0, 3);
|
||||||
|
this.worker.name = totalNameArray[0] + newCode.slice(1);
|
||||||
|
|
||||||
|
if (!this.worker.companyFk)
|
||||||
|
this.worker.companyFk = this.vnConfig.user.companyFk;
|
||||||
|
}
|
||||||
|
|
||||||
|
get province() {
|
||||||
|
return this._province;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Province auto complete
|
||||||
|
set province(selection) {
|
||||||
|
this._province = selection;
|
||||||
|
|
||||||
|
if (!selection) return;
|
||||||
|
|
||||||
|
const country = selection.country;
|
||||||
|
|
||||||
|
if (!this.worker.countryFk)
|
||||||
|
this.worker.countryFk = country.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
get town() {
|
||||||
|
return this._town;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Town auto complete
|
||||||
|
set town(selection) {
|
||||||
|
this._town = selection;
|
||||||
|
|
||||||
|
if (!selection) return;
|
||||||
|
|
||||||
|
const province = selection.province;
|
||||||
|
const country = province.country;
|
||||||
|
const postcodes = selection.postcodes;
|
||||||
|
|
||||||
|
if (!this.worker.provinceFk)
|
||||||
|
this.worker.provinceFk = province.id;
|
||||||
|
|
||||||
|
if (!this.worker.countryFk)
|
||||||
|
this.worker.countryFk = country.id;
|
||||||
|
|
||||||
|
if (postcodes.length === 1)
|
||||||
|
this.worker.postcode = postcodes[0].code;
|
||||||
|
}
|
||||||
|
|
||||||
|
get postcode() {
|
||||||
|
return this._postcode;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Postcode auto complete
|
||||||
|
set postcode(selection) {
|
||||||
|
this._postcode = selection;
|
||||||
|
|
||||||
|
if (!selection) return;
|
||||||
|
|
||||||
|
const town = selection.town;
|
||||||
|
const province = town.province;
|
||||||
|
const country = province.country;
|
||||||
|
|
||||||
|
if (!this.worker.city)
|
||||||
|
this.worker.city = town.name;
|
||||||
|
|
||||||
|
if (!this.worker.provinceFk)
|
||||||
|
this.worker.provinceFk = province.id;
|
||||||
|
|
||||||
|
if (!this.worker.countryFk)
|
||||||
|
this.worker.countryFk = country.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
onResponse(response) {
|
||||||
|
this.worker.postcode = response.code;
|
||||||
|
this.worker.city = response.city;
|
||||||
|
this.worker.provinceFk = response.provinceFk;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Controller.$inject = ['$element', '$scope'];
|
||||||
|
|
||||||
|
ngModule.vnComponent('vnWorkerCreate', {
|
||||||
|
template: require('./index.html'),
|
||||||
|
controller: Controller
|
||||||
|
});
|
|
@ -0,0 +1,133 @@
|
||||||
|
import './index';
|
||||||
|
|
||||||
|
describe('Worker', () => {
|
||||||
|
describe('Component vnWorkerCreate', () => {
|
||||||
|
let $scope;
|
||||||
|
let $state;
|
||||||
|
let controller;
|
||||||
|
|
||||||
|
beforeEach(ngModule('worker'));
|
||||||
|
|
||||||
|
beforeEach(inject(($componentController, $rootScope, _$state_) => {
|
||||||
|
$scope = $rootScope.$new();
|
||||||
|
$state = _$state_;
|
||||||
|
$scope.watcher = {
|
||||||
|
submit: () => {
|
||||||
|
return {
|
||||||
|
then: callback => {
|
||||||
|
callback({data: {id: '1234'}});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const $element = angular.element('<vn-worker-create></vn-worker-create>');
|
||||||
|
controller = $componentController('vnWorkerCreate', {$element, $scope});
|
||||||
|
controller.worker = {};
|
||||||
|
controller.vnConfig = {user: {companyFk: 1}};
|
||||||
|
}));
|
||||||
|
|
||||||
|
describe('onSubmit()', () => {
|
||||||
|
it(`should call submit() on the watcher then expect a callback`, () => {
|
||||||
|
jest.spyOn($state, 'go');
|
||||||
|
controller.onSubmit();
|
||||||
|
|
||||||
|
expect(controller.$state.go).toHaveBeenCalledWith('worker.card.basicData', {id: '1234'});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('province() setter', () => {
|
||||||
|
it(`should set countryFk property`, () => {
|
||||||
|
controller.worker.countryFk = null;
|
||||||
|
controller.province = {
|
||||||
|
id: 1,
|
||||||
|
name: 'New york',
|
||||||
|
country: {
|
||||||
|
id: 2,
|
||||||
|
name: 'USA'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
expect(controller.worker.countryFk).toEqual(2);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('town() setter', () => {
|
||||||
|
it(`should set provinceFk property`, () => {
|
||||||
|
controller.town = {
|
||||||
|
provinceFk: 1,
|
||||||
|
code: 46001,
|
||||||
|
province: {
|
||||||
|
id: 1,
|
||||||
|
name: 'New york',
|
||||||
|
country: {
|
||||||
|
id: 2,
|
||||||
|
name: 'USA'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
postcodes: []
|
||||||
|
};
|
||||||
|
|
||||||
|
expect(controller.worker.provinceFk).toEqual(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`should set provinceFk property and fill the postalCode if there's just one`, () => {
|
||||||
|
controller.town = {
|
||||||
|
provinceFk: 1,
|
||||||
|
code: 46001,
|
||||||
|
province: {
|
||||||
|
id: 1,
|
||||||
|
name: 'New york',
|
||||||
|
country: {
|
||||||
|
id: 2,
|
||||||
|
name: 'USA'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
postcodes: [{code: '46001'}]
|
||||||
|
};
|
||||||
|
|
||||||
|
expect(controller.worker.provinceFk).toEqual(1);
|
||||||
|
expect(controller.worker.postcode).toEqual('46001');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('postcode() setter', () => {
|
||||||
|
it(`should set the town, provinceFk and contryFk properties`, () => {
|
||||||
|
controller.postcode = {
|
||||||
|
townFk: 1,
|
||||||
|
code: 46001,
|
||||||
|
town: {
|
||||||
|
id: 1,
|
||||||
|
name: 'New York',
|
||||||
|
province: {
|
||||||
|
id: 1,
|
||||||
|
name: 'New york',
|
||||||
|
country: {
|
||||||
|
id: 2,
|
||||||
|
name: 'USA'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
expect(controller.worker.city).toEqual('New York');
|
||||||
|
expect(controller.worker.provinceFk).toEqual(1);
|
||||||
|
expect(controller.worker.countryFk).toEqual(2);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('generateCodeUser()', () => {
|
||||||
|
it(`should generate worker code, name and company `, () => {
|
||||||
|
controller.worker = {
|
||||||
|
firstName: 'default',
|
||||||
|
lastNames: 'generate worker'
|
||||||
|
};
|
||||||
|
|
||||||
|
controller.generateCodeUser();
|
||||||
|
|
||||||
|
expect(controller.worker.code).toEqual('DGW');
|
||||||
|
expect(controller.worker.name).toEqual('defaultgw');
|
||||||
|
expect(controller.worker.companyFk).toEqual(controller.vnConfig.user.companyFk);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,12 @@
|
||||||
|
Firstname: Nombre
|
||||||
|
Lastname: Apellidos
|
||||||
|
Fi: DNI/NIF/NIE
|
||||||
|
Birth: Fecha de nacimiento
|
||||||
|
Code: Código de trabajador
|
||||||
|
Province: Provincia
|
||||||
|
City: Población
|
||||||
|
ProfileType: Tipo de perfil
|
||||||
|
Street: Dirección
|
||||||
|
Postcode: Código postal
|
||||||
|
Web user: Usuario Web
|
||||||
|
Access permission: Permiso de acceso
|
|
@ -4,6 +4,7 @@ import './main';
|
||||||
import './index/';
|
import './index/';
|
||||||
import './summary';
|
import './summary';
|
||||||
import './card';
|
import './card';
|
||||||
|
import './create';
|
||||||
import './descriptor';
|
import './descriptor';
|
||||||
import './descriptor-popover';
|
import './descriptor-popover';
|
||||||
import './search-panel';
|
import './search-panel';
|
||||||
|
|
|
@ -42,6 +42,14 @@
|
||||||
</div>
|
</div>
|
||||||
</vn-card>
|
</vn-card>
|
||||||
</vn-data-viewer>
|
</vn-data-viewer>
|
||||||
|
<a ui-sref="worker.create"
|
||||||
|
vn-tooltip="New worker"
|
||||||
|
vn-bind="+"
|
||||||
|
vn-acl="hr"
|
||||||
|
vn-acl-action="remove"
|
||||||
|
fixed-bottom-right>
|
||||||
|
<vn-float-button icon="person_add"></vn-float-button>
|
||||||
|
</a>
|
||||||
<vn-popup vn-id="preview">
|
<vn-popup vn-id="preview">
|
||||||
<vn-worker-summary
|
<vn-worker-summary
|
||||||
worker="$ctrl.selectedWorker">
|
worker="$ctrl.selectedWorker">
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
New worker: Nuevo trabajador
|
|
@ -134,6 +134,13 @@
|
||||||
"worker": "$ctrl.worker"
|
"worker": "$ctrl.worker"
|
||||||
},
|
},
|
||||||
"acl": ["hr"]
|
"acl": ["hr"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "/create",
|
||||||
|
"state": "worker.create",
|
||||||
|
"component": "vn-worker-create",
|
||||||
|
"description": "New worker",
|
||||||
|
"acl": ["hr"]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "salix-back",
|
"name": "salix-back",
|
||||||
"version": "230401",
|
"version": "23.04.01",
|
||||||
"author": "Verdnatura Levante SL",
|
"author": "Verdnatura Levante SL",
|
||||||
"description": "Salix backend",
|
"description": "Salix backend",
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
const Component = require(`vn-print/core/component`);
|
||||||
|
const reportHeader = new Component('report-header');
|
||||||
|
const reportFooter = new Component('report-footer');
|
||||||
|
const reportBody = new Component('report-body');
|
||||||
|
const NotFoundError = require('vn-loopback/util/not-found-error');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
components: {
|
||||||
|
'report-body': reportBody.build(),
|
||||||
|
'report-header': reportHeader.build(),
|
||||||
|
'report-footer': reportFooter.build()
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
checkMainEntity: function(entity) {
|
||||||
|
if (entity == null)
|
||||||
|
throw new NotFoundError();
|
||||||
|
},
|
||||||
|
formatDate: function(date, format) {
|
||||||
|
const filters = this.$options.filters;
|
||||||
|
return filters.date(date, format);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
|
@ -10,7 +10,7 @@ module.exports = {
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
url: {
|
url: {
|
||||||
type: [String],
|
type: String,
|
||||||
required: true
|
required: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,8 +8,8 @@ description:
|
||||||
<a href='https://www.youtube.com/watch?v=qhb0kgQF3o8' title='Youtube' target='_blank'
|
<a href='https://www.youtube.com/watch?v=qhb0kgQF3o8' title='Youtube' target='_blank'
|
||||||
style='color:#8dba25'>https://www.youtube.com/watch?v=qhb0kgQF3o8</a>. También
|
style='color:#8dba25'>https://www.youtube.com/watch?v=qhb0kgQF3o8</a>. También
|
||||||
necesitarás el QLabel, el programa para imprimir las cintas.
|
necesitarás el QLabel, el programa para imprimir las cintas.
|
||||||
downloadFrom: Puedes descargarlo desde este enlace <a href='https://godex.s3-accelerate.amazonaws.com/gGnOPoojkP6vC1lgmrbEqQ.file?v01'
|
downloadFrom: Puedes descargarlo desde este enlace <a href='https://cdn.verdnatura.es/public/QLabel_IV_V1.37_Install_en.exe'
|
||||||
title='Descargar QLabel' target='_blank' style='color:#8dba25'>https://godex.s3-accelerate.amazonaws.com/gGnOPoojkP6vC1lgmrbEqQ.file?v01</a>
|
title='Descargar QLabel' target='_blank' style='color:#8dba25'>https://cdn.verdnatura.es/public/QLabel_IV_V1.37_Install_en.exe</a>
|
||||||
downloadDriver: En este enlace puedes descargar el driver de la impresora <a href='https://es.seagullscientific.com/support/downloads/drivers/godex/download/'
|
downloadDriver: En este enlace puedes descargar el driver de la impresora <a href='https://es.seagullscientific.com/support/downloads/drivers/godex/download/'
|
||||||
title='Descargar driver' target='_blank' style='color:#8dba25'>https://es.seagullscientific.com/support/downloads/drivers/godex/download/</a>
|
title='Descargar driver' target='_blank' style='color:#8dba25'>https://es.seagullscientific.com/support/downloads/drivers/godex/download/</a>
|
||||||
sections:
|
sections:
|
||||||
|
|
|
@ -10,7 +10,7 @@ module.exports = {
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
url: {
|
url: {
|
||||||
type: [String],
|
type: String,
|
||||||
required: true
|
required: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
const Stylesheet = require(`vn-print/core/stylesheet`);
|
||||||
|
|
||||||
|
const path = require('path');
|
||||||
|
const vnPrintPath = path.resolve('print');
|
||||||
|
|
||||||
|
module.exports = new Stylesheet([
|
||||||
|
`${vnPrintPath}/common/css/spacing.css`,
|
||||||
|
`${vnPrintPath}/common/css/misc.css`,
|
||||||
|
`${vnPrintPath}/common/css/layout.css`,
|
||||||
|
`${vnPrintPath}/common/css/email.css`])
|
||||||
|
.mergeStyles();
|
|
@ -0,0 +1,8 @@
|
||||||
|
subject: Bienvenido a Verdnatura
|
||||||
|
title: "¡Te damos la bienvenida!"
|
||||||
|
dearWorker: Estimado trabajador
|
||||||
|
workerData: 'Estos son los datos de tu usuario de Verdnatura.
|
||||||
|
Usuario: <strong>{0}</strong>. Haz click aquí para
|
||||||
|
<a href="{1}"
|
||||||
|
title="Cambiar contraseña" target="_blank" style="color: #8dba25">establecer tu contraseña
|
||||||
|
</a>.'
|
|
@ -0,0 +1,7 @@
|
||||||
|
SELECT
|
||||||
|
u.id,
|
||||||
|
u.name,
|
||||||
|
e.email
|
||||||
|
FROM account.user u
|
||||||
|
LEFT JOIN account.emailUser e ON e.userFk = u.id
|
||||||
|
WHERE u.id = ?;
|
|
@ -0,0 +1,9 @@
|
||||||
|
<email-body v-bind="$props">
|
||||||
|
<div class="grid-row">
|
||||||
|
<div class="grid-block vn-pa-ml">
|
||||||
|
<h1>{{ $t('title', [id]) }}</h1>
|
||||||
|
<p>{{ $t('dearWorker') }},</p>
|
||||||
|
<p v-html="$t('workerData', [this.worker.name, this.url])"></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</email-body>
|
|
@ -0,0 +1,27 @@
|
||||||
|
const Component = require(`vn-print/core/component`);
|
||||||
|
const emailBody = new Component('email-body');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: 'worker-welcome',
|
||||||
|
async serverPrefetch() {
|
||||||
|
this.worker = await this.fetchWorker(this.id);
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
fetchWorker(id) {
|
||||||
|
return this.findOneFromDef('worker', [id]);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
components: {
|
||||||
|
'email-body': emailBody.build(),
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
id: {
|
||||||
|
type: Number,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
url: {
|
||||||
|
type: String,
|
||||||
|
required: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
|
@ -3,7 +3,7 @@
|
||||||
<div class="grid-block">
|
<div class="grid-block">
|
||||||
<div class="columns">
|
<div class="columns">
|
||||||
<div class="size50">
|
<div class="size50">
|
||||||
<p style="text-align: right">{{$t('Place')}} {{currentDate()}}</p>
|
<p style="text-align: right">{{$t('Place')}} {{formatDate(new Date(), '%d-%m-%Y')}}</p>
|
||||||
<h3 style="text-align: center; margin-top: 8%">{{$t('Compensation') | uppercase}}</h3>
|
<h3 style="text-align: center; margin-top: 8%">{{$t('Compensation') | uppercase}}</h3>
|
||||||
<p style="margin-top: 8%">{{$t('In one hand')}}:</p>
|
<p style="margin-top: 8%">{{$t('In one hand')}}:</p>
|
||||||
<p style="text-align: justify">
|
<p style="text-align: justify">
|
||||||
|
@ -17,7 +17,7 @@
|
||||||
</p>
|
</p>
|
||||||
<h4 style="text-align: center; margin-top: 10%">{{$t('Agree') | uppercase}}</h4>
|
<h4 style="text-align: center; margin-top: 10%">{{$t('Agree') | uppercase}}</h4>
|
||||||
<p style="margin-top: 8%; text-align: justify">
|
<p style="margin-top: 8%; text-align: justify">
|
||||||
{{$t('Date')}} {{client.payed | date('%d-%m-%Y')}} {{$t('Compensate')}} {{client.amountPaid}} €
|
{{$t('Date')}} {{formatDate(client.payed, '%d-%m-%Y')}} {{$t('Compensate')}} {{client.amountPaid}} €
|
||||||
{{$t('From client')}} {{client.name}} {{$t('Toclient')}} {{company.name}}.
|
{{$t('From client')}} {{client.name}} {{$t('Toclient')}} {{company.name}}.
|
||||||
</p>
|
</p>
|
||||||
<p style="margin-top: 8%">
|
<p style="margin-top: 8%">
|
||||||
|
|
|
@ -1,28 +1,12 @@
|
||||||
const Component = require(`vn-print/core/component`);
|
const vnReport = require('../../../core/mixins/vn-report.js');
|
||||||
const reportBody = new Component('report-body');
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'balance-compensation',
|
name: 'balance-compensation',
|
||||||
|
mixins: [vnReport],
|
||||||
async serverPrefetch() {
|
async serverPrefetch() {
|
||||||
this.client = await this.fetchClient(this.id);
|
this.client = await this.findOneFromDef('client', [this.id]);
|
||||||
this.company = await this.fetchCompany(this.id);
|
this.checkMainEntity(this.client);
|
||||||
},
|
this.company = await this.findOneFromDef('company', [this.id]);
|
||||||
methods: {
|
|
||||||
fetchClient(id) {
|
|
||||||
return this.findOneFromDef('client', [id]);
|
|
||||||
},
|
|
||||||
fetchCompany(id) {
|
|
||||||
return this.findOneFromDef('company', [id]);
|
|
||||||
},
|
|
||||||
|
|
||||||
currentDate() {
|
|
||||||
const current = new Date();
|
|
||||||
const date = `${current.getDate()}/${current.getMonth() + 1}/${current.getFullYear()}`;
|
|
||||||
return date;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
components: {
|
|
||||||
'report-body': reportBody.build()
|
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
id: {
|
id: {
|
||||||
|
|
|
@ -13,11 +13,11 @@
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="font gray">{{$t('From')}}</td>
|
<td class="font gray">{{$t('From')}}</td>
|
||||||
<th>{{from | date('%d-%m-%Y')}}</th>
|
<th>{{formatDate(from, '%d-%m-%Y')}}</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="font gray">{{$t('To')}}</td>
|
<td class="font gray">{{$t('To')}}</td>
|
||||||
<th>{{to | date('%d-%m-%Y')}}</th>
|
<th>{{formatDate(to, '%d-%m-%Y')}}</th>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -1,27 +1,12 @@
|
||||||
const Component = require(`vn-print/core/component`);
|
const vnReport = require('../../../core/mixins/vn-report.js');
|
||||||
const reportBody = new Component('report-body');
|
|
||||||
const reportFooter = new Component('report-footer');
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'campaign-metrics',
|
name: 'campaign-metrics',
|
||||||
|
mixins: [vnReport],
|
||||||
async serverPrefetch() {
|
async serverPrefetch() {
|
||||||
this.client = await this.fetchClient(this.id);
|
this.client = await this.findOneFromDef('client', [this.id]);
|
||||||
this.sales = await this.fetchSales(this.id, this.from, this.to);
|
this.checkMainEntity(this.client);
|
||||||
|
this.sales = await this.rawSqlFromDef('sales', [this.id, this.from, this.to]);
|
||||||
if (!this.client)
|
|
||||||
throw new Error('Something went wrong');
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
fetchClient(id) {
|
|
||||||
return this.findOneFromDef('client', [id]);
|
|
||||||
},
|
|
||||||
fetchSales(id, from, to) {
|
|
||||||
return this.rawSqlFromDef('sales', [id, from, to]);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
components: {
|
|
||||||
'report-body': reportBody.build(),
|
|
||||||
'report-footer': reportFooter.build()
|
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
id: {
|
id: {
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="font gray uppercase">{{$t('date')}}</td>
|
<td class="font gray uppercase">{{$t('date')}}</td>
|
||||||
<th>{{dated}}</th>
|
<th>{{formatDate(new Date(), '%d-%m-%Y')}}</th>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -1,34 +1,12 @@
|
||||||
const Component = require(`vn-print/core/component`);
|
const vnReport = require('../../../core/mixins/vn-report.js');
|
||||||
const reportBody = new Component('report-body');
|
|
||||||
const reportFooter = new Component('report-footer');
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'claim-pickup-order',
|
name: 'claim-pickup-order',
|
||||||
|
mixins: [vnReport],
|
||||||
async serverPrefetch() {
|
async serverPrefetch() {
|
||||||
this.client = await this.fetchClient(this.id);
|
this.client = await this.findOneFromDef('client', [this.id]);
|
||||||
this.sales = await this.fetchSales(this.id);
|
this.checkMainEntity(this.client);
|
||||||
|
this.sales = await this.rawSqlFromDef('sales', [this.id]);
|
||||||
if (!this.client)
|
|
||||||
throw new Error('Something went wrong');
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
dated: function() {
|
|
||||||
const filters = this.$options.filters;
|
|
||||||
|
|
||||||
return filters.date(new Date(), '%d-%m-%Y');
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
fetchClient(id) {
|
|
||||||
return this.findOneFromDef('client', [id]);
|
|
||||||
},
|
|
||||||
fetchSales(id) {
|
|
||||||
return this.rawSqlFromDef('sales', [id]);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
components: {
|
|
||||||
'report-body': reportBody.build(),
|
|
||||||
'report-footer': reportFooter.build()
|
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
id: {
|
id: {
|
||||||
|
@ -36,5 +14,5 @@ module.exports = {
|
||||||
required: true,
|
required: true,
|
||||||
description: 'The claim id'
|
description: 'The claim id'
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="font gray uppercase">{{$t('date')}}</td>
|
<td class="font gray uppercase">{{$t('date')}}</td>
|
||||||
<th>{{dated}}</th>
|
<th>{{formatDate(new Date(), '%d-%m-%Y');}}</th>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
@ -44,7 +44,7 @@
|
||||||
</thead>
|
</thead>
|
||||||
<tbody v-for="sale in sales" :key="sale.id">
|
<tbody v-for="sale in sales" :key="sale.id">
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{sale.issued | date('%d-%m-%Y')}}</td>
|
<td>{{formatDate(sale.issued, '%d-%m-%Y');}}</td>
|
||||||
<td>{{sale.ref}}</td>
|
<td>{{sale.ref}}</td>
|
||||||
<td class="number">{{sale.debtOut}}</td>
|
<td class="number">{{sale.debtOut}}</td>
|
||||||
<td class="number">{{sale.debtIn}}</td>
|
<td class="number">{{sale.debtIn}}</td>
|
||||||
|
|
|
@ -1,44 +1,18 @@
|
||||||
const Component = require(`vn-print/core/component`);
|
const vnReport = require('../../../core/mixins/vn-report.js');
|
||||||
const reportBody = new Component('report-body');
|
|
||||||
const reportFooter = new Component('report-footer');
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'client-debt-statement',
|
name: 'client-debt-statement',
|
||||||
|
mixins: [vnReport],
|
||||||
async serverPrefetch() {
|
async serverPrefetch() {
|
||||||
this.client = await this.fetchClient(this.id);
|
this.client = await this.findOneFromDef('client', [this.id]);
|
||||||
this.sales = await this.fetchSales(this.id, this.from);
|
this.checkMainEntity(this.client);
|
||||||
|
this.sales = await this.rawSqlFromDef('sales',
|
||||||
if (!this.client)
|
[this.from, this.id, this.from, this.id, this.from, this.id, this.from, this.id, this.from, this.id]);
|
||||||
throw new Error('Something went wrong');
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
dated: function() {
|
|
||||||
const filters = this.$options.filters;
|
|
||||||
|
|
||||||
return filters.date(new Date(), '%d-%m-%Y');
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {totalBalance: 0.00};
|
return {totalBalance: 0.00};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
fetchClient(id) {
|
|
||||||
return this.findOneFromDef('client', [id]);
|
|
||||||
},
|
|
||||||
fetchSales(id, from) {
|
|
||||||
return this.rawSqlFromDef('sales', [
|
|
||||||
from,
|
|
||||||
id,
|
|
||||||
from,
|
|
||||||
id,
|
|
||||||
from,
|
|
||||||
id,
|
|
||||||
from,
|
|
||||||
id,
|
|
||||||
from,
|
|
||||||
id
|
|
||||||
]);
|
|
||||||
},
|
|
||||||
getBalance(sale) {
|
getBalance(sale) {
|
||||||
if (sale.debtOut)
|
if (sale.debtOut)
|
||||||
this.totalBalance += parseFloat(sale.debtOut);
|
this.totalBalance += parseFloat(sale.debtOut);
|
||||||
|
@ -63,10 +37,6 @@ module.exports = {
|
||||||
return debtIn.toFixed(2);
|
return debtIn.toFixed(2);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
components: {
|
|
||||||
'report-body': reportBody.build(),
|
|
||||||
'report-footer': reportFooter.build()
|
|
||||||
},
|
|
||||||
props: {
|
props: {
|
||||||
id: {
|
id: {
|
||||||
type: Number,
|
type: Number,
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
const Component = require(`vn-print/core/component`);
|
|
||||||
const reportBody = new Component('report-body');
|
|
||||||
const jsBarcode = require('jsbarcode');
|
const jsBarcode = require('jsbarcode');
|
||||||
const {DOMImplementation, XMLSerializer} = require('xmldom');
|
const {DOMImplementation, XMLSerializer} = require('xmldom');
|
||||||
const UserError = require('vn-loopback/util/user-error');
|
const vnReport = require('../../../core/mixins/vn-report.js');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'collection-label',
|
name: 'collection-label',
|
||||||
|
mixins: [vnReport],
|
||||||
props: {
|
props: {
|
||||||
id: {
|
id: {
|
||||||
type: Number,
|
type: Number,
|
||||||
|
@ -30,8 +29,7 @@ module.exports = {
|
||||||
ticketIds = [this.id];
|
ticketIds = [this.id];
|
||||||
|
|
||||||
this.labelsData = await this.rawSqlFromDef('labelsData', [ticketIds]);
|
this.labelsData = await this.rawSqlFromDef('labelsData', [ticketIds]);
|
||||||
if (!this.labelsData.length)
|
this.checkMainEntity(this.labelsData);
|
||||||
throw new UserError('Empty data source');
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getBarcode(id) {
|
getBarcode(id) {
|
||||||
|
@ -62,7 +60,4 @@ module.exports = {
|
||||||
return value;
|
return value;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
components: {
|
|
||||||
'report-body': reportBody.build()
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -159,6 +159,6 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<template v-slot:footer>
|
<template v-slot:footer>
|
||||||
<report-footer id="pageFooter" v-bind:left-text="dated" v-bind="$props"> </report-footer>
|
<report-footer id="pageFooter" v-bind:left-text="formatDate(new Date(), '%d-%m-%Y')" v-bind="$props"> </report-footer>
|
||||||
</template>
|
</template>
|
||||||
</report-body>
|
</report-body>
|
||||||
|
|
|
@ -1,20 +1,7 @@
|
||||||
const Component = require(`vn-print/core/component`);
|
const vnReport = require('../../../core/mixins/vn-report.js');
|
||||||
const reportBody = new Component('report-body')
|
|
||||||
const reportFooter = new Component('report-footer');
|
|
||||||
|
|
||||||
const rptCreditRequest = {
|
module.exports = {
|
||||||
name: 'credit-request',
|
name: 'credit-request',
|
||||||
computed: {
|
mixins: [vnReport],
|
||||||
dated: function() {
|
|
||||||
const filters = this.$options.filters;
|
|
||||||
|
|
||||||
return filters.date(new Date(), '%d-%m-%Y');
|
|
||||||
}
|
|
||||||
},
|
|
||||||
components: {
|
|
||||||
'report-body': reportBody.build(),
|
|
||||||
'report-footer': reportFooter.build()
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = rptCreditRequest;
|
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="font gray uppercase">{{$t('date')}}</td>
|
<td class="font gray uppercase">{{$t('date')}}</td>
|
||||||
<th>{{ticket.shipped | date('%d-%m-%Y')}}</th>
|
<th>{{formatDate(ticket.shipped, '%d-%m-%Y')}}</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="font gray uppercase">{{$t('packages')}}</td>
|
<td class="font gray uppercase">{{$t('packages')}}</td>
|
||||||
|
@ -231,7 +231,7 @@
|
||||||
<div class="header">{{$t('digitalSignature')}}</div>
|
<div class="header">{{$t('digitalSignature')}}</div>
|
||||||
<div class="body centered">
|
<div class="body centered">
|
||||||
<img v-bind:src="dmsPath" />
|
<img v-bind:src="dmsPath" />
|
||||||
<div>{{signature.created | date('%d-%m-%Y')}}</div>
|
<div>{{formatDate(signature.created, '%d-%m-%Y')}}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,25 +1,21 @@
|
||||||
const config = require(`vn-print/core/config`);
|
const config = require(`vn-print/core/config`);
|
||||||
const Component = require(`vn-print/core/component`);
|
const vnReport = require('../../../core/mixins/vn-report.js');
|
||||||
const reportBody = new Component('report-body');
|
|
||||||
const reportHeader = new Component('report-header');
|
|
||||||
const reportFooter = new Component('report-footer');
|
|
||||||
const md5 = require('md5');
|
const md5 = require('md5');
|
||||||
const fs = require('fs-extra');
|
const fs = require('fs-extra');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'delivery-note',
|
name: 'delivery-note',
|
||||||
|
mixins: [vnReport],
|
||||||
async serverPrefetch() {
|
async serverPrefetch() {
|
||||||
this.client = await this.fetchClient(this.id);
|
this.ticket = await this.findOneFromDef('ticket', [this.id]);
|
||||||
this.ticket = await this.fetchTicket(this.id);
|
this.checkMainEntity(this.ticket);
|
||||||
this.sales = await this.fetchSales(this.id);
|
this.client = await this.findOneFromDef('client', [this.id]);
|
||||||
this.address = await this.fetchAddress(this.id);
|
this.sales = await this.rawSqlFromDef('sales', [this.id]);
|
||||||
this.services = await this.fetchServices(this.id);
|
this.address = await this.findOneFromDef(`address`, [this.id]);
|
||||||
this.taxes = await this.fetchTaxes(this.id);
|
this.services = await this.rawSqlFromDef('services', [this.id]);
|
||||||
this.packagings = await this.fetchPackagings(this.id);
|
this.taxes = await this.rawSqlFromDef('taxes', [this.id]);
|
||||||
this.signature = await this.fetchSignature(this.id);
|
this.packagings = await this.rawSqlFromDef('packagings', [this.id]);
|
||||||
|
this.signature = await this.findOneFromDef('signature', [this.id]);
|
||||||
if (!this.ticket)
|
|
||||||
throw new Error('Something went wrong');
|
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {totalBalance: 0.00};
|
return {totalBalance: 0.00};
|
||||||
|
@ -61,31 +57,6 @@ module.exports = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
fetchClient(id) {
|
|
||||||
return this.findOneFromDef('client', [id]);
|
|
||||||
},
|
|
||||||
fetchTicket(id) {
|
|
||||||
return this.findOneFromDef('ticket', [id]);
|
|
||||||
},
|
|
||||||
fetchAddress(id) {
|
|
||||||
return this.findOneFromDef(`address`, [id]);
|
|
||||||
},
|
|
||||||
fetchSignature(id) {
|
|
||||||
return this.findOneFromDef('signature', [id]);
|
|
||||||
},
|
|
||||||
fetchTaxes(id) {
|
|
||||||
return this.findOneFromDef(`taxes`, [id]);
|
|
||||||
},
|
|
||||||
fetchSales(id) {
|
|
||||||
return this.rawSqlFromDef('sales', [id]);
|
|
||||||
},
|
|
||||||
fetchPackagings(id) {
|
|
||||||
return this.rawSqlFromDef('packagings', [id]);
|
|
||||||
},
|
|
||||||
fetchServices(id) {
|
|
||||||
return this.rawSqlFromDef('services', [id]);
|
|
||||||
},
|
|
||||||
|
|
||||||
getSubTotal() {
|
getSubTotal() {
|
||||||
let subTotal = 0.00;
|
let subTotal = 0.00;
|
||||||
this.sales.forEach(sale => {
|
this.sales.forEach(sale => {
|
||||||
|
@ -125,11 +96,6 @@ module.exports = {
|
||||||
).join(', ');
|
).join(', ');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
components: {
|
|
||||||
'report-body': reportBody.build(),
|
|
||||||
'report-header': reportHeader.build(),
|
|
||||||
'report-footer': reportFooter.build()
|
|
||||||
},
|
|
||||||
props: {
|
props: {
|
||||||
id: {
|
id: {
|
||||||
type: Number,
|
type: Number,
|
||||||
|
|
|
@ -16,13 +16,13 @@
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="font gray align-right">{{$t('date')}}</th>
|
<th class="font gray align-right">{{$t('date')}}</th>
|
||||||
<td>{{route.created | date('%d-%m-%Y')}}</td>
|
<td>{{formatDate(route.created, '%d-%m-%Y')}}</td>
|
||||||
<th class="font gray align-right">{{$t('vehicle')}}</th>
|
<th class="font gray align-right">{{$t('vehicle')}}</th>
|
||||||
<td>{{route.vehicleTradeMark}} {{route.vehicleModel}}</td>
|
<td>{{route.vehicleTradeMark}} {{route.vehicleModel}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="font gray align-right">{{$t('time')}}</th>
|
<th class="font gray align-right">{{$t('time')}}</th>
|
||||||
<td>{{route.time | date('%H:%M')}}</td>
|
<td>{{formatDate(route.time, '%H:%M')}}</td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td>{{route.plateNumber}}</td>
|
<td>{{route.plateNumber}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
const Component = require(`vn-print/core/component`);
|
const vnReport = require('../../../core/mixins/vn-report.js');
|
||||||
const reportBody = new Component('report-body');
|
|
||||||
const reportFooter = new Component('report-footer');
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'driver-route',
|
name: 'driver-route',
|
||||||
|
mixins: [vnReport],
|
||||||
async serverPrefetch() {
|
async serverPrefetch() {
|
||||||
let ids = this.id;
|
let ids = this.id;
|
||||||
|
|
||||||
|
@ -11,8 +10,8 @@ module.exports = {
|
||||||
if (hasMultipleRoutes)
|
if (hasMultipleRoutes)
|
||||||
ids = this.id.split(',');
|
ids = this.id.split(',');
|
||||||
|
|
||||||
const routes = await this.fetchRoutes(ids);
|
const routes = await this.rawSqlFromDef('routes', [ids]);
|
||||||
const tickets = await this.fetchTickets(ids);
|
const tickets = await this.rawSqlFromDef('tickets', [ids, ids]);
|
||||||
|
|
||||||
const map = new Map();
|
const map = new Map();
|
||||||
|
|
||||||
|
@ -27,20 +26,7 @@ module.exports = {
|
||||||
|
|
||||||
this.routes = routes;
|
this.routes = routes;
|
||||||
|
|
||||||
if (!this.routes)
|
this.checkMainEntity(this.routes);
|
||||||
throw new Error('Something went wrong');
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
fetchRoutes(ids) {
|
|
||||||
return this.rawSqlFromDef('routes', [ids]);
|
|
||||||
},
|
|
||||||
fetchTickets(ids) {
|
|
||||||
return this.rawSqlFromDef('tickets', [ids, ids]);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
components: {
|
|
||||||
'report-body': reportBody.build(),
|
|
||||||
'report-footer': reportFooter.build()
|
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
id: {
|
id: {
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="font gray uppercase">{{$t('date')}}</td>
|
<td class="font gray uppercase">{{$t('date')}}</td>
|
||||||
<th>{{entry.landed | date('%d-%m-%Y')}}</th>
|
<th>{{formatDate(entry.landed,'%d-%m-%Y')}}</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="font gray uppercase">{{$t('ref')}}</td>
|
<td class="font gray uppercase">{{$t('ref')}}</td>
|
||||||
|
|
|
@ -1,31 +1,18 @@
|
||||||
const Component = require(`vn-print/core/component`);
|
const vnReport = require('../../../core/mixins/vn-report.js');
|
||||||
const reportBody = new Component('report-body');
|
|
||||||
const reportHeader = new Component('report-header');
|
|
||||||
const reportFooter = new Component('report-footer');
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'entry-order',
|
name: 'entry-order',
|
||||||
|
mixins: [vnReport],
|
||||||
async serverPrefetch() {
|
async serverPrefetch() {
|
||||||
this.supplier = await this.fetchSupplier(this.id);
|
this.entry = await this.findOneFromDef('entry', [this.id]);
|
||||||
this.entry = await this.fetchEntry(this.id);
|
this.checkMainEntity(this.entry);
|
||||||
this.buys = await this.fetchBuys(this.id);
|
this.supplier = await this.findOneFromDef('supplier', [this.id]);
|
||||||
|
this.buys = await this.rawSqlFromDef('buys', [this.id]);
|
||||||
if (!this.entry)
|
|
||||||
throw new Error('Something went wrong');
|
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {totalBalance: 0.00};
|
return {totalBalance: 0.00};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
fetchSupplier(id) {
|
|
||||||
return this.findOneFromDef('supplier', [id]);
|
|
||||||
},
|
|
||||||
fetchEntry(id) {
|
|
||||||
return this.findOneFromDef('entry', [id]);
|
|
||||||
},
|
|
||||||
fetchBuys(id) {
|
|
||||||
return this.rawSqlFromDef('buys', [id]);
|
|
||||||
},
|
|
||||||
getTotal() {
|
getTotal() {
|
||||||
let total = 0.00;
|
let total = 0.00;
|
||||||
this.buys.forEach(buy => {
|
this.buys.forEach(buy => {
|
||||||
|
@ -35,11 +22,6 @@ module.exports = {
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
components: {
|
|
||||||
'report-body': reportBody.build(),
|
|
||||||
'report-header': reportHeader.build(),
|
|
||||||
'report-footer': reportFooter.build()
|
|
||||||
},
|
|
||||||
props: {
|
props: {
|
||||||
id: {
|
id: {
|
||||||
type: Number,
|
type: Number,
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
const Component = require(`vn-print/core/component`);
|
const vnReport = require('../../../core/mixins/vn-report.js');
|
||||||
const reportBody = new Component('report-body');
|
|
||||||
const jsBarcode = require('jsbarcode');
|
const jsBarcode = require('jsbarcode');
|
||||||
const {DOMImplementation, XMLSerializer} = require('xmldom');
|
const {DOMImplementation, XMLSerializer} = require('xmldom');
|
||||||
const UserError = require('vn-loopback/util/user-error');
|
|
||||||
const qrcode = require('qrcode');
|
const qrcode = require('qrcode');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'expedition-pallet-label',
|
name: 'expedition-pallet-label',
|
||||||
|
mixins: [vnReport],
|
||||||
props: {
|
props: {
|
||||||
id: {
|
id: {
|
||||||
type: Number,
|
type: Number,
|
||||||
|
@ -33,8 +32,7 @@ module.exports = {
|
||||||
});
|
});
|
||||||
|
|
||||||
this.QR = await this.getQR(QRdata);
|
this.QR = await this.getQR(QRdata);
|
||||||
if (!this.labelsData.length)
|
this.checkMainEntity(this.labelsData);
|
||||||
throw new UserError('Empty data source');
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getQR(id) {
|
getQR(id) {
|
||||||
|
@ -56,7 +54,4 @@ module.exports = {
|
||||||
return xmlSerializer.serializeToString(svgNode);
|
return xmlSerializer.serializeToString(svgNode);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
components: {
|
|
||||||
'report-body': reportBody.build()
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<div class="grid-block">
|
<div class="grid-block">
|
||||||
<h1 class="title centered uppercase">{{$t('title')}}</h1>
|
<h1 class="title centered uppercase">{{$t('title')}}</h1>
|
||||||
<p>{{$t('toAttention')}}</p>
|
<p>{{$t('toAttention')}}</p>
|
||||||
<p v-html="$t('declaration', [invoice.ref, issued])"></p>
|
<p v-html="$t('declaration', [invoice.ref, formatDate(invoice.issued, '%d-%m-%Y')])"></p>
|
||||||
<p>
|
<p>
|
||||||
<ul>
|
<ul>
|
||||||
<li v-for="responsibility in $t('responsibilities')">
|
<li v-for="responsibility in $t('responsibilities')">
|
||||||
|
|
|
@ -1,33 +1,13 @@
|
||||||
const Component = require(`vn-print/core/component`);
|
const vnReport = require('../../../core/mixins/vn-report.js');
|
||||||
const reportBody = new Component('report-body');
|
|
||||||
const reportFooter = new Component('report-footer');
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'exportation',
|
name: 'exportation',
|
||||||
|
mixins: [vnReport],
|
||||||
async serverPrefetch() {
|
async serverPrefetch() {
|
||||||
this.invoice = await this.fetchInvoice(this.reference);
|
this.invoice = await this.findOneFromDef('invoice', [this.reference]);
|
||||||
|
this.checkMainEntity(this.invoice);
|
||||||
if (!this.invoice)
|
|
||||||
throw new Error('Something went wrong');
|
|
||||||
|
|
||||||
this.company = await this.findOneFromDef('company', [this.invoice.companyFk]);
|
this.company = await this.findOneFromDef('company', [this.invoice.companyFk]);
|
||||||
},
|
},
|
||||||
methods: {
|
|
||||||
fetchInvoice(reference) {
|
|
||||||
return this.findOneFromDef('invoice', [reference]);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
issued: function() {
|
|
||||||
const filters = this.$options.filters;
|
|
||||||
|
|
||||||
return filters.date(this.invoice.issued, '%d-%m-%Y');
|
|
||||||
}
|
|
||||||
},
|
|
||||||
components: {
|
|
||||||
'report-body': reportBody.build(),
|
|
||||||
'report-footer': reportFooter.build()
|
|
||||||
},
|
|
||||||
props: {
|
props: {
|
||||||
reference: {
|
reference: {
|
||||||
type: Number,
|
type: Number,
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="font gray align-right">{{$t('shipped')}}</th>
|
<th class="font gray align-right">{{$t('shipped')}}</th>
|
||||||
<td>{{travel.shipped | date('%d-%m-%Y')}}</td>
|
<td>{{formatDate(travel.shipped, '%d-%m-%Y')}}</td>
|
||||||
<th class="font gray align-right">{{$t('physicalKg')}}</th>
|
<th class="font gray align-right">{{$t('physicalKg')}}</th>
|
||||||
<td>{{travel.loadedKg | number($i18n.locale)}}</td>
|
<td>{{travel.loadedKg | number($i18n.locale)}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -62,6 +62,6 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<template v-slot:footer>
|
<template v-slot:footer>
|
||||||
<report-footer id="pageFooter" v-bind:left-text="dated" v-bind="$props"></report-footer>
|
<report-footer id="pageFooter" v-bind:left-text="formatDate(new Date(), '%d-%m-%Y')" v-bind="$props"></report-footer>
|
||||||
</template>
|
</template>
|
||||||
</report-body>
|
</report-body>
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
const Component = require(`vn-print/core/component`);
|
const vnReport = require('../../../core/mixins/vn-report.js');
|
||||||
const reportBody = new Component('report-body');
|
|
||||||
const reportFooter = new Component('report-footer');
|
|
||||||
const db = require(`vn-print/core/database`);
|
const db = require(`vn-print/core/database`);
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'extra-community',
|
name: 'extra-community',
|
||||||
|
mixins: [vnReport],
|
||||||
async serverPrefetch() {
|
async serverPrefetch() {
|
||||||
this.filters = this.$options.filters;
|
|
||||||
const args = {
|
const args = {
|
||||||
landedTo: this.landedEnd,
|
landedTo: this.landedEnd,
|
||||||
shippedFrom: this.shippedStart,
|
shippedFrom: this.shippedStart,
|
||||||
|
@ -21,8 +19,9 @@ module.exports = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const travels = await this.fetchTravels(args);
|
const travels = await this.fetchTravels(args);
|
||||||
|
this.checkMainEntity(travels);
|
||||||
const travelIds = travels.map(travel => travel.id);
|
const travelIds = travels.map(travel => travel.id);
|
||||||
const entries = await this.fetchEntries(travelIds);
|
const entries = await this.rawSqlFromDef('entries', [travelIds]);
|
||||||
|
|
||||||
const map = new Map();
|
const map = new Map();
|
||||||
for (let travel of travels)
|
for (let travel of travels)
|
||||||
|
@ -35,23 +34,15 @@ module.exports = {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.travels = travels;
|
this.travels = travels;
|
||||||
|
|
||||||
if (!this.travels)
|
|
||||||
throw new Error('Something went wrong');
|
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
dated: function() {
|
|
||||||
return this.filters.date(new Date(), '%d-%m-%Y');
|
|
||||||
},
|
|
||||||
landedEnd: function() {
|
landedEnd: function() {
|
||||||
if (!this.landedTo) return;
|
if (!this.landedTo) return;
|
||||||
|
return formatDate(this.landedTo, '%Y-%m-%d');
|
||||||
return this.filters.date(this.landedTo, '%Y-%m-%d');
|
|
||||||
},
|
},
|
||||||
shippedStart: function() {
|
shippedStart: function() {
|
||||||
if (!this.shippedFrom) return;
|
if (!this.shippedFrom) return;
|
||||||
|
return formatDate(this.shippedFrom, '%Y-%m-%d');
|
||||||
return this.filters.date(this.shippedFrom, '%Y-%m-%d');
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -94,14 +85,6 @@ module.exports = {
|
||||||
|
|
||||||
return this.rawSql(query);
|
return this.rawSql(query);
|
||||||
},
|
},
|
||||||
|
|
||||||
fetchEntries(travelIds) {
|
|
||||||
return this.rawSqlFromDef('entries', [travelIds]);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
components: {
|
|
||||||
'report-body': reportBody.build(),
|
|
||||||
'report-footer': reportFooter.build()
|
|
||||||
},
|
},
|
||||||
props: [
|
props: [
|
||||||
'landedTo',
|
'landedTo',
|
||||||
|
|
|
@ -1,23 +1,12 @@
|
||||||
const Component = require(`vn-print/core/component`);
|
const vnReport = require('../../../core/mixins/vn-report.js');
|
||||||
const reportBody = new Component('report-body');
|
|
||||||
const reportFooter = new Component('report-footer');
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'incoterms-authorization',
|
name: 'incoterms-authorization',
|
||||||
|
mixins: [vnReport],
|
||||||
async serverPrefetch() {
|
async serverPrefetch() {
|
||||||
this.client = await this.findOneFromDef('client', [this.id]);
|
this.client = await this.findOneFromDef('client', [this.id]);
|
||||||
|
this.checkMainEntity(this.client);
|
||||||
this.company = await this.findOneFromDef('company', [this.companyId]);
|
this.company = await this.findOneFromDef('company', [this.companyId]);
|
||||||
if (!this.client)
|
|
||||||
throw new Error('Something went wrong');
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
issued: function() {
|
|
||||||
return new Date();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
components: {
|
|
||||||
'report-body': reportBody.build(),
|
|
||||||
'report-footer': reportFooter.build()
|
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
id: {
|
id: {
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="font gray uppercase">{{$t('date')}}</td>
|
<td class="font gray uppercase">{{$t('date')}}</td>
|
||||||
<th>{{invoice.issued | date('%d-%m-%Y')}}</th>
|
<th>{{formatDate(invoice.issued, '%d-%m-%Y')}}</th>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -1,34 +1,13 @@
|
||||||
const Component = require(`vn-print/core/component`);
|
const vnReport = require('../../../core/mixins/vn-report.js');
|
||||||
const reportBody = new Component('report-body');
|
|
||||||
const reportHeader = new Component('report-header');
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'invoice-incoterms',
|
name: 'invoice-incoterms',
|
||||||
|
mixins: [vnReport],
|
||||||
async serverPrefetch() {
|
async serverPrefetch() {
|
||||||
this.invoice = await this.fetchInvoice(this.reference);
|
this.invoice = await this.findOneFromDef('invoice', [this.reference]);
|
||||||
this.client = await this.fetchClient(this.reference);
|
this.checkMainEntity(this.invoice);
|
||||||
this.incoterms = await this.fetchIncoterms(this.reference);
|
this.client = await this.findOneFromDef('client', [this.reference]);
|
||||||
|
this.incoterms = await this.findOneFromDef('incoterms', [this.reference, this.reference, this.reference]);
|
||||||
if (!this.invoice)
|
|
||||||
throw new Error('Something went wrong');
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
fetchInvoice(reference) {
|
|
||||||
return this.findOneFromDef('invoice', [reference]);
|
|
||||||
},
|
|
||||||
fetchClient(reference) {
|
|
||||||
return this.findOneFromDef('client', [reference]);
|
|
||||||
},
|
|
||||||
fetchIncoterms(reference) {
|
|
||||||
return this.findOneFromDef('incoterms', [reference, reference, reference]);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
components: {
|
|
||||||
'report-body': reportBody.build(),
|
|
||||||
'report-header': reportHeader.build()
|
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
reference: {
|
reference: {
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="font gray uppercase">{{$t('date')}}</td>
|
<td class="font gray uppercase">{{$t('date')}}</td>
|
||||||
<th>{{invoice.issued | date('%d-%m-%Y')}}</th>
|
<th>{{formatDate(invoice.issued, '%d-%m-%Y')}}</th>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
@ -53,7 +53,7 @@
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr v-for="row in rectified">
|
<tr v-for="row in rectified">
|
||||||
<td>{{row.ref}}</td>
|
<td>{{row.ref}}</td>
|
||||||
<td>{{row.issued | date}}</td>
|
<td>{{formatDate(row.issued, '%d-%m-%Y')}}</td>
|
||||||
<td class="number">{{row.amount | currency('EUR', $i18n.locale)}}</td>
|
<td class="number">{{row.amount | currency('EUR', $i18n.locale)}}</td>
|
||||||
<td width="50%">{{row.description}}</td>
|
<td width="50%">{{row.description}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -75,7 +75,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="pull-left">
|
<div class="pull-left">
|
||||||
<div class="field rectangle">
|
<div class="field rectangle">
|
||||||
<span>{{ticket.shipped | date}}</span>
|
<span>{{formatDate(ticket.shipped, '%d-%m-%Y')}}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<span id="nickname" class="pull-right">
|
<span id="nickname" class="pull-right">
|
||||||
|
|
|
@ -1,22 +1,21 @@
|
||||||
const Component = require(`vn-print/core/component`);
|
|
||||||
const Report = require(`vn-print/core/report`);
|
const Report = require(`vn-print/core/report`);
|
||||||
const reportBody = new Component('report-body');
|
const vnReport = require('../../../core/mixins/vn-report.js');
|
||||||
const reportHeader = new Component('report-header');
|
|
||||||
const reportFooter = new Component('report-footer');
|
|
||||||
const invoiceIncoterms = new Report('invoice-incoterms');
|
const invoiceIncoterms = new Report('invoice-incoterms');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'invoice',
|
name: 'invoice',
|
||||||
|
mixins: [vnReport],
|
||||||
async serverPrefetch() {
|
async serverPrefetch() {
|
||||||
this.invoice = await this.fetchInvoice(this.reference);
|
this.invoice = await this.findOneFromDef('invoice', [this.reference]);
|
||||||
this.client = await this.fetchClient(this.reference);
|
this.checkMainEntity(this.invoice);
|
||||||
this.taxes = await this.fetchTaxes(this.reference);
|
this.client = await this.findOneFromDef('client', [this.reference]);
|
||||||
this.intrastat = await this.fetchIntrastat(this.reference);
|
this.taxes = await this.rawSqlFromDef(`taxes`, [this.reference]);
|
||||||
this.rectified = await this.fetchRectified(this.reference);
|
this.intrastat = await this.rawSqlFromDef(`intrastat`, [this.reference, this.reference, this.reference]);
|
||||||
this.hasIncoterms = await this.fetchHasIncoterms(this.reference);
|
this.rectified = await this.rawSqlFromDef(`rectified`, [this.reference]);
|
||||||
|
this.hasIncoterms = await this.findValueFromDef(`hasIncoterms`, [this.reference]);
|
||||||
|
|
||||||
const tickets = await this.fetchTickets(this.reference);
|
const tickets = await this.rawSqlFromDef('tickets', [this.reference]);
|
||||||
const sales = await this.fetchSales(this.reference);
|
const sales = await this.rawSqlFromDef('sales', [this.reference, this.reference]);
|
||||||
|
|
||||||
const map = new Map();
|
const map = new Map();
|
||||||
|
|
||||||
|
@ -33,9 +32,6 @@ module.exports = {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.tickets = tickets;
|
this.tickets = tickets;
|
||||||
|
|
||||||
if (!this.invoice)
|
|
||||||
throw new Error('Something went wrong');
|
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {totalBalance: 0.00};
|
return {totalBalance: 0.00};
|
||||||
|
@ -66,30 +62,6 @@ module.exports = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
fetchInvoice(reference) {
|
|
||||||
return this.findOneFromDef('invoice', [reference]);
|
|
||||||
},
|
|
||||||
fetchClient(reference) {
|
|
||||||
return this.findOneFromDef('client', [reference]);
|
|
||||||
},
|
|
||||||
fetchTickets(reference) {
|
|
||||||
return this.rawSqlFromDef('tickets', [reference]);
|
|
||||||
},
|
|
||||||
fetchSales(reference) {
|
|
||||||
return this.rawSqlFromDef('sales', [reference, reference]);
|
|
||||||
},
|
|
||||||
fetchTaxes(reference) {
|
|
||||||
return this.rawSqlFromDef(`taxes`, [reference]);
|
|
||||||
},
|
|
||||||
fetchIntrastat(reference) {
|
|
||||||
return this.rawSqlFromDef(`intrastat`, [reference, reference, reference]);
|
|
||||||
},
|
|
||||||
fetchRectified(reference) {
|
|
||||||
return this.rawSqlFromDef(`rectified`, [reference]);
|
|
||||||
},
|
|
||||||
fetchHasIncoterms(reference) {
|
|
||||||
return this.findValueFromDef(`hasIncoterms`, [reference]);
|
|
||||||
},
|
|
||||||
saleImport(sale) {
|
saleImport(sale) {
|
||||||
const price = sale.quantity * sale.price;
|
const price = sale.quantity * sale.price;
|
||||||
|
|
||||||
|
@ -111,9 +83,6 @@ module.exports = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
'report-body': reportBody.build(),
|
|
||||||
'report-header': reportHeader.build(),
|
|
||||||
'report-footer': reportFooter.build(),
|
|
||||||
'invoice-incoterms': invoiceIncoterms.build()
|
'invoice-incoterms': invoiceIncoterms.build()
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="font gray uppercase">{{$t('date')}}</td>
|
<td class="font gray uppercase">{{$t('date')}}</td>
|
||||||
<th>{{invoice.created | date('%d-%m-%Y')}}</th>
|
<th>{{formatDate(invoice.created, '%d-%m-%Y')}}</th>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
@ -54,7 +54,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="pull-left">
|
<div class="pull-left">
|
||||||
<div class="field rectangle">
|
<div class="field rectangle">
|
||||||
<span>{{entry.landed | date}}</span>
|
<span>{{formatDate(entry.landed, '%d-%m-%Y')}}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<span id="nickname" class="pull-right">
|
<span id="nickname" class="pull-right">
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue