#128 - Client invoices form
This commit is contained in:
parent
3d4ff56888
commit
de145bd814
|
@ -179,6 +179,15 @@
|
||||||
"description": "Mandate",
|
"description": "Mandate",
|
||||||
"icon": "pan_tool"
|
"icon": "pan_tool"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "/invoices",
|
||||||
|
"state": "clientCard.invoices",
|
||||||
|
"component": "vn-client-invoices",
|
||||||
|
"menu": {
|
||||||
|
"description": "Invoices",
|
||||||
|
"icon": "insert_drive_file"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,3 +19,4 @@ import './credit-create/credit-create';
|
||||||
import './greuge-list/greuge-list';
|
import './greuge-list/greuge-list';
|
||||||
import './greuge-create/greuge-create';
|
import './greuge-create/greuge-create';
|
||||||
import './mandate/mandate';
|
import './mandate/mandate';
|
||||||
|
import './invoices/invoices';
|
||||||
|
|
|
@ -1,30 +1,40 @@
|
||||||
<mg-ajax path="/client/api/Clients/{{index.params.id}}/listAddresses" options="mgIndex"></mg-ajax>
|
<mg-ajax path="/client/api/InvoiceOuts/filter" options="vnIndexNonAuto"></mg-ajax>
|
||||||
<vn-card margin-medium pad-large>
|
<mg-ajax path="/client/api/InvoiceOuts/{{edit.params.id}}/sumAmount" options="mgEdit"></mg-ajax>
|
||||||
<vn-title>Invoices</vn-title>
|
<vn-card margin-medium>
|
||||||
<vn-grid data="invoices">
|
<vn-vertical pad-large>
|
||||||
<table>
|
<vn-title margin-large-bottom>Invoices</vn-title>
|
||||||
<vn-grid-header>
|
<vn-vertical style="text-align: center;">
|
||||||
<vn-column-header field="ref" text="Reference" default-order="ASC"></vn-column-header>
|
<vn-grid-header on-order="$ctrl.onOrder(field, order)">
|
||||||
<vn-column-header field="issued" text="Issue date"></vn-column-header>
|
<vn-column-header vn-one field="ref" text="Reference" default-order="ASC"></vn-column-header>
|
||||||
<vn-column-header field="amount" text="Amount"></vn-column-header>
|
<vn-column-header vn-one field="issued" text="Issue date"></vn-column-header>
|
||||||
|
<vn-column-header vn-one field="dued" text="Due date"></vn-column-header>
|
||||||
|
<vn-column-header vn-one field="amount" text="Amount"></vn-column-header>
|
||||||
</vn-grid-header>
|
</vn-grid-header>
|
||||||
<tbody>
|
<vn-vertical>
|
||||||
<tr ng-if="invoices.length > 0" ng-repeat="invoice in invoices track by id">
|
<vn-one
|
||||||
<td>{{::invoice.ref}}</td>
|
ng-if="index.model.count > 0"
|
||||||
<td>{{::invoice.issued | date:'dd/MM/yyyy'}}</td>
|
class="list list-content">
|
||||||
<td>{{::invoice.amount | currency:'€':2}} €</td>
|
<vn-horizontal
|
||||||
</tr>
|
class="list list-element"
|
||||||
<tr ng-if="!invoices || invoices.length == 0">
|
pad-small-bottom
|
||||||
<td colspan="3" translate>No results</td>
|
ng-repeat="invoice in index.model.instances track by greuge.id">
|
||||||
</tr>
|
<vn-one>{{::invoice.ref}}</vn-one>
|
||||||
</tbody>
|
<vn-one>{{::invoice.issued | date:'dd/MM/yyyy' }}</vn-one>
|
||||||
<tfoot>
|
<vn-one>{{::invoice.dued | date:'dd/MM/yyyy' }}</vn-one>
|
||||||
<tr>
|
<vn-one>{{::invoice.amount | currency:'€':2}}</vn-one>
|
||||||
<td colspan="2"></td>
|
</vn-horizontal>
|
||||||
<td ng-if="$ctrl.sum > 0">{{total | currency:'€':2}}</td>
|
</vn-one>
|
||||||
</tr>
|
<vn-one
|
||||||
</tfoot>
|
ng-if="index.model.count === 0"
|
||||||
</table>
|
pad-small-v translate>
|
||||||
<vn-paging margin-large-top index="index" total="index.model.count"></vn-paging>
|
No results
|
||||||
</vn-grid>
|
</vn-one>
|
||||||
|
</vn-vertical>
|
||||||
|
<vn-horizontal vn-one class="list list-footer">
|
||||||
|
<vn-three></vn-three>
|
||||||
|
<vn-one>{{edit.model.sumAmount | currency:'€':2}}</vn-one>
|
||||||
|
</vn-horizontal>
|
||||||
|
</vn-vertical>
|
||||||
|
<vn-paging margin-large-top vn-one index="index" total="index.model.count"></vn-paging>
|
||||||
|
</vn-vertical>
|
||||||
</vn-card>
|
</vn-card>
|
|
@ -1,7 +1,15 @@
|
||||||
import ngModule from '../module';
|
import ngModule from '../module';
|
||||||
import FilterClientList from '../filter-client-list';
|
import FilterClientList from '../filter-client-list';
|
||||||
|
|
||||||
|
class Controller extends FilterClientList {
|
||||||
|
constructor($scope, $timeout, $state, $stateParams) {
|
||||||
|
super($scope, $timeout, $state);
|
||||||
|
$scope.$stateParams = $stateParams;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Controller.$inject = ['$scope', '$timeout', '$state', '$stateParams'];
|
||||||
|
|
||||||
ngModule.component('vnClientInvoices', {
|
ngModule.component('vnClientInvoices', {
|
||||||
template: require('./invoices.html'),
|
template: require('./invoices.html'),
|
||||||
controller: FilterClientList
|
controller: Controller
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
Invoices: Facturas
|
Invoices: Facturas
|
||||||
Reference: Referencia
|
Reference: Referencia
|
||||||
Issue date: Fecha de emisión
|
Issue date: Fecha de emisión
|
||||||
|
Due date: Vencimiento
|
||||||
Amount: Total
|
Amount: Total
|
|
@ -0,0 +1,14 @@
|
||||||
|
module.exports = Self => {
|
||||||
|
Self.installMethod('filter', filterParams);
|
||||||
|
|
||||||
|
function filterParams(params) {
|
||||||
|
return {
|
||||||
|
where: {
|
||||||
|
clientFk: params.clientFk
|
||||||
|
},
|
||||||
|
skip: (params.page - 1) * params.size,
|
||||||
|
limit: params.size,
|
||||||
|
order: params.order,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
|
@ -0,0 +1,27 @@
|
||||||
|
module.exports = Self => {
|
||||||
|
Self.remoteMethod('sumAmount', {
|
||||||
|
description: 'Returns the sum of invoices amount for a client',
|
||||||
|
accessType: 'READ',
|
||||||
|
accepts: [{
|
||||||
|
arg: 'id',
|
||||||
|
description: 'The client Id',
|
||||||
|
type: 'number',
|
||||||
|
required: true,
|
||||||
|
http: {source: 'path'}
|
||||||
|
}],
|
||||||
|
returns: {
|
||||||
|
arg: 'sumAmount',
|
||||||
|
type: 'number'
|
||||||
|
},
|
||||||
|
http: {
|
||||||
|
path: `/:id/sumAmount`,
|
||||||
|
verb: 'GET'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Self.sumAmount = async id => {
|
||||||
|
let query = `SELECT SUM(amount) AS sumAmount FROM vn.invoiceOut WHERE clientFk = ?`;
|
||||||
|
let result = await Self.rawSql(query, [id]);
|
||||||
|
return result[0].sumAmount;
|
||||||
|
};
|
||||||
|
};
|
|
@ -0,0 +1,4 @@
|
||||||
|
module.exports = function(Self) {
|
||||||
|
require('../methods/invoiceOut/filter.js')(Self);
|
||||||
|
require('../methods/invoiceOut/sumAmount.js')(Self);
|
||||||
|
};
|
Loading…
Reference in New Issue