#1179 invoice.index crear el módulo

This commit is contained in:
Carlos Jimenez Ruiz 2019-03-13 14:10:45 +01:00
parent 4b76eadd07
commit f4b74abe3b
10 changed files with 317 additions and 46 deletions

View File

@ -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');
}
}

View File

@ -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
}
}
}
}

View File

@ -0,0 +1,4 @@
export * from './module';
import './index/';
import './search-panel';

View File

@ -0,0 +1,83 @@
<vn-crud-model
vn-id="model"
url="/api/InvoiceOuts"
filter="::$ctrl.filter"
limit="20"
data="invoices"
order="id ASC"
auto-load="false">
</vn-crud-model>
<div class="content-block">
<div class="vn-list">
<vn-card pad-medium-h>
<vn-searchbar
panel="vn-invoice-search-panel"
model="model"
expr-builder="$ctrl.exprBuilder(param, value)"
auto-load="true"
vn-focus>
</vn-searchbar>
</vn-card>
</div>
<vn-card margin-medium-v compact>
<vn-table model="model" auto-load="false">
<vn-thead>
<vn-tr>
<vn-th field="ref">Reference</vn-th>
<vn-th field="issued">Issued</vn-th>
<vn-th field="amount" number>Amount</vn-th>
<vn-th field="clientFk">Client</vn-th>
<vn-th field="created">Created</vn-th>
<vn-th field="companyFk">Company</vn-th>
<vn-th field="dued">Due date</vn-th>
<vn-th></vn-th>
<vn-th></vn-th>
</vn-tr>
</vn-thead>
<vn-tbody>
<a ng-repeat="invoice in invoices"
class="clickable vn-tr searchResult"
ui-sref="invoice.card.summary({id: {{::invoice.id}}})">
<vn-td>{{::invoice.ref | dashIfEmpty}}</vn-td>
<vn-td>{{::invoice.issued | dateTime:'dd/MM/yyyy' | dashIfEmpty}}</vn-td>
<vn-td number>{{::invoice.amount | currency: 'EUR': 2 | dashIfEmpty}}</vn-td>
<vn-td>
<span
class="link"
ng-click="$ctrl.showClientDescriptor($event, invoice.clientFk)">
{{::invoice.client.name | dashIfEmpty}}
</span>
</vn-td>
<vn-td>{{::invoice.created | dateTime:'dd/MM/yyyy' | dashIfEmpty}}</vn-td>
<vn-td>{{::invoice.company.code | dashIfEmpty}}</vn-td>
<vn-td>{{::invoice.dued | dateTime:'dd/MM/yyyy' | dashIfEmpty}}</vn-td>
<vn-td>
<vn-icon-button
ng-show="invoice.hasPdf"
ng-click="$ctrl.openPdf(invoice.id)"
icon="cloud_download"
title="Download PDF"
vn-tooltip="Download PDF">
</vn-icon-button>
</vn-td>
<vn-td>
<vn-icon-button
ng-click="$ctrl.preview($event, invoice)"
vn-tooltip="Preview"
icon="desktop_windows">
</vn-icon-button>
</vn-td>
</a>
</vn-tbody>
</vn-table>
</vn-card>
<vn-pagination model="model"></vn-pagination>
</div>
<vn-dialog
vn-id="summary"
class="dialog-summary">
<tpl-body>
<vn-invoice-summary invoice="$ctrl.selectedTicket"></vn-invoice-summary>
</tpl-body>
</vn-dialog>
<vn-client-descriptor-popover vn-id="clientDescriptor"></vn-client-descriptor-popover>

View File

@ -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
});

View File

@ -0,0 +1,6 @@
Created: Fecha creacion
Issued: Fecha factura
Due date: Fecha vencimiento
Has PDF: PDF disponible
Minimum: Minimo
Maximum: Máximo

View File

@ -0,0 +1,3 @@
import {ng} from 'core/vendor';
export default ng.module('invoice', ['vnCore']);

View File

@ -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"
}
]
}

View File

@ -0,0 +1,62 @@
<div class="search-panel">
<form ng-submit="$ctrl.onSearch()">
<vn-horizontal>
<vn-textfield
vn-one
label="General search"
model="filter.search"
vn-focus>
</vn-textfield>
</vn-horizontal>
<vn-horizontal>
<vn-textfield
vn-one
label="Client"
model="filter.clientFk">
</vn-textfield>
<vn-check
vn-one
triple-state="true"
label="Has PDF"
field="filter.hasPdf">
</vn-check>
</vn-horizontal>
<vn-horizontal>
<vn-textfield
vn-one
label="Amount"
model="filter.amount">
</vn-textfield>
<vn-textfield
vn-one
label="Minimum"
model="filter.min">
</vn-textfield>
<vn-textfield
vn-one
label="Maximum"
model="filter.max">
</vn-textfield>
</vn-horizontal>
<vn-horizontal>
<vn-date-picker
vn-one
label="Issued"
model="filter.issued">
</vn-date-picker>
<vn-date-picker
vn-one
label="Created"
model="filter.created">
</vn-date-picker>
<vn-date-picker
vn-one
label="Due date"
model="filter.dued">
</vn-date-picker>
</vn-horizontal>
<vn-horizontal margin-large-top>
<vn-submit label="Search"></vn-submit>
</vn-horizontal>
</form>
</div>

View File

@ -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
});