refactor: pull request changes
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
3bf2b46689
commit
655db502f7
|
@ -1,2 +1,2 @@
|
||||||
INSERT INTO `vn`.`component` (`name`,`typeFk`,`classRate`,`isRenewable`,`code`,`isRequired`)
|
INSERT INTO `vn`.`component` (`name`,`typeFk`,`classRate`,`isRenewable`,`code`,`isRequired`)
|
||||||
VALUES ('maná reclamacion',7,4,0,'mana claim',0);
|
VALUES ('maná reclamacion',7,4,0,'manaClaim',0);
|
|
@ -20,7 +20,7 @@ BEGIN
|
||||||
FROM `component` WHERE code = 'autoMana';
|
FROM `component` WHERE code = 'autoMana';
|
||||||
|
|
||||||
SELECT id INTO vClaimManaId
|
SELECT id INTO vClaimManaId
|
||||||
FROM `component` WHERE code = 'mana claim';
|
FROM `component` WHERE code = 'manaClaim';
|
||||||
|
|
||||||
SELECT id INTO vManaBankId
|
SELECT id INTO vManaBankId
|
||||||
FROM `bank` WHERE code = 'mana';
|
FROM `bank` WHERE code = 'mana';
|
||||||
|
|
|
@ -30,7 +30,7 @@ BEGIN
|
||||||
FROM `component` WHERE code = 'autoMana';
|
FROM `component` WHERE code = 'autoMana';
|
||||||
|
|
||||||
SELECT id INTO vClaimMana
|
SELECT id INTO vClaimMana
|
||||||
FROM `component` WHERE code = 'mana claim';
|
FROM `component` WHERE code = 'manaClaim';
|
||||||
|
|
||||||
SELECT id INTO vManaBank
|
SELECT id INTO vManaBank
|
||||||
FROM `bank` WHERE code = 'mana';
|
FROM `bank` WHERE code = 'mana';
|
||||||
|
|
|
@ -175,7 +175,7 @@ describe('Ticket Edit sale path', () => {
|
||||||
it('should update the discount', async() => {
|
it('should update the discount', async() => {
|
||||||
await page.waitToClick(selectors.ticketSales.firstSaleDiscount);
|
await page.waitToClick(selectors.ticketSales.firstSaleDiscount);
|
||||||
await page.waitForSelector(selectors.ticketSales.firstSaleDiscountInput);
|
await page.waitForSelector(selectors.ticketSales.firstSaleDiscountInput);
|
||||||
await page.type(selectors.ticketSales.firstSaleDiscountInput, '50\u000d');
|
await page.type(selectors.ticketSales.firstSaleDiscountInput, '50');
|
||||||
await page.waitToClick(selectors.ticketSales.saveSaleDiscountButton);
|
await page.waitToClick(selectors.ticketSales.saveSaleDiscountButton);
|
||||||
const message = await page.waitForSnackbar();
|
const message = await page.waitForSnackbar();
|
||||||
|
|
||||||
|
|
|
@ -90,7 +90,7 @@ describe('sale updateDiscount()', () => {
|
||||||
expect(error.message).toEqual(`The sales of this ticket can't be modified`);
|
expect(error.message).toEqual(`The sales of this ticket can't be modified`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should update the discount if the salesPerson has mana and manaType = "mana"', async() => {
|
it('should update the discount if the salesPerson has mana and manaCode = "mana"', async() => {
|
||||||
const tx = await models.Ticket.beginTransaction({});
|
const tx = await models.Ticket.beginTransaction({});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -108,9 +108,9 @@ describe('sale updateDiscount()', () => {
|
||||||
const newDiscount = 100;
|
const newDiscount = 100;
|
||||||
const manaDiscount = await models.Component.findOne({where: {code: 'mana'}}, options);
|
const manaDiscount = await models.Component.findOne({where: {code: 'mana'}}, options);
|
||||||
const componentId = manaDiscount.id;
|
const componentId = manaDiscount.id;
|
||||||
const manaType = 'mana';
|
const manaCode = 'mana';
|
||||||
|
|
||||||
await models.Ticket.updateDiscount(ctx, ticketId, sales, newDiscount, manaType, options);
|
await models.Ticket.updateDiscount(ctx, ticketId, sales, newDiscount, manaCode, options);
|
||||||
|
|
||||||
const updatedSale = await models.Sale.findById(originalSaleId, null, options);
|
const updatedSale = await models.Sale.findById(originalSaleId, null, options);
|
||||||
const createdSaleComponent = await models.SaleComponent.findOne({
|
const createdSaleComponent = await models.SaleComponent.findOne({
|
||||||
|
@ -130,7 +130,7 @@ describe('sale updateDiscount()', () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should update the discount if the salesPerson has mana and manaType = "mana claim"', async() => {
|
it('should update the discount if the salesPerson has mana and manaCode = "manaClaim"', async() => {
|
||||||
const tx = await models.Ticket.beginTransaction({});
|
const tx = await models.Ticket.beginTransaction({});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -146,11 +146,11 @@ describe('sale updateDiscount()', () => {
|
||||||
const ticketId = 11;
|
const ticketId = 11;
|
||||||
const sales = [originalSaleId];
|
const sales = [originalSaleId];
|
||||||
const newDiscount = 100;
|
const newDiscount = 100;
|
||||||
const manaDiscount = await models.Component.findOne({where: {code: 'mana claim'}}, options);
|
const manaDiscount = await models.Component.findOne({where: {code: 'manaClaim'}}, options);
|
||||||
const componentId = manaDiscount.id;
|
const componentId = manaDiscount.id;
|
||||||
const manaType = 'mana claim';
|
const manaCode = 'manaClaim';
|
||||||
|
|
||||||
await models.Ticket.updateDiscount(ctx, ticketId, sales, newDiscount, manaType, options);
|
await models.Ticket.updateDiscount(ctx, ticketId, sales, newDiscount, manaCode, options);
|
||||||
|
|
||||||
const updatedSale = await models.Sale.findById(originalSaleId, null, options);
|
const updatedSale = await models.Sale.findById(originalSaleId, null, options);
|
||||||
const createdSaleComponent = await models.SaleComponent.findOne({
|
const createdSaleComponent = await models.SaleComponent.findOne({
|
||||||
|
|
|
@ -25,7 +25,7 @@ module.exports = Self => {
|
||||||
required: true
|
required: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
arg: 'manaType',
|
arg: 'manaCode',
|
||||||
description: 'The type of mana',
|
description: 'The type of mana',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
required: false
|
required: false
|
||||||
|
@ -41,7 +41,7 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.updateDiscount = async(ctx, id, salesIds, newDiscount, manaType, options) => {
|
Self.updateDiscount = async(ctx, id, salesIds, newDiscount, manaCode, options) => {
|
||||||
const $t = ctx.req.__; // $translate
|
const $t = ctx.req.__; // $translate
|
||||||
const models = Self.app.models;
|
const models = Self.app.models;
|
||||||
const myOptions = {};
|
const myOptions = {};
|
||||||
|
@ -104,7 +104,7 @@ module.exports = Self => {
|
||||||
},
|
},
|
||||||
fields: 'amount'}, myOptions);
|
fields: 'amount'}, myOptions);
|
||||||
|
|
||||||
const componentCode = usesMana ? manaType : 'buyerDiscount';
|
const componentCode = usesMana ? manaCode : 'buyerDiscount';
|
||||||
const discountComponent = await models.Component.findOne({
|
const discountComponent = await models.Component.findOne({
|
||||||
where: {code: componentCode}}, myOptions);
|
where: {code: componentCode}}, myOptions);
|
||||||
|
|
||||||
|
|
|
@ -292,12 +292,12 @@
|
||||||
<vn-radio
|
<vn-radio
|
||||||
label="Promotion mana"
|
label="Promotion mana"
|
||||||
val="mana"
|
val="mana"
|
||||||
ng-model="$ctrl.manaType">
|
ng-model="$ctrl.manaCode">
|
||||||
</vn-radio>
|
</vn-radio>
|
||||||
<vn-radio
|
<vn-radio
|
||||||
label="Claim mana"
|
label="Claim mana"
|
||||||
val="mana claim"
|
val="manaClaim"
|
||||||
ng-model="$ctrl.manaType">
|
ng-model="$ctrl.manaCode">
|
||||||
</vn-radio>
|
</vn-radio>
|
||||||
</vn-vertical>
|
</vn-vertical>
|
||||||
<div class="simulator">
|
<div class="simulator">
|
||||||
|
|
|
@ -6,15 +6,15 @@ class Controller extends Section {
|
||||||
constructor($element, $) {
|
constructor($element, $) {
|
||||||
super($element, $);
|
super($element, $);
|
||||||
this._sales = [];
|
this._sales = [];
|
||||||
this.manaType = 'mana';
|
this.manaCode = 'mana';
|
||||||
}
|
}
|
||||||
|
|
||||||
get manaType() {
|
get manaCode() {
|
||||||
return this._manaType;
|
return this._manaCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
set manaType(value) {
|
set manaCode(value) {
|
||||||
this._manaType = value;
|
this._manaCode = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
get ticket() {
|
get ticket() {
|
||||||
|
@ -290,7 +290,7 @@ class Controller extends Section {
|
||||||
return sale.id;
|
return sale.id;
|
||||||
});
|
});
|
||||||
|
|
||||||
const params = {salesIds: saleIds, newDiscount: this.edit.discount, manaType: this.manaType};
|
const params = {salesIds: saleIds, newDiscount: this.edit.discount, manaCode: this.manaCode};
|
||||||
const query = `Tickets/${this.$params.id}/updateDiscount`;
|
const query = `Tickets/${this.$params.id}/updateDiscount`;
|
||||||
this.$http.post(query, params).then(() => {
|
this.$http.post(query, params).then(() => {
|
||||||
this.vnApp.showSuccess(this.$t('Data saved!'));
|
this.vnApp.showSuccess(this.$t('Data saved!'));
|
||||||
|
|
|
@ -63,14 +63,6 @@ describe('Ticket', () => {
|
||||||
controller._sales = sales;
|
controller._sales = sales;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
describe('manaType() setter/getter', () => {
|
|
||||||
it('should set the manaType data', () => {
|
|
||||||
controller.manaType = 'mana claim';
|
|
||||||
|
|
||||||
expect(controller.manaType).toEqual('mana claim');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('ticket() setter', () => {
|
describe('ticket() setter', () => {
|
||||||
it('should set the ticket data an then call the isTicketEditable() and isTicketLocked() methods', () => {
|
it('should set the ticket data an then call the isTicketEditable() and isTicketLocked() methods', () => {
|
||||||
jest.spyOn(controller, 'isTicketEditable').mockReturnThis();
|
jest.spyOn(controller, 'isTicketEditable').mockReturnThis();
|
||||||
|
@ -456,7 +448,7 @@ describe('Ticket', () => {
|
||||||
|
|
||||||
const expectedSales = [firstSelectedSale, secondSelectedSale];
|
const expectedSales = [firstSelectedSale, secondSelectedSale];
|
||||||
const expectedSaleIds = [firstSelectedSale.id, secondSelectedSale.id];
|
const expectedSaleIds = [firstSelectedSale.id, secondSelectedSale.id];
|
||||||
const expectedParams = {salesIds: expectedSaleIds, newDiscount: expectedDiscount, manaType: 'mana'};
|
const expectedParams = {salesIds: expectedSaleIds, newDiscount: expectedDiscount, manaCode: 'mana'};
|
||||||
$httpBackend.expect('POST', `Tickets/1/updateDiscount`, expectedParams).respond(200, {discount: 10});
|
$httpBackend.expect('POST', `Tickets/1/updateDiscount`, expectedParams).respond(200, {discount: 10});
|
||||||
controller.updateDiscount(expectedSales);
|
controller.updateDiscount(expectedSales);
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
|
@ -743,15 +735,6 @@ describe('Ticket', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('save()', () => {
|
|
||||||
it('should call changeDiscount()', () => {
|
|
||||||
jest.spyOn(controller, 'changeDiscount').mockReturnThis();
|
|
||||||
controller.save();
|
|
||||||
|
|
||||||
expect(controller.changeDiscount).toHaveBeenCalledWith();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('cancel()', () => {
|
describe('cancel()', () => {
|
||||||
it('should call hide()', () => {
|
it('should call hide()', () => {
|
||||||
jest.spyOn(controller.$.editDiscount, 'hide').mockReturnThis();
|
jest.spyOn(controller.$.editDiscount, 'hide').mockReturnThis();
|
||||||
|
|
Loading…
Reference in New Issue