fix: refs #6703 tests & front

This commit is contained in:
Jorge Penadés 2024-01-31 09:59:32 +01:00
parent c136395d1e
commit e6eac54709
4 changed files with 42 additions and 3 deletions

View File

@ -67,4 +67,42 @@ describe('Ticket cloning - clone function', () => {
expect(services.length).toBeGreaterThan(0);
}
});
it('should create a ticket without sales', async() => {
const servicesIds = [4];
const tx = await models.Sale.beginTransaction({});
const options = {transaction: tx};
try {
const tickets = await models.Sale.clone(ctx, null, servicesIds, false, options);
const refundedTicket = await getTicketRefund(tickets[0].id, options);
expect(refundedTicket).toBeDefined();
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});
async function getTicketRefund(id, options) {
return models.Ticket.findOne({
where: {
id
},
include: [
{
relation: 'ticketSales',
scope: {
include: {
relation: 'components'
}
}
},
{
relation: 'ticketServices',
}
]
}, options);
}

View File

@ -523,7 +523,7 @@ class Controller extends Section {
if (!sales) return;
const salesIds = sales.map(sale => sale.id);
const params = {salesIds: salesIds, withWarehouse: withWarehouse,};
const params = {salesIds: salesIds, withWarehouse: withWarehouse, negative: true};
const query = 'Sales/clone';
this.$http.post(query, params).then(res => {
const [refundTicket] = res.data;

View File

@ -727,6 +727,7 @@ describe('Ticket', () => {
jest.spyOn(controller.$state, 'go');
const params = {
salesIds: [1, 4],
negative: true
};
const refundTicket = {id: 99};
$httpBackend.expect('POST', 'Sales/clone', params).respond(200, [refundTicket]);

View File

@ -55,10 +55,10 @@ class Controller extends Section {
createRefund() {
if (!this.checkeds.length) return;
const params = {servicesIds: this.checkeds, withWarehouse: false};
const params = {servicesIds: this.checkeds, withWarehouse: false, negative: true};
const query = 'Sales/clone';
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
}));