Auto-filter hyperlinks for PO vs. invoice breakdown in Receiving

This commit is contained in:
Lance Edgar 2022-02-20 19:52:24 -06:00
parent 4d404cb20b
commit 8ae1b87a1e
3 changed files with 64 additions and 9 deletions

View file

@ -158,7 +158,7 @@
<div class="object-helper"> <div class="object-helper">
<h3>Row Status Breakdown</h3> <h3>Row Status Breakdown</h3>
<div class="object-helper-content"> <div class="object-helper-content">
${status_breakdown_grid|n} ${status_breakdown_grid}
</div> </div>
</div> </div>
% elif status_breakdown is not Undefined and status_breakdown is not None: % elif status_breakdown is not Undefined and status_breakdown is not None:

View file

@ -288,7 +288,7 @@
<div class="object-helper"> <div class="object-helper">
<h3>PO vs. Invoice</h3> <h3>PO vs. Invoice</h3>
<div class="object-helper-content"> <div class="object-helper-content">
${po_vs_invoice_breakdown_grid.render_buefy_table_element(data_prop='poVsInvoiceBreakdownData', empty_labels=True)|n} ${po_vs_invoice_breakdown_grid}
</div> </div>
</div> </div>
% endif % endif
@ -371,8 +371,51 @@
ThisPageData.autoReceiveShowDialog = false ThisPageData.autoReceiveShowDialog = false
ThisPageData.autoReceiveSubmitting = false ThisPageData.autoReceiveSubmitting = false
% if po_vs_invoice_breakdown_grid is not Undefined: % if po_vs_invoice_breakdown_data is not Undefined:
ThisPageData.poVsInvoiceBreakdownData = ${json.dumps(po_vs_invoice_breakdown_grid.get_buefy_data()['data'])|n} ThisPageData.poVsInvoiceBreakdownData = ${json.dumps(po_vs_invoice_breakdown_data)|n}
ThisPage.methods.autoFilterPoVsInvoice = function(row) {
let filters = []
if (row.key == 'both') {
filters = [
{key: 'po_line_number',
verb: 'is_not_null'},
{key: 'invoice_line_number',
verb: 'is_not_null'},
]
} else if (row.key == 'po_not_invoice') {
filters = [
{key: 'po_line_number',
verb: 'is_not_null'},
{key: 'invoice_line_number',
verb: 'is_null'},
]
} else if (row.key == 'invoice_not_po') {
filters = [
{key: 'po_line_number',
verb: 'is_null'},
{key: 'invoice_line_number',
verb: 'is_not_null'},
]
} else if (row.key == 'neither') {
filters = [
{key: 'po_line_number',
verb: 'is_null'},
{key: 'invoice_line_number',
verb: 'is_null'},
]
}
if (!filters.length) {
return
}
this.$refs.rowGrid.setFilters(filters)
document.getElementById('rowGrid').scrollIntoView({
behavior: 'smooth',
})
}
% endif % endif
</script> </script>

View file

@ -674,6 +674,7 @@ class ReceivingBatchView(PurchasingBatchView):
for key, label in labels.items(): for key, label in labels.items():
if key in grouped: if key in grouped:
breakdown.append({ breakdown.append({
'key': key,
'title': label, 'title': label,
'count': len(grouped[key]), 'count': len(grouped[key]),
}) })
@ -683,15 +684,26 @@ class ReceivingBatchView(PurchasingBatchView):
def template_kwargs_view(self, **kwargs): def template_kwargs_view(self, **kwargs):
kwargs = super(ReceivingBatchView, self).template_kwargs_view(**kwargs) kwargs = super(ReceivingBatchView, self).template_kwargs_view(**kwargs)
batch = kwargs['instance'] batch = kwargs['instance']
use_buefy = self.get_use_buefy()
if self.handler.has_purchase_order(batch) and self.handler.has_invoice_file(batch): if self.handler.has_purchase_order(batch) and self.handler.has_invoice_file(batch):
breakdown = self.make_po_vs_invoice_breakdown(batch) breakdown = self.make_po_vs_invoice_breakdown(batch)
factory = self.get_grid_factory() factory = self.get_grid_factory()
kwargs['po_vs_invoice_breakdown_grid'] = factory( if use_buefy:
'batch_po_vs_invoice_breakdown',
data=breakdown, g = factory('batch_po_vs_invoice_breakdown', [],
columns=['title', 'count']) columns=['title', 'count'])
g.set_click_handler('title', "autoFilterPoVsInvoice(props.row)")
kwargs['po_vs_invoice_breakdown_data'] = breakdown
kwargs['po_vs_invoice_breakdown_grid'] = HTML.literal(
g.render_buefy_table_element(data_prop='poVsInvoiceBreakdownData',
empty_labels=True))
else:
kwargs['po_vs_invoice_breakdown_grid'] = factory(
'batch_po_vs_invoice_breakdown',
data=breakdown,
columns=['title', 'count'])
return kwargs return kwargs