0
1
Fork 0

fix: refs #7498 Download invoice out error

This commit is contained in:
Guillermo Bonet 2024-05-29 10:45:34 +02:00
parent 961ff02053
commit bcbbee411f
2 changed files with 12 additions and 24 deletions

View File

@ -3,30 +3,17 @@ import './style.scss';
export default new Class({
Extends: Hedera.Form,
Template: require('./ui.xml'),
donwloadRenderer(column, invoice) {
var invoiceId = invoice.$.id;
if (invoice.$.hasPdf && invoiceId) {
var params = {
srv: 'rest:dms/invoice',
invoice: invoiceId,
access_token: this.conn.token
};
onDownloadClick(column, value, row) {
var model = this.$.invoices;
var hasPdf = model.get(row, 'hasPdf');
var id = model.get(row, 'id');
Object.assign(column, {
tip: _('Download PDF'),
disabled: false,
icon: 'download',
href: '?'+ Vn.Url.makeUri(params)
});
if (hasPdf && id) {
let params = Vn.Url.makeUri({ access_token: this.conn.token });
window.open(`/api/InvoiceOuts/${id}/download?${params}`);
} else
Object.assign(column, {
tip: _('Request the invoice to your salesperson'),
disabled: true,
icon: 'warning',
href: null
});
Htk.Toast.showWarning(_('Request the invoice to your salesperson'));
}
});

View File

@ -6,7 +6,7 @@
<htk-grid
class="box vn-w-sm"
show-header="false">
<db-model property="model" id="tickets">
<db-model property="model" id="invoices">
SELECT id, ref, issued, amount, hasPdf
FROM myInvoice
ORDER BY issued DESC
@ -16,8 +16,9 @@
<htk-column-date title="_Date" column="issued" format="_%e %b %Y"/>
<htk-column-spin title="_Import" column="amount" unit="€" digits="2"/>
<htk-column-button
renderer="donwloadRenderer"
target="_blank"/>
icon="download"
tip="_Download PDF"
on-clicked="onDownloadClick"/>
</htk-grid>
</div>
</vn>