Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 5594-sendPdf_whenMakeInvoice
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
commit
2d181139b4
|
@ -0,0 +1,2 @@
|
|||
DROP PROCEDURE `vn`.`refund`;
|
||||
DROP PROCEDURE `vn`.`ticket_doRefund`;
|
|
@ -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.');
|
|
@ -68,6 +68,7 @@ TABLES=(
|
|||
time
|
||||
volumeConfig
|
||||
workCenter
|
||||
companyI18n
|
||||
)
|
||||
dump_tables ${TABLES[@]}
|
||||
|
||||
|
|
|
@ -246,6 +246,7 @@ describe('Ticket Edit sale path', () => {
|
|||
it('should select the third sale and create a claim of it', async() => {
|
||||
await page.accessToSearchResult('16');
|
||||
await page.accessToSection('ticket.card.sale');
|
||||
await page.waitToClick(selectors.ticketSales.firstSaleCheckbox);
|
||||
await page.waitToClick(selectors.ticketSales.thirdSaleCheckbox);
|
||||
await page.waitToClick(selectors.ticketSales.moreMenu);
|
||||
await page.waitToClick(selectors.ticketSales.moreMenuCreateClaim);
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
</vn-crud-model>
|
||||
<vn-portal slot="topbar">
|
||||
<vn-searchbar
|
||||
vn-focus
|
||||
panel="vn-user-search-panel"
|
||||
info="Search user by id, name or nickname"
|
||||
model="model"
|
||||
|
@ -15,4 +16,4 @@
|
|||
<vn-portal slot="menu">
|
||||
<vn-left-menu></vn-left-menu>
|
||||
</vn-portal>
|
||||
<ui-view></ui-view>
|
||||
<ui-view></ui-view>
|
||||
|
|
|
@ -109,6 +109,11 @@ module.exports = Self => {
|
|||
zoneFk: zone.id
|
||||
}, myOptions);
|
||||
|
||||
await models.TicketRefund.create({
|
||||
refundTicketFk: newRefundTicket.id,
|
||||
originalTicketFk: claim.ticket().id
|
||||
}, myOptions);
|
||||
|
||||
await saveObservation({
|
||||
description: `Reclama ticket: ${claim.ticketFk}`,
|
||||
ticketFk: newRefundTicket.id,
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
value="{{$ctrl.claimedTotal | currency: 'EUR':2}}">
|
||||
</vn-label-value>
|
||||
</vn-card>
|
||||
<vn-card class="vn-pa-lg vn-w-lg">
|
||||
<vn-card class="vn-pa-md vn-w-lg">
|
||||
<smart-table
|
||||
model="model"
|
||||
options="$ctrl.smartTableOptions"
|
||||
|
@ -31,10 +31,10 @@
|
|||
translate-attr="{title: 'Imports claim details'}">
|
||||
</vn-button>
|
||||
<vn-button
|
||||
label="Change destination"
|
||||
disabled="$ctrl.checked.length == 0"
|
||||
ng-click="changeDestination.show()">
|
||||
</vn-button>
|
||||
label="Change destination"
|
||||
disabled="$ctrl.checked.length == 0"
|
||||
ng-click="changeDestination.show()">
|
||||
</vn-button>
|
||||
<vn-range
|
||||
label="Responsability"
|
||||
min-label="Company"
|
||||
|
@ -45,15 +45,15 @@
|
|||
step="1"
|
||||
on-change="$ctrl.save({responsibility: value})">
|
||||
</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-check class="right"
|
||||
vn-one
|
||||
label="Is paid with mana"
|
||||
ng-model="$ctrl.claim.isChargedToMana"
|
||||
on-change="$ctrl.save({isChargedToMana: value})">
|
||||
</vn-check>
|
||||
</section>
|
||||
</slot-actions>
|
||||
</slot-actions>
|
||||
<slot-table>
|
||||
<table model="model">
|
||||
<thead>
|
||||
|
|
|
@ -35,7 +35,7 @@ module.exports = Self => {
|
|||
const tickets = await models.Ticket.find(filter, myOptions);
|
||||
|
||||
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();
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ describe('InvoiceOut refund()', () => {
|
|||
try {
|
||||
const result = await models.InvoiceOut.refund('T1111111', options);
|
||||
|
||||
expect(result.length).toEqual(1);
|
||||
expect(result).toBeDefined();
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
|
|
|
@ -118,8 +118,11 @@ class Controller extends Section {
|
|||
const query = 'InvoiceOuts/refund';
|
||||
const params = {ref: this.invoiceOut.ref};
|
||||
this.$http.post(query, params).then(res => {
|
||||
const ticketIds = res.data.map(ticket => ticket.id).join(', ');
|
||||
this.vnApp.showSuccess(this.$t('The following refund tickets have been created', {ticketIds}));
|
||||
const refundTicket = res.data;
|
||||
this.vnApp.showSuccess(this.$t('The following refund ticket have been created', {
|
||||
ticketId: refundTicket.id
|
||||
}));
|
||||
this.$state.go('ticket.card.sale', {id: refundTicket.id});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,11 +11,6 @@ module.exports = Self => {
|
|||
{
|
||||
arg: 'servicesIds',
|
||||
type: ['number']
|
||||
},
|
||||
{
|
||||
arg: 'createSingleTicket',
|
||||
type: 'boolean',
|
||||
required: false
|
||||
}
|
||||
],
|
||||
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 myOptions = {};
|
||||
let tx;
|
||||
|
@ -67,40 +62,14 @@ module.exports = Self => {
|
|||
const sales = await models.Sale.find(salesFilter, myOptions);
|
||||
const ticketsIds = [...new Set(sales.map(sale => sale.ticketFk))];
|
||||
|
||||
const refundTickets = [];
|
||||
const mappedTickets = new Map();
|
||||
const now = Date.vnNew();
|
||||
|
||||
const [firstTicketId] = ticketsIds;
|
||||
if (createSingleTicket) {
|
||||
await createTicketRefund(
|
||||
firstTicketId,
|
||||
refundTickets,
|
||||
mappedTickets,
|
||||
now,
|
||||
refundAgencyMode,
|
||||
refoundZoneId,
|
||||
myOptions
|
||||
);
|
||||
} else {
|
||||
for (let ticketId of ticketsIds) {
|
||||
await createTicketRefund(
|
||||
ticketId,
|
||||
refundTickets,
|
||||
mappedTickets,
|
||||
now,
|
||||
refundAgencyMode,
|
||||
refoundZoneId,
|
||||
myOptions
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const refundTicket = await createTicketRefund(firstTicketId, now, refundAgencyMode, refoundZoneId, myOptions);
|
||||
|
||||
for (const sale of sales) {
|
||||
const refundTicketId = await getTicketRefundId(createSingleTicket, sale.ticketFk, refundTickets, mappedTickets);
|
||||
|
||||
const createdSale = await models.Sale.create({
|
||||
ticketFk: refundTicketId,
|
||||
ticketFk: refundTicket.id,
|
||||
itemFk: sale.itemFk,
|
||||
quantity: - sale.quantity,
|
||||
concept: sale.concept,
|
||||
|
@ -120,16 +89,13 @@ module.exports = Self => {
|
|||
where: {id: {inq: servicesIds}}
|
||||
};
|
||||
const services = await models.TicketService.find(servicesFilter, myOptions);
|
||||
|
||||
for (const service of services) {
|
||||
const refundTicketId = await getTicketRefundId(createSingleTicket, service.ticketFk, refundTickets, mappedTickets);
|
||||
|
||||
await models.TicketService.create({
|
||||
description: service.description,
|
||||
quantity: - service.quantity,
|
||||
price: service.price,
|
||||
taxClassFk: service.taxClassFk,
|
||||
ticketFk: refundTicketId,
|
||||
ticketFk: refundTicket.id,
|
||||
ticketServiceTypeFk: service.ticketServiceTypeFk,
|
||||
}, myOptions);
|
||||
}
|
||||
|
@ -137,22 +103,14 @@ module.exports = Self => {
|
|||
|
||||
if (tx) await tx.commit();
|
||||
|
||||
return refundTickets;
|
||||
return refundTicket;
|
||||
} catch (e) {
|
||||
if (tx) await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
|
||||
async function createTicketRefund(
|
||||
ticketId,
|
||||
refundTickets,
|
||||
mappedTickets,
|
||||
now,
|
||||
refundAgencyMode,
|
||||
refoundZoneId,
|
||||
myOptions
|
||||
) {
|
||||
async function createTicketRefund(ticketId, now, refundAgencyMode, refoundZoneId, myOptions) {
|
||||
const models = Self.app.models;
|
||||
|
||||
const filter = {include: {relation: 'address'}};
|
||||
|
@ -170,20 +128,11 @@ module.exports = Self => {
|
|||
zoneFk: refoundZoneId
|
||||
}, myOptions);
|
||||
|
||||
refundTickets.push(refundTicket);
|
||||
|
||||
mappedTickets.set(ticketId, refundTicket.id);
|
||||
|
||||
await models.TicketRefund.create({
|
||||
refundTicketFk: refundTicket.id,
|
||||
originalTicketFk: ticket.id,
|
||||
}, myOptions);
|
||||
}
|
||||
|
||||
async function getTicketRefundId(createSingleTicket, ticketId, refundTickets, mappedTickets) {
|
||||
if (createSingleTicket) {
|
||||
const [firstRefundTicket] = refundTickets;
|
||||
return firstRefundTicket.id;
|
||||
} else return mappedTickets.get(ticketId);
|
||||
return refundTicket;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -22,9 +22,9 @@ describe('Sale refund()', () => {
|
|||
try {
|
||||
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();
|
||||
} 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 salesIds = [6, 7];
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const createSingleTicket = false;
|
||||
const tickets = await models.Sale.refund(salesIds, servicesIds, createSingleTicket, options);
|
||||
const ticket = await models.Sale.refund(salesIds, servicesIds, options);
|
||||
|
||||
const ticketsIds = tickets.map(ticket => ticket.id);
|
||||
|
||||
const refundedTickets = await models.Ticket.find({
|
||||
const refundedTicket = await models.Ticket.findOne({
|
||||
where: {
|
||||
id: {
|
||||
inq: ticketsIds
|
||||
}
|
||||
id: ticket.id
|
||||
},
|
||||
include: [
|
||||
{
|
||||
|
@ -66,16 +61,12 @@ describe('Sale refund()', () => {
|
|||
]
|
||||
}, options);
|
||||
|
||||
const firstRefoundedTicket = refundedTickets[0];
|
||||
const secondRefoundedTicket = refundedTickets[1];
|
||||
const salesLength = firstRefoundedTicket.ticketSales().length;
|
||||
const componentsLength = firstRefoundedTicket.ticketSales()[0].components().length;
|
||||
const servicesLength = secondRefoundedTicket.ticketServices().length;
|
||||
const salesLength = refundedTicket.ticketSales().length;
|
||||
const componentsLength = refundedTicket.ticketSales()[0].components().length;
|
||||
|
||||
expect(refundedTickets.length).toEqual(2);
|
||||
expect(salesLength).toEqual(1);
|
||||
expect(refundedTicket).toBeDefined();
|
||||
expect(salesLength).toEqual(2);
|
||||
expect(componentsLength).toEqual(4);
|
||||
expect(servicesLength).toBeGreaterThanOrEqual(1);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
|
|
|
@ -7,11 +7,6 @@ module.exports = Self => {
|
|||
arg: 'ticketsIds',
|
||||
type: ['number'],
|
||||
required: true
|
||||
},
|
||||
{
|
||||
arg: 'createSingleTicket',
|
||||
type: 'boolean',
|
||||
required: false
|
||||
}
|
||||
],
|
||||
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 myOptions = {};
|
||||
let tx;
|
||||
|
@ -46,7 +41,7 @@ module.exports = Self => {
|
|||
const services = await models.TicketService.find(filter, myOptions);
|
||||
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();
|
||||
|
||||
|
|
|
@ -300,7 +300,7 @@ class Controller extends Section {
|
|||
const params = {ticketsIds: [this.id]};
|
||||
const query = 'Tickets/refund';
|
||||
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', {
|
||||
ticketId: refundTicket.id
|
||||
}));
|
||||
|
|
|
@ -250,7 +250,7 @@ describe('Ticket Component vnTicketDescriptorMenu', () => {
|
|||
const params = {
|
||||
ticketsIds: [16]
|
||||
};
|
||||
$httpBackend.expectPOST('Tickets/refund', params).respond([{id: 99}]);
|
||||
$httpBackend.expectPOST('Tickets/refund', params).respond({id: 99});
|
||||
controller.refund();
|
||||
$httpBackend.flush();
|
||||
|
||||
|
|
|
@ -516,7 +516,7 @@ class Controller extends Section {
|
|||
const params = {salesIds: salesIds};
|
||||
const query = 'Sales/refund';
|
||||
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', {
|
||||
ticketId: refundTicket.id
|
||||
}));
|
||||
|
|
|
@ -726,8 +726,7 @@ describe('Ticket', () => {
|
|||
salesIds: [1, 4],
|
||||
};
|
||||
const refundTicket = {id: 99};
|
||||
const createdTickets = [refundTicket];
|
||||
$httpBackend.expect('POST', 'Sales/refund', params).respond(200, createdTickets);
|
||||
$httpBackend.expect('POST', 'Sales/refund', params).respond(200, refundTicket);
|
||||
controller.createRefund();
|
||||
$httpBackend.flush();
|
||||
|
||||
|
|
Loading…
Reference in New Issue