Merge branch 'dev' into 5316-kkeoEntryNotes
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Carlos Satorres 2023-04-27 12:08:28 +00:00
commit 66986d3c21
29 changed files with 150 additions and 157 deletions

View File

@ -1,21 +0,0 @@
create or replace definer = root@localhost view User as
select `account`.`user`.`id` AS `id`,
`account`.`user`.`realm` AS `realm`,
`account`.`user`.`name` AS `name`,
`account`.`user`.`nickname` AS `nickname`,
`account`.`user`.`bcryptPassword` AS `password`,
`account`.`user`.`role` AS `role`,
`account`.`user`.`active` AS `active`,
`account`.`user`.`email` AS `email`,
`account`.`user`.`emailVerified` AS `emailVerified`,
`account`.`user`.`verificationToken` AS `verificationToken`,
`account`.`user`.`lang` AS `lang`,
`account`.`user`.`lastPassChange` AS `lastPassChange`,
`account`.`user`.`created` AS `created`,
`account`.`user`.`updated` AS `updated`,
`account`.`user`.`image` AS `image`,
`account`.`user`.`recoverPass` AS `recoverPass`,
`account`.`user`.`sync` AS `sync`,
`account`.`user`.`hasGrant` AS `hasGrant`
from `account`.`user`;

View File

@ -0,0 +1,2 @@
DROP PROCEDURE `vn`.`refund`;
DROP PROCEDURE `vn`.`ticket_doRefund`;

View File

@ -1,5 +0,0 @@
INSERT INTO `vn`.`companyI18n` (`companyFk`, `lang`, `footnotes`)
VALUES (442, 'en', 'In compliance with the provisions of Organic Law 15/1999, on the Protection of Personal Data, we inform you that the personal data you provide will be included in automated files of VERDNATURA LEVANTE SL, being able at all times to exercise the rights of access, rectification, cancellation and opposition, communicating it in writing to the registered office of the entity. The purpose of the file is administrative management, accounting, and billing.'),
(442, 'es', 'En cumplimiento de lo dispuesto en la Ley Orgánica 15/1999, de Protección de Datos de Carácter Personal, le comunicamos que los datos personales que facilite se incluirán en ficheros automatizados de VERDNATURA LEVANTE S.L., pudiendo en todo momento ejercitar los derechos de acceso, rectificación, cancelación y oposición, comunicándolo por escrito al domicilio social de la entidad. La finalidad del fichero es la gestión administrativa, contabilidad, y facturación.'),
(442, 'fr', 'Conformément aux dispositions de la loi organique 15/1999 sur la protection des données personnelles, nous vous informons que les données personnelles que vous fournissez seront incluses dans des dossiers. VERDNATURA LEVANTE S.L., vous pouvez à tout moment, exercer les droits d``accès, de rectification, d``annulation et d``opposition, en communiquant par écrit au siège social de la société. Le dossier a pour objet la gestion administrative, la comptabilité et la facturation.'),
(442, 'pt', 'Em cumprimento do disposto na lei Orgânica 15/1999, de Protecção de Dados de Carácter Pessoal, comunicamos que os dados pessoais que facilite se incluirão nos ficheiros automatizados de VERDNATURA LEVANTE S.L., podendo em todo momento exercer os direitos de acesso, rectificação, cancelação e oposição, comunicando por escrito ao domicílio social da entidade. A finalidade do ficheiro é a gestão administrativa, contabilidade e facturação.');

View File

@ -68,6 +68,7 @@ TABLES=(
time time
volumeConfig volumeConfig
workCenter workCenter
companyI18n
) )
dump_tables ${TABLES[@]} dump_tables ${TABLES[@]}

View File

