invoice_az/invoice_az/client/sales_invoice_list.js

51 lines
1.7 KiB
JavaScript

// List view settings for Sales Invoice. Loaded only via doctype_list_js. Do NOT add frappe.ui.form.on(...) here.
frappe.listview_settings['Sales Invoice'] = {
// Make sure both signals reach the formatter, even though the column is bound
// to only one of them.
add_fields: ['is_taxes_doc', 'etaxes_send_status'],
onload: function(listview) {
// Single universal E-Taxes column. It reflects everything related to the
// tax portal for this document: whether it was loaded from E-Taxes,
// whether a draft was created there, or whether it was sent and signed.
listview.columns.push({
type: 'Select',
df: {
label: __('E-Taxes'),
fieldname: 'etaxes_send_status'
},
width: 170
});
// Force refresh list with the new column
listview.refresh();
},
formatters: {
// Universal E-Taxes status. The formatter receives the full row as its
// third argument (value, df, doc), so we combine the send status with the
// "loaded from E-Taxes" flag into a single indicator.
etaxes_send_status: function(value, df, doc) {
const send_status = doc.etaxes_send_status;
// Outgoing flow (document sent to the portal) takes priority — it is
// the most specific state.
if (send_status === 'Sent and Signed') {
return `<span class="indicator-pill green">${__('Sent to E-Taxes')}</span>`;
}
if (send_status === 'Created, not signed') {
return `<span class="indicator-pill orange">${__('Draft on E-Taxes')}</span>`;
}
// Incoming flow (document imported from the portal).
if (doc.is_taxes_doc) {
return `<span class="indicator-pill blue">${__('Loaded from E-Taxes')}</span>`;
}
// Not related to the tax portal — keep the cell clean.
return '';
}
}
};