Hi Martin,
Thanks for your suggestion.
To be honest I’m quite unhappy with this solution, since I use a lot the
--lot-prices feature of ledger, and your solution makes it unusable on
the long term...
(also, I’ll end up averaging hundreds of postings which can be a long
computation...)

Kind regards,

(Wed, Oct 25, 2017 at 02:48:02AM +0000) Martin Blais :
> Hi Ismael,
> 
> In your specific case, what I would do is avoid even doing the adjustments,
> and when I need to make a sale, just sum up the cost bases in all the
> historical lots to obtain the average cost basis at that point and record a
> sale with that basis. The sum of the units, and the sum of the cost bases
> (signed units x cost price), should separately be correct even if the
> postings don't reduce each other.
> 
> I hope this helps,
> 
> 
> On Tue, Oct 24, 2017 at 6:03 PM, Ismaël Bouya <
> [email protected]> wrote:
> 
> > In France, the taxation model when buying and selling actions is based on
> > mean value of the actions rather than "older first". This means that I have
> > to use tweaks like that to have them correct in ledger:
> > ----------------------
> > 2002/03/20 Buy Actions
> >     Assets:Broker       10.00 Foo {5.00 EUR}
> >     Assets:Checking    -50.00 EUR
> >
> > 2002/03/25 Buy Actions
> >     Assets:Broker       15.00 Foo {10.00 EUR}
> >     Assets:Checking   -150.00 EUR
> >
> > ; In France, we consider the mean value of an action for taxation
> > 2002/03/25 Price adjustment
> >     Assets:Broker       25.00 Foo {8.00 EUR}
> >     Assets:Broker      -10.00 Foo {5.00 EUR}  @ 1 Foo {8.00 EUR}
> >     Assets:Broker      -15.00 Foo {10.00 EUR} @ 1 Foo {8.00 EUR}
> > -------------------
> >
> > Now, the problem comes when I buy some actions again, even with another
> > account:
> > --------------------
> > 2002/03/20 Buy Actions
> >     Assets:BrokerA      10.00 Foo {5.00 EUR}
> >     Assets:Checking    -50.00 EUR
> >
> > 2002/03/25 Buy Actions
> >     Assets:BrokerA      15.00 Foo {10.00 EUR}
> >     Assets:Checking   -150.00 EUR
> >
> > ; In France, we consider the mean value of an action for taxation
> > 2002/03/25 Price adjustment
> >     Assets:BrokerA      25.00 Foo {8.00 EUR}
> >     Assets:BrokerA     -10.00 Foo {5.00 EUR}  @ 1 Foo {8.00 EUR}
> >     Assets:BrokerA     -15.00 Foo {10.00 EUR} @ 1 Foo {8.00 EUR}
> >
> > 2002/05/15 Buy Actions
> >     Assets:BrokerB      10.00 Foo {50.00 EUR}
> >     Assets:Checking    -500.00 EUR
> >
> > 2002/05/25 Buy Actions
> >     Assets:BrokerB      15.00 Foo {100.00 EUR}
> >     Assets:Checking   -1500.00 EUR
> >
> > 2002/05/25 Price adjustment
> >     Assets:BrokerB      25.00 Foo {80.00 EUR}
> >     Assets:BrokerB     -10.00 Foo {50.00 EUR}  @ 1 Foo {80.00 EUR}
> >     Assets:BrokerB     -15.00 Foo {100.00 EUR} @ 1 Foo {80.00 EUR}
> > --------------------
> >
> > This example fails with "Error: Cannot compare amounts with different
> > commodities: 'Foo {8.00 EUR}' and 'Foo {80.00 EUR}'"
> >
> > I don’t understand where this error comes from, the two accounts are not
> > even related...
> >
> > Any hint how I could achieve my goal?
> >
> > Kind regards,
> >
> > --
> >
> > ---
> > You received this message because you are subscribed to the Google Groups
> > "Ledger" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to [email protected].
> > For more options, visit https://groups.google.com/d/optout.
> >
> 
> -- 
> 
> --- 
> You received this message because you are subscribed to the Google Groups 
> "Ledger" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.

