Add support for 'receiving' mode for purchase batches
This commit is contained in:
parent
8acb9b0029
commit
67f6c11307
9 changed files with 292 additions and 70 deletions
|
@ -4,11 +4,71 @@
|
|||
<%def name="head_tags()">
|
||||
${parent.head_tags()}
|
||||
<script type="text/javascript">
|
||||
|
||||
function show_mode(mode) {
|
||||
if (mode == ${enum.PURCHASE_BATCH_MODE_NEW}) {
|
||||
$('.field-wrapper.store_uuid').show();
|
||||
$('.field-wrapper.purchase_uuid').hide();
|
||||
$('.field-wrapper.buyer_uuid').show();
|
||||
$('.field-wrapper.date_ordered').show();
|
||||
$('.field-wrapper.date_received').hide();
|
||||
} else if (mode == ${enum.PURCHASE_BATCH_MODE_RECEIVING}) {
|
||||
$('.field-wrapper.store_uuid').hide();
|
||||
$('.field-wrapper.purchase_uuid').show();
|
||||
$('.field-wrapper.buyer_uuid').hide();
|
||||
$('.field-wrapper.date_ordered').hide();
|
||||
$('.field-wrapper.date_received').show();
|
||||
}
|
||||
}
|
||||
|
||||
function vendor_selected(uuid, name) {
|
||||
var mode = $('.mode select').val();
|
||||
if (mode == ${enum.PURCHASE_BATCH_MODE_RECEIVING}) {
|
||||
var purchases = $('.purchase_uuid select');
|
||||
purchases.empty();
|
||||
|
||||
var data = {'vendor_uuid': uuid, 'mode': mode};
|
||||
$.get('${url('purchases.batch.eligible_purchases')}', data, function(data) {
|
||||
if (data.error) {
|
||||
alert(data.error);
|
||||
} else {
|
||||
$.each(data.purchases, function(i, purchase) {
|
||||
purchases.append($('<option value="' + purchase.uuid + '">' + purchase.display + '</option>'));
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// TODO: apparently refresh doesn't work right?
|
||||
// http://stackoverflow.com/a/10280078
|
||||
// purchases.selectmenu('refresh');
|
||||
purchases.selectmenu('destroy').selectmenu();
|
||||
}
|
||||
}
|
||||
|
||||
function vendor_cleared() {
|
||||
var purchases = $('.purchase_uuid select');
|
||||
purchases.empty();
|
||||
|
||||
// TODO: apparently refresh doesn't work right?
|
||||
// http://stackoverflow.com/a/10280078
|
||||
// purchases.selectmenu('refresh');
|
||||
purchases.selectmenu('destroy').selectmenu();
|
||||
}
|
||||
|
||||
$(function() {
|
||||
|
||||
$('.field-wrapper.mode select').selectmenu();
|
||||
$('.field-wrapper.mode select').selectmenu({
|
||||
change: function(event, ui) {
|
||||
show_mode(ui.item.value);
|
||||
}
|
||||
});
|
||||
|
||||
$('.field-wrapper.purchase_uuid select').selectmenu();
|
||||
|
||||
show_mode(${form.fieldset.model.mode or enum.PURCHASE_BATCH_MODE_NEW});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
</%def>
|
||||
|
||||
|
|
|
@ -154,7 +154,18 @@
|
|||
<th>Pref.</th>
|
||||
<th>Unit Cost</th>
|
||||
% for data in history.itervalues():
|
||||
<th>${data['purchase'].date_ordered.strftime('%m/%d') if data else ''}</th>
|
||||
<th>
|
||||
% if data:
|
||||
% if data['purchase'].date_ordered:
|
||||
${data['purchase'].date_ordered.strftime('%m/%d') if data else ''}
|
||||
% elif data['purchase'].date_received:
|
||||
Rec.<br />
|
||||
${data['purchase'].date_received.strftime('%m/%d') if data else ''}
|
||||
% else:
|
||||
??
|
||||
% endif
|
||||
% endif
|
||||
</th>
|
||||
% endfor
|
||||
<th>
|
||||
${batch.date_ordered.strftime('%m/%d')}<br />
|
||||
|
@ -180,9 +191,15 @@
|
|||
<td class="unit-cost">$${'{:0.2f}'.format(cost.unit_cost)}</td>
|
||||
% for data in history.itervalues():
|
||||
<td class="scratch_pad">
|
||||
% if data and cost.product_uuid in data['items']:
|
||||
${'{} / {}'.format(int(data['items'][cost.product_uuid].cases_ordered or 0), int(data['items'][cost.product_uuid].units_ordered or 0))}
|
||||
## ${int(data['items'][cost.product_uuid].cases_ordered or 0) or ''}
|
||||
% if data:
|
||||
<% item = data['items'].get(cost.product_uuid) %>
|
||||
% if item:
|
||||
% if data['purchase'].date_ordered and (item.cases_ordered is not None or item.units_ordered is not None):
|
||||
${'{} / {}'.format(int(item.cases_ordered or 0), int(item.units_ordered or 0))}
|
||||
% elif item.cases_received is not None or item.units_received is not None:
|
||||
${'{} / {}'.format(int(item.cases_received or 0), int(item.units_received or 0))}
|
||||
% endif
|
||||
% endif
|
||||
% endif
|
||||
</td>
|
||||
% endfor
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
</%def>
|
||||
|
||||
<%def name="leading_buttons()">
|
||||
% if not batch.complete and not batch.executed and request.has_perm('purchases.batch.order_form'):
|
||||
% if batch.mode == enum.PURCHASE_BATCH_MODE_NEW and not batch.complete and not batch.executed and request.has_perm('purchases.batch.order_form'):
|
||||
<button type="button" id="order-form">View as Order Form</button>
|
||||
% endif
|
||||
</%def>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue