Merge branch 'dev' of https://git.verdnatura.es/salix into dev

This commit is contained in:
Joan Sanchez 2018-08-23 10:08:15 +02:00
commit c7ff42b409
4 changed files with 55 additions and 23 deletions

View File

@ -4,12 +4,6 @@
filter="{}"
data="sales" on-data-change="$ctrl.onDataChange()">
</vn-crud-model>
<vn-watcher
vn-id="watcher"
data="sales">
</vn-watcher>
<vn-vertical>
<vn-card pad-large>
<vn-vertical>
@ -53,10 +47,9 @@
<vn-table model="model">
<vn-thead>
<vn-tr>
<vn-th number>
<vn-th number ng-show="$ctrl.isEditable">
<vn-multi-check
data="$ctrl.sales"
disabled="!$ctrl.isEditable">
data="$ctrl.sales">
</vn-multi-check>
</vn-th>
<vn-th></vn-th>
@ -71,10 +64,9 @@
</vn-thead>
<vn-tbody>
<vn-tr ng-repeat="sale in sales">
<vn-td number>
<vn-td number ng-show="$ctrl.isEditable">
<vn-check
field="sale.checked"
disabled="!$ctrl.isEditable">
field="sale.checked">
</vn-check>
</vn-td>
<vn-td>
@ -140,7 +132,7 @@
</vn-empty-rows>
<vn-tfoot>
<vn-tr ng-if="model.data.length > 0">
<vn-td></vn-td>
<vn-td ng-show="$ctrl.isEditable"></vn-td>
<vn-td></vn-td>
<vn-td></vn-td>
<vn-td></vn-td>

View File

@ -20,14 +20,14 @@ describe('item clone()', () => {
});
it('should attempt to clone the given item but give an error as it doesnt exist', async() => {
let result;
try {
let itemFk = 999;
result = await app.models.Item.clone(itemFk);
} catch (error) {
expect(error.toString()).toContain('Cannot convert undefined or null to object');
}
let error;
let itemFk = 999;
await app.models.Item.clone(itemFk)
.catch(e => {
expect(e.message).toContain('Cannot convert undefined or null to object');
error = e;
});
expect(result).toBeFalsy();
expect(error).toBeDefined();
});
});

View File

@ -0,0 +1,40 @@
const app = require(`${servicesDir}/item/server/server`);
describe('item updateTaxes()', () => {
afterAll(async() => {
let taxesInFixtures = [{id: 509368, taxClassFk: 1}];
await app.models.Item.updateTaxes(taxesInFixtures);
});
it('should throw an error if the taxClassFk is blank', async() => {
let error;
let taxes = [{id: 509368, taxClassFk: undefined}];
await app.models.Item.updateTaxes(taxes)
.catch(err => {
expect(err.message).toEqual('Tax class cannot be blank');
error = err;
});
expect(error).toBeDefined();
});
it('should update the tax of a given country of an item', async() => {
let taxCountry = await app.models.ItemTaxCountry.findById(509368);
expect(taxCountry.taxClassFk).toEqual(1);
let taxes = [{id: 509368, taxClassFk: 2}];
let result = await app.models.Item.updateTaxes(taxes);
expect(result).toBeTruthy();
});
it('should confirm the tax class was updated', async() => {
let taxCountry = await app.models.ItemTaxCountry.findById(509368);
expect(taxCountry.taxClassFk).toEqual(2);
});
});

View File

@ -11,7 +11,7 @@ module.exports = Self => {
description: 'The item id',
http: {source: 'path'}
}, {
arg: 'niches',
arg: 'taxes',
type: ['object'],
required: true,
description: 'The list of taxes to update',
@ -27,7 +27,7 @@ module.exports = Self => {
}
});
Self.updateTaxes = async(id, taxes) => {
Self.updateTaxes = async taxes => {
let promises = [];
for (let tax of taxes) {
if (!tax.taxClassFk)