fix: refs #7498 Download invoice out error
gitea/hedera-web/pipeline/pr-master This commit looks good Details
gitea/hedera-web/pipeline/pr-dev This commit looks good Details

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

View File

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