@ -755,6 +755,7 @@ export default {
anyDocument: 'vn-ticket-dms-index > vn-data-viewer vn-tbody vn-tr' anyDocument: 'vn-ticket-dms-index > vn-data-viewer vn-tbody vn-tr'
}, },
ticketFuture: { ticketFuture: {
searchResult: 'vn-ticket-future tbody tr',
openAdvancedSearchButton: 'vn-searchbar .append vn-icon[icon="arrow_drop_down"]', openAdvancedSearchButton: 'vn-searchbar .append vn-icon[icon="arrow_drop_down"]',
originDated: 'vn-date-picker[label="Origin date"]', originDated: 'vn-date-picker[label="Origin date"]',
futureDated: 'vn-date-picker[label="Destination date"]', futureDated: 'vn-date-picker[label="Destination date"]',
@ -770,7 +771,6 @@ export default {
problems: 'vn-check[label="With problems"]', problems: 'vn-check[label="With problems"]',
tableButtonSearch: 'vn-button[vn-tooltip="Search"]', tableButtonSearch: 'vn-button[vn-tooltip="Search"]',
moveButton: 'vn-button[vn-tooltip="Future tickets"]', moveButton: 'vn-button[vn-tooltip="Future tickets"]',
acceptButton: '.vn-confirm.shown button[response="accept"]',
firstCheck: 'tbody > tr:nth-child(1) > td > vn-check', firstCheck: 'tbody > tr:nth-child(1) > td > vn-check',
multiCheck: 'vn-multi-check', multiCheck: 'vn-multi-check',
tableId: 'vn-textfield[name="id"]', tableId: 'vn-textfield[name="id"]',

View File

@ -81,9 +81,7 @@ describe('SmartTable SearchBar integration', () => {
await page.accessToSection('item.fixedPrice'); await page.accessToSection('item.fixedPrice');
await page.keyboard.press('Enter'); await page.keyboard.press('Enter');
const result = await page.waitToGetProperty(selectors.itemFixedPrice.firstItemID, 'value'); await page.waitForTextInField(selectors.itemFixedPrice.firstItemID, '1');
expect(result).toEqual('1');
}); });
it('should order by last id, reload page and have same order', async() => { it('should order by last id, reload page and have same order', async() => {
@ -91,9 +89,7 @@ describe('SmartTable SearchBar integration', () => {
await page.reload({ await page.reload({
waitUntil: 'networkidle2' waitUntil: 'networkidle2'
}); });
const result = await page.waitToGetProperty(selectors.itemFixedPrice.firstItemID, 'value'); await page.waitForTextInField(selectors.itemFixedPrice.firstItemID, '13');
expect(result).toEqual('13');
}); });
}); });
}); });

View File