>    Hi Ismael,
>    In your specific case, what I would do is avoid even doing the
>    adjustments, and when I need to make a sale, just sum up the cost bases in
>    all the historical lots to obtain the average cost basis at that point and
>    record a sale with that basis. The sum of the units, and the sum of the
>    cost bases (signed units x cost price), should separately be correct even
>    if the postings don't reduce each other.
>    I hope this helps,
>    On Tue, Oct 24, 2017 at 6:03 PM, Ismaël Bouya
>    <[1][email protected]> wrote:
> 
>      In France, the taxation model when buying and selling actions is based
>      on mean value of the actions rather than "older first". This means that
>      I have to use tweaks like that to have them correct in ledger:
>      ----------------------
>      2002/03/20 Buy Actions
>          Assets:Broker       10.00 Foo {5.00 EUR}
>          Assets:Checking    -50.00 EUR
> 
>      2002/03/25 Buy Actions
>          Assets:Broker       15.00 Foo {10.00 EUR}
>          Assets:Checking   -150.00 EUR
> 
>      ; In France, we consider the mean value of an action for taxation
>      2002/03/25 Price adjustment
>          Assets:Broker       25.00 Foo {8.00 EUR}
>          Assets:Broker      -10.00 Foo {5.00 EUR}  @ 1 Foo {8.00 EUR}
>          Assets:Broker      -15.00 Foo {10.00 EUR} @ 1 Foo {8.00 EUR}
>      -------------------
> 
>      Now, the problem comes when I buy some actions again, even with another
>      account:
>      --------------------
>      2002/03/20 Buy Actions
>          Assets:BrokerA      10.00 Foo {5.00 EUR}
>          Assets:Checking    -50.00 EUR
> 
>      2002/03/25 Buy Actions
>          Assets:BrokerA      15.00 Foo {10.00 EUR}
>          Assets:Checking   -150.00 EUR
> 
>      ; In France, we consider the mean value of an action for taxation
>      2002/03/25 Price adjustment
>          Assets:BrokerA      25.00 Foo {8.00 EUR}
>          Assets:BrokerA     -10.00 Foo {5.00 EUR}  @ 1 Foo {8.00 EUR}
>          Assets:BrokerA     -15.00 Foo {10.00 EUR} @ 1 Foo {8.00 EUR}
> 
>      2002/05/15 Buy Actions
>          Assets:BrokerB      10.00 Foo {50.00 EUR}
>          Assets:Checking    -500.00 EUR
> 
>      2002/05/25 Buy Actions
>          Assets:BrokerB      15.00 Foo {100.00 EUR}
>          Assets:Checking   -1500.00 EUR
> 
>      2002/05/25 Price adjustment
>          Assets:BrokerB      25.00 Foo {80.00 EUR}
>          Assets:BrokerB     -10.00 Foo {50.00 EUR}  @ 1 Foo {80.00 EUR}
>          Assets:BrokerB     -15.00 Foo {100.00 EUR} @ 1 Foo {80.00 EUR}
>      --------------------
> 
>      This example fails with "Error: Cannot compare amounts with different
>      commodities: 'Foo {8.00 EUR}' and 'Foo {80.00 EUR}'"
> 
>      I don’t understand where this error comes from, the two accounts are not
>      even related...
> 
>      Any hint how I could achieve my goal?
> 
>      Kind regards,
> 
>      --
> 
>      ---
>      You received this message because you are subscribed to the Google
>      Groups "Ledger" group.
>      To unsubscribe from this group and stop receiving emails from it, send
>      an email to [2][email protected].
>      For more options, visit [3]https://groups.google.com/d/optout.
> 
>    --
> 
>    ---
>    You received this message because you are subscribed to the Google Groups
>    "Ledger" group.
>    To unsubscribe from this group and stop receiving emails from it, send an
>    email to [4][email protected].
>    For more options, visit [5]https://groups.google.com/d/optout.
> 
> References
> 
>    Visible links
>    1. mailto:[email protected]
>    2. mailto:[email protected]
>    3. https://groups.google.com/d/optout
>    4. mailto:[email protected]
>    5. https://groups.google.com/d/optout


-- 
Ismael

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"Ledger" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Attachment: signature.asc
Description: PGP signature

Reply via email to