PO totals do not include all amounts

Bug #1380803 reported by Bill Erickson
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Evergreen
Fix Released
Medium
Unassigned
2.6
Fix Released
Undecided
Unassigned
2.7
Fix Released
Undecided
Unassigned

Bug Description

Evergreen master (circa 2.7); likely affects all versions.

In the purchase order UI , the total estimated and total spent values do not include all of the values relevant to the PO.

1. Charges created directly from the PO via the New Charge button at the bottom of the page appear in the total encumbered and spent, but not the total estimated. To fix this, we can move the total-estimated calculation into the API which counts the debits for total encumbered and spent. Inside the function, we can add po_item amounts to the estimated amount.

2. Charges created directly from an invoice do not appear in either the total spent or total estimated on the PO. (These would never be encumbered, so they won't show there, regardless). This is slightly trickier, because this type of charge doesn't link to a specific PO, since you can have multiple PO's on one invoice.

Note there is an acq.invoice_item.purchase_order column, but this is only populated for invoice_item's which are created from acq.po_item's. invoice_item's created within an invoice are assumed to not have a specific PO target, so the column is unset.

My proposed solution for this is to virtually prorate the shared costs when calculating the amount estimated/spent on such charges across the relevant POs. For example, if an invoice has two POs with $5 charged for one and $15 for the other, a $4 tax would be (virtually) attributed as $1 (25%) to the $5 PO and $3 (75%) to the $15 PO. The extra $1 and $3 would be added to the total estimated and total spent for their respective PO's. That is, the $5 PO would show $6 estimated and $6 spent.

Of course for single-PO invoices, no virtual prorating is required. A $3 tax would just show as an extra $3 on the amounts estimated and spent for the single PO.

Does the proposed solution to #2 sound reasonable and would it be useful? Confusing?

Are there cases where an invoice containing multiple PO's would include a charge (tax, fee, etc.) that should not be attributed to all PO's on the invoice?

Revision history for this message
Mike Rylander (mrylander) wrote :

I assume we would only prorate where acq.invoice_item.purchase_order is null. If that's the case, I have an adjustment to request for the "add Item from Invoice" workflow. When doing that, I think the UI should offer to add the item to a specific PO, but allow "all" ("none"?) as an option. If one PO is chosen, we know where the line item belongs. If it's null, we prorate. That is, I think, the crux of you second question.

With that, it all makes perfect sense to me and sounds good.

And, for pedantry's sake, the single-PO case needn't be special -- the virtual prorating still happens, but 100% is applied to the one PO. I don't think there's a need for a special code path there.

Revision history for this message
Bill Erickson (berick) wrote : Re: [Bug 1380803] Re: PO totals do not include all amounts

On Wed, Oct 15, 2014 at 11:33 AM, Mike Rylander <email address hidden> wrote:

> I assume we would only prorate where acq.invoice_item.purchase_order is
> null.

Yes.

> If that's the case, I have an adjustment to request for the "add
> Item from Invoice" workflow. When doing that, I think the UI should
> offer to add the item to a specific PO, but allow "all" ("none"?) as an
> option. If one PO is chosen, we know where the line item belongs. If
> it's null, we prorate. That is, I think, the crux of you second
> question.
>

Yes, this would resolve the attribution issue. I like it.

>
> With that, it all makes perfect sense to me and sounds good.
>
> And, for pedantry's sake, the single-PO case needn't be special -- the
> virtual prorating still happens, but 100% is applied to the one PO. I
> don't think there's a need for a special code path there.
>

Yes, exactly.

Thanks, Mike. Appreciate the feedback.

Kathy Lussier (klussier)
Changed in evergreen:
status: New → Confirmed
importance: Undecided → Medium
Bill Erickson (berick)
Changed in evergreen:
assignee: nobody → Bill Erickson (berick)
Revision history for this message
Bill Erickson (berick) wrote :

I have code in progress to implement #1.

Testing this, it occurs to me that we could do a better job of updating the summary information as PO data is modified (charges added, changing lineitem prices, adding copies, etc.). Right now, the data is only updated when the page is reloaded.

Regarding #2, I'm having second thoughts. I'm concerned that adding to the amounts estimated/spent on a PO for charges that are not represented directly in the PO will be confusing. Or, to put it another way, if a charge (e.g. tax) was not added to the PO as a direct charge and encumbered to begin with, its contribution should not be included in the PO summary.

If we do want to include such charges in the summary, perhaps we could display them in a different summary value, one to represent "everything in this PO plus external charges from related invoices"

Revision history for this message
Bill Erickson (berick) wrote :

Pushed code for #1, including keeping the summary amounts updated as data changes in the page, to:

http://git.evergreen-ils.org/?p=working/Evergreen.git;a=shortlog;h=refs/heads/user/berick/lp1380803-direct-charge-affects-summaries

Adding pullrequest for this, since it stands alone as a needed fix.

Deferring for now on #2.

tags: added: pullrequest
Changed in evergreen:
assignee: Bill Erickson (berick) → nobody
milestone: none → 2.8.1
Revision history for this message
Bill Erickson (berick) wrote :

Note the posted branch has 2 commits.

Revision history for this message
Kathy Lussier (klussier) wrote :

Hi Bill,

I'm having trouble when this branch is loaded that is unrelated to the summary amounts in the PO.

When I search for a record, click view/place orders, and then click any of the options (add to selection list, add to po, create po), I get a progress bar that gets stuck at 0% as it tries to load the next dialog. I don't have this problem when the branch is removed.

Revision history for this message
Bill Erickson (berick) wrote :

Thanks for the report, Kathy. I'll take a look later today.

Revision history for this message
Bill Erickson (berick) wrote :

Force-pushed a fixed branch.

Revision history for this message
Kathy Lussier (klussier) wrote :

Hi Bill,

This looks good, but I'm now getting a conflict when I try to cherry-pick the top commit.

Kathy

Revision history for this message
Bill Erickson (berick) wrote :

Rebased and force-pushed to same branch.

Revision history for this message
Kathy Lussier (klussier) wrote :
tags: added: signedoff
Revision history for this message
Bill Erickson (berick) wrote :

Thanks for testing and sign-off, Kathy. I've merge the commit to 2.6 and beyond.

Changed in evergreen:
status: Confirmed → Fix Committed
Changed in evergreen:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.