Price difference account - incorrect calculation

Bug #805697 reported by Kevin McMenamin
20
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Fix Released
Medium
Unassigned

Bug Description

The accounting entries generated for the price difference account are not consistently correct.
Environment:
6.0.2 release 30/06/2011
anglo-saxon accounting
PO invoicing control = from picking
product costing method = average price
inventory valuation = real time (automated)

When a PO is raised for a product with a purchase price <> average cost AND
the invoice when processed has a price difference to the PO, THEN
the price difference value is calculated by (Quantity * (Old Average Price - New Average Price)) (+ve value = DR)
but should be calculated by (Quantity * (Invoice Price - PO Price)) (+ve value = DR)

I can provide a worked example if required

Revision history for this message
Kevin McMenamin (kevin-mcmenamin) wrote :

I think the issue is that in anglo-saxon invoice.py line 122 the price variance calculation is based on the average cost at the time the invoice is processed, not the original PO cost.

So either,

a) this needs to be changed to pick up the original PO cost to calculate the variance; or
b) when the goods are receipted, if there is a difference to the average cost there will need to be a GL entry created for that difference.

My preference is a) so that in reconciling the goods received not invoiced account in the GL there is a recognisable recognition between PO and invoice (ie any difference is solely price variance an invoice processing time)

Revision history for this message
Graeme Gellatly (gdgellatly) wrote : Re: [Bug 805697] [NEW] Price difference account - incorrect calculation

I agree, price difference account can give weird errors, but the logic here
is incorrect. We should not use the PO Price for any calculation of price
differences. Please do not implement this as suggested.

This is because we can specify cost at time of goods receipt and price
difference is to be the difference between receipted cost and supplier
invoice, not the difference between PO and invoice. Priced packing slips
and/or adding freight in to costs is the primary use case where the stated
logic does not work. It would also make interfacing with extended modules
such as those going on for landed cost calculation that much tougher,
basically requiring an anglo_saxon overwrite as well.

While I have not tested, it will be interesting if recent bugfix to store
price_unit on all inwards stock_moves fixes this issue anyway. At the very
least it probably provides for an easy refactor of the price difference
logic in account_anglo_saxon. Just use stock.move price_unit.

On Tue, Jul 5, 2011 at 9:22 AM, Kevin McMenamin
<email address hidden>wrote:

> Public bug reported:
>
> The accounting entries generated for the price difference account are not
> consistently correct.
> Environment:
> 6.0.2 release 30/06/2011
> anglo-saxon accounting
> PO invoicing control = from picking
> product costing method = average price
> inventory valuation = real time (automated)
>
> When a PO is raised for a product with a purchase price <> average cost AND
> the invoice when processed has a price difference to the PO, THEN
> the price difference value is calculated by (Quantity * (Old Average Price
> - New Average Price)) (+ve value = DR)
> but should be calculated by (Quantity * (Invoice Price - PO Price)) (+ve
> value = DR)
>
> I can provide a worked example if required
>
> ** Affects: openobject-addons
> Importance: Undecided
> Status: New
>
> --
> You received this bug notification because you are subscribed to OpenERP
> Addons.
> https://bugs.launchpad.net/bugs/805697
>
> Title:
> Price difference account - incorrect calculation
>
> Status in OpenERP Modules (addons):
> New
>
> Bug description:
> The accounting entries generated for the price difference account are not
> consistently correct.
> Environment:
> 6.0.2 release 30/06/2011
> anglo-saxon accounting
> PO invoicing control = from picking
> product costing method = average price
> inventory valuation = real time (automated)
>
> When a PO is raised for a product with a purchase price <> average cost
> AND
> the invoice when processed has a price difference to the PO, THEN
> the price difference value is calculated by (Quantity * (Old Average Price
> - New Average Price)) (+ve value = DR)
> but should be calculated by (Quantity * (Invoice Price - PO Price)) (+ve
> value = DR)
>
> I can provide a worked example if required
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/openobject-addons/+bug/805697/+subscriptions
>

Revision history for this message
Kevin McMenamin (kevin-mcmenamin) wrote :

agree with Graeme's comments - I hadn't considered that you can change the cost at receipting time. I'll download the latest version and see if fixed.

Revision history for this message
Graeme Gellatly (gdgellatly) wrote :
Download full text (5.4 KiB)

I've had a closer look at the file invoice.py in account anglo saxon. It is
one I had to over write quite heavily to make product_variant_multi work for
anglo_saxon countries. There are quite a few issues which cause errors.

Any access directly to standard_price field is a potential source of error.
 e.g. i_line.product_id.product_tmpl_id.standard_price - in order to get a
price we must use price_get, as this allows computation of cost_price_extra
or price_extra fields that are stored at the product level. At the very
least it breaks the extensibility of product modules.

Provided the bug fix to store price_unit on all stock_moves is released then
we really should access the stock_move price_unit at line 120. However if
it is not released then we might need separate scenario's depending on
invoice policy on PO. However I have a feeling getting the correct price
there is going to show up errors in the get_price function and throw things
out.

This would need to cover scenarios where standard price (and I suppose
average cost, seeing it is the same field) had changed between receipt and
invoice. In fact it is this scenario which is giving rise to the
differences Kevin is experiencing. I am surprised his stock input contra
calculation is not also incorrect. So following the logic through, it
becomes quite clear that the only solution which makes sense for all cost
scenarios is to use the price_unit stored in the stock_move and for all
stock_moves to store price_unit. This also needs to change on line 120, and
the function get_price needs an overhaul as well, and probably any reference
to standard_price in this module.

