Merge pull request '3682-item_fixed-price' (#901) from 3682-item_fixed-price into dev
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
Reviewed-on: #901
This commit is contained in:
commit
b8910e38ea
|
@ -812,25 +812,25 @@ INSERT INTO `vn`.`itemFamily`(`code`, `description`)
|
||||||
('VT', 'Sales');
|
('VT', 'Sales');
|
||||||
|
|
||||||
INSERT INTO `vn`.`item`(`id`, `typeFk`, `size`, `inkFk`, `stems`, `originFk`, `description`, `producerFk`, `intrastatFk`, `expenceFk`,
|
INSERT INTO `vn`.`item`(`id`, `typeFk`, `size`, `inkFk`, `stems`, `originFk`, `description`, `producerFk`, `intrastatFk`, `expenceFk`,
|
||||||
`comment`, `relevancy`, `image`, `subName`, `minPrice`, `stars`, `family`, `isFloramondo`, `genericFk`, `itemPackingTypeFk`)
|
`comment`, `relevancy`, `image`, `subName`, `minPrice`, `stars`, `family`, `isFloramondo`, `genericFk`, `itemPackingTypeFk`, `hasMinPrice`)
|
||||||
VALUES
|
VALUES
|
||||||
(1, 2, 70, 'YEL', 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '1', NULL, 0, 1, 'VT', 0, NULL, 'V'),
|
(1, 2, 70, 'YEL', 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '1', NULL, 0, 1, 'VT', 0, NULL, 'V', 0),
|
||||||
(2, 2, 70, 'BLU', 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '2', NULL, 0, 2, 'VT', 0, NULL, 'H'),
|
(2, 2, 70, 'BLU', 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '2', NULL, 0, 2, 'VT', 0, NULL, 'H', 0),
|
||||||
(3, 1, 60, 'YEL', 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '3', NULL, 0, 5, 'VT', 0, NULL, NULL),
|
(3, 1, 60, 'YEL', 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '3', NULL, 0, 5, 'VT', 0, NULL, NULL, 0),
|
||||||
(4, 1, 60, 'YEL', 1, 1, 'Increases block', 1, 05080000, 4751000000, NULL, 0, '4', NULL, 0, 3, 'VT', 0, NULL, NULL),
|
(4, 1, 60, 'YEL', 1, 1, 'Increases block', 1, 05080000, 4751000000, NULL, 0, '4', NULL, 0, 3, 'VT', 0, NULL, NULL, 0),
|
||||||
(5, 3, 30, 'RED', 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '5', NULL, 0, 3, 'VT', 0, NULL, NULL),
|
(5, 3, 30, 'RED', 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '5', NULL, 0, 3, 'VT', 0, NULL, NULL, 0),
|
||||||
(6, 5, 30, 'RED', 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '6', NULL, 0, 4, 'VT', 0, NULL, NULL),
|
(6, 5, 30, 'RED', 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '6', NULL, 0, 4, 'VT', 0, NULL, NULL, 0),
|
||||||
(7, 5, 90, 'BLU', 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '7', NULL, 0, 4, 'VT', 0, NULL, NULL),
|
(7, 5, 90, 'BLU', 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '7', NULL, 0, 4, 'VT', 0, NULL, NULL, 0),
|
||||||
(8, 2, 70, 'YEL', 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '8', NULL, 0, 5, 'VT', 0, NULL, NULL),
|
(8, 2, 70, 'YEL', 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '8', NULL, 0, 5, 'VT', 0, NULL, NULL, 0),
|
||||||
(9, 2, 70, 'BLU', 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '9', NULL, 0, 4, 'VT', 1, NULL, NULL),
|
(9, 2, 70, 'BLU', 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '9', NULL, 0, 4, 'VT', 1, NULL, NULL, 0),
|
||||||
(10, 1, 60, 'YEL', 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '10', NULL, 0, 4, 'VT', 0, NULL, NULL),
|
(10, 1, 60, 'YEL', 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '10', NULL, 0, 4, 'VT', 0, NULL, NULL, 0),
|
||||||
(11, 1, 60, 'YEL', 1, 1, NULL, 1, 05080000, 4751000000, NULL, 0, '11', NULL, 0, 4, 'VT', 0, NULL, NULL),
|
(11, 1, 60, 'YEL', 1, 1, NULL, 1, 05080000, 4751000000, NULL, 0, '11', NULL, 0, 4, 'VT', 0, NULL, NULL, 0),
|
||||||
(12, 3, 30, 'RED', 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '12', NULL, 0, 3, 'VT', 0, NULL, NULL),
|
(12, 3, 30, 'RED', 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '12', NULL, 0, 3, 'VT', 0, NULL, NULL, 0),
|
||||||
(13, 5, 30, 'RED', 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '13', NULL, 0, 2, 'VT', 1, NULL, NULL),
|
(13, 5, 30, 'RED', 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '13', NULL, 1, 2, 'VT', 1, NULL, NULL, 1),
|
||||||
(14, 5, 90, 'BLU', 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 4, 'VT', 1, NULL, NULL),
|
(14, 5, 90, 'BLU', 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 4, 'VT', 1, NULL, NULL, 0),
|
||||||
(15, 4, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 0, 'EMB', 0, NULL, NULL),
|
(15, 4, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 0, 'EMB', 0, NULL, NULL, 0),
|
||||||
(16, 6, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 0, 'EMB', 0, NULL, NULL),
|
(16, 6, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 0, 'EMB', 0, NULL, NULL, 0),
|
||||||
(71, 6, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 0, 'VT', 0, NULL, NULL);
|
(71, 6, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 0, 'VT', 0, NULL, NULL, 0);
|
||||||
|
|
||||||
-- Update the taxClass after insert of the items
|
-- Update the taxClass after insert of the items
|
||||||
UPDATE `vn`.`itemTaxCountry` SET `taxClassFk` = 2
|
UPDATE `vn`.`itemTaxCountry` SET `taxClassFk` = 2
|
||||||
|
@ -840,7 +840,7 @@ INSERT INTO `vn`.`priceFixed`(`id`, `itemFk`, `rate0`, `rate1`, `rate2`, `rate3`
|
||||||
VALUES
|
VALUES
|
||||||
(1, 1, 0, 0, 2.5, 2, CURDATE(), DATE_ADD(CURDATE(), INTERVAL +1 MONTH), 0, 1, CURDATE()),
|
(1, 1, 0, 0, 2.5, 2, CURDATE(), DATE_ADD(CURDATE(), INTERVAL +1 MONTH), 0, 1, CURDATE()),
|
||||||
(2, 3, 10, 10, 10, 10, CURDATE(), DATE_ADD(CURDATE(), INTERVAL +1 MONTH), 0, 1, CURDATE()),
|
(2, 3, 10, 10, 10, 10, CURDATE(), DATE_ADD(CURDATE(), INTERVAL +1 MONTH), 0, 1, CURDATE()),
|
||||||
(3, 5, 8.5, 10, 7.5, 6, CURDATE(), DATE_ADD(CURDATE(), INTERVAL +1 MONTH), 1, 2, CURDATE());
|
(3, 13, 8.5, 10, 7.5, 6, CURDATE(), DATE_ADD(CURDATE(), INTERVAL +1 MONTH), 1, 2, CURDATE());
|
||||||
|
|
||||||
INSERT INTO `vn`.`expeditionBoxVol`(`boxFk`, `m3`, `ratio`)
|
INSERT INTO `vn`.`expeditionBoxVol`(`boxFk`, `m3`, `ratio`)
|
||||||
VALUES
|
VALUES
|
||||||
|
|
|
@ -346,16 +346,17 @@ export default {
|
||||||
saveFieldsButton: '.vn-popover.shown vn-button[label="Save"] > button'
|
saveFieldsButton: '.vn-popover.shown vn-button[label="Save"] > button'
|
||||||
},
|
},
|
||||||
itemFixedPrice: {
|
itemFixedPrice: {
|
||||||
add: 'vn-fixed-price vn-icon[icon="add_circle"]',
|
add: 'vn-fixed-price vn-icon-button[icon="add_circle"]',
|
||||||
fourthFixedPrice: 'vn-fixed-price vn-tr:nth-child(4)',
|
fourthFixedPrice: 'vn-fixed-price tr:nth-child(5)',
|
||||||
fourthItemID: 'vn-fixed-price vn-tr:nth-child(4) vn-autocomplete[ng-model="price.itemFk"]',
|
fourthItemID: 'vn-fixed-price tr:nth-child(5) vn-autocomplete[ng-model="price.itemFk"]',
|
||||||
fourthWarehouse: 'vn-fixed-price vn-tr:nth-child(4) vn-autocomplete[ng-model="price.warehouseFk"]',
|
fourthWarehouse: 'vn-fixed-price tr:nth-child(5) vn-autocomplete[ng-model="price.warehouseFk"]',
|
||||||
fourthPPU: 'vn-fixed-price vn-tr:nth-child(4) > vn-td-editable:nth-child(4)',
|
fourthPPU: 'vn-fixed-price tr:nth-child(5) > td:nth-child(4)',
|
||||||
fourthPPP: 'vn-fixed-price vn-tr:nth-child(4) > vn-td-editable:nth-child(5)',
|
fourthPPP: 'vn-fixed-price tr:nth-child(5) > td:nth-child(5)',
|
||||||
fourthMinPrice: 'vn-fixed-price vn-tr:nth-child(4) > vn-td-editable:nth-child(6)',
|
fourthHasMinPrice: 'vn-fixed-price tr:nth-child(5) > td:nth-child(6) > vn-check[ng-model="price.hasMinPrice"]',
|
||||||
fourthStarted: 'vn-fixed-price vn-tr:nth-child(4) vn-date-picker[ng-model="price.started"]',
|
fourthMinPrice: 'vn-fixed-price tr:nth-child(5) > td:nth-child(6) > vn-input-number[ng-model="price.minPrice"]',
|
||||||
fourthEnded: 'vn-fixed-price vn-tr:nth-child(4) vn-date-picker[ng-model="price.ended"]',
|
fourthStarted: 'vn-fixed-price tr:nth-child(5) vn-date-picker[ng-model="price.started"]',
|
||||||
fourthDeleteIcon: 'vn-fixed-price vn-tr:nth-child(4) > vn-td:nth-child(9) > vn-icon-button[icon="delete"]'
|
fourthEnded: 'vn-fixed-price tr:nth-child(5) vn-date-picker[ng-model="price.ended"]',
|
||||||
|
fourthDeleteIcon: 'vn-fixed-price tr:nth-child(5) > td:nth-child(9) > vn-icon-button[icon="delete"]'
|
||||||
},
|
},
|
||||||
itemCreateView: {
|
itemCreateView: {
|
||||||
temporalName: 'vn-item-create vn-textfield[ng-model="$ctrl.item.provisionalName"]',
|
temporalName: 'vn-item-create vn-textfield[ng-model="$ctrl.item.provisionalName"]',
|
||||||
|
|
|
@ -16,33 +16,17 @@ describe('Item fixed prices path', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should click on the add new foxed price button', async() => {
|
it('should click on the add new foxed price button', async() => {
|
||||||
|
await page.doSearch();
|
||||||
await page.waitToClick(selectors.itemFixedPrice.add);
|
await page.waitToClick(selectors.itemFixedPrice.add);
|
||||||
await page.waitForSelector(selectors.itemFixedPrice.fourthFixedPrice);
|
await page.waitForSelector(selectors.itemFixedPrice.fourthFixedPrice);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should fill the fixed price data', async() => {
|
it('should fill the fixed price data', async() => {
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
const searchValue = 'Chest ammo box';
|
|
||||||
await page.waitToClick(selectors.itemFixedPrice.fourthItemID);
|
|
||||||
await page.write('body > div > div > div.content > div.filter.ng-scope > vn-textfield', searchValue);
|
|
||||||
try {
|
|
||||||
await page.waitForFunction(searchValue => {
|
|
||||||
const element = document.querySelector('li.active');
|
|
||||||
if (element)
|
|
||||||
return element.innerText.toLowerCase().includes(searchValue.toLowerCase());
|
|
||||||
}, {}, searchValue);
|
|
||||||
} catch (error) {
|
|
||||||
const builtSelector = await page.selectorFormater(selectors.ticketSales.moreMenuState);
|
|
||||||
const inputValue = await page.evaluate(() => {
|
|
||||||
return document.querySelector('.vn-drop-down.shown vn-textfield input').value;
|
|
||||||
});
|
|
||||||
throw new Error(`${builtSelector} value is ${inputValue}! ${error}`);
|
|
||||||
}
|
|
||||||
await page.keyboard.press('Enter');
|
|
||||||
await page.autocompleteSearch(selectors.itemFixedPrice.fourthWarehouse, 'Warehouse one');
|
await page.autocompleteSearch(selectors.itemFixedPrice.fourthWarehouse, 'Warehouse one');
|
||||||
await page.writeOnEditableTD(selectors.itemFixedPrice.fourthPPU, '20');
|
await page.write(selectors.itemFixedPrice.fourthPPU, '1');
|
||||||
await page.writeOnEditableTD(selectors.itemFixedPrice.fourthPPP, '10');
|
await page.write(selectors.itemFixedPrice.fourthPPP, '1');
|
||||||
await page.writeOnEditableTD(selectors.itemFixedPrice.fourthMinPrice, '5');
|
await page.write(selectors.itemFixedPrice.fourthMinPrice, '1');
|
||||||
await page.pickDate(selectors.itemFixedPrice.fourthStarted, now);
|
await page.pickDate(selectors.itemFixedPrice.fourthStarted, now);
|
||||||
await page.pickDate(selectors.itemFixedPrice.fourthEnded, now);
|
await page.pickDate(selectors.itemFixedPrice.fourthEnded, now);
|
||||||
const message = await page.waitForSnackbar();
|
const message = await page.waitForSnackbar();
|
||||||
|
@ -53,7 +37,9 @@ describe('Item fixed prices path', () => {
|
||||||
it('should reload the section and check the created price has the expected ID', async() => {
|
it('should reload the section and check the created price has the expected ID', async() => {
|
||||||
await page.accessToSection('item.index');
|
await page.accessToSection('item.index');
|
||||||
await page.accessToSection('item.fixedPrice');
|
await page.accessToSection('item.fixedPrice');
|
||||||
const result = await page.getProperty('vn-fixed-price > div > vn-card > vn-table > div > vn-tbody > vn-tr:nth-child(4) > vn-td:nth-child(1) > span', 'innerText');
|
await page.doSearch();
|
||||||
|
|
||||||
|
const result = await page.waitToGetProperty(selectors.itemFixedPrice.fourthItemID, 'value');
|
||||||
|
|
||||||
expect(result).toContain('13');
|
expect(result).toContain('13');
|
||||||
});
|
});
|
||||||
|
|
|
@ -32,6 +32,9 @@ export default class SmartTable extends Component {
|
||||||
this._options = options;
|
this._options = options;
|
||||||
if (!options) return;
|
if (!options) return;
|
||||||
|
|
||||||
|
if (options.defaultSearch)
|
||||||
|
this.displaySearch();
|
||||||
|
|
||||||
const activeButtons = options.activeButtons;
|
const activeButtons = options.activeButtons;
|
||||||
const missingId = activeButtons && activeButtons.shownColumns && !this.viewConfigId;
|
const missingId = activeButtons && activeButtons.shownColumns && !this.viewConfigId;
|
||||||
if (missingId)
|
if (missingId)
|
||||||
|
|
|
@ -90,7 +90,7 @@ describe('fixed price filter()', () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return no results filtering by hasMinPrice', async() => {
|
it('should return 1 result filtering by hasMinPrice', async() => {
|
||||||
const tx = await models.FixedPrice.beginTransaction({});
|
const tx = await models.FixedPrice.beginTransaction({});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -103,7 +103,7 @@ describe('fixed price filter()', () => {
|
||||||
};
|
};
|
||||||
const result = await models.FixedPrice.filter(ctx, null, options);
|
const result = await models.FixedPrice.filter(ctx, null, options);
|
||||||
|
|
||||||
expect(result.length).toEqual(0);
|
expect(result.length).toEqual(1);
|
||||||
|
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
url="FixedPrices/filter"
|
url="FixedPrices/filter"
|
||||||
limit="20"
|
limit="20"
|
||||||
data="prices"
|
data="prices"
|
||||||
auto-load="true"
|
order="itemFk"
|
||||||
order="itemFk">
|
auto-load="false">
|
||||||
</vn-crud-model>
|
</vn-crud-model>
|
||||||
<vn-crud-model
|
<vn-crud-model
|
||||||
auto-load="true"
|
auto-load="true"
|
||||||
|
@ -18,39 +18,56 @@
|
||||||
panel="vn-fixed-price-search-panel"
|
panel="vn-fixed-price-search-panel"
|
||||||
info="Search prices by item ID or code"
|
info="Search prices by item ID or code"
|
||||||
placeholder="Search fixed prices"
|
placeholder="Search fixed prices"
|
||||||
filter="{}"
|
|
||||||
model="model">
|
model="model">
|
||||||
</vn-searchbar>
|
</vn-searchbar>
|
||||||
</vn-portal>
|
</vn-portal>
|
||||||
<div class="vn-w-lg">
|
<div class="vn-w-xl">
|
||||||
<vn-card>
|
<vn-card>
|
||||||
<vn-table model="model">
|
<smart-table
|
||||||
<vn-thead>
|
model="model"
|
||||||
<vn-tr>
|
options="$ctrl.smartTableOptions"
|
||||||
<vn-th field="itemFk" shrink>Item ID</vn-th>
|
expr-builder="$ctrl.exprBuilder(param, value)">
|
||||||
<vn-th field="itemFk">Description</vn-th>
|
<slot-table>
|
||||||
<vn-th field="warehouseFk">Warehouse</vn-th>
|
<table>
|
||||||
<vn-th field="rate2">P.P.U.</vn-th>
|
<thead>
|
||||||
<vn-th field="rate3">P.P.P.</vn-th>
|
<tr>
|
||||||
<vn-th field="minPrice">Min price</vn-th>
|
<th field="itemFk">
|
||||||
<vn-th field="started" style="width: 90px">Started</vn-th>
|
<span translate>Item ID</span>
|
||||||
<vn-th field="ended" style="width: 90px">Ended</vn-th>
|
</th>
|
||||||
<vn-th shrink></vn-th>
|
<th field="itemName">
|
||||||
</vn-tr>
|
<span translate>Description</span>
|
||||||
</vn-thead>
|
</th>
|
||||||
<vn-tbody>
|
<th field="warehouseFk">
|
||||||
<vn-tr ng-repeat="price in prices">
|
<span translate>Warehouse</span>
|
||||||
<vn-td shrink>
|
</th>
|
||||||
<span
|
<th
|
||||||
ng-if="price.itemFk"
|
field="rate2"
|
||||||
ng-click="itemDescriptor.show($event, price.itemFk)"
|
vn-tooltip="Price By Unit">
|
||||||
class="link">
|
<span translate>P.P.U.</span>
|
||||||
{{price.itemFk}}
|
</th>
|
||||||
</span>
|
<th
|
||||||
|
field="rate3"
|
||||||
|
vn-tooltip="Price By Package">
|
||||||
|
<span translate>P.P.P.</span>
|
||||||
|
</th>
|
||||||
|
<th field="minPrice">
|
||||||
|
<span translate>Min price</span>
|
||||||
|
</th>
|
||||||
|
<th field="started">
|
||||||
|
<span translate>Started</span>
|
||||||
|
</th>
|
||||||
|
<th field="ended">
|
||||||
|
<span translate>Ended</span>
|
||||||
|
</th>
|
||||||
|
<th shrink></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr ng-repeat="price in prices">
|
||||||
|
<td shrink-field>
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
class="dense"
|
|
||||||
ng-if="!price.itemFk"
|
|
||||||
vn-focus
|
vn-focus
|
||||||
|
class="dense"
|
||||||
url="Items/withName"
|
url="Items/withName"
|
||||||
ng-model="price.itemFk"
|
ng-model="price.itemFk"
|
||||||
show-field="name"
|
show-field="name"
|
||||||
|
@ -60,13 +77,22 @@
|
||||||
order="id DESC"
|
order="id DESC"
|
||||||
tabindex="1">
|
tabindex="1">
|
||||||
<tpl-item>
|
<tpl-item>
|
||||||
{{::id}} - {{::name}}
|
<div>{{id}}</div>
|
||||||
|
<div class="text-caption text-secondary">
|
||||||
|
{{name}}
|
||||||
|
</div>
|
||||||
</tpl-item>
|
</tpl-item>
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
</vn-td>
|
</td>
|
||||||
<vn-td vn-fetched-tags>
|
<td vn-fetched-tags>
|
||||||
<div>
|
<div>
|
||||||
<vn-one title="{{price.name}}">{{price.name}}</vn-one>
|
<span
|
||||||
|
vn-one
|
||||||
|
ng-if="price.itemFk"
|
||||||
|
ng-click="itemDescriptor.show($event, price.itemFk)"
|
||||||
|
class="link">
|
||||||
|
{{price.name}}
|
||||||
|
</span>
|
||||||
<vn-one ng-if="price.subName">
|
<vn-one ng-if="price.subName">
|
||||||
<h3 title="{{price.subName}}">{{price.subName}}</h3>
|
<h3 title="{{price.subName}}">{{price.subName}}</h3>
|
||||||
</vn-one>
|
</vn-one>
|
||||||
|
@ -76,89 +102,82 @@
|
||||||
item="price"
|
item="price"
|
||||||
tabindex="-1">
|
tabindex="-1">
|
||||||
</vn-fetched-tags>
|
</vn-fetched-tags>
|
||||||
</vn-td>
|
</td>
|
||||||
<vn-td>
|
<td shrink-field-expand>
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
vn-one
|
vn-one
|
||||||
label="Warehouse"
|
|
||||||
ng-model="price.warehouseFk"
|
ng-model="price.warehouseFk"
|
||||||
url="Warehouses"
|
data="warehouses"
|
||||||
on-change="$ctrl.upsertPrice(price)"
|
on-change="$ctrl.upsertPrice(price)"
|
||||||
tabindex="2">
|
tabindex="2">
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
</vn-td>
|
</td>
|
||||||
<vn-td-editable number>
|
<td shrink-field>
|
||||||
<text>{{price.rate2 | currency: 'EUR':2}}</text>
|
|
||||||
<field>
|
|
||||||
<vn-input-number
|
<vn-input-number
|
||||||
class="dense"
|
|
||||||
vn-focus
|
|
||||||
ng-model="price.rate2"
|
ng-model="price.rate2"
|
||||||
on-change="$ctrl.upsertPrice(price)">
|
on-change="$ctrl.upsertPrice(price)"
|
||||||
|
step="0.01">
|
||||||
</vn-input-number>
|
</vn-input-number>
|
||||||
</field>
|
</td>
|
||||||
</vn-td-editable>
|
<td shrink-field>
|
||||||
<vn-td-editable number>
|
|
||||||
<text>{{price.rate3 | currency: 'EUR':2}}</text>
|
|
||||||
<field>
|
|
||||||
<vn-input-number
|
<vn-input-number
|
||||||
class="dense"
|
|
||||||
vn-focus
|
|
||||||
ng-model="price.rate3"
|
ng-model="price.rate3"
|
||||||
on-change="$ctrl.upsertPrice(price)">
|
on-change="$ctrl.upsertPrice(price)"
|
||||||
|
step="0.01">
|
||||||
</vn-input-number>
|
</vn-input-number>
|
||||||
</field>
|
</td>
|
||||||
</vn-td-editable>
|
<td shrink-field-expand class="minPrice">
|
||||||
<vn-td-editable number>
|
<vn-check
|
||||||
<text>{{(price.hasMinPrice ? (price.minPrice | currency: 'EUR':2) : "-")}}</text>
|
vn-one
|
||||||
<field>
|
ng-model="price.hasMinPrice">
|
||||||
|
</vn-check>
|
||||||
<vn-input-number
|
<vn-input-number
|
||||||
class="dense"
|
disabled="!price.hasMinPrice"
|
||||||
vn-focus
|
|
||||||
ng-model="price.minPrice"
|
ng-model="price.minPrice"
|
||||||
on-change="$ctrl.upsertPrice(price)"
|
on-change="$ctrl.upsertPrice(price)"
|
||||||
step="0.01">
|
step="0.01">
|
||||||
</vn-input-number>
|
</vn-input-number>
|
||||||
</field>
|
</td>
|
||||||
</vn-td-editable>
|
<td shrink-date>
|
||||||
<vn-td>
|
|
||||||
<vn-date-picker
|
<vn-date-picker
|
||||||
vn-one
|
vn-one
|
||||||
label="Started"
|
|
||||||
ng-model="price.started"
|
ng-model="price.started"
|
||||||
on-change="$ctrl.upsertPrice(price)">
|
on-change="$ctrl.upsertPrice(price)">
|
||||||
</vn-date-picker>
|
</vn-date-picker>
|
||||||
</vn-td>
|
</td>
|
||||||
<vn-td>
|
<td shrink-date>
|
||||||
<vn-date-picker
|
<vn-date-picker
|
||||||
vn-one
|
vn-one
|
||||||
label="Ended"
|
|
||||||
ng-model="price.ended"
|
ng-model="price.ended"
|
||||||
on-change="$ctrl.upsertPrice(price)">
|
on-change="$ctrl.upsertPrice(price)">
|
||||||
</vn-date-picker>
|
</vn-date-picker>
|
||||||
</vn-td>
|
</td>
|
||||||
<vn-td shrink>
|
<td shrink>
|
||||||
<vn-icon-button
|
<vn-icon-button
|
||||||
icon="delete"
|
icon="delete"
|
||||||
vn-tooltip="Delete"
|
vn-tooltip="Delete"
|
||||||
ng-click="deleteFixedPrice.show({$index})">
|
ng-click="deleteFixedPrice.show({$index})">
|
||||||
</vn-icon-button>
|
</vn-icon-button>
|
||||||
</vn-td>
|
</td>
|
||||||
</vn-tr>
|
</tr>
|
||||||
</vn-tbody>
|
</tbody>
|
||||||
</vn-table>
|
</table>
|
||||||
<div class="vn-pa-md">
|
<div class="vn-pa-md">
|
||||||
<vn-icon-button
|
<vn-icon-button
|
||||||
vn-tooltip="Add fixed price"
|
vn-tooltip="Add fixed price"
|
||||||
icon="add_circle"
|
icon="add_circle"
|
||||||
vn-bind="+"
|
vn-bind="+"
|
||||||
ng-click="model.insert()">
|
ng-click="$ctrl.add()">
|
||||||
</vn-icon-button>
|
</vn-icon-button>
|
||||||
</div>
|
</div>
|
||||||
<vn-pagination
|
<vn-pagination
|
||||||
model="model"
|
model="model"
|
||||||
class="vn-pt-md">
|
class="vn-pt-md"
|
||||||
|
scroll-selector="vn-item-price-fixed vn-table"
|
||||||
|
scroll-offset="100">
|
||||||
</vn-pagination>
|
</vn-pagination>
|
||||||
|
</slot-table>
|
||||||
|
</smart-table>
|
||||||
</vn-card>
|
</vn-card>
|
||||||
</div>
|
</div>
|
||||||
<vn-item-descriptor-popover
|
<vn-item-descriptor-popover
|
||||||
|
|
|
@ -5,13 +5,69 @@ import './style.scss';
|
||||||
export default class Controller extends Section {
|
export default class Controller extends Section {
|
||||||
constructor($element, $) {
|
constructor($element, $) {
|
||||||
super($element, $);
|
super($element, $);
|
||||||
|
|
||||||
|
this.smartTableOptions = {
|
||||||
|
activeButtons: {
|
||||||
|
search: true
|
||||||
|
},
|
||||||
|
defaultSearch: true,
|
||||||
|
columns: [
|
||||||
|
{
|
||||||
|
field: 'itemName',
|
||||||
|
autocomplete: {
|
||||||
|
url: 'Items',
|
||||||
|
showField: 'name',
|
||||||
|
valueField: 'id'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'warehouseFk',
|
||||||
|
autocomplete: {
|
||||||
|
url: 'Warehouses',
|
||||||
|
showField: 'name',
|
||||||
|
valueField: 'id',
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'started',
|
||||||
|
searchable: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'ended',
|
||||||
|
searchable: false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Inserts a new instance
|
|
||||||
*/
|
|
||||||
add() {
|
add() {
|
||||||
|
if (!this.$.model.data || this.$.model.data.length == 0) {
|
||||||
|
this.$.model.data = [];
|
||||||
|
this.$.model.proxiedData = [];
|
||||||
this.$.model.insert({});
|
this.$.model.insert({});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const lastIndex = this.$.model.data.length - 1;
|
||||||
|
const lastItem = this.$.model.data[lastIndex];
|
||||||
|
this.$.model.insert({
|
||||||
|
itemFk: lastItem.itemFk,
|
||||||
|
name: lastItem.name,
|
||||||
|
subName: lastItem.subName,
|
||||||
|
value5: lastItem.value5,
|
||||||
|
value6: lastItem.value6,
|
||||||
|
value7: lastItem.value7,
|
||||||
|
value8: lastItem.value8,
|
||||||
|
value9: lastItem.value9,
|
||||||
|
value10: lastItem.value10,
|
||||||
|
warehouseFk: lastItem.warehouseFk,
|
||||||
|
rate2: lastItem.rate2,
|
||||||
|
rate3: lastItem.rate3,
|
||||||
|
hasMinPrice: lastItem.hasMinPrice,
|
||||||
|
minPrice: lastItem.minPrice,
|
||||||
|
started: lastItem.started,
|
||||||
|
ended: lastItem.ended,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
upsertPrice(price) {
|
upsertPrice(price) {
|
||||||
|
@ -46,6 +102,22 @@ export default class Controller extends Section {
|
||||||
? {id: $search}
|
? {id: $search}
|
||||||
: {name: {like: '%' + $search + '%'}};
|
: {name: {like: '%' + $search + '%'}};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exprBuilder(param, value) {
|
||||||
|
switch (param) {
|
||||||
|
case 'itemName':
|
||||||
|
return {'i.id': value};
|
||||||
|
case 'itemFk':
|
||||||
|
case 'warehouseFk':
|
||||||
|
case 'rate2':
|
||||||
|
case 'rate3':
|
||||||
|
param = `fp.${param}`;
|
||||||
|
return {[param]: value};
|
||||||
|
case 'minPrice':
|
||||||
|
param = `i.${param}`;
|
||||||
|
return {[param]: value};
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ngModule.vnComponent('vnFixedPrice', {
|
ngModule.vnComponent('vnFixedPrice', {
|
||||||
|
|
|
@ -55,6 +55,8 @@ describe('fixed price', () => {
|
||||||
jest.spyOn(controller.vnApp, 'showSuccess');
|
jest.spyOn(controller.vnApp, 'showSuccess');
|
||||||
jest.spyOn(controller.$.model, 'remove');
|
jest.spyOn(controller.$.model, 'remove');
|
||||||
|
|
||||||
|
$httpBackend.expectGET('Warehouses').respond();
|
||||||
|
|
||||||
controller.removePrice($index);
|
controller.removePrice($index);
|
||||||
|
|
||||||
expect(controller.vnApp.showSuccess).not.toHaveBeenCalled();
|
expect(controller.vnApp.showSuccess).not.toHaveBeenCalled();
|
||||||
|
|
|
@ -3,3 +3,5 @@ Search prices by item ID or code: Buscar por ID de artículo o código
|
||||||
Search fixed prices: Buscar precios fijados
|
Search fixed prices: Buscar precios fijados
|
||||||
Add fixed price: Añadir precio fijado
|
Add fixed price: Añadir precio fijado
|
||||||
This row will be removed: Esta linea se eliminará
|
This row will be removed: Esta linea se eliminará
|
||||||
|
Price By Unit: Precio Por Unidad
|
||||||
|
Price By Package: Precio Por Paquete
|
|
@ -1,5 +1,20 @@
|
||||||
@import "variables";
|
@import "variables";
|
||||||
|
smart-table table{
|
||||||
|
[shrink-field]{
|
||||||
|
width: 80px;
|
||||||
|
max-width: 80px;
|
||||||
|
}
|
||||||
|
[shrink-field-expand]{
|
||||||
|
width: 150px;
|
||||||
|
max-width: 150px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
vn-table vn-date-picker {
|
.minPrice {
|
||||||
|
align-items: center;
|
||||||
|
text-align: center;
|
||||||
|
vn-input-number {
|
||||||
|
width: 90px;
|
||||||
max-width: 90px;
|
max-width: 90px;
|
||||||
}
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue