diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql
index 62a5b7ca2..ae7fbe67e 100644
--- a/db/dump/fixtures.sql
+++ b/db/dump/fixtures.sql
@@ -1208,11 +1208,11 @@ INSERT INTO `vn`.`annualAverageInvoiced`(`clientFk`, `invoiced`)
(104, 500),
(105, 5000);
-INSERT INTO `vn`.`supplier`(`id`, `name`, `nickname`,`account`,`countryFk`,`nif`,`isFarmer`,`retAccount`,`commission`, `created`, `postcodeFk`, `isActive`, `street`, `city`, `provinceFk`, `postCode`, `payMethodFk`, `payDemFk`)
+INSERT INTO `vn`.`supplier`(`id`, `name`, `nickname`,`account`,`countryFk`,`nif`,`isFarmer`,`retAccount`,`commission`, `created`, `postcodeFk`, `isActive`, `street`, `city`, `provinceFk`, `postCode`, `payMethodFk`, `payDemFk`, `phone`, `payDay`)
VALUES
- (1, 'Plants SL', 'Plants nick', 4000000001, 1, 'A11111111', 0, NULL, 0, CURDATE(), 1111, 1, 'supplier address 1', 'PONTEVEDRA', 1, 15214, 1, 1),
- (2, 'Flower King', 'The king', 4000000002, 1, 'B22222222', 0, NULL, 0, CURDATE(), 2222, 1, 'supplier address 2', 'LONDON', 2, 45671, 1, 2),
- (442, 'Verdnatura Levante SL', 'Verdnatura', 4000000442, 1, 'C33333333', 0, NULL, 0, CURDATE(), 3333, 1, 'supplier address 3', 'SILLA', 1, 43022, 1, 2);
+ (1, 'Plants SL', 'Plants nick', 4000000001, 1, 'A11111111', 0, NULL, 0, CURDATE(), 1111, 1, 'supplier address 1', 'PONTEVEDRA', 1, 15214, 1, 1, 123456789, 15),
+ (2, 'Flower King', 'The king', 4000000002, 1, 'B22222222', 0, NULL, 0, CURDATE(), 2222, 1, 'supplier address 2', 'LONDON', 2, 45671, 1, 2, 987654321, 10),
+ (442, 'Verdnatura Levante SL', 'Verdnatura', 4000000442, 1, 'C33333333', 0, NULL, 0, CURDATE(), 3333, 1, 'supplier address 3', 'SILLA', 1, 43022, 1, 2, 987123654, 15);
INSERT INTO `cache`.`cache_calc`(`id`, `cache_id`, `cacheName`, `params`, `last_refresh`, `expires`, `created`, `connection_id`)
VALUES
diff --git a/front/core/styles/icons/salixfont.css b/front/core/styles/icons/salixfont.css
index 52a2308b4..aafc549a1 100644
--- a/front/core/styles/icons/salixfont.css
+++ b/front/core/styles/icons/salixfont.css
@@ -22,6 +22,9 @@
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
+.icon-supplier:before {
+ content: "\e936";
+}
.icon-latestBuys:before {
content: "\e95f";
}
diff --git a/front/core/styles/icons/salixfont.svg b/front/core/styles/icons/salixfont.svg
index 7e8695d63..ee14609a4 100644
--- a/front/core/styles/icons/salixfont.svg
+++ b/front/core/styles/icons/salixfont.svg
@@ -61,7 +61,7 @@
-
+
@@ -102,7 +102,7 @@
-
+
diff --git a/front/core/styles/icons/salixfont.ttf b/front/core/styles/icons/salixfont.ttf
index 608dd7c80..6958c0e3d 100644
Binary files a/front/core/styles/icons/salixfont.ttf and b/front/core/styles/icons/salixfont.ttf differ
diff --git a/front/core/styles/icons/salixfont.woff b/front/core/styles/icons/salixfont.woff
index ecea37f50..a9e083c83 100644
Binary files a/front/core/styles/icons/salixfont.woff and b/front/core/styles/icons/salixfont.woff differ
diff --git a/front/module-import.js b/front/module-import.js
index baebe30eb..a726e2cc7 100755
--- a/front/module-import.js
+++ b/front/module-import.js
@@ -19,5 +19,6 @@ export default function moduleImport(moduleName) {
case 'route' : return import('route/front');
case 'entry' : return import('entry/front');
case 'account' : return import('account/front');
+ case 'supplier' : return import('supplier/front');
}
}
diff --git a/front/salix/locale/es.yml b/front/salix/locale/es.yml
index 75c65ef64..f2a23a7a7 100644
--- a/front/salix/locale/es.yml
+++ b/front/salix/locale/es.yml
@@ -45,6 +45,7 @@ Locator: Localizador
Invoices out: Facturas emitidas
Entries: Entradas
Users: Usuarios
+Suppliers: Proveedores
# Common
diff --git a/modules/item/back/model-config.json b/modules/item/back/model-config.json
index c5623dcca..13e30dc15 100644
--- a/modules/item/back/model-config.json
+++ b/modules/item/back/model-config.json
@@ -76,8 +76,5 @@
},
"TaxType": {
"dataSource": "vn"
- },
- "Supplier": {
- "dataSource": "vn"
}
}
diff --git a/modules/supplier/back/methods/supplier/filter.js b/modules/supplier/back/methods/supplier/filter.js
new file mode 100644
index 000000000..3eddda294
--- /dev/null
+++ b/modules/supplier/back/methods/supplier/filter.js
@@ -0,0 +1,106 @@
+
+const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
+const buildFilter = require('vn-loopback/util/filter').buildFilter;
+const mergeFilters = require('vn-loopback/util/filter').mergeFilters;
+
+module.exports = Self => {
+ Self.remoteMethodCtx('filter', {
+ description: 'Find all instances of the model matched by filter from the data source.',
+ accessType: 'READ',
+ accepts: [
+ {
+ arg: 'filter',
+ type: 'Object',
+ description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string',
+ http: {source: 'query'}
+ }, {
+ arg: 'search',
+ type: 'String',
+ description: 'Searchs the supplier by id',
+ http: {source: 'query'}
+ }, {
+ arg: 'id',
+ type: 'Integer',
+ description: 'The supplier id',
+ http: {source: 'query'}
+ }, {
+ arg: 'nickname',
+ type: 'String',
+ description: 'The supplier name to filter',
+ http: {source: 'query'}
+ }, {
+ arg: 'provinceFk',
+ type: 'Number',
+ description: 'The province id to filter',
+ http: {source: 'query'}
+ }, {
+ arg: 'countryFk',
+ type: 'Number',
+ description: 'The country id to filter',
+ http: {source: 'query'}
+ }, {
+ arg: 'nif',
+ type: 'String',
+ description: 'The supplier nif to filter',
+ http: {source: 'query'}
+ }
+ ],
+ returns: {
+ type: ['Object'],
+ root: true
+ },
+ http: {
+ path: `/filter`,
+ verb: 'GET'
+ }
+ });
+
+ Self.filter = async(ctx, filter) => {
+ let conn = Self.dataSource.connector;
+ let where = buildFilter(ctx.args, (param, value) => {
+ switch (param) {
+ case 'search':
+ return {'s.id': value};
+ case 'nickname':
+ param = `s.${param}`;
+ return {[param]: {like: `%${value}%`}};
+ case 'id':
+ case 'provinceFk':
+ case 'countryFk':
+ case 'nif':
+ param = `s.${param}`;
+ return {[param]: value};
+ }
+ });
+ filter = mergeFilters(ctx.args.filter, {where});
+
+ let stmts = [];
+ let stmt;
+ stmt = new ParameterizedSQL(
+ `SELECT
+ s.id,
+ s.name AS socialName,
+ s.nickname AS alias,
+ s.account,
+ s.provinceFk,
+ s.nif,
+ s.payDemFk,
+ s.payDay,
+ s.phone,
+ s.city,
+ pm.name AS payMethod,
+ pd.payDem AS payDem
+ FROM vn.supplier s
+ JOIN vn.payMethod pm ON pm.id = s.payMethodFk
+ JOIN vn.payDem pd ON pd.id = s.payDemFk`
+ );
+
+ stmt.merge(conn.makeSuffix(filter));
+ let itemsIndex = stmts.push(stmt) - 1;
+
+ let sql = ParameterizedSQL.join(stmts, ';');
+ let result = await conn.executeStmt(sql);
+ return itemsIndex === 0 ? result : result[itemsIndex];
+ };
+};
+
diff --git a/modules/supplier/back/methods/supplier/specs/filter.spec.js b/modules/supplier/back/methods/supplier/specs/filter.spec.js
new file mode 100644
index 000000000..1f74b10ff
--- /dev/null
+++ b/modules/supplier/back/methods/supplier/specs/filter.spec.js
@@ -0,0 +1,28 @@
+const app = require('vn-loopback/server/server');
+
+describe('Supplier filter()', () => {
+ it('should return the supplier matching "search"', async() => {
+ let ctx = {
+ args: {
+ search: 1
+ }
+ };
+
+ let result = await app.models.Supplier.filter(ctx);
+
+ expect(result.length).toEqual(1);
+ expect(result[0].id).toEqual(1);
+ });
+
+ it('should return the supplier matching the province', async() => {
+ let ctx = {
+ args: {
+ provinceFk: 1
+ }
+ };
+
+ let result = await app.models.Supplier.filter(ctx);
+
+ expect(result.length).toEqual(2);
+ });
+});
diff --git a/modules/supplier/back/model-config.json b/modules/supplier/back/model-config.json
new file mode 100644
index 000000000..899e3c38a
--- /dev/null
+++ b/modules/supplier/back/model-config.json
@@ -0,0 +1,5 @@
+{
+ "Supplier": {
+ "dataSource": "vn"
+ }
+}
diff --git a/modules/supplier/back/models/supplier.js b/modules/supplier/back/models/supplier.js
new file mode 100644
index 000000000..953df5106
--- /dev/null
+++ b/modules/supplier/back/models/supplier.js
@@ -0,0 +1,3 @@
+module.exports = Self => {
+ require('../methods/supplier/filter')(Self);
+};
diff --git a/modules/item/back/models/supplier.json b/modules/supplier/back/models/supplier.json
similarity index 100%
rename from modules/item/back/models/supplier.json
rename to modules/supplier/back/models/supplier.json
diff --git a/modules/supplier/front/index.js b/modules/supplier/front/index.js
new file mode 100644
index 000000000..cb25b3b8c
--- /dev/null
+++ b/modules/supplier/front/index.js
@@ -0,0 +1,5 @@
+export * from './module';
+
+import './main';
+import './index/';
+import './search-panel';
diff --git a/modules/supplier/front/index/index.html b/modules/supplier/front/index/index.html
new file mode 100644
index 000000000..9c4dd21d2
--- /dev/null
+++ b/modules/supplier/front/index/index.html
@@ -0,0 +1,61 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/modules/supplier/front/index/index.js b/modules/supplier/front/index/index.js
new file mode 100644
index 000000000..f4a3d7c6d
--- /dev/null
+++ b/modules/supplier/front/index/index.js
@@ -0,0 +1,9 @@
+import ngModule from '../module';
+import Section from 'salix/components/section';
+
+export default class Controller extends Section {}
+
+ngModule.vnComponent('vnSupplierIndex', {
+ template: require('./index.html'),
+ controller: Controller
+});
diff --git a/modules/supplier/front/index/locale/es.yml b/modules/supplier/front/index/locale/es.yml
new file mode 100644
index 000000000..ad8a4f0bb
--- /dev/null
+++ b/modules/supplier/front/index/locale/es.yml
@@ -0,0 +1,5 @@
+Payment deadline: Plazo de pago
+Pay day: Dia de pago
+Account: Cuenta
+Pay method: Metodo de pago
+Tax number: Nif
\ No newline at end of file
diff --git a/modules/supplier/front/main/index.html b/modules/supplier/front/main/index.html
new file mode 100644
index 000000000..2278087c2
--- /dev/null
+++ b/modules/supplier/front/main/index.html
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/modules/supplier/front/main/index.js b/modules/supplier/front/main/index.js
new file mode 100644
index 000000000..2fd870573
--- /dev/null
+++ b/modules/supplier/front/main/index.js
@@ -0,0 +1,9 @@
+import ngModule from '../module';
+import ModuleMain from 'salix/components/module-main';
+
+export default class Supplier extends ModuleMain {}
+
+ngModule.vnComponent('vnSupplier', {
+ controller: Supplier,
+ template: require('./index.html')
+});
diff --git a/modules/supplier/front/module.js b/modules/supplier/front/module.js
new file mode 100644
index 000000000..d7f78389a
--- /dev/null
+++ b/modules/supplier/front/module.js
@@ -0,0 +1,3 @@
+import {ng} from 'core/vendor';
+
+export default ng.module('supplier', ['salix']);
diff --git a/modules/supplier/front/routes.json b/modules/supplier/front/routes.json
new file mode 100644
index 000000000..21f1ceb26
--- /dev/null
+++ b/modules/supplier/front/routes.json
@@ -0,0 +1,27 @@
+{
+ "module": "supplier",
+ "name": "Suppliers",
+ "icon" : "icon-supplier",
+ "validations" : true,
+ "menus": {
+ "main": [
+ {"state": "supplier.index", "icon": "icon-supplier"}
+ ],
+ "card": [
+ ]
+ },
+ "routes": [
+ {
+ "url": "/supplier",
+ "state": "supplier",
+ "abstract": true,
+ "component": "vn-supplier",
+ "description": "Suppliers"
+ }, {
+ "url": "/index?q",
+ "state": "supplier.index",
+ "component": "vn-supplier-index",
+ "description": "Suppliers"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/modules/supplier/front/search-panel/index.html b/modules/supplier/front/search-panel/index.html
new file mode 100644
index 000000000..5ad5e6e3a
--- /dev/null
+++ b/modules/supplier/front/search-panel/index.html
@@ -0,0 +1,46 @@
+
+
+
\ No newline at end of file
diff --git a/modules/supplier/front/search-panel/index.js b/modules/supplier/front/search-panel/index.js
new file mode 100644
index 000000000..6223b5670
--- /dev/null
+++ b/modules/supplier/front/search-panel/index.js
@@ -0,0 +1,7 @@
+import ngModule from '../module';
+import SearchPanel from 'core/components/searchbar/search-panel';
+
+ngModule.vnComponent('vnSupplierSearchPanel', {
+ template: require('./index.html'),
+ controller: SearchPanel
+});
diff --git a/modules/supplier/front/search-panel/locale/es.yml b/modules/supplier/front/search-panel/locale/es.yml
new file mode 100644
index 000000000..6df042998
--- /dev/null
+++ b/modules/supplier/front/search-panel/locale/es.yml
@@ -0,0 +1,3 @@
+Province: Provincia
+Country: Pais
+Tax number: Nif
\ No newline at end of file