@ -246,6 +246,7 @@ describe('Ticket Edit sale path', () => {
it('should select the third sale and create a claim of it', async() => { it('should select the third sale and create a claim of it', async() => {
await page.accessToSearchResult('16'); await page.accessToSearchResult('16');
await page.accessToSection('ticket.card.sale'); await page.accessToSection('ticket.card.sale');
await page.waitToClick(selectors.ticketSales.firstSaleCheckbox);
await page.waitToClick(selectors.ticketSales.thirdSaleCheckbox); await page.waitToClick(selectors.ticketSales.thirdSaleCheckbox);
await page.waitToClick(selectors.ticketSales.moreMenu); await page.waitToClick(selectors.ticketSales.moreMenu);
await page.waitToClick(selectors.ticketSales.moreMenuCreateClaim); await page.waitToClick(selectors.ticketSales.moreMenuCreateClaim);

View File

@ -126,10 +126,11 @@ describe('Ticket Future path', () => {
}); });
it('should check the three last tickets and move to the future', async() => { it('should check the three last tickets and move to the future', async() => {
await page.waitForNumberOfElements(selectors.ticketFuture.searchResult, 4);
await page.waitToClick(selectors.ticketFuture.multiCheck); await page.waitToClick(selectors.ticketFuture.multiCheck);
await page.waitToClick(selectors.ticketFuture.firstCheck); await page.waitToClick(selectors.ticketFuture.firstCheck);
await page.waitToClick(selectors.ticketFuture.moveButton); await page.waitToClick(selectors.ticketFuture.moveButton);
await page.waitToClick(selectors.ticketFuture.acceptButton); await page.waitToClick(selectors.globalItems.acceptButton);
const message = await page.waitForSnackbar(); const message = await page.waitForSnackbar();
expect(message.text).toContain('Tickets moved successfully!'); expect(message.text).toContain('Tickets moved successfully!');

View File

@ -35,7 +35,7 @@ describe('InvoiceIn serial path', () => {
}); });
it('should go to index and check if the search-panel has the correct params', async() => { it('should go to index and check if the search-panel has the correct params', async() => {
await page.click(selectors.invoiceInSerial.goToIndex); await page.waitToClick(selectors.invoiceInSerial.goToIndex);
const params = await page.$$(selectors.invoiceInIndex.topbarSearchParams); const params = await page.$$(selectors.invoiceInIndex.topbarSearchParams);
const serial = await params[0].getProperty('title'); const serial = await params[0].getProperty('title');
const isBooked = await params[1].getProperty('title'); const isBooked = await params[1].getProperty('title');

View File

@ -156,18 +156,19 @@
"Component cost not set": "Componente coste no está estabecido", "Component cost not set": "Componente coste no está estabecido",
"Tickets with associated refunds can't be deleted. This ticket is associated with refund Nº 2": "Tickets with associated refunds can't be deleted. This ticket is associated with refund Nº 2", "Tickets with associated refunds can't be deleted. This ticket is associated with refund Nº 2": "Tickets with associated refunds can't be deleted. This ticket is associated with refund Nº 2",
"Description cannot be blank": "Description cannot be blank", "Description cannot be blank": "Description cannot be blank",
"company": "Company", "company": "Company",
"country": "Country", "country": "Country",
"clientId": "Id client", "clientId": "Id client",
"clientSocialName": "Client", "clientSocialName": "Client",
"amount": "Amount", "amount": "Amount",
"taxableBase": "Taxable base", "taxableBase": "Taxable base",
"ticketFk": "Id ticket", "ticketFk": "Id ticket",
"isActive": "Active", "isActive": "Active",
"hasToInvoice": "Invoice", "hasToInvoice": "Invoice",
"isTaxDataChecked": "Data checked", "isTaxDataChecked": "Data checked",
"comercialId": "Id Comercial", "comercialId": "Id Comercial",
"comercialName": "Comercial", "comercialName": "Comercial",
"Added observation": "Added observation", "Added observation": "Added observation",
"Comment added to client": "Comment added to client" "Comment added to client": "Comment added to client",
} "This ticket is already a refund": "This ticket is already a refund"
}

View File

@ -6,6 +6,7 @@
</vn-crud-model> </vn-crud-model>
<vn-portal slot="topbar"> <vn-portal slot="topbar">
<vn-searchbar <vn-searchbar
vn-focus
panel="vn-user-search-panel" panel="vn-user-search-panel"
info="Search user by id, name or nickname" info="Search user by id, name or nickname"
model="model" model="model"
@ -15,4 +16,4 @@
<vn-portal slot="menu"> <vn-portal slot="menu">
<vn-left-menu></vn-left-menu> <vn-left-menu></vn-left-menu>
</vn-portal> </vn-portal>
<ui-view></ui-view> <ui-view></ui-view>

View File

@ -109,6 +109,11 @@ module.exports = Self => {
zoneFk: zone.id zoneFk: zone.id
}, myOptions); }, myOptions);
await models.TicketRefund.create({
refundTicketFk: newRefundTicket.id,
originalTicketFk: claim.ticket().id
}, myOptions);
await saveObservation({ await saveObservation({
description: `Reclama ticket: ${claim.ticketFk}`, description: `Reclama ticket: ${claim.ticketFk}`,
ticketFk: newRefundTicket.id, ticketFk: newRefundTicket.id,

View File

@ -16,7 +16,7 @@
value="{{$ctrl.claimedTotal | currency: 'EUR':2}}"> value="{{$ctrl.claimedTotal | currency: 'EUR':2}}">
</vn-label-value> </vn-label-value>
</vn-card> </vn-card>
<vn-card class="vn-pa-lg vn-w-lg"> <vn-card class="vn-pa-md vn-w-lg">
<smart-table <smart-table
model="model" model="model"
options="$ctrl.smartTableOptions" options="$ctrl.smartTableOptions"
@ -31,10 +31,10 @@
translate-attr="{title: 'Imports claim details'}"> translate-attr="{title: 'Imports claim details'}">
</vn-button> </vn-button>
<vn-button <vn-button
label="Change destination" label="Change destination"
disabled="$ctrl.checked.length == 0" disabled="$ctrl.checked.length == 0"
ng-click="changeDestination.show()"> ng-click="changeDestination.show()">
</vn-button> </vn-button>
<vn-range <vn-range
label="Responsability" label="Responsability"
min-label="Company" min-label="Company"
@ -45,15 +45,15 @@
step="1" step="1"
on-change="$ctrl.save({responsibility: value})"> on-change="$ctrl.save({responsibility: value})">
</vn-range> </vn-range>
<vn-check class="right"
vn-one
label="Is paid with mana"
ng-model="$ctrl.claim.isChargedToMana"
on-change="$ctrl.save({isChargedToMana: value})">
</vn-check>
</vn-tool-bar> </vn-tool-bar>
<vn-check class="right"
vn-one
label="Is paid with mana"
ng-model="$ctrl.claim.isChargedToMana"
on-change="$ctrl.save({isChargedToMana: value})">
</vn-check>
</section> </section>
</slot-actions> </slot-actions>
<slot-table> <slot-table>
<table model="model"> <table model="model">
<thead> <thead>

View File

@ -35,7 +35,7 @@ module.exports = Self => {
const tickets = await models.Ticket.find(filter, myOptions); const tickets = await models.Ticket.find(filter, myOptions);
const ticketsIds = tickets.map(ticket => ticket.id); const ticketsIds = tickets.map(ticket => ticket.id);
const refundedTickets = await models.Ticket.refund(ticketsIds, true, myOptions); const refundedTickets = await models.Ticket.refund(ticketsIds, myOptions);
if (tx) await tx.commit(); if (tx) await tx.commit();

View File

@ -17,7 +17,7 @@ describe('InvoiceOut refund()', () => {
try { try {
const result = await models.InvoiceOut.refund('T1111111', options); const result = await models.InvoiceOut.refund('T1111111', options);
expect(result.length).toEqual(1); expect(result).toBeDefined();
await tx.rollback(); await tx.rollback();
} catch (e) { } catch (e) {

View File

@ -118,8 +118,11 @@ class Controller extends Section {
const query = 'InvoiceOuts/refund'; const query = 'InvoiceOuts/refund';
const params = {ref: this.invoiceOut.ref}; const params = {ref: this.invoiceOut.ref};
this.$http.post(query, params).then(res => { this.$http.post(query, params).then(res => {
const ticketIds = res.data.map(ticket => ticket.id).join(', '); const refundTicket = res.data;
this.vnApp.showSuccess(this.$t('The following refund tickets have been created', {ticketIds})); this.vnApp.showSuccess(this.$t('The following refund ticket have been created', {
ticketId: refundTicket.id
}));
this.$state.go('ticket.card.sale', {id: refundTicket.id});
}); });
} }
} }

View File

@ -53,7 +53,7 @@ module.exports = Self => {
let start = new Date(expedition.created); let start = new Date(expedition.created);
let end = new Date(start.getTime() + (packingSiteConfig.avgBoxingTime * 1000)); let end = new Date(start.getTime() + (packingSiteConfig.avgBoxingTime * 1000));
if (from && to) { if (from != undefined && to != undefined) {
start.setHours(from, 0, 0); start.setHours(from, 0, 0);
end.setHours(to, 0, 0); end.setHours(to, 0, 0);
} }

View File

@ -11,11 +11,6 @@ module.exports = Self => {
{ {
arg: 'servicesIds', arg: 'servicesIds',
type: ['number'] type: ['number']
},
{
arg: 'createSingleTicket',
type: 'boolean',
required: false
} }
], ],
returns: { returns: {
@ -28,7 +23,7 @@ module.exports = Self => {
} }
}); });
Self.refund = async(salesIds, servicesIds, createSingleTicket = false, options) => { Self.refund = async(salesIds, servicesIds, options) => {
const models = Self.app.models; const models = Self.app.models;
const myOptions = {}; const myOptions = {};
let tx; let tx;
@ -67,40 +62,14 @@ module.exports = Self => {
const sales = await models.Sale.find(salesFilter, myOptions); const sales = await models.Sale.find(salesFilter, myOptions);
const ticketsIds = [...new Set(sales.map(sale => sale.ticketFk))]; const ticketsIds = [...new Set(sales.map(sale => sale.ticketFk))];
const refundTickets = [];
const mappedTickets = new Map();
const now = Date.vnNew(); const now = Date.vnNew();
const [firstTicketId] = ticketsIds; const [firstTicketId] = ticketsIds;
if (createSingleTicket) {
await createTicketRefund( const refundTicket = await createTicketRefund(firstTicketId, now, refundAgencyMode, refoundZoneId, myOptions);
firstTicketId,
refundTickets,
mappedTickets,
now,
refundAgencyMode,
refoundZoneId,
myOptions
);
} else {
for (let ticketId of ticketsIds) {
await createTicketRefund(
ticketId,
refundTickets,
mappedTickets,
now,
refundAgencyMode,
refoundZoneId,
myOptions
);
}
}
for (const sale of sales) { for (const sale of sales) {
const refundTicketId = await getTicketRefundId(createSingleTicket, sale.ticketFk, refundTickets, mappedTickets);
const createdSale = await models.Sale.create({ const createdSale = await models.Sale.create({
ticketFk: refundTicketId, ticketFk: refundTicket.id,
itemFk: sale.itemFk, itemFk: sale.itemFk,
quantity: - sale.quantity, quantity: - sale.quantity,
concept: sale.concept, concept: sale.concept,
@ -120,16 +89,13 @@ module.exports = Self => {
where: {id: {inq: servicesIds}} where: {id: {inq: servicesIds}}
}; };
const services = await models.TicketService.find(servicesFilter, myOptions); const services = await models.TicketService.find(servicesFilter, myOptions);
for (const service of services) { for (const service of services) {
const refundTicketId = await getTicketRefundId(createSingleTicket, service.ticketFk, refundTickets, mappedTickets);
await models.TicketService.create({ await models.TicketService.create({
description: service.description, description: service.description,
quantity: - service.quantity, quantity: - service.quantity,
price: service.price, price: service.price,
taxClassFk: service.taxClassFk, taxClassFk: service.taxClassFk,
ticketFk: refundTicketId, ticketFk: refundTicket.id,
ticketServiceTypeFk: service.ticketServiceTypeFk, ticketServiceTypeFk: service.ticketServiceTypeFk,
}, myOptions); }, myOptions);
} }
@ -137,22 +103,14 @@ module.exports = Self => {
if (tx) await tx.commit(); if (tx) await tx.commit();
return refundTickets; return refundTicket;
} catch (e) { } catch (e) {
if (tx) await tx.rollback(); if (tx) await tx.rollback();
throw e; throw e;
} }
}; };
async function createTicketRefund( async function createTicketRefund(ticketId, now, refundAgencyMode, refoundZoneId, myOptions) {
ticketId,
refundTickets,
mappedTickets,
now,
refundAgencyMode,
refoundZoneId,
myOptions
) {
const models = Self.app.models; const models = Self.app.models;
const filter = {include: {relation: 'address'}}; const filter = {include: {relation: 'address'}};
@ -170,20 +128,11 @@ module.exports = Self => {
zoneFk: refoundZoneId zoneFk: refoundZoneId
}, myOptions); }, myOptions);
refundTickets.push(refundTicket);
mappedTickets.set(ticketId, refundTicket.id);
await models.TicketRefund.create({ await models.TicketRefund.create({
refundTicketFk: refundTicket.id, refundTicketFk: refundTicket.id,
originalTicketFk: ticket.id, originalTicketFk: ticket.id,
}, myOptions); }, myOptions);
}
async function getTicketRefundId(createSingleTicket, ticketId, refundTickets, mappedTickets) { return refundTicket;
if (createSingleTicket) {
const [firstRefundTicket] = refundTickets;
return firstRefundTicket.id;
} else return mappedTickets.get(ticketId);
} }
}; };

View File

@ -22,9 +22,9 @@ describe('Sale refund()', () => {
try { try {
const options = {transaction: tx}; const options = {transaction: tx};
const response = await models.Sale.refund(salesIds, servicesIds, false, options); const refundedTicket = await models.Sale.refund(salesIds, servicesIds, options);
expect(response.length).toBeGreaterThanOrEqual(1); expect(refundedTicket).toBeDefined();
await tx.rollback(); await tx.rollback();
} catch (e) { } catch (e) {
@ -33,23 +33,18 @@ describe('Sale refund()', () => {
} }
}); });
it('should create a ticket for each unique ticketFk in the sales', async() => { it('should create one ticket for each unique ticketFk in the sales', async() => {
const tx = await models.Sale.beginTransaction({}); const tx = await models.Sale.beginTransaction({});
const salesIds = [6, 7]; const salesIds = [6, 7];
try { try {
const options = {transaction: tx}; const options = {transaction: tx};
const createSingleTicket = false; const ticket = await models.Sale.refund(salesIds, servicesIds, options);
const tickets = await models.Sale.refund(salesIds, servicesIds, createSingleTicket, options);
const ticketsIds = tickets.map(ticket => ticket.id); const refundedTicket = await models.Ticket.findOne({
const refundedTickets = await models.Ticket.find({
where: { where: {
id: { id: ticket.id
inq: ticketsIds
}
}, },
include: [ include: [
{ {
@ -66,16 +61,12 @@ describe('Sale refund()', () => {
] ]
}, options); }, options);
const firstRefoundedTicket = refundedTickets[0]; const salesLength = refundedTicket.ticketSales().length;
const secondRefoundedTicket = refundedTickets[1]; const componentsLength = refundedTicket.ticketSales()[0].components().length;
const salesLength = firstRefoundedTicket.ticketSales().length;
const componentsLength = firstRefoundedTicket.ticketSales()[0].components().length;
const servicesLength = secondRefoundedTicket.ticketServices().length;
expect(refundedTickets.length).toEqual(2); expect(refundedTicket).toBeDefined();
expect(salesLength).toEqual(1); expect(salesLength).toEqual(2);
expect(componentsLength).toEqual(4); expect(componentsLength).toEqual(4);
expect(servicesLength).toBeGreaterThanOrEqual(1);
await tx.rollback(); await tx.rollback();
} catch (e) { } catch (e) {

View File

@ -7,11 +7,6 @@ module.exports = Self => {
arg: 'ticketsIds', arg: 'ticketsIds',
type: ['number'], type: ['number'],
required: true required: true
},
{
arg: 'createSingleTicket',
type: 'boolean',
required: false
} }
], ],
returns: { returns: {
@ -24,7 +19,7 @@ module.exports = Self => {
} }
}); });
Self.refund = async(ticketsIds, createSingleTicket = false, options) => { Self.refund = async(ticketsIds, options) => {
const models = Self.app.models; const models = Self.app.models;
const myOptions = {}; const myOptions = {};
let tx; let tx;
@ -46,7 +41,7 @@ module.exports = Self => {
const services = await models.TicketService.find(filter, myOptions); const services = await models.TicketService.find(filter, myOptions);
const servicesIds = services.map(service => service.id); const servicesIds = services.map(service => service.id);
const refundedTickets = await models.Sale.refund(salesIds, servicesIds, createSingleTicket, myOptions); const refundedTickets = await models.Sale.refund(salesIds, servicesIds, myOptions);
if (tx) await tx.commit(); if (tx) await tx.commit();

View File

@ -300,7 +300,7 @@ class Controller extends Section {
const params = {ticketsIds: [this.id]}; const params = {ticketsIds: [this.id]};
const query = 'Tickets/refund'; const query = 'Tickets/refund';
return this.$http.post(query, params).then(res => { return this.$http.post(query, params).then(res => {
const [refundTicket] = res.data; const refundTicket = res.data;
this.vnApp.showSuccess(this.$t('The following refund ticket have been created', { this.vnApp.showSuccess(this.$t('The following refund ticket have been created', {
ticketId: refundTicket.id ticketId: refundTicket.id
})); }));

View File

@ -250,7 +250,7 @@ describe('Ticket Component vnTicketDescriptorMenu', () => {
const params = { const params = {
ticketsIds: [16] ticketsIds: [16]
}; };
$httpBackend.expectPOST('Tickets/refund', params).respond([{id: 99}]); $httpBackend.expectPOST('Tickets/refund', params).respond({id: 99});
controller.refund(); controller.refund();
$httpBackend.flush(); $httpBackend.flush();

View File

@ -516,7 +516,7 @@ class Controller extends Section {
const params = {salesIds: salesIds}; const params = {salesIds: salesIds};
const query = 'Sales/refund'; const query = 'Sales/refund';
this.$http.post(query, params).then(res => { this.$http.post(query, params).then(res => {
const [refundTicket] = res.data; const refundTicket = res.data;
this.vnApp.showSuccess(this.$t('The following refund ticket have been created', { this.vnApp.showSuccess(this.$t('The following refund ticket have been created', {
ticketId: refundTicket.id ticketId: refundTicket.id
})); }));

View File

@ -726,8 +726,7 @@ describe('Ticket', () => {
salesIds: [1, 4], salesIds: [1, 4],
}; };
const refundTicket = {id: 99}; const refundTicket = {id: 99};
const createdTickets = [refundTicket]; $httpBackend.expect('POST', 'Sales/refund', params).respond(200, refundTicket);
$httpBackend.expect('POST', 'Sales/refund', params).respond(200, createdTickets);
controller.createRefund(); controller.createRefund();
$httpBackend.flush(); $httpBackend.flush();

View File

@ -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();

View File

@ -0,0 +1,15 @@
<email-body v-bind="$props">
<div class="grid-row">
<div class="grid-block vn-px-ml centered">
<h1>{{ $t('total') }}: {{tickets.length}}</h1>
<hr>
</div>
<div v-for="ticket in tickets" class="grid-block vn-px-ml">
<p v-if="ticket.ticketId"><b>{{ $t('ticketId') }}:</b> {{ticket.ticketId}}</p>
<p><b>{{ $t('clientId') }}:</b> <a :href="clientGreugeUrl(ticket.clientId)" target="_blank">{{ticket.clientId}}</a></p>
<p v-if="ticket.description"><b>{{ $t('description') }}:</b> {{ticket.description}}</p>
<p><b>{{ $t('amount') }}:</b> {{ticket.amount}} €</p>
<hr>
</div>
</div>
</email-body>

View File

@ -0,0 +1,36 @@
const Component = require(`vn-print/core/component`);
const emailBody = new Component('email-body');
const models = require('vn-loopback/server/server').models;
module.exports = {
name: 'greuge-wrong',
async serverPrefetch() {
this.url = await this.salixUrl();
if (!this.url)
throw new Error('Something went wrong');
},
components: {
'email-body': emailBody.build(),
},
methods: {
async salixUrl() {
const salix = await models.Url.findOne({
where: {
appName: 'salix',
environment: process.env.NODE_ENV || 'dev'
}
});
return salix.url;
},
clientGreugeUrl(clientId) {
return `${this.url}client/${clientId}/greuge/index`
},
},
props: {
tickets: {
type: Array,
required: true
},
},
};

View File

@ -0,0 +1,6 @@
subject: Abnormal greuges have been created
total: Total number of abnormal greuges
ticketId: Ticket
clientId: Client
description: Description
amount: Amount

View File

@ -0,0 +1,6 @@
subject: Se han creado greuges anormales
total: Número total de greuges anormales
ticketId: Ticket
clientId: Cliente
description: Descipción
amount: Importe