Fix bug 1187: Allow balance assertions with multiple posts to same account
This commit is contained in:
parent
e27ae09e22
commit
d541cceaf7
5 changed files with 117 additions and 1 deletions
|
|
@ -1655,7 +1655,8 @@ post_t * instance_t::parse_post(char * line,
|
|||
|
||||
switch (account_total.type()) {
|
||||
case value_t::AMOUNT:
|
||||
diff -= account_total.as_amount();
|
||||
if (account_total.as_amount().commodity_ptr() == diff.commodity_ptr())
|
||||
diff -= account_total.as_amount();
|
||||
break;
|
||||
|
||||
case value_t::BALANCE:
|
||||
|
|
@ -1673,6 +1674,16 @@ post_t * instance_t::parse_post(char * line,
|
|||
DEBUG("textual.parse", "line " << context.linenum << ": "
|
||||
<< "POST assign: diff = " << diff);
|
||||
|
||||
// Subtract amounts from previous posts to this account in the xact.
|
||||
for (post_t* p : xact->posts) {
|
||||
if (p->account == post->account &&
|
||||
p->amount.commodity_ptr() == diff.commodity_ptr()) {
|
||||
diff -= p->amount;
|
||||
DEBUG("textual.parse", "line " << context.linenum << ": "
|
||||
<< "Subtract " << p->amount << ", diff = " << diff);
|
||||
}
|
||||
}
|
||||
|
||||
if (post->amount.is_null()) {
|
||||
// balance assignment
|
||||
if (! diff.is_zero()) {
|
||||
|
|
|
|||
19
test/regress/1187_1.test
Normal file
19
test/regress/1187_1.test
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
2006/08/17 * Au Bon Bec
|
||||
Dépense:Alimentation:Restaurant 100,00 €
|
||||
Passif:Crédit:Banque
|
||||
|
||||
2006/08/20 * Retrait
|
||||
Dépense:Liquide 60,00 €
|
||||
Passif:Crédit:Banque -60,00 €
|
||||
Passif:Crédit:Banque 60,00 € = -100,00 €
|
||||
Actif:Courant:Cc -60,00 €
|
||||
|
||||
test bal
|
||||
-60,00 € Actif:Courant:Cc
|
||||
160,00 € Dépense
|
||||
100,00 € Alimentation:Restaurant
|
||||
60,00 € Liquide
|
||||
-100,00 € Passif:Crédit:Banque
|
||||
--------------------
|
||||
0
|
||||
end test
|
||||
18
test/regress/1187_2.test
Normal file
18
test/regress/1187_2.test
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
2001/01/01 * Balance
|
||||
Actif:Courant:Cc 10000,00 F = 10000,00 F
|
||||
Equity
|
||||
|
||||
2002/01/11 * Passage à l'euro
|
||||
Actif:Courant:Cc -10000,00 F = 0,00 F
|
||||
Actif:Courant:Cc 1524,49 € = 1524,49 €
|
||||
Revenu:Devise 10000,00 F
|
||||
Revenu:Devise -1524,49 €
|
||||
|
||||
test bal
|
||||
1524,49 € Actif:Courant:Cc
|
||||
-10000,00 F Equity
|
||||
10000,00 F
|
||||
-1524,49 € Revenu:Devise
|
||||
--------------------
|
||||
0
|
||||
end test
|
||||
36
test/regress/1187_3.test
Normal file
36
test/regress/1187_3.test
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
2000/01/01 Multiple posts
|
||||
A $5.00
|
||||
B $7.20
|
||||
C $-114.99
|
||||
D
|
||||
|
||||
2000/01/02 Many assertions
|
||||
A $2.00
|
||||
A $3.00 = $10.00
|
||||
B $0.80 = $8.00
|
||||
C $-0.01 = $-115.00
|
||||
B $1.00
|
||||
C $1
|
||||
C $4 = $-110
|
||||
D
|
||||
|
||||
2000/01/03 Incremental
|
||||
A $1.00 = $11.00
|
||||
A $1.00 = $12.00
|
||||
A $1.00 = $13.00
|
||||
D
|
||||
|
||||
2000/01/04 Assignment
|
||||
A $2
|
||||
A = $25
|
||||
D $-10
|
||||
D $-2
|
||||
|
||||
test bal
|
||||
$25.00 A
|
||||
$9.00 B
|
||||
$-110.00 C
|
||||
$76.00 D
|
||||
--------------------
|
||||
0
|
||||
end test
|
||||
32
test/regress/1187_4.test
Normal file
32
test/regress/1187_4.test
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
2000/01/01 Multiple commodities
|
||||
A $5.00
|
||||
A 32 F
|
||||
B $-12
|
||||
C
|
||||
|
||||
2000/01/02 Assertions
|
||||
A $1 = $6
|
||||
A 1 F = 33 F
|
||||
A $1 = $7
|
||||
A 1 F = 34 F
|
||||
B 3 F = 3 F
|
||||
B $12 = $0
|
||||
B 1 F = 4 F
|
||||
C
|
||||
|
||||
2000/01/03 Assignments
|
||||
A = $0
|
||||
A -4 F = 30 F
|
||||
B $-7 = $-7
|
||||
B = 0 F
|
||||
C $14
|
||||
C 8 F
|
||||
|
||||
test bal
|
||||
30 F A
|
||||
$-7.00 B
|
||||
$7.00
|
||||
-30 F C
|
||||
--------------------
|
||||
0
|
||||
end test
|
||||
Loading…
Add table
Reference in a new issue