In fact the only scenario where I can see account_anglo_saxon working
correctly calculating price_differences consistently is in a single company,
never changing standard price using standard cost with no variants that
change price and a PO policy on order.

Now all of this assumes a standard workflow from PO to Invoice - I have no
idea what happens in the case of raising a manual invoice, hmm there are no
stock_moves, but are there price differences, I don't know - I think this
needs a bit more thinking and discussion but there are definitely errors
here and quite a few. Definitely more than a few hours work to figure this
end to end. I geuss it depends, fix the bug as reported, or fix the module
properly, and really test it for the bugs.

On Tue, Jul 5, 2011 at 9:47 AM, Graeme Gellatly <email address hidden>wrote:

> I agree, price difference account can give weird errors, but the logic here
> is incorrect. We should not use the PO Price for any calculation of price
> differences. Please do not implement this as suggested.
>
> This is because we can specify cost at time of goods receipt and price
> difference is to be the difference between receipted cost and supplier
> invoice, not the difference between PO and invoice. Priced packing slips
> and/or adding freight in to costs is the primary use case where the stated
> logic does not work. It would also make interfacing with extended modules
> such as those going on for landed cost calculation that much tougher,
> basically requiring an anglo_saxon overwrite as w...

Read more...

Revision history for this message
Kevin McMenamin (kevin-mcmenamin) wrote :

Just to confirm the stock input account is incorrect as well (being the offset with the error in price difference)

Revision history for this message
Dmitri (7a-support-6r) wrote :

Any progress on this issue?

Revision history for this message
Kevin McMenamin (kevin-mcmenamin) wrote :

This issue is still outstanding - I have just retested on the latest nightly build - previously it worked if a PO had Invoicing control = from order, but now both from picking and from order create incorrect entries - but even better, they are wrong in different ways!

I have enclosed a video to show what is happening.

Revision history for this message
Amit Parik (amit-parik) wrote :

Hello Kevin,

Thanks for your response and excellent video.

I have faced the same problem at my end.

If the Invoicing control =from picking price difference account does not calculated properly.

Thanks.

Amit Parik (amit-parik)
Changed in openobject-addons:
assignee: nobody → OpenERP R&D Addons Team 2 (openerp-dev-addons2)
importance: Undecided → Medium
status: New → Confirmed
Changed in openobject-addons:
status: Confirmed → In Progress
Changed in openobject-addons:
status: In Progress → Confirmed
Revision history for this message
qdp (OpenERP) (qdp) wrote :

Hi,

i would like to know, according to you, what should be the created entries in both case (invoicing from picking and from order)?

Thanks

Changed in openobject-addons:
status: Confirmed → Incomplete
Revision history for this message
Kevin McMenamin (kevin-mcmenamin) wrote :

Based on anglo-saxon accounting, the entries required are:

For stock receipt:

DR Stock Variation Account
CR Stock Input Account

For the supplier Invoice

DR Stock Input Account (must be = the receipted value)
CR Creditors
DR/CR Price Difference Account (DR/CR determined by value)

Revision history for this message
Kevin McMenamin (kevin-mcmenamin) wrote :

Just thought about service lines. In this case, there will be no stock receipt journal, so the creditor invoice needs to be:

DR Expense Account
CR Creditors

Revision history for this message
Kevin McMenamin (kevin-mcmenamin) wrote :

The service issue was bug 869556 and I see a release of fix was done yesterday.

Revision history for this message
Burhan Ghee (anisghee) wrote :

Is this issue resolved?

Revision history for this message
qdp (OpenERP) (qdp) wrote :

wow it's 1 year old... i don't have any idea. Can someone check if the problem occures in trunk? i'm setting back the status to 'new'

thanks

Changed in openobject-addons:
assignee: OpenERP R&D Addons Team 2 (openerp-dev-addons2) → nobody
status: Incomplete → New
Revision history for this message
Amit Parik (amit-parik) wrote :

Hello qdp,

Thanks for the remind this issue.

I have checked this issue on latest trunk with both scenario and its working correct. And give the journal entry for price difference account is as follow. (Data taken from above example of video)
Account Debit Credit
Payable account: 0.0 115.00
Tax Account 15.00 0.0
Price Difference A/c 50.00 0.0
Stock I/P A/c 50.00 0.0

Same entries are created f invoice created from Purchase Order or from Reception (Incoming shipment).

So this issue is resolved on Trunk.

Thank you!

Changed in openobject-addons:
status: New → Fix Released
Revision history for this message
Amit Parik (amit-parik) wrote :

#Correction on above comment.

Same entries are created of both part "Invoice created from Purchase Order" or "Invoice created from Reception (Incoming shipment)".

Thanks!

Revision history for this message
Kevin McMenamin (kevin-mcmenamin) wrote :

I have retested this using my production version of 6.0.4 and journal entries created are correct

Revision history for this message
Javier Santos (javier-santos) wrote : [Openerp-india] [Bug 805697] Re: Price difference account - incorrect calculation

Hi Kevin I would appreciate an example of the

  [Openerp-india] [Bug 805697] Re: Price difference account - incorrect
  calculation
  <http://www.mail-archive.com/search?<email address hidden>&q=subject:%22%5BOpenerp-india%5D+%5BBug+805697%5D+Re%3A+Price+difference+account+-%09incorrect+calculation%22>

Thanks and best regards

Javier Santos

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.