diff --git a/front/salix/components/user-popover/index.html b/front/salix/components/user-popover/index.html
index 22d86f1aa..0fa6800c5 100644
--- a/front/salix/components/user-popover/index.html
+++ b/front/salix/components/user-popover/index.html
@@ -63,7 +63,7 @@
show-field="bank"
order="id"
value-field="id"
- search-function="{or: [{id: $search}, {bank: {like: '%'+ $search +'%'}}]}">
+ search-function="$ctrl.bankSearchFunc($search)">
{{id}}: {{bank}}
{
});
describe('getImageUrl()', () => {
- it('should return de url image', () => {
+ it('should return the url image', () => {
const url = $root.imagePath('user', '160x160', userId);
expect(url).toBeDefined();
expect(url).toEqual(`/api/Images/user/160x160/${userId}/download?access_token=null`);
});
});
+
+ describe('bankSearchFunc()', () => {
+ it('should return the filter by id property for an input of a number', () => {
+ const bankId = 1;
+ const result = controller.bankSearchFunc(bankId);
+
+ expect(result).toEqual({id: bankId});
+ });
+
+ it('should return the filter by bank property for an input of an string', () => {
+ const bankName = 'Bank of America';
+ const result = controller.bankSearchFunc(bankName);
+
+ expect(result).toEqual({bank: {like: '%' + bankName + '%'}});
+ });
+ });
});
});
diff --git a/modules/client/front/balance/create/index.html b/modules/client/front/balance/create/index.html
index 357ae5d03..f9bf89b04 100644
--- a/modules/client/front/balance/create/index.html
+++ b/modules/client/front/balance/create/index.html
@@ -33,7 +33,7 @@
fields="['accountingTypeFk']"
include="{relation: 'accountingType'}"
ng-model="$ctrl.bankFk"
- search-function="{or: [{id: $search}, {bank: {like: '%'+ $search +'%'}}]}"
+ search-function="$ctrl.bankSearchFunc($search)"
selection="$ctrl.bankSelection"
order="id"
required="true">
diff --git a/modules/client/front/balance/create/index.js b/modules/client/front/balance/create/index.js
index be05983ca..e78a9c1b2 100644
--- a/modules/client/front/balance/create/index.js
+++ b/modules/client/front/balance/create/index.js
@@ -137,6 +137,12 @@ class Controller extends Dialog {
}
});
}
+
+ bankSearchFunc($search) {
+ return /^\d+$/.test($search)
+ ? {id: $search}
+ : {bank: {like: '%' + $search + '%'}};
+ }
}
Controller.$inject = ['$element', '$scope', '$transclude', 'vnReport'];
diff --git a/modules/client/front/balance/create/index.spec.js b/modules/client/front/balance/create/index.spec.js
index 75ab6fa13..bd0607a79 100644
--- a/modules/client/front/balance/create/index.spec.js
+++ b/modules/client/front/balance/create/index.spec.js
@@ -118,5 +118,21 @@ describe('Client', () => {
expect(controller.receipt.compensationAccount).toEqual('4000000003');
});
});
+
+ describe('bankSearchFunc()', () => {
+ it('should return the filter by id property for an input of a number', () => {
+ const bankId = 1;
+ const result = controller.bankSearchFunc(bankId);
+
+ expect(result).toEqual({id: bankId});
+ });
+
+ it('should return the filter by bank property for an input of an string', () => {
+ const bankName = 'Bank of America';
+ const result = controller.bankSearchFunc(bankName);
+
+ expect(result).toEqual({bank: {like: '%' + bankName + '%'}});
+ });
+ });
});
});
diff --git a/modules/ticket/front/sale/index.spec.js b/modules/ticket/front/sale/index.spec.js
index 169b41c5f..cee1fe5b4 100644
--- a/modules/ticket/front/sale/index.spec.js
+++ b/modules/ticket/front/sale/index.spec.js
@@ -679,5 +679,21 @@ describe('Ticket', () => {
expect(controller.$.model.refresh).toHaveBeenCalledWith();
});
});
+
+ describe('itemSearchFunc()', () => {
+ it('should return the filter by id property for an input of a number', () => {
+ const itemId = 1;
+ const result = controller.itemSearchFunc(itemId);
+
+ expect(result).toEqual({id: itemId});
+ });
+
+ it('should return the filter by bank property for an input of an string', () => {
+ const itemName = 'Bow';
+ const result = controller.itemSearchFunc(itemName);
+
+ expect(result).toEqual({name: {like: '%' + itemName + '%'}});
+ });
+ });
});
});