diff --git a/db/changes/225001/00-priceFixed_getRate2.sql b/db/changes/225201/00-priceFixed_getRate2.sql similarity index 100% rename from db/changes/225001/00-priceFixed_getRate2.sql rename to db/changes/225201/00-priceFixed_getRate2.sql diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 9dab10673..f3fb496a0 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -415,8 +415,8 @@ export default { fourthFixedPrice: 'vn-fixed-price tr:nth-child(5)', fourthItemID: 'vn-fixed-price tr:nth-child(5) vn-autocomplete[ng-model="price.itemFk"]', fourthWarehouse: 'vn-fixed-price tr:nth-child(5) vn-autocomplete[ng-model="price.warehouseFk"]', - fourthPPU: 'vn-fixed-price tr:nth-child(5) > td:nth-child(4)', - fourthPPP: 'vn-fixed-price tr:nth-child(5) > td:nth-child(5)', + fourthGroupingPrice: 'vn-fixed-price tr:nth-child(5) > td:nth-child(4)', + fourthPackingPrice: 'vn-fixed-price tr:nth-child(5) > td:nth-child(5)', fourthHasMinPrice: 'vn-fixed-price tr:nth-child(5) > td:nth-child(6) > vn-check[ng-model="price.hasMinPrice"]', fourthMinPrice: 'vn-fixed-price tr:nth-child(5) > td:nth-child(6) > vn-input-number[ng-model="price.minPrice"]', fourthStarted: 'vn-fixed-price tr:nth-child(5) vn-date-picker[ng-model="price.started"]', diff --git a/e2e/paths/04-item/13_fixedPrice.spec.js b/e2e/paths/04-item/13_fixedPrice.spec.js index fc7aac3d0..673705eff 100644 --- a/e2e/paths/04-item/13_fixedPrice.spec.js +++ b/e2e/paths/04-item/13_fixedPrice.spec.js @@ -1,7 +1,7 @@ import selectors from '../../helpers/selectors.js'; import getBrowser from '../../helpers/puppeteer'; -describe('Item fixed prices path', () => { +fdescribe('Item fixed prices path', () => { let browser; let page; beforeAll(async() => { @@ -24,8 +24,8 @@ describe('Item fixed prices path', () => { it('should fill the fixed price data', async() => { const now = new Date(); await page.autocompleteSearch(selectors.itemFixedPrice.fourthWarehouse, 'Warehouse one'); - await page.write(selectors.itemFixedPrice.fourthPPU, '1'); - await page.write(selectors.itemFixedPrice.fourthPPP, '1'); + await page.writeOnEditableTD(selectors.itemFixedPrice.fourthGroupingPrice, '1'); + await page.writeOnEditableTD(selectors.itemFixedPrice.fourthPackingPrice, '1'); await page.write(selectors.itemFixedPrice.fourthMinPrice, '1'); await page.pickDate(selectors.itemFixedPrice.fourthStarted, now); await page.pickDate(selectors.itemFixedPrice.fourthEnded, now); diff --git a/modules/item/back/methods/fixed-price/getRate2.js b/modules/item/back/methods/fixed-price/getRate2.js index e1a399be6..c90a380e3 100644 --- a/modules/item/back/methods/fixed-price/getRate2.js +++ b/modules/item/back/methods/fixed-price/getRate2.js @@ -1,6 +1,6 @@ module.exports = Self => { Self.remoteMethod('getRate2', { - description: 'Return the rate2.', + description: 'Return the rate2', accessType: 'READ', accepts: [ { @@ -11,13 +11,13 @@ module.exports = Self => { }, { arg: 'rate3', - type: 'object', + type: 'number', description: `The price rate 3`, required: true } ], returns: { - type: 'number', + type: 'object', root: true }, http: { @@ -26,9 +26,14 @@ module.exports = Self => { } }); - Self.getRate2 = async(fixedPriceId, rate3) => { + Self.getRate2 = async(fixedPriceId, rate3, options) => { + const myOptions = {}; + + if (typeof options == 'object') + Object.assign(myOptions, options); + const [result] = await Self.rawSql(`SELECT vn.priceFixed_getRate2(?, ?) as rate2`, - [fixedPriceId, rate3]); + [fixedPriceId, rate3], myOptions); return result; }; }; diff --git a/modules/item/back/methods/fixed-price/specs/getRate2.spec.js b/modules/item/back/methods/fixed-price/specs/getRate2.spec.js new file mode 100644 index 000000000..2f5dd93cd --- /dev/null +++ b/modules/item/back/methods/fixed-price/specs/getRate2.spec.js @@ -0,0 +1,39 @@ +const models = require('vn-loopback/server/server').models; + +describe('getRate2()', () => { + it(`should return new rate2 if exists rate`, async() => { + const tx = await models.FixedPrice.beginTransaction({}); + + try { + const options = {transaction: tx}; + const fixedPriceId = 1; + const rate3 = 2; + const result = await models.FixedPrice.getRate2(fixedPriceId, rate3, options); + + expect(result.rate2).toEqual(1.9); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + + it(`should return null if not exists rate`, async() => { + const tx = await models.FixedPrice.beginTransaction({}); + + try { + const options = {transaction: tx}; + const fixedPriceId = 13; + const rate3 = 2; + const result = await models.FixedPrice.getRate2(fixedPriceId, rate3, options); + + expect(result.rate2).toEqual(null); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); +});