sub entry_amount_per_item {
my $entry = shift;
return $entry->amount_paid if $U->is_true($entry->billed_per_item);
+ return 0 if $entry->phys_item_count == 0;
return $entry->amount_paid / $entry->phys_item_count;
}
from => {
acqfdeb => {
acqlid => {
- filter => {cancel_reason => undef, recv_time => {'!=' => undef}},
join => {
jub => {
join => {
}
},
where => {'+acqfdeb' => {encumbrance => $encumbrance}},
- order_by => {'acqlid' => ['recv_time']},
+ order_by => {'acqlid' => ['recv_time']}, # un-received items will sort to the end
limit => $entry->phys_item_count
};
sub create_lineitem_detail_debit {
my ($mgr, $li, $lid, $dry_run, $no_translate) = @_;
+ # don't create the debit if one already exists
+ return $mgr->editor->retrieve_acq_fund_debit($lid->fund_debit) if $lid->fund_debit;
+
my $li_id = ref($li) ? $li->id : $li;
unless(ref $li and ref $li->provider) {
$mgr->editor->allowed("CREATE_PURCHASE_ORDER", $po->ordering_agency);
$po->state("cancelled");
- $po->cancel_reason($cancel_reason);
+ $po->cancel_reason($cancel_reason->id);
my $li_ids = $mgr->editor->search_acq_lineitem(
{"purchase_order" => $po_id}, {"idlist" => 1}
);
$li->state("cancelled");
- $li->cancel_reason($cancel_reason);
+ $li->cancel_reason($cancel_reason->id);
my $lids = $mgr->editor->search_acq_lineitem_detail([{
"lineitem" => $li_id
# Attempt to delete the gathered copies (this will also handle volume deletion and bib deletion)
# Another edge case, if we have a bib but not copies, are we supposed to delete the bib?
if (scalar(@$copies)>0) {
- my $override = 0;
+ my $override = 1;
my $delete_stats = undef;
my $retarget_holds = [];
my $cat_evt = OpenILS::Application::Cat::AssetCommon->update_fleshed_copies(
}
}
- # TODO delete the associated fund debits?
- # TODO who/what/where/how do we indicate this change for electronic orders?
-
update_lineitem($mgr, $li) or return 0;
$result->{"li"} = {
$li_id => {
$lid->lineitem->purchase_order->ordering_agency
) or (! $lid->lineitem->purchase_order);
- $lid->cancel_reason($cancel_reason);
+ $lid->cancel_reason($cancel_reason->id);
- # TODO who/what/where/how do we indicate this change for electronic orders?
+ unless($U->is_true($cancel_reason->keep_debits)) {
+ my $debit_id = $lid->fund_debit;
+ $lid->clear_fund_debit;
- my $debit_id = $lid->fund_debit;
- $lid->clear_fund_debit;
+ if($debit_id) {
+ # item is cancelled. Remove the fund debit.
+ my $debit = $mgr->editor->retrieve_acq_fund_debit($debit_id);
+ if (!$U->is_true($debit->encumbrance)) {
+ $mgr->editor->rollback;
+ return OpenILS::Event->new('ACQ_NOT_CANCELABLE',
+ note => "Debit is marked as paid: $debit_id");
+ }
+ $mgr->editor->delete_acq_fund_debit($debit) or return $mgr->editor->die_event;
+ }
+ }
# XXX LIDs don't have either an editor or a edit_time field. Should we
# update these on the LI when we alter an LID?
$mgr->editor->update_acq_lineitem_detail($lid) or return 0;
- if($debit_id) {
- # item is cancelled. Remove the fund debit.
- my $debit = $mgr->editor->retrieve_acq_fund_debit($debit_id);
- if (!$U->is_true($debit->encumbrance)) {
- $mgr->editor->rollback;
- return OpenILS::Event->new('ACQ_NOT_CANCELABLE',
- note => "Debit is marked as paid: $debit_id");
- }
- $mgr->editor->delete_acq_fund_debit($debit) or return $mgr->editor->die_event;
- }
-
return {"lid" => {$lid_id => {"cancel_reason" => $cancel_reason}}};
}
"<a style='padding-right: 10px;' href='${11}/acq/po/view/${12}'>PO#${13} ${18}</a>" +
"<a style='padding-right: 10px;' href='${11}/acq/picklist/view/${14}'>${15}</a></div>",
'INVOICE_CONFIRM_PRORATE' : "Prorate charges?\n\nAny subsequent changes to the invoice that would affect prorated amounts should be resolved manually.",
- 'INVOICE_EXTRA_COPIES' : "You are invoicing <b>${0}</b> more copies than originally ordered. <br/>The order will be updated to reflect the additional copies" +
- "<br/><br/>After saving the invoice, you may finish editing and importing the new copies from the lineitem details page.",
+ 'INVOICE_EXTRA_COPIES' : "You are attempting to invoice <b>${0}</b> more copies than originally ordered. <br/><br/>To add these items to the original order, " +
+ "select a fund and choose 'Add New Items' below. <br/>After saving the invoice, you may finish editing and importing the new copies from the lineitem details page.",
//'INVOICE_EXTRA_COPIES_CATALOG' : "Add <b>${0}</b> new copies to the catalog?",
'UNNAMED': "Unnamed",
'NO_FIND_INVOICE': "Could not find that invoice.\nNote that the Invoice # field is case-sensitive.",
/* of course I'd rather just populate a <span> element inside the
* option element, but it seems you can't actually have any elements
- * inside option elements */
+ * inside option elements
+ * TODO: move to dojo/i18n
+ * */
option.innerHTML = option.innerHTML.replace(
/(^.+)(.*)( existing.+$)/, "$1" + String(count) + "$3"
);
/* handle links that appear/disappear based on whether LI is received */
if (this.isPO) {
var self = this;
+
+ actNewInvoice.onclick = function() {
+ location.href = oilsBasePath + '/acq/invoice/view?create=1&attach_li=' + li.id();
+ nodeByName("action_none", row).selected = true;
+ };
+ actLinkInvoice.onclick = function() {
+ self.invoiceLinkDialogManager.target = li;
+ acqLitLinkInvoiceDialog.show();
+ nodeByName("action_none", row).selected = true;
+ };
+ actViewInvoice.onclick = function() {
+ location.href = oilsBasePath +
+ "/acq/search/unified?so=" +
+ base64Encode({"jub":[{"id": li.id()}]}) +
+ "&rt=invoice";
+ nodeByName("action_none", row).selected = true;
+ };
+
+ actNewInvoice.disabled = false;
+ actLinkInvoice.disabled = false;
+ actViewInvoice.disabled = false;
+
switch(li.state()) {
case "on-order":
actReceive.disabled = false;
nodeByName("action_none", row).selected = true;
};
return;
+
case "received":
actUnRecv.disabled = false;
actUnRecv.onclick = function() {
actHoldingsMaint.disabled = false;
actHoldingsMaint.onclick = self.generateMakeRecTab( li.eg_bib_id(), 'copy_browser', row );
- actNewInvoice.disabled = false;
- actLinkInvoice.disabled = false;
- actViewInvoice.disabled = false;
-
- actNewInvoice.onclick = function() {
- location.href = oilsBasePath + '/acq/invoice/view?create=1&attach_li=' + li.id();
- nodeByName("action_none", row).selected = true;
- };
- actLinkInvoice.onclick = function() {
- self.invoiceLinkDialogManager.target = li;
- acqLitLinkInvoiceDialog.show();
- nodeByName("action_none", row).selected = true;
- };
- actViewInvoice.onclick = function() {
- location.href = oilsBasePath +
- "/acq/search/unified?so=" +
- base64Encode({"jub":[{"id": li.id()}]}) +
- "&rt=invoice";
- nodeByName("action_none", row).selected = true;
- };
-
return;
}
}
searchFilter : {active : 't'},
labelFormat : fundLabelFormat,
searchFormat : fundSearchFormat,
+ dijitArgs : {required : true},
parentNode : dojo.byId('acq-invoice-extra-copies-fund')
});
extraCopiesFund.build();
labelFormat : fundLabelFormat,
searchFormat : fundSearchFormat,
readOnly : invoice && openils.Util.isTrue(invoice.complete()),
+ dijitArgs : {required : true},
parentNode : nodeByName('fund', row)
}
entry.lineitem(li);
entry.purchase_order(li.purchase_order());
nodeByName('title_details', row).innerHTML = html;
- }
- );
- dojo.forEach(
- ['inv_item_count', 'phys_item_count', 'cost_billed', 'amount_paid'],
- function(field) {
- var dijitArgs = {required : true, constraints : {min: 0}, style : 'width:6em'};
- if(entry.isnew() && field == 'phys_item_count') dijitArgs.value = numReceived;
- registerWidget(
- entry,
- field,
- new openils.widget.AutoFieldWidget({
- fmObject : entry,
- fmClass : 'acqie',
- fmField : field,
- dijitArgs : dijitArgs,
- readOnly : invoice && openils.Util.isTrue(invoice.complete()),
- parentNode : nodeByName(field, row)
- }),
- function(w) {
- if(field == 'phys_item_count') {
- dojo.connect(w, 'onChange',
- function() {
- // staff entered a higher number in the receive field than was originally ordered
- if(Number(this.attr('value')) > entry.lineitem().item_count()) {
- storeExtraCopies(
- entry.lineitem().id(),
- Number(this.attr('value')) - entry.lineitem().item_count()
- );
- }
- }
- )
+ dojo.forEach(
+ ['inv_item_count', 'phys_item_count', 'cost_billed', 'amount_paid'],
+ function(field) {
+ var dijitArgs = {required : true, constraints : {min: 0}, style : 'width:6em'};
+ if(entry.isnew() && field == 'phys_item_count') {
+ // by default, attempt to pay for all received and as-of-yet-un-invoiced items
+ dijitArgs.value = (Number(li.order_summary().recv_count()) - Number(li.order_summary().invoice_count())) || 0;
}
+ registerWidget(
+ entry,
+ field,
+ new openils.widget.AutoFieldWidget({
+ fmObject : entry,
+ fmClass : 'acqie',
+ fmField : field,
+ dijitArgs : dijitArgs,
+ readOnly : invoice && openils.Util.isTrue(invoice.complete()),
+ parentNode : nodeByName(field, row)
+ }),
+ function(w) {
+ if(field == 'phys_item_count') {
+ dojo.connect(w, 'onChange',
+ function() {
+ // staff entered a higher number in the receive field than was originally ordered
+ // taking into account already invoiced items
+ var extra = Number(this.attr('value')) -
+ (Number(entry.lineitem().item_count()) - Number(entry.lineitem().order_summary().invoice_count()));
+ if(extra > 0) {
+ storeExtraCopies(entry, extra);
+ }
+ }
+ )
+ }
+ }
+ );
}
);
}
);
}
-function storeExtraCopies(liId, numExtra) {
+function storeExtraCopies(entry, numExtra) {
dojo.byId('acq-invoice-extra-copies-message').innerHTML =
dojo.string.substitute(
extraCopiesGo,
'onClick',
function() {
- extraCopies[liId] = {
+ extraCopies[entry.lineitem().id()] = {
numExtra : numExtra,
fund : extraCopiesFund.widget.attr('value')
}
);
dojo.connect(
- extraCopiesCancel,
- 'onClick',
- function() { extraItemsDialog.hide() }
+ extraCopiesCancel,
+ 'onClick',
+ function() {
+ widgetRegistry.acqie[entry.id()].phys_item_count.widget.attr('value', '');
+ extraItemsDialog.hide()
+ }
);
extraItemsDialog.show();
<option name='action_link_invoice' disabled='disabled'>Link to Invoice</option>
<option name='action_view_invoice' disabled='disabled'>View Invoice(s)</option>
<option name='action_view_claim_policy'>Apply Claim Policy</option>
- <option name='action_manage_claims' disabled='disabled'>Manage Claims ( existing)</option>
+ <option name='action_manage_claims' disabled='disabled'>Claims ( existing)</option>
</select>
</td>
<td><span name='li_state'></span></td>
<tr>
<th colspan='2'>Title Details</th>
<th class='acq-invoice-center-col'># Invoiced</th>
- <th class='acq-invoice-center-col'># Received</th>
+ <th class='acq-invoice-center-col'># Paid</th>
<th class='acq-invoice-center-col'>Billed</th>
<th class='acq-invoice-paid-col'>Paid</th>
<th class='acq-invoice-center-col hide-complete'>Detach</th>
<br/>
Select a fund for the new items: <div id='acq-invoice-extra-copies-fund'></div>
<br/><br/>
- <!--
- <span id='acq-invoice-extra-copies-add-msg'></span>
- <input dojoType='dijit.form.CheckBox' jsId='extraCopiesInCatalogCheckbox'></input>
- -->
<br/><br/>
<span style='padding-right: 10px;'>
<button dojoType='dijit.form.Button' jsId='extraCopiesCancel'>Cancel</button>
</span>
- <button dojoType='dijit.form.Button' jsId='extraCopiesGo'>Continue</button>
+ <button dojoType='dijit.form.Button' jsId='extraCopiesGo'>Add New Items</button>
</div>
</div>
[% END %]