Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 5439-newFilterEnPeticionesDeCompra
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
commit
36af9d45e7
|
@ -5,5 +5,6 @@
|
||||||
"editor.codeActionsOnSave": {
|
"editor.codeActionsOnSave": {
|
||||||
"source.fixAll.eslint": true
|
"source.fixAll.eslint": true
|
||||||
},
|
},
|
||||||
"search.useIgnoreFiles": false
|
"search.useIgnoreFiles": false,
|
||||||
|
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
|
||||||
}
|
}
|
||||||
|
|
|
@ -299,7 +299,8 @@ INSERT INTO `vn`.`payMethod`(`id`,`code`, `name`, `graceDays`, `outstandingDebt
|
||||||
INSERT INTO `vn`.`payDem`(`id`, `payDem`)
|
INSERT INTO `vn`.`payDem`(`id`, `payDem`)
|
||||||
VALUES
|
VALUES
|
||||||
(1, 10),
|
(1, 10),
|
||||||
(2, 20);
|
(2, 20),
|
||||||
|
(7, 0);
|
||||||
|
|
||||||
INSERT INTO `vn`.`autonomy`(`id`, `name`, `countryFk`)
|
INSERT INTO `vn`.`autonomy`(`id`, `name`, `countryFk`)
|
||||||
VALUES
|
VALUES
|
||||||
|
|
|
@ -524,7 +524,7 @@ export default {
|
||||||
},
|
},
|
||||||
itemLog: {
|
itemLog: {
|
||||||
anyLineCreated: 'vn-item-log > vn-log vn-tbody > vn-tr',
|
anyLineCreated: 'vn-item-log > vn-log vn-tbody > vn-tr',
|
||||||
fifthLineCreatedProperty: 'vn-item-log > vn-log vn-tbody > vn-tr:nth-child(5) table tr:nth-child(4) td.after',
|
fifthLineCreatedProperty: 'vn-item-log > vn-log vn-tbody > vn-tr:nth-child(5) table tr:nth-child(5) td.after',
|
||||||
},
|
},
|
||||||
ticketSummary: {
|
ticketSummary: {
|
||||||
header: 'vn-ticket-summary > vn-card > h5',
|
header: 'vn-ticket-summary > vn-card > h5',
|
||||||
|
@ -1040,7 +1040,6 @@ export default {
|
||||||
boss: 'vn-worker-create vn-autocomplete[ng-model="$ctrl.worker.bossFk"]',
|
boss: 'vn-worker-create vn-autocomplete[ng-model="$ctrl.worker.bossFk"]',
|
||||||
role: 'vn-worker-create vn-autocomplete[ng-model="$ctrl.worker.roleFk"]',
|
role: 'vn-worker-create vn-autocomplete[ng-model="$ctrl.worker.roleFk"]',
|
||||||
iban: 'vn-worker-create vn-textfield[ng-model="$ctrl.worker.iban"]',
|
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"]',
|
createButton: 'vn-worker-create vn-submit[label="Create"]',
|
||||||
},
|
},
|
||||||
workerPda: {
|
workerPda: {
|
||||||
|
|
|
@ -27,7 +27,7 @@ describe('Worker time control path', () => {
|
||||||
date.setMonth(date.getMonth() + 1);
|
date.setMonth(date.getMonth() + 1);
|
||||||
let month = date.toLocaleString('default', {month: 'long'});
|
let month = date.toLocaleString('default', {month: 'long'});
|
||||||
|
|
||||||
await page.click(selectors.workerTimeControl.nextMonthButton);
|
await page.waitToClick(selectors.workerTimeControl.nextMonthButton);
|
||||||
let result = await page.getProperty(selectors.workerTimeControl.monthName, 'innerText');
|
let result = await page.getProperty(selectors.workerTimeControl.monthName, 'innerText');
|
||||||
|
|
||||||
expect(result).toContain(month);
|
expect(result).toContain(month);
|
||||||
|
@ -36,7 +36,7 @@ describe('Worker time control path', () => {
|
||||||
date.setDate(1);
|
date.setDate(1);
|
||||||
month = date.toLocaleString('default', {month: 'long'});
|
month = date.toLocaleString('default', {month: 'long'});
|
||||||
|
|
||||||
await page.click(selectors.workerTimeControl.previousMonthButton);
|
await page.waitToClick(selectors.workerTimeControl.previousMonthButton);
|
||||||
result = await page.getProperty(selectors.workerTimeControl.monthName, 'innerText');
|
result = await page.getProperty(selectors.workerTimeControl.monthName, 'innerText');
|
||||||
|
|
||||||
expect(result).toContain(month);
|
expect(result).toContain(month);
|
||||||
|
@ -49,7 +49,7 @@ describe('Worker time control path', () => {
|
||||||
|
|
||||||
await page.loginAndModule('salesBoss', 'worker');
|
await page.loginAndModule('salesBoss', 'worker');
|
||||||
await page.goto(`http://localhost:5000/#!/worker/${hankPymId}/time-control?timestamp=${timestamp}`);
|
await page.goto(`http://localhost:5000/#!/worker/${hankPymId}/time-control?timestamp=${timestamp}`);
|
||||||
await page.click(selectors.workerTimeControl.secondWeekDay);
|
await page.waitToClick(selectors.workerTimeControl.secondWeekDay);
|
||||||
|
|
||||||
result = await page.getProperty(selectors.workerTimeControl.monthName, 'innerText');
|
result = await page.getProperty(selectors.workerTimeControl.monthName, 'innerText');
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,6 @@ describe('Worker create path', () => {
|
||||||
await page.write(selectors.workerCreate.street, 'S/ Doomstadt');
|
await page.write(selectors.workerCreate.street, 'S/ Doomstadt');
|
||||||
await page.write(selectors.workerCreate.email, 'doctorDoom@marvel.com');
|
await page.write(selectors.workerCreate.email, 'doctorDoom@marvel.com');
|
||||||
await page.write(selectors.workerCreate.iban, 'ES9121000418450200051332');
|
await page.write(selectors.workerCreate.iban, 'ES9121000418450200051332');
|
||||||
await page.autocompleteSearch(selectors.workerCreate.switft, 'BBKKESMMMMM');
|
|
||||||
|
|
||||||
// should check for autocompleted worker code and worker user name
|
// should check for autocompleted worker code and worker user name
|
||||||
const workerCode = await page
|
const workerCode = await page
|
||||||
|
|
|
@ -54,7 +54,7 @@ describe('Ticket Future path', () => {
|
||||||
it('should search with the origin IPT', async() => {
|
it('should search with the origin IPT', async() => {
|
||||||
await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton);
|
await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton);
|
||||||
|
|
||||||
await page.autocompleteSearch(selectors.ticketFuture.ipt, 'Horizontal');
|
await page.autocompleteSearch(selectors.ticketFuture.ipt, 'H');
|
||||||
await page.waitToClick(selectors.ticketFuture.submit);
|
await page.waitToClick(selectors.ticketFuture.submit);
|
||||||
|
|
||||||
expect(httpRequest).toContain('ipt=H');
|
expect(httpRequest).toContain('ipt=H');
|
||||||
|
@ -65,7 +65,7 @@ describe('Ticket Future path', () => {
|
||||||
|
|
||||||
await page.clearInput(selectors.ticketFuture.ipt);
|
await page.clearInput(selectors.ticketFuture.ipt);
|
||||||
|
|
||||||
await page.autocompleteSearch(selectors.ticketFuture.futureIpt, 'Horizontal');
|
await page.autocompleteSearch(selectors.ticketFuture.futureIpt, 'H');
|
||||||
await page.waitToClick(selectors.ticketFuture.submit);
|
await page.waitToClick(selectors.ticketFuture.submit);
|
||||||
|
|
||||||
expect(httpRequest).toContain('futureIpt=H');
|
expect(httpRequest).toContain('futureIpt=H');
|
||||||
|
@ -108,7 +108,7 @@ describe('Ticket Future path', () => {
|
||||||
|
|
||||||
it('should search in smart-table with an IPT Destination', async() => {
|
it('should search in smart-table with an IPT Destination', async() => {
|
||||||
await page.waitToClick(selectors.ticketFuture.tableButtonSearch);
|
await page.waitToClick(selectors.ticketFuture.tableButtonSearch);
|
||||||
await page.autocompleteSearch(selectors.ticketFuture.tableFutureIpt, 'Horizontal');
|
await page.autocompleteSearch(selectors.ticketFuture.tableFutureIpt, 'H');
|
||||||
|
|
||||||
expect(httpRequest).toContain('futureIpt');
|
expect(httpRequest).toContain('futureIpt');
|
||||||
await page.waitToClick(selectors.ticketFuture.tableButtonSearch);
|
await page.waitToClick(selectors.ticketFuture.tableButtonSearch);
|
||||||
|
|
|
@ -54,7 +54,7 @@ describe('Ticket Advance path', () => {
|
||||||
|
|
||||||
it('should search with the origin IPT', async() => {
|
it('should search with the origin IPT', async() => {
|
||||||
await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton);
|
await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton);
|
||||||
await page.autocompleteSearch(selectors.ticketAdvance.futureIpt, 'Horizontal');
|
await page.autocompleteSearch(selectors.ticketAdvance.futureIpt, 'H');
|
||||||
await page.waitToClick(selectors.ticketAdvance.submit);
|
await page.waitToClick(selectors.ticketAdvance.submit);
|
||||||
|
|
||||||
expect(httpRequest).toContain('futureIpt=H');
|
expect(httpRequest).toContain('futureIpt=H');
|
||||||
|
@ -66,7 +66,7 @@ describe('Ticket Advance path', () => {
|
||||||
|
|
||||||
it('should search with the destination IPT', async() => {
|
it('should search with the destination IPT', async() => {
|
||||||
await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton);
|
await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton);
|
||||||
await page.autocompleteSearch(selectors.ticketAdvance.ipt, 'Horizontal');
|
await page.autocompleteSearch(selectors.ticketAdvance.ipt, 'H');
|
||||||
await page.waitToClick(selectors.ticketAdvance.submit);
|
await page.waitToClick(selectors.ticketAdvance.submit);
|
||||||
|
|
||||||
expect(httpRequest).toContain('ipt=H');
|
expect(httpRequest).toContain('ipt=H');
|
||||||
|
@ -78,7 +78,7 @@ describe('Ticket Advance path', () => {
|
||||||
|
|
||||||
it('should search in smart-table with an IPT Origin', async() => {
|
it('should search in smart-table with an IPT Origin', async() => {
|
||||||
await page.waitToClick(selectors.ticketAdvance.tableButtonSearch);
|
await page.waitToClick(selectors.ticketAdvance.tableButtonSearch);
|
||||||
await page.autocompleteSearch(selectors.ticketAdvance.tableFutureIpt, 'Vertical');
|
await page.autocompleteSearch(selectors.ticketAdvance.tableFutureIpt, 'V');
|
||||||
|
|
||||||
expect(httpRequest).toContain('futureIpt');
|
expect(httpRequest).toContain('futureIpt');
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ describe('Ticket Advance path', () => {
|
||||||
|
|
||||||
it('should search in smart-table with an IPT Destination', async() => {
|
it('should search in smart-table with an IPT Destination', async() => {
|
||||||
await page.waitToClick(selectors.ticketAdvance.tableButtonSearch);
|
await page.waitToClick(selectors.ticketAdvance.tableButtonSearch);
|
||||||
await page.autocompleteSearch(selectors.ticketAdvance.tableIpt, 'Vertical');
|
await page.autocompleteSearch(selectors.ticketAdvance.tableIpt, 'V');
|
||||||
|
|
||||||
expect(httpRequest).toContain('ipt');
|
expect(httpRequest).toContain('ipt');
|
||||||
|
|
||||||
|
|
|
@ -114,12 +114,14 @@ export default class Calendar extends FormInput {
|
||||||
let day = date.getDate();
|
let day = date.getDate();
|
||||||
let wday = date.getDay();
|
let wday = date.getDay();
|
||||||
let month = date.getMonth();
|
let month = date.getMonth();
|
||||||
|
let year = date.getFullYear();
|
||||||
|
|
||||||
const currentDay = Date.vnNew().getDate();
|
const currentDay = Date.vnNew().getDate();
|
||||||
const currentMonth = Date.vnNew().getMonth();
|
const currentMonth = Date.vnNew().getMonth();
|
||||||
|
const currentYear = Date.vnNew().getFullYear();
|
||||||
|
|
||||||
let classes = {
|
let classes = {
|
||||||
today: day === currentDay && month === currentMonth,
|
today: day === currentDay && month === currentMonth && year === currentYear,
|
||||||
weekend: wday === 6 || wday === 0,
|
weekend: wday === 6 || wday === 0,
|
||||||
previous: month < this.month,
|
previous: month < this.month,
|
||||||
current: month == this.month,
|
current: month == this.month,
|
||||||
|
|
|
@ -82,6 +82,11 @@
|
||||||
"type": "hasMany",
|
"type": "hasMany",
|
||||||
"model": "ClaimDms",
|
"model": "ClaimDms",
|
||||||
"foreignKey": "claimFk"
|
"foreignKey": "claimFk"
|
||||||
|
},
|
||||||
|
"lines": {
|
||||||
|
"type": "hasMany",
|
||||||
|
"model": "ClaimBeginning",
|
||||||
|
"foreignKey": "claimFk"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,49 +0,0 @@
|
||||||
|
|
||||||
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
|
|
||||||
|
|
||||||
module.exports = Self => {
|
|
||||||
Self.remoteMethod('getTransactions', {
|
|
||||||
description: 'Returns last entries',
|
|
||||||
accessType: 'READ',
|
|
||||||
accepts: [{
|
|
||||||
arg: 'filter',
|
|
||||||
type: 'object',
|
|
||||||
description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string',
|
|
||||||
http: {source: 'query'}
|
|
||||||
}],
|
|
||||||
returns: {
|
|
||||||
type: ['object'],
|
|
||||||
root: true
|
|
||||||
},
|
|
||||||
http: {
|
|
||||||
path: `/getTransactions`,
|
|
||||||
verb: 'GET'
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Self.getTransactions = async(filter, options) => {
|
|
||||||
const myOptions = {};
|
|
||||||
|
|
||||||
if (typeof options == 'object')
|
|
||||||
Object.assign(myOptions, options);
|
|
||||||
|
|
||||||
const conn = Self.dataSource.connector;
|
|
||||||
const stmt = new ParameterizedSQL(`
|
|
||||||
SELECT
|
|
||||||
t.id,
|
|
||||||
t.clientFk,
|
|
||||||
t.created,
|
|
||||||
t.amount / 100 amount,
|
|
||||||
t.receiptFk IS NOT NULL AS isConfirmed,
|
|
||||||
tt.message responseMessage,
|
|
||||||
te.message errorMessage
|
|
||||||
FROM hedera.tpvTransaction t
|
|
||||||
JOIN hedera.tpvMerchant m ON m.id = t.merchantFk
|
|
||||||
LEFT JOIN hedera.tpvResponse tt ON tt.id = t.response
|
|
||||||
LEFT JOIN hedera.tpvError te ON te.code = errorCode`);
|
|
||||||
|
|
||||||
stmt.merge(conn.makeSuffix(filter, 't'));
|
|
||||||
|
|
||||||
return Self.rawStmt(stmt, myOptions);
|
|
||||||
};
|
|
||||||
};
|
|
|
@ -1,21 +0,0 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
|
||||||
|
|
||||||
describe('Client getTransations', () => {
|
|
||||||
it('should call getTransations() method to receive a list of Web Payments from Bruce Wayne', async() => {
|
|
||||||
const tx = await models.Client.beginTransaction({});
|
|
||||||
|
|
||||||
try {
|
|
||||||
const options = {transaction: tx};
|
|
||||||
|
|
||||||
const filter = {where: {clientFk: 1101}};
|
|
||||||
const result = await models.Client.getTransactions(filter, options);
|
|
||||||
|
|
||||||
expect(result[1].id).toBeTruthy();
|
|
||||||
|
|
||||||
await tx.rollback();
|
|
||||||
} catch (e) {
|
|
||||||
await tx.rollback();
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -0,0 +1,66 @@
|
||||||
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
|
describe('Client transactions', () => {
|
||||||
|
it('should call transactions() method to receive a list of Web Payments from Bruce Wayne', async() => {
|
||||||
|
const tx = await models.Client.beginTransaction({});
|
||||||
|
|
||||||
|
try {
|
||||||
|
const options = {transaction: tx};
|
||||||
|
|
||||||
|
const ctx = {};
|
||||||
|
const filter = {where: {clientFk: 1101}};
|
||||||
|
const result = await models.Client.transactions(ctx, filter, options);
|
||||||
|
|
||||||
|
expect(result[1].id).toBeTruthy();
|
||||||
|
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should call transactions() method filtering by orderFk', async() => {
|
||||||
|
const tx = await models.Client.beginTransaction({});
|
||||||
|
|
||||||
|
try {
|
||||||
|
const options = {transaction: tx};
|
||||||
|
|
||||||
|
const ctx = {args: {orderFk: 6}};
|
||||||
|
const filter = {};
|
||||||
|
const result = await models.Client.transactions(ctx, filter, options);
|
||||||
|
|
||||||
|
const firstRow = result[0];
|
||||||
|
|
||||||
|
expect(result.length).toEqual(1);
|
||||||
|
expect(firstRow.id).toEqual(6);
|
||||||
|
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should call transactions() method filtering by amount', async() => {
|
||||||
|
const tx = await models.Client.beginTransaction({});
|
||||||
|
|
||||||
|
try {
|
||||||
|
const options = {transaction: tx};
|
||||||
|
|
||||||
|
const ctx = {args: {amount: 40}};
|
||||||
|
const filter = {};
|
||||||
|
const result = await models.Client.transactions(ctx, filter, options);
|
||||||
|
|
||||||
|
const randomIndex = Math.floor(Math.random() * result.length);
|
||||||
|
const transaction = result[randomIndex];
|
||||||
|
|
||||||
|
expect(transaction.amount).toEqual(40);
|
||||||
|
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,84 @@
|
||||||
|
|
||||||
|
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
|
||||||
|
const buildFilter = require('vn-loopback/util/filter').buildFilter;
|
||||||
|
const mergeFilters = require('vn-loopback/util/filter').mergeFilters;
|
||||||
|
|
||||||
|
module.exports = Self => {
|
||||||
|
Self.remoteMethodCtx('transactions', {
|
||||||
|
description: 'Returns customer transactions',
|
||||||
|
accessType: 'READ',
|
||||||
|
accepts: [
|
||||||
|
{
|
||||||
|
arg: 'filter',
|
||||||
|
type: 'object',
|
||||||
|
description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string',
|
||||||
|
http: {source: 'query'}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'orderFk',
|
||||||
|
type: 'number',
|
||||||
|
http: {source: 'query'}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'clientFk',
|
||||||
|
type: 'number',
|
||||||
|
http: {source: 'query'}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'amount',
|
||||||
|
type: 'number',
|
||||||
|
http: {source: 'query'}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
returns: {
|
||||||
|
type: ['object'],
|
||||||
|
root: true
|
||||||
|
},
|
||||||
|
http: {
|
||||||
|
path: `/transactions`,
|
||||||
|
verb: 'GET'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Self.transactions = async(ctx, filter, options) => {
|
||||||
|
const args = ctx.args;
|
||||||
|
const myOptions = {};
|
||||||
|
|
||||||
|
if (typeof options == 'object')
|
||||||
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
|
const where = buildFilter(args, (param, value) => {
|
||||||
|
switch (param) {
|
||||||
|
case 'orderFk':
|
||||||
|
return {'t.id': value};
|
||||||
|
case 'clientFk':
|
||||||
|
return {'t.clientFk': value};
|
||||||
|
case 'amount':
|
||||||
|
return {'t.amount': (value * 100)};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
filter = mergeFilters(filter, {where});
|
||||||
|
|
||||||
|
const conn = Self.dataSource.connector;
|
||||||
|
const stmt = new ParameterizedSQL(`
|
||||||
|
SELECT
|
||||||
|
t.id,
|
||||||
|
t.clientFk,
|
||||||
|
c.name AS customerName,
|
||||||
|
t.created,
|
||||||
|
t.amount / 100 amount,
|
||||||
|
t.receiptFk IS NOT NULL AS isConfirmed,
|
||||||
|
tt.message responseMessage,
|
||||||
|
te.message errorMessage
|
||||||
|
FROM hedera.tpvTransaction t
|
||||||
|
JOIN client c ON c.id = t.clientFk
|
||||||
|
JOIN hedera.tpvMerchant m ON m.id = t.merchantFk
|
||||||
|
LEFT JOIN hedera.tpvResponse tt ON tt.id = t.response
|
||||||
|
LEFT JOIN hedera.tpvError te ON te.code = errorCode`);
|
||||||
|
|
||||||
|
stmt.merge(conn.makeSuffix(filter, 't'));
|
||||||
|
|
||||||
|
return Self.rawStmt(stmt, myOptions);
|
||||||
|
};
|
||||||
|
};
|
|
@ -13,7 +13,7 @@ module.exports = Self => {
|
||||||
require('../methods/client/getCard')(Self);
|
require('../methods/client/getCard')(Self);
|
||||||
require('../methods/client/getDebt')(Self);
|
require('../methods/client/getDebt')(Self);
|
||||||
require('../methods/client/getMana')(Self);
|
require('../methods/client/getMana')(Self);
|
||||||
require('../methods/client/getTransactions')(Self);
|
require('../methods/client/transactions')(Self);
|
||||||
require('../methods/client/hasCustomerRole')(Self);
|
require('../methods/client/hasCustomerRole')(Self);
|
||||||
require('../methods/client/isValidClient')(Self);
|
require('../methods/client/isValidClient')(Self);
|
||||||
require('../methods/client/lastActiveTickets')(Self);
|
require('../methods/client/lastActiveTickets')(Self);
|
||||||
|
|
|
@ -1,55 +1,39 @@
|
||||||
<vn-crud-model
|
<vn-crud-model vn-id="model" url="clients/transactions" link="{clientFk: $ctrl.$params.id}" limit="20"
|
||||||
vn-id="model"
|
data="transactions" order="created DESC" auto-load="true">
|
||||||
url="clients/getTransactions"
|
|
||||||
link="{clientFk: $ctrl.$params.id}"
|
|
||||||
limit="20"
|
|
||||||
data="transactions"
|
|
||||||
order="created DESC"
|
|
||||||
auto-load="true">
|
|
||||||
</vn-crud-model>
|
</vn-crud-model>
|
||||||
<vn-data-viewer
|
<vn-data-viewer model="model" class="vn-w-md">
|
||||||
model="model"
|
|
||||||
class="vn-w-md">
|
|
||||||
<vn-card>
|
<vn-card>
|
||||||
<vn-table model="model">
|
<vn-table model="model">
|
||||||
<vn-thead>
|
<vn-thead>
|
||||||
<vn-tr>
|
<vn-tr>
|
||||||
<vn-th shrink>State</vn-th>
|
<vn-th shrink>State</vn-th>
|
||||||
<vn-th field="id" number>Id</vn-th>
|
<vn-th field="id" number>Id</vn-th>
|
||||||
<vn-th field="created" expand>Date</vn-th>
|
<vn-th field="created" expand>Date</vn-th>
|
||||||
<vn-th field="amount" number>Amount</vn-th>
|
<vn-th field="amount" number>Amount</vn-th>
|
||||||
<vn-th shrink></vn-th>
|
<vn-th shrink></vn-th>
|
||||||
</vn-tr>
|
</vn-tr>
|
||||||
</vn-thead>
|
</vn-thead>
|
||||||
<vn-tbody>
|
<vn-tbody>
|
||||||
<vn-tr ng-repeat="transaction in transactions">
|
<vn-tr ng-repeat="transaction in transactions">
|
||||||
<vn-td shrink>
|
<vn-td shrink>
|
||||||
<vn-icon
|
<vn-icon vn-tooltip="{{::$ctrl.getFormattedMessage(transaction)}}"
|
||||||
vn-tooltip="{{::$ctrl.getFormattedMessage(transaction)}}"
|
ng-show="::((transaction.errorMessage || transaction.responseMessage) && !transaction.isConfirmed)"
|
||||||
ng-show="::((transaction.errorMessage || transaction.responseMessage) && !transaction.isConfirmed)"
|
icon="clear">
|
||||||
icon="clear">
|
</vn-icon>
|
||||||
</vn-icon>
|
<vn-icon vn-tooltip="Confirmed" ng-show="::(transaction.isConfirmed)" icon="check">
|
||||||
<vn-icon
|
</vn-icon>
|
||||||
vn-tooltip="Confirmed"
|
</vn-td>
|
||||||
ng-show="::(transaction.isConfirmed)"
|
<vn-td number>{{::transaction.id}}</vn-td>
|
||||||
icon="check">
|
<vn-td>{{::transaction.created | date:'dd/MM/yyyy HH:mm'}}</vn-td>
|
||||||
</vn-icon>
|
<vn-td number>{{::transaction.amount | currency: 'EUR':2}}</vn-td>
|
||||||
</vn-td>
|
<vn-td shrink>
|
||||||
<vn-td number>{{::transaction.id}}</vn-td>
|
<vn-icon-button icon="done_all" vn-acl="administrative" vn-acl-action="remove"
|
||||||
<vn-td>{{::transaction.created | date:'dd/MM/yyyy HH:mm'}}</vn-td>
|
translate-attr="{title: 'Confirm transaction'}" ng-show="::!transaction.isConfirmed"
|
||||||
<vn-td number>{{::transaction.amount | currency: 'EUR':2}}</vn-td>
|
ng-click="$ctrl.confirm(transaction)">
|
||||||
<vn-td shrink>
|
</vn-icon-button>
|
||||||
<vn-icon-button
|
</vn-td>
|
||||||
icon="done_all"
|
</vn-tr>
|
||||||
vn-acl="administrative"
|
</vn-tbody>
|
||||||
vn-acl-action="remove"
|
</vn-table>
|
||||||
translate-attr="{title: 'Confirm transaction'}"
|
|
||||||
ng-show="::!transaction.isConfirmed"
|
|
||||||
ng-click="$ctrl.confirm(transaction)">
|
|
||||||
</vn-icon-button>
|
|
||||||
</vn-td>
|
|
||||||
</vn-tr>
|
|
||||||
</vn-tbody>
|
|
||||||
</vn-table>
|
|
||||||
</vn-card>
|
</vn-card>
|
||||||
</vn-data-viewer>
|
</vn-data-viewer>
|
|
@ -3,7 +3,8 @@
|
||||||
"base": "Loggable",
|
"base": "Loggable",
|
||||||
"log": {
|
"log": {
|
||||||
"model": "EntryLog",
|
"model": "EntryLog",
|
||||||
"relation": "entry"
|
"relation": "entry",
|
||||||
|
"grabUser": true
|
||||||
},
|
},
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
|
@ -70,4 +71,4 @@
|
||||||
"foreignKey": "packageFk"
|
"foreignKey": "packageFk"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
"name": "Entry",
|
"name": "Entry",
|
||||||
"base": "Loggable",
|
"base": "Loggable",
|
||||||
"log": {
|
"log": {
|
||||||
"model":"EntryLog"
|
"model":"EntryLog",
|
||||||
|
"grabUser": true
|
||||||
},
|
},
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
"base": "Loggable",
|
"base": "Loggable",
|
||||||
"log": {
|
"log": {
|
||||||
"model": "ItemLog",
|
"model": "ItemLog",
|
||||||
"showField": "id"
|
"showField": "id",
|
||||||
|
"grabUser": true
|
||||||
},
|
},
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
|
@ -220,4 +221,4 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,11 +86,11 @@
|
||||||
class="expendable">
|
class="expendable">
|
||||||
<span
|
<span
|
||||||
vn-tooltip="
|
vn-tooltip="
|
||||||
{{::$ctrl.$t('Cost')}}: {{::entry.buyingValue | currency: 'EUR':2 | dashIfEmpty}}<br>
|
{{::$ctrl.$t('Cost')}}: {{::entry.buyingValue | currency: 'EUR':3 | dashIfEmpty}}<br>
|
||||||
{{::$ctrl.$t('Package')}}: {{::entry.packageValue | currency: 'EUR':2 | dashIfEmpty}}<br>
|
{{::$ctrl.$t('Package')}}: {{::entry.packageValue | currency: 'EUR':3 | dashIfEmpty}}<br>
|
||||||
{{::$ctrl.$t('Freight')}}: {{::entry.freightValue | currency: 'EUR':2 | dashIfEmpty}}<br>
|
{{::$ctrl.$t('Freight')}}: {{::entry.freightValue | currency: 'EUR':3 | dashIfEmpty}}<br>
|
||||||
{{::$ctrl.$t('Comission')}}: {{::entry.comissionValue | currency: 'EUR':2 | dashIfEmpty}}">
|
{{::$ctrl.$t('Comission')}}: {{::entry.comissionValue | currency: 'EUR':3 | dashIfEmpty}}">
|
||||||
{{::entry.cost | currency: 'EUR':2 | dashIfEmpty}}
|
{{::entry.cost | currency: 'EUR':3 | dashIfEmpty}}
|
||||||
</span>
|
</span>
|
||||||
</vn-td>
|
</vn-td>
|
||||||
<vn-td number>{{::entry.weight | dashIfEmpty}}</vn-td>
|
<vn-td number>{{::entry.weight | dashIfEmpty}}</vn-td>
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
"name": "Route",
|
"name": "Route",
|
||||||
"base": "Loggable",
|
"base": "Loggable",
|
||||||
"log": {
|
"log": {
|
||||||
"model":"RouteLog"
|
"model":"RouteLog",
|
||||||
|
"grabUser": true
|
||||||
},
|
},
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethod('newSupplier', {
|
Self.remoteMethodCtx('newSupplier', {
|
||||||
description: 'Creates a new supplier and returns it',
|
description: 'Creates a new supplier and returns it',
|
||||||
accessType: 'WRITE',
|
accessType: 'WRITE',
|
||||||
accepts: [{
|
accepts: [{
|
||||||
arg: 'params',
|
arg: 'name',
|
||||||
type: 'object',
|
type: 'string'
|
||||||
http: {source: 'body'}
|
|
||||||
}],
|
}],
|
||||||
returns: {
|
returns: {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
|
@ -17,29 +16,18 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.newSupplier = async params => {
|
Self.newSupplier = async(ctx, options) => {
|
||||||
const models = Self.app.models;
|
const models = Self.app.models;
|
||||||
|
const args = ctx.args;
|
||||||
const myOptions = {};
|
const myOptions = {};
|
||||||
|
|
||||||
if (typeof(params) == 'string')
|
if (typeof options == 'object')
|
||||||
params = JSON.parse(params);
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
params.nickname = params.name;
|
delete args.ctx;
|
||||||
|
const data = {...args, ...{nickname: args.name}};
|
||||||
|
const supplier = await models.Supplier.create(data, myOptions);
|
||||||
|
|
||||||
if (!myOptions.transaction) {
|
return supplier;
|
||||||
tx = await Self.beginTransaction({});
|
|
||||||
myOptions.transaction = tx;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
const supplier = await models.Supplier.create(params, myOptions);
|
|
||||||
|
|
||||||
if (tx) await tx.commit();
|
|
||||||
|
|
||||||
return supplier;
|
|
||||||
} catch (e) {
|
|
||||||
if (tx) await tx.rollback();
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,31 +1,39 @@
|
||||||
const app = require('vn-loopback/server/server');
|
const models = require('vn-loopback/server/server').models;
|
||||||
const LoopBackContext = require('loopback-context');
|
const LoopBackContext = require('loopback-context');
|
||||||
|
|
||||||
describe('Supplier newSupplier()', () => {
|
describe('Supplier newSupplier()', () => {
|
||||||
const newSupp = {
|
|
||||||
name: 'TestSupplier-1'
|
|
||||||
};
|
|
||||||
const administrativeId = 5;
|
const administrativeId = 5;
|
||||||
|
const activeCtx = {
|
||||||
|
accessToken: {userId: administrativeId},
|
||||||
|
http: {
|
||||||
|
req: {
|
||||||
|
headers: {origin: 'http://localhost'}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const ctx = {req: activeCtx};
|
||||||
|
|
||||||
it('should create a new supplier containing only the name', async() => {
|
beforeEach(() => {
|
||||||
pending('https://redmine.verdnatura.es/issues/5203');
|
|
||||||
const activeCtx = {
|
|
||||||
accessToken: {userId: administrativeId},
|
|
||||||
};
|
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||||
active: activeCtx
|
active: activeCtx
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
let result = await app.models.Supplier.newSupplier(JSON.stringify(newSupp));
|
it('should create a new supplier containing only the name', async() => {
|
||||||
|
const tx = await models.Supplier.beginTransaction({});
|
||||||
|
|
||||||
expect(result.name).toEqual('TestSupplier-1');
|
try {
|
||||||
expect(result.id).toEqual(443);
|
const options = {transaction: tx};
|
||||||
|
ctx.args = {
|
||||||
|
name: 'newSupplier'
|
||||||
|
};
|
||||||
|
|
||||||
const createdSupplier = await app.models.Supplier.findById(result.id);
|
const result = await models.Supplier.newSupplier(ctx, options);
|
||||||
|
|
||||||
expect(createdSupplier.id).toEqual(result.id);
|
expect(result.name).toEqual('newSupplier');
|
||||||
expect(createdSupplier.name).toEqual(result.name);
|
} catch (e) {
|
||||||
expect(createdSupplier.payDemFk).toEqual(7);
|
await tx.rollback();
|
||||||
expect(createdSupplier.nickname).toEqual(result.name);
|
throw e;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
<vn-watcher
|
<vn-watcher
|
||||||
vn-id="watcher"
|
vn-id="watcher"
|
||||||
url="suppliers/newSupplier"
|
url="Suppliers/newSupplier"
|
||||||
data="$ctrl.supplier"
|
data="$ctrl.supplier"
|
||||||
|
params="$ctrl.supplier"
|
||||||
insert-mode="true"
|
insert-mode="true"
|
||||||
form="form">
|
form="form">
|
||||||
</vn-watcher>
|
</vn-watcher>
|
||||||
|
@ -9,8 +10,8 @@
|
||||||
<vn-card class="vn-pa-lg">
|
<vn-card class="vn-pa-lg">
|
||||||
<vn-horizontal>
|
<vn-horizontal>
|
||||||
<vn-textfield
|
<vn-textfield
|
||||||
label="Supplier name"
|
label="Supplier name"
|
||||||
ng-model="$ctrl.supplier.name"
|
ng-model="$ctrl.supplier.name"
|
||||||
vn-focus>
|
vn-focus>
|
||||||
</vn-textfield>
|
</vn-textfield>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
|
|
|
@ -127,19 +127,6 @@ module.exports = Self => {
|
||||||
], myOptions);
|
], myOptions);
|
||||||
|
|
||||||
const ticket = await models.Ticket.findById(result[1][0].newTicketId, null, myOptions);
|
const ticket = await models.Ticket.findById(result[1][0].newTicketId, null, myOptions);
|
||||||
const cleanInstance = JSON.parse(JSON.stringify(ticket));
|
|
||||||
|
|
||||||
const logRecord = {
|
|
||||||
originFk: cleanInstance.id,
|
|
||||||
userFk: myUserId,
|
|
||||||
action: 'insert',
|
|
||||||
changedModel: 'Ticket',
|
|
||||||
changedModelId: cleanInstance.id,
|
|
||||||
oldInstance: {},
|
|
||||||
newInstance: cleanInstance
|
|
||||||
};
|
|
||||||
|
|
||||||
await models.TicketLog.create(logRecord, myOptions);
|
|
||||||
|
|
||||||
if (tx) await tx.commit();
|
if (tx) await tx.commit();
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,8 @@
|
||||||
"log": {
|
"log": {
|
||||||
"model": "TicketLog",
|
"model": "TicketLog",
|
||||||
"relation": "ticket",
|
"relation": "ticket",
|
||||||
"showField": "concept"
|
"showField": "concept",
|
||||||
|
"grabUser": true
|
||||||
},
|
},
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
"base": "Loggable",
|
"base": "Loggable",
|
||||||
"log": {
|
"log": {
|
||||||
"model":"TicketLog",
|
"model":"TicketLog",
|
||||||
"showField": "id"
|
"showField": "id",
|
||||||
|
"grabUser": true
|
||||||
},
|
},
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
"base": "Loggable",
|
"base": "Loggable",
|
||||||
"log": {
|
"log": {
|
||||||
"model":"TravelLog",
|
"model":"TravelLog",
|
||||||
"showField": "ref"
|
"showField": "ref",
|
||||||
|
"grabUser": true
|
||||||
},
|
},
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
|
|
Loading…
Reference in New Issue