Add support for editing invoice cost in receiving batch, per new theme
This commit is contained in:
parent
36a5f2ab49
commit
cceb66e500
|
@ -133,6 +133,15 @@
|
|||
</b-checkbox>
|
||||
</b-field>
|
||||
|
||||
<b-field>
|
||||
<b-checkbox name="rattail.batch.purchase.receiving.allow_edit_invoice_unit_cost"
|
||||
v-model="simpleSettings['rattail.batch.purchase.receiving.allow_edit_invoice_unit_cost']"
|
||||
native-value="true"
|
||||
@input="settingsNeedSaved = true">
|
||||
Allow edit of Invoice Unit Cost
|
||||
</b-checkbox>
|
||||
</b-field>
|
||||
|
||||
</div>
|
||||
|
||||
<h3 class="block is-size-3">Mobile Interface</h3>
|
||||
|
|
|
@ -264,19 +264,26 @@
|
|||
|
||||
<%def name="extra_styles()">
|
||||
${parent.extra_styles()}
|
||||
% if use_buefy and allow_edit_catalog_unit_cost:
|
||||
% if use_buefy:
|
||||
<style type="text/css">
|
||||
|
||||
% if allow_edit_catalog_unit_cost:
|
||||
td.catalog_unit_cost {
|
||||
cursor: pointer;
|
||||
background-color: #fcc;
|
||||
}
|
||||
|
||||
tr.catalog_cost_confirmed td.catalog_unit_cost {
|
||||
/* cursor: pointer; */
|
||||
background-color: #cfc;
|
||||
}
|
||||
|
||||
% endif
|
||||
% if allow_edit_invoice_unit_cost:
|
||||
td.invoice_unit_cost {
|
||||
cursor: pointer;
|
||||
background-color: #fcc;
|
||||
}
|
||||
tr.invoice_cost_confirmed td.invoice_unit_cost {
|
||||
background-color: #cfc;
|
||||
}
|
||||
% endif
|
||||
</style>
|
||||
% elif not use_buefy and not batch.executed and master.has_perm('edit_row'):
|
||||
<style type="text/css">
|
||||
|
@ -374,7 +381,7 @@
|
|||
<%def name="render_this_page_template()">
|
||||
${parent.render_this_page_template()}
|
||||
|
||||
% if allow_edit_catalog_unit_cost:
|
||||
% if allow_edit_catalog_unit_cost or allow_edit_invoice_unit_cost:
|
||||
<script type="text/x-template" id="receiving-cost-editor-template">
|
||||
<div>
|
||||
<span v-show="!editing">
|
||||
|
@ -452,12 +459,13 @@
|
|||
|
||||
% endif
|
||||
|
||||
% if allow_edit_catalog_unit_cost:
|
||||
% if allow_edit_catalog_unit_cost or allow_edit_invoice_unit_cost:
|
||||
|
||||
let ReceivingCostEditor = {
|
||||
template: '#receiving-cost-editor-template',
|
||||
props: {
|
||||
row: Object,
|
||||
'field': String,
|
||||
value: String,
|
||||
},
|
||||
data() {
|
||||
|
@ -510,8 +518,8 @@
|
|||
|
||||
let params = {
|
||||
row_uuid: this.$props.row.uuid,
|
||||
catalog_unit_cost: this.inputValue,
|
||||
}
|
||||
params[this.$props.field] = this.inputValue
|
||||
|
||||
this.$http.post(url, params, {headers: headers}).then(response => {
|
||||
if (!response.data.error) {
|
||||
|
@ -519,7 +527,7 @@
|
|||
// let parent know cost value has changed
|
||||
// (this in turn will update data in *this*
|
||||
// component, and display will refresh)
|
||||
this.$emit('input', response.data.row.catalog_unit_cost,
|
||||
this.$emit('input', response.data.row[this.$props.field],
|
||||
this.$props.row._index)
|
||||
|
||||
// and hide the input box
|
||||
|
@ -546,6 +554,10 @@
|
|||
|
||||
Vue.component('receiving-cost-editor', ReceivingCostEditor)
|
||||
|
||||
% endif
|
||||
|
||||
% if allow_edit_catalog_unit_cost:
|
||||
|
||||
${rows_grid.component_studly}.methods.catalogUnitCostClicked = function(row) {
|
||||
|
||||
// start edit for clicked cell
|
||||
|
@ -567,6 +579,29 @@
|
|||
|
||||
% endif
|
||||
|
||||
% if allow_edit_invoice_unit_cost:
|
||||
|
||||
${rows_grid.component_studly}.methods.invoiceUnitCostClicked = function(row) {
|
||||
|
||||
// start edit for clicked cell
|
||||
this.$refs['invoiceUnitCost_' + row.uuid].startEdit()
|
||||
}
|
||||
|
||||
${rows_grid.component_studly}.methods.invoiceCostConfirmed = function(amount, index) {
|
||||
|
||||
// update display to indicate cost was confirmed
|
||||
this.addRowClass(index, 'invoice_cost_confirmed')
|
||||
|
||||
// start editing next row, unless there are no more
|
||||
let nextRow = index + 1
|
||||
if (this.data.length > nextRow) {
|
||||
nextRow = this.data[nextRow]
|
||||
this.$refs['invoiceUnitCost_' + nextRow.uuid].startEdit()
|
||||
}
|
||||
}
|
||||
|
||||
% endif
|
||||
|
||||
</script>
|
||||
</%def>
|
||||
|
||||
|
|
|
@ -724,6 +724,11 @@ class ReceivingBatchView(PurchasingBatchView):
|
|||
and self.has_perm('edit_row')
|
||||
and self.batch_handler.allow_receiving_edit_catalog_unit_cost())
|
||||
|
||||
def allow_edit_invoice_unit_cost(self, batch):
|
||||
return (not batch.executed
|
||||
and self.has_perm('edit_row')
|
||||
and self.batch_handler.allow_receiving_edit_invoice_unit_cost())
|
||||
|
||||
def template_kwargs_view(self, **kwargs):
|
||||
kwargs = super(ReceivingBatchView, self).template_kwargs_view(**kwargs)
|
||||
batch = kwargs['instance']
|
||||
|
@ -749,6 +754,7 @@ class ReceivingBatchView(PurchasingBatchView):
|
|||
columns=['title', 'count'])
|
||||
|
||||
kwargs['allow_edit_catalog_unit_cost'] = self.allow_edit_catalog_unit_cost(batch)
|
||||
kwargs['allow_edit_invoice_unit_cost'] = self.allow_edit_invoice_unit_cost(batch)
|
||||
|
||||
return kwargs
|
||||
|
||||
|
@ -960,6 +966,12 @@ class ReceivingBatchView(PurchasingBatchView):
|
|||
g.set_click_handler('catalog_unit_cost',
|
||||
'catalogUnitCostClicked(props.row)')
|
||||
|
||||
# invoice_unit_cost
|
||||
if use_buefy and self.allow_edit_invoice_unit_cost(batch):
|
||||
g.set_raw_renderer('invoice_unit_cost', self.render_invoice_unit_cost)
|
||||
g.set_click_handler('invoice_unit_cost',
|
||||
'invoiceUnitCostClicked(props.row)')
|
||||
|
||||
# nb. only show PO *or* invoice cost; prefer the latter unless
|
||||
# we have a PO and no invoice
|
||||
if (self.batch_handler.has_purchase_order(batch)
|
||||
|
@ -1019,12 +1031,22 @@ class ReceivingBatchView(PurchasingBatchView):
|
|||
|
||||
def render_catalog_unit_cost(self):
|
||||
return HTML.tag('receiving-cost-editor', **{
|
||||
'field': 'catalog_unit_cost',
|
||||
'v-model': 'props.row.catalog_unit_cost',
|
||||
':ref': "'catalogUnitCost_' + props.row.uuid",
|
||||
':row': 'props.row',
|
||||
'@input': 'catalogCostConfirmed',
|
||||
})
|
||||
|
||||
def render_invoice_unit_cost(self):
|
||||
return HTML.tag('receiving-cost-editor', **{
|
||||
'field': 'invoice_unit_cost',
|
||||
'v-model': 'props.row.invoice_unit_cost',
|
||||
':ref': "'invoiceUnitCost_' + props.row.uuid",
|
||||
':row': 'props.row',
|
||||
'@input': 'invoiceCostConfirmed',
|
||||
})
|
||||
|
||||
def row_grid_extra_class(self, row, i):
|
||||
css_class = super(ReceivingBatchView, self).row_grid_extra_class(row, i)
|
||||
|
||||
|
@ -1966,6 +1988,9 @@ class ReceivingBatchView(PurchasingBatchView):
|
|||
{'section': 'rattail.batch',
|
||||
'option': 'purchase.receiving.allow_edit_catalog_unit_cost',
|
||||
'type': bool},
|
||||
{'section': 'rattail.batch',
|
||||
'option': 'purchase.receiving.allow_edit_invoice_unit_cost',
|
||||
'type': bool},
|
||||
|
||||
# mobile interface
|
||||
{'section': 'rattail.batch',
|
||||
|
|
Loading…
Reference in a new issue