From f4b74abe3bd5f3418a748783efcc47b438a20e36 Mon Sep 17 00:00:00 2001 From: Carlos Jimenez Ruiz Date: Wed, 13 Mar 2019 14:10:45 +0100 Subject: [PATCH] =?UTF-8?q?#1179=20=20invoice.index=20crear=20el=20m=C3=B3?= =?UTF-8?q?dulo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- front/module-import.js | 1 + modules/client/back/models/invoice-out.json | 95 ++++++++++--------- modules/invoice/front/index.js | 4 + modules/invoice/front/index/index.html | 83 ++++++++++++++++ modules/invoice/front/index/index.js | 76 +++++++++++++++ modules/invoice/front/index/locale/es.yml | 6 ++ modules/invoice/front/module.js | 3 + modules/invoice/front/routes.json | 26 +++++ modules/invoice/front/search-panel/index.html | 62 ++++++++++++ modules/invoice/front/search-panel/index.js | 7 ++ 10 files changed, 317 insertions(+), 46 deletions(-) create mode 100644 modules/invoice/front/index.js create mode 100644 modules/invoice/front/index/index.html create mode 100644 modules/invoice/front/index/index.js create mode 100644 modules/invoice/front/index/locale/es.yml create mode 100644 modules/invoice/front/module.js create mode 100644 modules/invoice/front/routes.json create mode 100644 modules/invoice/front/search-panel/index.html create mode 100644 modules/invoice/front/search-panel/index.js diff --git a/front/module-import.js b/front/module-import.js index ec69401840..ed46b5b377 100755 --- a/front/module-import.js +++ b/front/module-import.js @@ -15,5 +15,6 @@ export default function moduleImport(moduleName) { case 'agency' : return import('agency/front'); case 'travel' : return import('travel/front'); case 'worker' : return import('worker/front'); + case 'invoice' : return import('invoice/front'); } } diff --git a/modules/client/back/models/invoice-out.json b/modules/client/back/models/invoice-out.json index 704901b086..ecbeb36b0c 100644 --- a/modules/client/back/models/invoice-out.json +++ b/modules/client/back/models/invoice-out.json @@ -2,54 +2,57 @@ "name": "InvoiceOut", "base": "VnModel", "options": { - "mysql": { - "table": "invoiceOut" - } + "mysql": { + "table": "invoiceOut" + } }, "properties": { - "id": { - "id": true, - "type": "Number", - "description": "Identifier" - }, - "ref": { - "id": true, - "type": "String", - "required": true - }, - "serial": { - "type": "String" - }, - "issued": { - "type": "date" - }, - "amount": { - "type": "Number" - }, - "created": { - "type": "date" - }, - "dued": { - "type": "date" - }, - "booked": { - "type": "date" - }, - "pdf": { - "type": "Number" - } + "id": { + "id": true, + "type": "Number", + "description": "Identifier" + }, + "ref": { + "id": true, + "type": "String", + "required": true + }, + "serial": { + "type": "String" + }, + "issued": { + "type": "date" + }, + "amount": { + "type": "Number" + }, + "created": { + "type": "date" + }, + "dued": { + "type": "date" + }, + "booked": { + "type": "date" + }, + "hasPdf": { + "type": "Number", + "mysql": { + "columnName": "pdf" + } + } }, "relations": { - "client": { - "type": "belongsTo", - "model": "Client", - "foreignKey": "clientFk" - }, - "company": { - "type": "belongsTo", - "model": "Company", - "foreignKey": "companyFk", - "required": true - } + "client": { + "type": "belongsTo", + "model": "Client", + "foreignKey": "clientFk" + }, + "company": { + "type": "belongsTo", + "model": "Company", + "foreignKey": "companyFk", + "required": true + } } - } \ No newline at end of file +} diff --git a/modules/invoice/front/index.js b/modules/invoice/front/index.js new file mode 100644 index 0000000000..6849e9df36 --- /dev/null +++ b/modules/invoice/front/index.js @@ -0,0 +1,4 @@ +export * from './module'; + +import './index/'; +import './search-panel'; diff --git a/modules/invoice/front/index/index.html b/modules/invoice/front/index/index.html new file mode 100644 index 0000000000..ce1b50948f --- /dev/null +++ b/modules/invoice/front/index/index.html @@ -0,0 +1,83 @@ + + +
+
+ + + + +
+ + + + + Reference + Issued + Amount + Client + Created + Company + Due date + + + + + + + {{::invoice.ref | dashIfEmpty}} + {{::invoice.issued | dateTime:'dd/MM/yyyy' | dashIfEmpty}} + {{::invoice.amount | currency: 'EUR': 2 | dashIfEmpty}} + + + {{::invoice.client.name | dashIfEmpty}} + + + {{::invoice.created | dateTime:'dd/MM/yyyy' | dashIfEmpty}} + {{::invoice.company.code | dashIfEmpty}} + {{::invoice.dued | dateTime:'dd/MM/yyyy' | dashIfEmpty}} + + + + + + + + + + + + + +
+ + + + + + diff --git a/modules/invoice/front/index/index.js b/modules/invoice/front/index/index.js new file mode 100644 index 0000000000..6affa4b654 --- /dev/null +++ b/modules/invoice/front/index/index.js @@ -0,0 +1,76 @@ +import ngModule from '../module'; + +export default class Controller { + constructor($scope, vnToken) { + this.accessToken = vnToken.token; + this.$ = $scope; + this.ticketSelected = null; + + this.filter = { + include: [ + { + relation: 'client', + scope: { + fields: ['name'] + } + }, + { + relation: 'company', + scope: { + fields: ['code'] + } + } + ] + }; + } + + exprBuilder(param, value) { + switch (param) { + case 'search': + return {ref: {like: `%${value}%`}}; + case 'min': + return {amount: {gte: value}}; + case 'max': + return {amount: {lte: value}}; + case 'hasPdf': + case 'amount': + case 'clientFk': + case 'companyFk': + case 'issued': + case 'created': + case 'dued': + return {[param]: value}; + } + } + + showClientDescriptor(event, clientFk) { + this.$.clientDescriptor.clientFk = clientFk; + this.$.clientDescriptor.parent = event.target; + this.$.clientDescriptor.show(); + event.preventDefault(); + event.stopImmediatePropagation(); + } + + preview(event, claim) { + this.claimSelected = claim; + this.$.dialogSummaryClaim.show(); + event.preventDefault(); + event.stopImmediatePropagation(); + } + + onDescriptorLoad() { + this.$.popover.relocate(); + } + + openPdf(id) { + let url = `api/InvoiceOuts/${id}/download?access_token=${this.accessToken}`; + window.open(url, '_blank'); + } +} + +Controller.$inject = ['$scope', 'vnToken']; + +ngModule.component('vnInvoiceIndex', { + template: require('./index.html'), + controller: Controller +}); diff --git a/modules/invoice/front/index/locale/es.yml b/modules/invoice/front/index/locale/es.yml new file mode 100644 index 0000000000..eb22e17799 --- /dev/null +++ b/modules/invoice/front/index/locale/es.yml @@ -0,0 +1,6 @@ +Created: Fecha creacion +Issued: Fecha factura +Due date: Fecha vencimiento +Has PDF: PDF disponible +Minimum: Minimo +Maximum: Máximo \ No newline at end of file diff --git a/modules/invoice/front/module.js b/modules/invoice/front/module.js new file mode 100644 index 0000000000..2a4377f915 --- /dev/null +++ b/modules/invoice/front/module.js @@ -0,0 +1,3 @@ +import {ng} from 'core/vendor'; + +export default ng.module('invoice', ['vnCore']); diff --git a/modules/invoice/front/routes.json b/modules/invoice/front/routes.json new file mode 100644 index 0000000000..5d4f0484e2 --- /dev/null +++ b/modules/invoice/front/routes.json @@ -0,0 +1,26 @@ +{ + "module": "invoice", + "name": "Invoices", + "icon": "icon-person", + "validations" : true, + "dependencies": ["client"], + "keybindings": [ + {"key": "i", "state": "invoice.index"} + ], + "routes": [ + { + "url": "/invoice", + "state": "invoice", + "abstract": true, + "component": "ui-view", + "description": "Invoices", + "acl": ["employee"] + }, + { + "url": "/index?q", + "state": "invoice.index", + "component": "vn-invoice-index", + "description": "Invoices" + } + ] +} \ No newline at end of file diff --git a/modules/invoice/front/search-panel/index.html b/modules/invoice/front/search-panel/index.html new file mode 100644 index 0000000000..31b08d5f48 --- /dev/null +++ b/modules/invoice/front/search-panel/index.html @@ -0,0 +1,62 @@ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
diff --git a/modules/invoice/front/search-panel/index.js b/modules/invoice/front/search-panel/index.js new file mode 100644 index 0000000000..1ca545ec79 --- /dev/null +++ b/modules/invoice/front/search-panel/index.js @@ -0,0 +1,7 @@ +import ngModule from '../module'; +import SearchPanel from 'core/components/searchbar/search-panel'; + +ngModule.component('vnInvoiceSearchPanel', { + template: require('./index.html'), + controller: SearchPanel +});