← Back to team overview

c2c-oerpscenario team mailing list archive

Re: [Bug 805697] [NEW] Price difference account - incorrect calculation

 

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
<gdgellatly@xxxxxxxxx>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 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 <805697@xxxxxxxxxxxxxxxxxx
> > 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
>>
>
>

-- 
You received this bug notification because you are a member of C2C
OERPScenario, which is subscribed to the OpenERP Project Group.
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


References