231801_test_to_master #1519
|
@ -1,3 +1,4 @@
|
||||||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||||
VALUES
|
VALUES
|
||||||
('InvoiceIn', 'unbilledTickets', 'READ', 'ALLOW', 'ROLE', 'administrative');
|
('InvoiceIn', 'unbilledTickets', 'READ', 'ALLOW', 'ROLE', 'administrative'),
|
||||||
|
('InvoiceIn', 'unbilledTicketsCsv', 'READ', 'ALLOW', 'ROLE', 'administrative');
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
const {toCSV} = require('vn-loopback/util/csv');
|
||||||
|
|
||||||
|
module.exports = Self => {
|
||||||
|
Self.remoteMethodCtx('unbilledTicketsCsv', {
|
||||||
|
description: 'Returns the unbilled tickets as .csv',
|
||||||
|
accessType: 'READ',
|
||||||
|
accepts: [{
|
||||||
|
arg: 'unbilledTickets',
|
||||||
|
type: ['object'],
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'from',
|
||||||
|
type: 'date',
|
||||||
|
description: 'From date'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'to',
|
||||||
|
type: 'date',
|
||||||
|
description: 'To date'
|
||||||
|
}],
|
||||||
|
returns: [
|
||||||
|
{
|
||||||
|
arg: 'body',
|
||||||
|
type: 'file',
|
||||||
|
root: true
|
||||||
|
}, {
|
||||||
|
arg: 'Content-Type',
|
||||||
|
type: 'String',
|
||||||
|
http: {target: 'header'}
|
||||||
|
}, {
|
||||||
|
arg: 'Content-Disposition',
|
||||||
|
type: 'String',
|
||||||
|
http: {target: 'header'}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
http: {
|
||||||
|
path: '/unbilledTicketsCsv',
|
||||||
|
verb: 'GET'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Self.unbilledTicketsCsv = async ctx => {
|
||||||
|
const args = ctx.args;
|
||||||
|
const content = toCSV(args.unbilledTickets);
|
||||||
|
|
||||||
|
return [
|
||||||
|
content,
|
||||||
|
'text/csv',
|
||||||
|
`attachment; filename="unbilled-tickets-${new Date(args.from).toLocaleDateString()}-${new Date(args.to).toLocaleDateString()}.csv"`
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
|
@ -7,4 +7,5 @@ module.exports = Self => {
|
||||||
require('../methods/invoice-in/invoiceInPdf')(Self);
|
require('../methods/invoice-in/invoiceInPdf')(Self);
|
||||||
require('../methods/invoice-in/invoiceInEmail')(Self);
|
require('../methods/invoice-in/invoiceInEmail')(Self);
|
||||||
require('../methods/invoice-in/unbilledTickets')(Self);
|
require('../methods/invoice-in/unbilledTickets')(Self);
|
||||||
|
require('../methods/invoice-in/unbilledTicketsCsv')(Self);
|
||||||
};
|
};
|
||||||
|
|
|
@ -13,17 +13,23 @@
|
||||||
expr-builder="$ctrl.exprBuilder(param, value)">
|
expr-builder="$ctrl.exprBuilder(param, value)">
|
||||||
<slot-actions>
|
<slot-actions>
|
||||||
<vn-date-picker
|
<vn-date-picker
|
||||||
vn-one
|
vn-one
|
||||||
label="From"
|
label="From"
|
||||||
ng-model="$ctrl.params.from"
|
ng-model="$ctrl.params.from"
|
||||||
on-change="model.refresh()">
|
on-change="model.refresh()">
|
||||||
</vn-date-picker>
|
</vn-date-picker>
|
||||||
<vn-date-picker
|
<vn-date-picker
|
||||||
vn-one
|
vn-one
|
||||||
label="To"
|
label="To"
|
||||||
ng-model="$ctrl.params.to"
|
ng-model="$ctrl.params.to"
|
||||||
on-change="model.refresh()">
|
on-change="model.refresh()">
|
||||||
</vn-date-picker>
|
</vn-date-picker>
|
||||||
|
<vn-button
|
||||||
|
disabled="model._orgData.length == 0"
|
||||||
|
icon="download"
|
||||||
|
ng-click="$ctrl.downloadCSV()"
|
||||||
|
vn-tooltip="Download as CSV">
|
||||||
|
</vn-button>
|
||||||
</slot-actions>
|
</slot-actions>
|
||||||
<slot-table>
|
<slot-table>
|
||||||
<table>
|
<table>
|
||||||
|
|
|
@ -3,8 +3,10 @@ import Section from 'salix/components/section';
|
||||||
import './style.scss';
|
import './style.scss';
|
||||||
|
|
||||||
export default class Controller extends Section {
|
export default class Controller extends Section {
|
||||||
constructor($element, $) {
|
constructor($element, $, vnReport) {
|
||||||
super($element, $);
|
super($element, $);
|
||||||
|
|
||||||
|
this.vnReport = vnReport;
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
const firstDayOfMonth = new Date(now.getFullYear(), now.getMonth(), 1);
|
const firstDayOfMonth = new Date(now.getFullYear(), now.getMonth(), 1);
|
||||||
const lastDayOfMonth = new Date(now.getFullYear(), now.getMonth() + 1, 0);
|
const lastDayOfMonth = new Date(now.getFullYear(), now.getMonth() + 1, 0);
|
||||||
|
@ -56,9 +58,27 @@ export default class Controller extends Section {
|
||||||
return {'comercialName': value};
|
return {'comercialName': value};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
downloadCSV() {
|
||||||
|
const data = [];
|
||||||
|
this.$.model._orgData.forEach(element => {
|
||||||
|
data.push(Object.keys(element).map(key => {
|
||||||
|
return {newName: this.$t(key), value: element[key]};
|
||||||
|
}).filter(item => item !== null)
|
||||||
|
.reduce((result, item) => {
|
||||||
|
result[item.newName] = item.value;
|
||||||
|
return result;
|
||||||
|
}, {}));
|
||||||
|
});
|
||||||
|
this.vnReport.show('InvoiceIns/unbilledTicketsCsv', {
|
||||||
|
unbilledTickets: data,
|
||||||
|
from: this.params.from,
|
||||||
|
to: this.params.to
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Controller.$inject = ['$element', '$scope'];
|
Controller.$inject = ['$element', '$scope', 'vnReport'];
|
||||||
|
|
||||||
ngModule.vnComponent('vnUnbilledTickets', {
|
ngModule.vnComponent('vnUnbilledTickets', {
|
||||||
template: require('./index.html'),
|
template: require('./index.html'),
|
||||||
|
|
|
@ -1 +1,14 @@
|
||||||
Has To Invoice: Facturar
|
Has To Invoice: Facturar
|
||||||
|
Download as CSV: Descargar como CSV
|
||||||
|
company: Compañía
|
||||||
|
country: País
|
||||||
|
clientId: Id Cliente
|
||||||
|
clientSocialName: Cliente
|
||||||
|
amount: Importe
|
||||||
|
taxableBase: Base
|
||||||
|
ticketFk: Id Ticket
|
||||||
|
isActive: Activo
|
||||||
|
hasToInvoice: Facturar
|
||||||
|
isTaxDataChecked: Datos comprobados
|
||||||
|
comercialId: Id Comercial
|
||||||
|
comercialName: Comercial
|
||||||
|
|
|
@ -4,4 +4,7 @@ vn-unbilled-tickets {
|
||||||
vn-date-picker{
|
vn-date-picker{
|
||||||
padding-right: 5%;
|
padding-right: 5%;
|
||||||
}
|
}
|
||||||
|
slot-actions{
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue