Tweaks for cost editing within a receiving batch
never show PO Cost column in row grid, since Invoice Cost is what receiving is most concerned with add "zig-zag" entry behavior when both catalog and invoice costs are editable
This commit is contained in:
parent
75caface6b
commit
bd7e6f9f8a
|
@ -177,6 +177,7 @@
|
||||||
|
|
||||||
let ReceivingCostEditor = {
|
let ReceivingCostEditor = {
|
||||||
template: '#receiving-cost-editor-template',
|
template: '#receiving-cost-editor-template',
|
||||||
|
mixins: [SimpleRequestMixin],
|
||||||
props: {
|
props: {
|
||||||
row: Object,
|
row: Object,
|
||||||
'field': String,
|
'field': String,
|
||||||
|
@ -232,41 +233,21 @@
|
||||||
submitEdit() {
|
submitEdit() {
|
||||||
let url = '${url('{}.update_row_cost'.format(route_prefix), uuid=batch.uuid)}'
|
let url = '${url('{}.update_row_cost'.format(route_prefix), uuid=batch.uuid)}'
|
||||||
|
|
||||||
// TODO: should get csrf token from parent component?
|
|
||||||
let csrftoken = ${json.dumps(request.session.get_csrf_token() or request.session.new_csrf_token())|n}
|
|
||||||
let headers = {'${csrf_header_name}': csrftoken}
|
|
||||||
|
|
||||||
let params = {
|
let params = {
|
||||||
row_uuid: this.$props.row.uuid,
|
row_uuid: this.$props.row.uuid,
|
||||||
}
|
}
|
||||||
params[this.$props.field] = this.inputValue
|
params[this.$props.field] = this.inputValue
|
||||||
|
|
||||||
this.$http.post(url, params, {headers: headers}).then(response => {
|
this.simplePOST(url, params, response => {
|
||||||
if (!response.data.error) {
|
|
||||||
|
|
||||||
// let parent know cost value has changed
|
// let parent know cost value has changed
|
||||||
// (this in turn will update data in *this*
|
// (this in turn will update data in *this*
|
||||||
// component, and display will refresh)
|
// component, and display will refresh)
|
||||||
this.$emit('input', response.data.row[this.$props.field],
|
this.$emit('input', response.data.row[this.$props.field],
|
||||||
this.$props.row._index)
|
this.$props.row._index)
|
||||||
|
|
||||||
// and hide the input box
|
// and hide the input box
|
||||||
this.editing = false
|
this.editing = false
|
||||||
|
|
||||||
} else {
|
|
||||||
this.$buefy.toast.open({
|
|
||||||
message: "Submit failed: " + response.data.error,
|
|
||||||
type: 'is-warning',
|
|
||||||
duration: 4000, // 4 seconds
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
}, response => {
|
|
||||||
this.$buefy.toast.open({
|
|
||||||
message: "Submit failed: (unknown error)",
|
|
||||||
type: 'is-warning',
|
|
||||||
duration: 4000, // 4 seconds
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -289,11 +270,23 @@
|
||||||
// update display to indicate cost was confirmed
|
// update display to indicate cost was confirmed
|
||||||
this.addRowClass(index, 'catalog_cost_confirmed')
|
this.addRowClass(index, 'catalog_cost_confirmed')
|
||||||
|
|
||||||
// start editing next row, unless there are no more
|
// advance to next editable cost input...
|
||||||
let nextRow = index + 1
|
|
||||||
if (this.data.length > nextRow) {
|
// first try invoice cost within same row
|
||||||
nextRow = this.data[nextRow]
|
let thisRow = this.data[index]
|
||||||
this.$refs['catalogUnitCost_' + nextRow.uuid].startEdit()
|
let cost = this.$refs['invoiceUnitCost_' + thisRow.uuid]
|
||||||
|
if (!cost) {
|
||||||
|
|
||||||
|
// or, try catalog cost from next row
|
||||||
|
let nextRow = this.data[index + 1]
|
||||||
|
if (nextRow) {
|
||||||
|
cost = this.$refs['catalogUnitCost_' + nextRow.uuid]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// start editing next cost if found
|
||||||
|
if (cost) {
|
||||||
|
cost.startEdit()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -312,11 +305,24 @@
|
||||||
// update display to indicate cost was confirmed
|
// update display to indicate cost was confirmed
|
||||||
this.addRowClass(index, 'invoice_cost_confirmed')
|
this.addRowClass(index, 'invoice_cost_confirmed')
|
||||||
|
|
||||||
// start editing next row, unless there are no more
|
// advance to next editable cost input...
|
||||||
let nextRow = index + 1
|
|
||||||
if (this.data.length > nextRow) {
|
// nb. always advance to next row, regardless of field
|
||||||
nextRow = this.data[nextRow]
|
let nextRow = this.data[index + 1]
|
||||||
this.$refs['invoiceUnitCost_' + nextRow.uuid].startEdit()
|
if (nextRow) {
|
||||||
|
|
||||||
|
// first try catalog cost from next row
|
||||||
|
let cost = this.$refs['catalogUnitCost_' + nextRow.uuid]
|
||||||
|
if (!cost) {
|
||||||
|
|
||||||
|
// or, try invoice cost from next row
|
||||||
|
cost = this.$refs['invoiceUnitCost_' + nextRow.uuid]
|
||||||
|
}
|
||||||
|
|
||||||
|
// start editing next cost if found
|
||||||
|
if (cost) {
|
||||||
|
cost.startEdit()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -162,7 +162,6 @@ class ReceivingBatchView(PurchasingBatchView):
|
||||||
'cases_received',
|
'cases_received',
|
||||||
'units_received',
|
'units_received',
|
||||||
'catalog_unit_cost',
|
'catalog_unit_cost',
|
||||||
'po_unit_cost',
|
|
||||||
'invoice_unit_cost',
|
'invoice_unit_cost',
|
||||||
'invoice_total_calculated',
|
'invoice_total_calculated',
|
||||||
'credits',
|
'credits',
|
||||||
|
@ -979,14 +978,6 @@ class ReceivingBatchView(PurchasingBatchView):
|
||||||
g.set_click_handler('invoice_unit_cost',
|
g.set_click_handler('invoice_unit_cost',
|
||||||
'this.invoiceUnitCostClicked')
|
'this.invoiceUnitCostClicked')
|
||||||
|
|
||||||
# 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)
|
|
||||||
and not self.batch_handler.has_invoice_file(batch)):
|
|
||||||
g.remove('invoice_unit_cost')
|
|
||||||
else:
|
|
||||||
g.remove('po_unit_cost')
|
|
||||||
|
|
||||||
# credits
|
# credits
|
||||||
# note that sorting by credits involves a subquery with group by clause.
|
# note that sorting by credits involves a subquery with group by clause.
|
||||||
# seems likely there may be a better way? but this seems to work fine
|
# seems likely there may be a better way? but this seems to work fine
|
||||||
|
|
Loading…
Reference in a new issue