How do I obtain the "lot price"?

2017-08-03 Thread Bob Hossley
Thanks for any help you can give me.



*Question about Report Format String*The "lot price" (the price of one 
share) is shown in curly braces by the format string parameter %(amount).  
But I have been unable to obtain just the "lot price" using a format string 
parameter.  I suspect that %(price) was intended to be the "lot price" and 
that it is a bug that it displays the %(cost) instead.

*Question about the Ledger Python Extension*

How do you obtain the "lot price" using the Ledger Python Extension?

I suspect that either post.price or post.amount.price should be the "lot 
price" and that it is a bug that neither exists.



*File lots.ledger*Attached is lots.ledger, a small test journal that shows 
the problem:

2008-02-19 (0) SPDR Lehman Int'l  Tres. Bond ETF - Buy 100 shares
> Assets:Vanguard Trust Account:Vanguard Investments: Bonds:Taxable:SPDR 
> Barclays Int'l Bond ETF  BWX 200. @ $27.25
> Expenses:Investment Expenses:Commissions:Vanguard $2.18
> * Assets:Vanguard Trust Account:Cash - Vanguard California Tax-Free 
> MMF$-5,452.18
>
> 2008-02-19 (1) SPDR Lehman Int'l  Tres. Bond ETF - Buy 117 shares
> Assets:Vanguard Trust Account:Vanguard Investments: Bonds:Taxable:SPDR 
> Barclays Int'l Bond ETF  BWX 234. @ $27.24995726
> Expenses:Investment Expenses:Commissions:Vanguard $2.56
> * Assets:Vanguard Trust Account:Cash - Vanguard California Tax-Free 
> MMF$-6,379.05
>
> 2008-02-19 (2) SPDR Lehman Int'l  Tres. Bond ETF - Buy 700 shares
> Assets:Vanguard Trust Account:Vanguard Investments: Bonds:Taxable:SPDR 
> Barclays Int'l Bond ETF  BWX 1400. @ $27.25
> Expenses:Investment Expenses:Commissions:Vanguard$15.26
> * Assets:Vanguard Trust Account:Cash - Vanguard California Tax-Free 
> MMF   $-38,165.26
>
> 2017-06-23 (1to15) SPDR Lehman Int'l  Tres. Bond ETF - Sell 3229.1222 
> shares
> Assets:Vanguard Trust Account:Vanguard Federal Money Market Fund
> $50,736.76
> Expenses:Investment Expenses:Commissions:Vanguard $1.95
> Assets:Vanguard Trust Account:Vanguard Investments: Bonds:Taxable:SPDR 
> Barclays Int'l Bond ETF  BWX -200. @ $27.6656  ; Sold all of lot 0
> Assets:Vanguard Trust Account:Vanguard Investments: Bonds:Taxable:SPDR 
> Barclays Int'l Bond ETF  BWX -1400. @ $27.6656  ; Sold all of lot 2
> Assets:Vanguard Trust Account:Vanguard Investments: Bonds:Taxable:SPDR 
> Barclays Int'l Bond ETF  BWX -234. @ $27.66559829  ; Sold all of lot 1
>
>


*Showing the Reports Problem*Here is a report format that shows the problem 
when run on lots.ledger:

ledger -f lots.ledger reg --no-revalued --format 'code=%C 
> amount="%(amount)" quantity=%(quantity(amount)) cost=%(cost) 
> price=%(price)\n'
>

2017-08-02 15:34:43 /pri/git/Ledger4/bugs
> $ ledger -f lots.ledger reg --no-revalued --format 'code=%C 
> amount="%(amount)" quantity=%(quantity(amount)) cost=%(cost) 
> price=%(price)\n'
> code=(0)  amount="BWX 200. {$27.25} [08-Feb-19]" quantity=200 
> cost=$5,450.00 price=$5,450.00
> code=(0)  amount="$2.18" quantity=2.18 cost=$2.18 price=$2.18
> code=(0)  amount="$-5,452.18" quantity=-5452.18 cost=$-5,452.18 
> price=$-5,452.18
> code=(1)  amount="BWX 234. {$27.24995726} [08-Feb-19]" quantity=234 
> cost=$6,376.48999884 price=$6,376.48999884
> code=(1)  amount="$2.56" quantity=2.56 cost=$2.56 price=$2.56
> code=(1)  amount="$-6,379.05" quantity=-6379.05 cost=$-6,379.05 
> price=$-6,379.05
> code=(2)  amount="BWX 1400. {$27.25} [08-Feb-19]" quantity=1400 
> cost=$38,150.00 price=$38,150.00
> code=(2)  amount="$15.26" quantity=15.26 cost=$15.26 price=$15.26
> code=(2)  amount="$-38,165.26" quantity=-38165.26 cost=$-38,165.26 
> price=$-38,165.26
> code=(1to15)  amount="$50,736.76" quantity=50736.76 cost=$50,736.76 
> price=$50,736.76
> code=(1to15)  amount="$1.95" quantity=1.95 cost=$1.95 price=$1.95
> code=(1to15)  amount="BWX -200. {$27.6656} [17-Jun-23]" quantity=-200 
> cost=$-5,533.12 price=$-5,533.12
> code=(1to15)  amount="BWX -1400. {$27.6656} [17-Jun-23]" 
> quantity=-1400 cost=$-38,731.84 price=$-38,731.84
> code=(1to15)  amount="BWX -234. {$27.66559829} [17-Jun-23]" 
> quantity=-234 cost=$-6,473.7486 price=$-6,473.7486
> 2017-08-02 15:35:22 /pri/git/Ledger4/bugs
>
>


*File costPrice.py*Attached is costPrice.py, a Python script that shows the 
problem when run on lots.ledger.

Here is the print statement that generates the output:

print('code={code} amount="{amt}" quantity={qt} cost={cost} 
> price={price} amount.price={aprice}'.format(
> code=xact.code, amt=post.amount, qt=post.amount.number(),
> cost=post.cost, price=hasattr(post, 'price'),
> aprice=hasattr(post.amount.price, 'price')))
>


2017-08-02 16:00:18 /pri/git/Ledger4/bugs/price
> $ python2 costPrice.py lots.ledger
> code=0 amount="BWX 200. {$27.25} [08-Feb-19]" quantity=200 
> cost=$5,450.00 price=False 

Sorting on multiple keys and Sort Stability

2017-07-05 Thread Bob Hossley
The ledger sort is *NOT* "stable".  A sort is "stable" iff when multiple 
records have the same key, their original order is preserved. Consequently, 
I can't use the ledger sort to achieve sorting on multiple keys.  When I 
convert my GnuCash file to Ledger, the transactions are in random order. I 
want the transactions in my journal ordered first by date and second by 
payee. 

Is there any chance that ledger sort will be made "stable"?  Can anyone 
suggest a way to achieve the journal structure I want?


-- 

--- 
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 ledger-cli+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.