diff --git a/back/methods/collection/setSaleQuantity.js b/back/methods/collection/setSaleQuantity.js
index 82451b8be1..95145e9a02 100644
--- a/back/methods/collection/setSaleQuantity.js
+++ b/back/methods/collection/setSaleQuantity.js
@@ -28,7 +28,7 @@ module.exports = Self => {
const args = ctx.args;
const models = Self.app.models;
- const sale = await models.Sale.findById(args.saleId,);
+ const sale = await models.Sale.findById(args.saleId);
return await sale.updateAttribute('quantity', args.quantity);
};
};
diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js
index 4bb7b97e12..2ecb739609 100644
--- a/e2e/helpers/selectors.js
+++ b/e2e/helpers/selectors.js
@@ -1133,7 +1133,7 @@ export default {
entryLatestBuys: {
firstBuy: 'vn-entry-latest-buys tbody > tr:nth-child(1)',
allBuysCheckBox: 'vn-entry-latest-buys thead vn-check',
- secondBuyCheckBox: 'vn-entry-latest-buys tbody tr:nth-child(2) vn-check[ng-model="buy.$checked"]',
+ secondBuyCheckBox: 'vn-entry-latest-buys tbody tr:nth-child(2) vn-check[ng-model="buy.checked"]',
editBuysButton: 'vn-entry-latest-buys vn-button[icon="edit"]',
fieldAutocomplete: 'vn-autocomplete[ng-model="$ctrl.editedColumn.field"]',
newValueInput: 'vn-textfield[ng-model="$ctrl.editedColumn.newValue"]',
diff --git a/front/core/components/multi-check/locale/en.yml b/front/core/components/multi-check/locale/en.yml
new file mode 100644
index 0000000000..ea52dcf8f2
--- /dev/null
+++ b/front/core/components/multi-check/locale/en.yml
@@ -0,0 +1 @@
+SelectAllRows: Select the {{rows}} row(s)
\ No newline at end of file
diff --git a/front/core/components/multi-check/locale/es.yml b/front/core/components/multi-check/locale/es.yml
new file mode 100644
index 0000000000..5365c3392b
--- /dev/null
+++ b/front/core/components/multi-check/locale/es.yml
@@ -0,0 +1,3 @@
+SelectAllRows: Seleccionar las {{rows}} fila(s)
+All: Se han seleccionado
+row(s) have been selected.: fila(s).
\ No newline at end of file
diff --git a/front/core/components/multi-check/multi-check.html b/front/core/components/multi-check/multi-check.html
index fb950aaff1..eaa4577f06 100644
--- a/front/core/components/multi-check/multi-check.html
+++ b/front/core/components/multi-check/multi-check.html
@@ -2,4 +2,23 @@
ng-model="$ctrl.checked"
indeterminate="$ctrl.isIndeterminate"
translate-attr="{title: 'Check all'}">
-
\ No newline at end of file
+
+
+
+
+
+ All
+
+ {{$ctrl.rows}}
+
+ row(s) have been selected.
+
+ {{$ctrl.allRowsText}}
+
+
+
\ No newline at end of file
diff --git a/front/core/components/multi-check/multi-check.js b/front/core/components/multi-check/multi-check.js
index afa1bc3c45..e60d16519d 100644
--- a/front/core/components/multi-check/multi-check.js
+++ b/front/core/components/multi-check/multi-check.js
@@ -106,6 +106,9 @@ export default class MultiCheck extends FormInput {
this.toggle();
this.emit('change', value);
+
+ if (!value)
+ this.checkedDummyCount = null;
}
/**
@@ -132,12 +135,43 @@ export default class MultiCheck extends FormInput {
areAllUnchecked() {
if (!this.model || !this.model.data) return;
+ this.checkedDummyCount = null;
const data = this.model.data;
return data.every(item => {
return item[this.checkField] === false;
});
}
+ countRows() {
+ if (!this.model || !this.model.data) return;
+
+ const data = this.model.data;
+ const modelParams = this.model.userParams;
+ const params = {
+ filter: {
+ modelParams: modelParams,
+ limit: null
+ }
+ };
+
+ this.rows = data.length;
+
+ this.$http.get(this.model.url, {params})
+ .then(res => {
+ this.allRowsCount = res.data.length;
+ this.allRowsText = this.$t('SelectAllRows', {
+ rows: this.allRowsCount
+ });
+ });
+ }
+
+ checkDummy() {
+ if (this.checkedDummyCount)
+ return this.checkedDummyCount = null;
+
+ this.checkedDummyCount = this.allRowsCount;
+ }
+
/**
* Toggles checked property on
* all instances
@@ -158,7 +192,9 @@ ngModule.vnComponent('vnMultiCheck', {
checkField: '@?',
checkAll: '=?',
checked: '=?',
- disabled: ''
+ disabled: '',
+ checkDummyEnabled: '',
+ checkedDummyCount: '=?'
}
});
diff --git a/front/core/components/multi-check/multi-check.spec.js b/front/core/components/multi-check/multi-check.spec.js
index c8069da3cc..1c0adb9d8b 100644
--- a/front/core/components/multi-check/multi-check.spec.js
+++ b/front/core/components/multi-check/multi-check.spec.js
@@ -4,10 +4,14 @@ import crudModel from 'core/mocks/crud-model';
describe('Component vnMultiCheck', () => {
let controller;
let $element;
+ let $httpBackend;
+ let $httpParamSerializer;
beforeEach(ngModule('vnCore'));
- beforeEach(inject($componentController => {
+ beforeEach(inject(($componentController, _$httpBackend_, _$httpParamSerializer_) => {
+ $httpBackend = _$httpBackend_;
+ $httpParamSerializer = _$httpParamSerializer_;
$element = angular.element(`
`);
controller = $componentController('vnMultiCheck', {$element: $element});
controller._model = crudModel;
@@ -26,6 +30,14 @@ describe('Component vnMultiCheck', () => {
expect(controller._checked).toEqual(crudModel);
expect(controller.toggle).toHaveBeenCalledWith();
});
+
+ it(`should set checkedDummyCount to null`, () => {
+ jest.spyOn(controller, 'toggle');
+ controller.checkedDummyCount = 12;
+ controller.checked = null;
+
+ expect(controller.checkedDummyCount).toBeNull();
+ });
});
describe('toggle()', () => {
@@ -132,4 +144,50 @@ describe('Component vnMultiCheck', () => {
expect(thirdRow.checked).toBeTruthy();
});
});
+
+ describe('countRows()', () => {
+ it(`should count visible rows and all rows of model`, () => {
+ controller.model.url = 'modelUrl/filter';
+ const data = controller.model.data;
+ const filter = {
+ limit: null
+ };
+ const serializedParams = $httpParamSerializer({filter});
+
+ const response = [
+ {id: 1, name: 'My item 1'},
+ {id: 2, name: 'My item 2'},
+ {id: 3, name: 'My item 3'},
+ {id: 4, name: 'My item 4'},
+ {id: 5, name: 'My item 5'},
+ {id: 6, name: 'My item 6'}
+ ];
+
+ controller.countRows();
+ $httpBackend.expectGET(`modelUrl/filter?${serializedParams}`).respond(response);
+ $httpBackend.flush();
+
+ expect(controller.rows).toEqual(data.length);
+ expect(controller.allRowsCount).toEqual(response.length);
+ expect(controller.allRowsCount).toBeGreaterThan(controller.rows);
+ });
+ });
+
+ describe('checkDummy()', () => {
+ const allRows = 1234;
+ it(`should set the checked dummy count to all rows count if there was no count yet`, () => {
+ controller.checkedDummyCount = null;
+ controller.allRowsCount = allRows;
+ controller.checkDummy();
+
+ expect(controller.checkedDummyCount).toEqual(controller.allRowsCount);
+ });
+
+ it(`should remove the dummy count if there was an existing one`, () => {
+ controller.checkedDummyCount = allRows;
+ controller.checkDummy();
+
+ expect(controller.checkedDummyCount).toBeNull();
+ });
+ });
});
diff --git a/front/core/components/multi-check/style.scss b/front/core/components/multi-check/style.scss
index 79c2397bcd..7a4d10675e 100644
--- a/front/core/components/multi-check/style.scss
+++ b/front/core/components/multi-check/style.scss
@@ -1,5 +1,17 @@
+@import "variables";
vn-multi-check {
.vn-check {
margin-bottom: 12px
}
+
+ vn-list{
+ padding: 50px;
+ }
+ vn-menu{
+ padding: 50px;
+ }
+
+}
+.bold{
+ font-weight: bold;
}
\ No newline at end of file
diff --git a/modules/client/front/descriptor/index.html b/modules/client/front/descriptor/index.html
index de7a86d3b8..cad2264169 100644
--- a/modules/client/front/descriptor/index.html
+++ b/modules/client/front/descriptor/index.html
@@ -105,7 +105,7 @@
diff --git a/modules/client/front/descriptor/locale/es.yml b/modules/client/front/descriptor/locale/es.yml
index e6aca96656..71723e6549 100644
--- a/modules/client/front/descriptor/locale/es.yml
+++ b/modules/client/front/descriptor/locale/es.yml
@@ -3,5 +3,6 @@ View consumer report: Ver informe de consumo
From date: Fecha desde
To date: Fecha hasta
Go to user: Ir al usuario
+Go to supplier: Ir al proveedor
Client invoices list: Listado de facturas del cliente
Pay method: Forma de pago
\ No newline at end of file
diff --git a/modules/entry/back/methods/entry/editLatestBuys.js b/modules/entry/back/methods/entry/editLatestBuys.js
index fb0397d2b4..72bee98ae6 100644
--- a/modules/entry/back/methods/entry/editLatestBuys.js
+++ b/modules/entry/back/methods/entry/editLatestBuys.js
@@ -1,27 +1,32 @@
module.exports = Self => {
- Self.remoteMethod('editLatestBuys', {
+ Self.remoteMethodCtx('editLatestBuys', {
description: 'Updates a column for one or more buys',
accessType: 'WRITE',
accepts: [{
arg: 'field',
- type: 'String',
+ type: 'string',
required: true,
description: `the column to edit`
},
{
arg: 'newValue',
- type: 'Any',
+ type: 'any',
required: true,
description: `The new value to save`
},
{
arg: 'lines',
- type: ['Object'],
+ type: ['object'],
required: true,
description: `the buys which will be modified`
+ },
+ {
+ arg: 'filter',
+ type: 'object',
+ description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string'
}],
returns: {
- type: 'Object',
+ type: 'object',
root: true
},
http: {
@@ -30,7 +35,7 @@ module.exports = Self => {
}
});
- Self.editLatestBuys = async(field, newValue, lines, options) => {
+ Self.editLatestBuys = async(ctx, field, newValue, lines, filter, options) => {
let tx;
const myOptions = {};
@@ -64,17 +69,19 @@ module.exports = Self => {
const models = Self.app.models;
const model = models[modelName];
-
try {
const promises = [];
+ const value = {};
+ value[field] = newValue;
+
+ if (filter) {
+ ctx.args.filter = {where: filter, limit: null};
+ lines = await models.Buy.latestBuysFilter(ctx, null, myOptions);
+ }
const targets = lines.map(line => {
return line[identifier];
});
-
- const value = {};
- value[field] = newValue;
-
for (let target of targets)
promises.push(model.upsertWithWhere({id: target}, value, myOptions));
diff --git a/modules/entry/back/methods/entry/latestBuysFilter.js b/modules/entry/back/methods/entry/latestBuysFilter.js
index 04570533c2..9693670c8f 100644
--- a/modules/entry/back/methods/entry/latestBuysFilter.js
+++ b/modules/entry/back/methods/entry/latestBuysFilter.js
@@ -86,7 +86,7 @@ module.exports = Self => {
}
],
returns: {
- type: ['Object'],
+ type: ['object'],
root: true
},
http: {
@@ -98,6 +98,9 @@ module.exports = Self => {
Self.latestBuysFilter = async(ctx, filter, options) => {
const myOptions = {};
+ if (filter && filter.modelParams)
+ ctx.args = filter.modelParams;
+
if (typeof options == 'object')
Object.assign(myOptions, options);
diff --git a/modules/entry/back/methods/entry/specs/editLatestBuys.spec.js b/modules/entry/back/methods/entry/specs/editLatestBuys.spec.js
index b17b0ab212..2413c18f67 100644
--- a/modules/entry/back/methods/entry/specs/editLatestBuys.spec.js
+++ b/modules/entry/back/methods/entry/specs/editLatestBuys.spec.js
@@ -6,7 +6,7 @@ describe('Buy editLatestsBuys()', () => {
const options = {transaction: tx};
try {
- let ctx = {
+ const ctx = {
args: {
search: 'Ranged weapon longbow 2m'
}
@@ -18,7 +18,35 @@ describe('Buy editLatestsBuys()', () => {
const newValue = 99;
const lines = [{itemFk: original.itemFk, id: original.id}];
- await models.Buy.editLatestBuys(field, newValue, lines, options);
+ await models.Buy.editLatestBuys(ctx, field, newValue, lines, null, options);
+
+ const [result] = await models.Buy.latestBuysFilter(ctx, null, options);
+
+ expect(result[field]).toEqual(newValue);
+
+ await tx.rollback();
+ } catch (e) {
+ await tx.rollback();
+ throw e;
+ }
+ });
+
+ it('should change the value of a given column for filter', async() => {
+ const tx = await models.Buy.beginTransaction({});
+ const options = {transaction: tx};
+
+ try {
+ const filter = {typeFk: 1};
+ const ctx = {
+ args: {
+ filter: filter
+ }
+ };
+
+ const field = 'size';
+ const newValue = 88;
+
+ await models.Buy.editLatestBuys(ctx, field, newValue, null, filter, options);
const [result] = await models.Buy.latestBuysFilter(ctx, null, options);
diff --git a/modules/entry/front/latest-buys/index.html b/modules/entry/front/latest-buys/index.html
index 4eeeeedce7..a4d6f7e837 100644
--- a/modules/entry/front/latest-buys/index.html
+++ b/modules/entry/front/latest-buys/index.html
@@ -29,9 +29,11 @@
+ checked="$ctrl.checkAll"
+ check-field="checked"
+ check-dummy-enabled="true"
+ checked-dummy-count="$ctrl.checkedDummyCount">
|
Picture |
@@ -126,7 +128,7 @@
}">
|
diff --git a/modules/entry/front/latest-buys/index.js b/modules/entry/front/latest-buys/index.js
index 385e7e4b65..44c29cb11b 100644
--- a/modules/entry/front/latest-buys/index.js
+++ b/modules/entry/front/latest-buys/index.js
@@ -6,7 +6,7 @@ export default class Controller extends Section {
constructor($element, $) {
super($element, $);
this.editedColumn;
- this.$checkAll = false;
+ this.checkAll = false;
this.smartTableOptions = {
activeButtons: {
@@ -91,7 +91,7 @@ export default class Controller extends Section {
const buys = this.$.model.data || [];
const checkedBuys = [];
for (let buy of buys) {
- if (buy.$checked)
+ if (buy.checked)
checkedBuys.push(buy);
}
@@ -142,6 +142,9 @@ export default class Controller extends Section {
}
get totalChecked() {
+ if (this.checkedDummyCount)
+ return this.checkedDummyCount;
+
return this.checked.length;
}
@@ -156,6 +159,9 @@ export default class Controller extends Section {
lines: rowsToEdit
};
+ if (this.checkedDummyCount && this.checkedDummyCount > 0)
+ data.filter = this.$.model.userParams;
+
return this.$http.post('Buys/editLatestBuys', data)
.then(() => {
this.uncheck();
diff --git a/modules/entry/front/latest-buys/index.spec.js b/modules/entry/front/latest-buys/index.spec.js
index e9392a7972..76e122d808 100644
--- a/modules/entry/front/latest-buys/index.spec.js
+++ b/modules/entry/front/latest-buys/index.spec.js
@@ -31,10 +31,10 @@ describe('Entry', () => {
describe('get checked', () => {
it(`should return a set of checked lines`, () => {
controller.$.model.data = [
- {$checked: true, id: 1},
- {$checked: true, id: 2},
- {$checked: true, id: 3},
- {$checked: false, id: 4},
+ {checked: true, id: 1},
+ {checked: true, id: 2},
+ {checked: true, id: 3},
+ {checked: false, id: 4},
];
let result = controller.checked;
diff --git a/modules/supplier/back/methods/supplier/getSummary.js b/modules/supplier/back/methods/supplier/getSummary.js
index 67f5267b64..c29a2a058e 100644
--- a/modules/supplier/back/methods/supplier/getSummary.js
+++ b/modules/supplier/back/methods/supplier/getSummary.js
@@ -100,12 +100,7 @@ module.exports = Self => {
},
]
};
- let supplier = await Self.app.models.Supplier.findOne(filter);
- const farmerCode = 2;
- if (supplier.sageWithholdingFk == farmerCode)
- supplier.isFarmer = true;
-
- return supplier;
+ return Self.app.models.Supplier.findOne(filter);
};
};
diff --git a/modules/supplier/back/methods/supplier/specs/getSummary.spec.js b/modules/supplier/back/methods/supplier/specs/getSummary.spec.js
index 21e56882f0..30713f5177 100644
--- a/modules/supplier/back/methods/supplier/specs/getSummary.spec.js
+++ b/modules/supplier/back/methods/supplier/specs/getSummary.spec.js
@@ -25,12 +25,4 @@ describe('Supplier getSummary()', () => {
expect(payMethod.name).toEqual('PayMethod one');
});
-
- it(`should get if supplier is farmer by sageWithholdingFk`, async() => {
- const supplier = await app.models.Supplier.findById(2);
- const supplierSummary = await app.models.Supplier.getSummary(2);
-
- expect(supplier.isFarmer).toBeUndefined();
- expect(supplierSummary.isFarmer).toEqual(true);
- });
});
diff --git a/modules/supplier/front/summary/index.html b/modules/supplier/front/summary/index.html
index 51ebde6951..086cd844d6 100644
--- a/modules/supplier/front/summary/index.html
+++ b/modules/supplier/front/summary/index.html
@@ -83,11 +83,6 @@
label="Account"
value="{{::$ctrl.summary.account}}">
-
-