var itemTbody;
var itemTemplate;
var entryTemplate;
-var totalAmountBox;
+var totalInvoicedBox;
+var totalPaidBox;
var invoicePane;
var itemTypes;
var virtualId = -1;
function updateTotalCost() {
var total = 0;
- if(!totalAmountBox) {
- totalAmountBox = new dijit.form.CurrencyTextBox(
+ if(!totalInvoicedBox) {
+ totalInvoicedBox = new dijit.form.CurrencyTextBox(
{style : 'width: 5em'}, dojo.byId('acq-invoice-total-invoiced'));
}
for(var id in widgetRegistry.acqii)
for(var id in widgetRegistry.acqie)
if(!widgetRegistry.acqie[id]._object.isdeleted())
total += widgetRegistry.acqie[id].cost_billed.getFormattedValue();
- totalAmountBox.attr('value', total);
+ totalInvoicedBox.attr('value', total);
+
+ total = 0;
+ if(!totalPaidBox) {
+ totalPaidBox = new dijit.form.CurrencyTextBox(
+ {style : 'width: 5em'}, dojo.byId('acq-invoice-total-paid'));
+ }
+ for(var id in widgetRegistry.acqii)
+ if(!widgetRegistry.acqii[id]._object.isdeleted())
+ total += widgetRegistry.acqii[id].amount_paid.getFormattedValue();
+ for(var id in widgetRegistry.acqie)
+ if(!widgetRegistry.acqie[id]._object.isdeleted())
+ total += widgetRegistry.acqie[id].amount_paid.getFormattedValue();
+ totalPaidBox.attr('value', total);
}
var itemType = itemTypes.filter(function(t) { return (t.code() == item.inv_item_type()) })[0];
dojo.forEach(
- ['title', 'author', 'cost_billed'],
+ ['title', 'author', 'cost_billed', 'amount_paid'],
function(field) {
registerWidget(
item,
fmClass : 'acqii',
fmObject : item,
fmField : field,
- dijitArgs : (field == 'cost_billed') ? {required : true, style : 'width: 5em'} : null,
+ dijitArgs : (field == 'cost_billed' || field == 'amount_paid') ? {required : true, style : 'width: 5em'} : null,
parentNode : nodeByName(field, row)
})
)
/* ----------- fund -------------- */
- var itemType = itemTypes.filter(function(t) { return (t.code() == item.inv_item_type()) })[0];
-
var fundArgs = {
fmClass : 'acqii',
fmObject : item,
}
if(item.fund_debit()) {
- fundArgs.readOnly = true;
+ fundArgs.searchFilter = {'-or' : [{active : 't'}, {id : item.fund()}]};
} else {
fundArgs.searchFilter = {active : 't'}
if(itemType && openils.Util.isTrue(itemType.prorate()))
- fundArgs.disabled = true;
+ fundArgs.dijitArgs = {disabled : true};
}
var fundWidget = new openils.widget.AutoFieldWidget(fundArgs);
dojo.forEach(
- ['inv_item_count', 'phys_item_count', 'cost_billed'],
+ ['inv_item_count', 'phys_item_count', 'cost_billed', 'amount_paid'],
function(field) {
var dijitArgs = {required : true, constraints : {min: 0}, style : 'width:5em'};
if(entry.isnew() && field == 'phys_item_count') dijitArgs.value = numReceived;
return (attr) ? attr.attr_value() : '';
}
-function saveChanges() {
+function saveChanges(doProrate) {
progressDialog.show(true);
progressDialog.hide();
var invoice = openils.Util.readResponse(r);
if(invoice) {
+ if(doProrate)
+ return prorateInvoice();
location.href = oilsBasePath + '/acq/invoice/view/' + invoice.id();
}
}
);
}
-function processInvoice() {
+function prorateInvoice() {
+ if(!confirm(localeStrings.INVOICE_CONFIRM_PRORATE)) return;
progressDialog.show(true);
fieldmapper.standardRequest(
- ['open-ils.acq', 'open-ils.acq.invoice.process'],
+ ['open-ils.acq', 'open-ils.acq.invoice.apply_prorate'],
{
params : [openils.User.authtoken, invoice.id()],
oncomplete : function(r) {
<!-- acq.invoice_entry -->
<thead>
<td colspan='3'>Title Details</td>
- <td># Items Invoiced / # Received</td>
+ <td># Invoiced / # Received</td>
<td>Amount Billed</td>
+ <td>Amount Paid</td>
<td>Detach</td>
</thead>
<tbody id='acq-invoice-entry-tbody'>
<tr id='acq-invoice-entry-template' class='acq-invoice-row'>
<td colspan='3'>
<div name='title_details'></div>
+ <div name='note'></div>
</td>
<td nowrap='nowrap'>
<span name='inv_item_count'></span> / <span name='phys_item_count'></span>
</td>
<td><div name='cost_billed'/></td>
+ <td><div name='amount_paid'/></td>
<td><a href='javascript:void(0);' name='detach'>Detach</a></td>
</tr>
</tbody>
<td>Author (optional)</td>
<td>Fund</td>
<td>Amount Billed</td>
+ <td>Amount Paid</td>
<td>Delete</td>
</thead>
<tbody id='acq-invoice-item-tbody'>
<td><div name='author'/></td>
<td><div name='fund'/></td>
<td><div name='cost_billed'/></td>
+ <td><div name='amount_paid'/></td>
<td><a href='javascript:void(0);' name='delete'>Delete</a></td>
</tr>
</tbody>
<tbody>
<tr>
<td colspan='0'>
- <a href='javascript:void(0);' id='acq-invoice-new-item'>Add Invoice Item...</a>
+ <a href='javascript:void(0);' id='acq-invoice-new-item'>Add Charge...</a>
</td>
</tr>
</tbody>
<thead>
<tr>
<td colspan='4'/>
- <td>Total Amount</td>
+ <td>Total Invoiced</td>
+ <td>Total Paid</td>
</tr>
</thead>
<tbody>
<tr>
<td colspan='4' style='text-align:right;'>
- <button dojoType='dijit.form.Button' onclick='saveChanges();'>Save & Continue</button>
- <button dojoType='dijit.form.Button' onclick='processInvoice();'>Process Invoice</button>
+ <button dojoType='dijit.form.Button' onclick='saveChanges();'>Save Changes</button>
+ <button dojoType='dijit.form.Button' onclick='saveChanges(true);'>Save & Prorate Charges</button>
</td>
<td><div id='acq-invoice-total-invoiced'/></td>
+ <td><div id='acq-invoice-total-paid'/></td>
</tr>
</tbody>
</table>