fixes #4523 item_fixed-price_rate2 #1218

Merged
alexm merged 11 commits from 4523-item_fixed-price_rate2 into dev 2023-01-17 10:45:30 +00:00
3 changed files with 23 additions and 3 deletions
Showing only changes of commit 5d2b69d063 - Show all commits

View File

@ -11,7 +11,7 @@ module.exports = Self => {
}, },
{ {
arg: 'rate3', arg: 'rate3',
type: 'number', type: 'object',
description: `The price rate 3`, description: `The price rate 3`,
required: true required: true
} }
@ -29,6 +29,6 @@ module.exports = Self => {
Self.getRate2 = async(fixedPriceId, rate3) => { Self.getRate2 = async(fixedPriceId, rate3) => {
const [result] = await Self.rawSql(`SELECT vn.priceFixed_getRate2(?, ?) as rate2`, const [result] = await Self.rawSql(`SELECT vn.priceFixed_getRate2(?, ?) as rate2`,
[fixedPriceId, rate3]); [fixedPriceId, rate3]);
return result.rate2; return result;
}; };
}; };

View File

@ -124,7 +124,7 @@ export default class Controller extends Section {
}; };
this.$http.get(query, {params}) this.$http.get(query, {params})
.then(res => { .then(res => {
const rate2 = res.data; const rate2 = res.data.rate2;
if (rate2) { if (rate2) {
price.rate2 = rate2; price.rate2 = rate2;
this.upsertPrice(price); this.upsertPrice(price);

View File

@ -85,5 +85,25 @@ describe('fixed price', () => {
expect(controller.$.model.remove).toHaveBeenCalled(); expect(controller.$.model.remove).toHaveBeenCalled();
}); });
}); });
describe('recalculateRate2()', () => {
it(`should rate2 recalculate`, () => {
jest.spyOn(controller.vnApp, 'showSuccess');
const price = {
id: 1,
itemFk: 1,
rate2: 2,
rate3: 2
};
const response = {rate2: 1};
controller.recalculateRate2(price);
const query = `FixedPrices/getRate2?fixedPriceId=${price.id}&rate3=${price.rate3}`;
$httpBackend.expectGET(query).respond(response);
$httpBackend.flush();
expect(price.rate2).toEqual(response.rate2);
});
});
}); });
}); });