@@ -263,7 +263,7 @@ fn auto_posting_rule() {
263263}
264264
265265#[ test]
266- fn two_full_transactions ( ) {
266+ fn full_transaction_1 ( ) {
267267 assert_format (
268268 r#"
2692692024-01-01 opening balances ; At the start, declare pre-existing balances this way.
@@ -273,33 +273,39 @@ fn two_full_transactions() {
273273 equity:start ; One amount can be left blank. $-10500 is inferred here.
274274 ; Some of these accounts we didn't declare above,
275275 ; so -s/--strict would complain.
276+ "# ,
277+ r#"
278+ 2024-01-01 opening balances ; At the start, declare pre-existing balances this way.
279+ assets:savings $10000 ; Account names can be anything. lower case is easy to type.
280+ assets:checking $1000 ; assets, liabilities, equity, revenues, expenses are common.
281+ liabilities:credit card $-500 ; liabilities, equity, revenues balances are usually negative.
282+ equity:start ; One amount can be left blank. $-10500 is inferred here.
283+ ; Some of these accounts we didn't declare above,
284+ ; so -s/--strict would complain.
285+ "# ,
286+ ) ;
287+ }
276288
277- 2024-01-03 ! (12345) pay rent
289+ #[ test]
290+ fn full_transaction_2 ( ) {
291+ assert_format (
292+ r#"2024-01-03 ! (12345) pay rent
278293 ; Additional transaction comment lines, indented.
279294 ; There can be a ! or * after the date meaning "pending" or "cleared".
280295 ; There can be a parenthesised (code) after the date/status.
281296 ; Amounts' sign shows direction of flow.
282297 assets:checking $-500 ; Minus means removed from this account (credit).
283298 expenses:rent $500 ; Plus means added to this account (debit).
284299"# ,
285- r#"
286- 2024-01-01 opening balances ; At the start, declare pre-existing balances this way.
287- assets:savings $10000 ; Account names can be anything. lower case is easy to type.
288- assets:checking $1000 ; assets, liabilities, equity, revenues, expenses are common.
289- liabilities:credit card $-500 ; liabilities, equity, revenues balances are usually negative.
290- equity:start ; One amount can be left blank. $-10500 is inferred here.
291- ; Some of these accounts we didn't declare above,
292- ; so -s/--strict would complain.
293-
294- 2024-01-03 ! (12345) pay rent
300+ r#"2024-01-03 ! (12345) pay rent
295301 ; Additional transaction comment lines, indented.
296302 ; There can be a ! or * after the date meaning "pending" or "cleared".
297303 ; There can be a parenthesised (code) after the date/status.
298304 ; Amounts' sign shows direction of flow.
299305 assets:checking $-500 ; Minus means removed from this account (credit).
300306 expenses:rent $500 ; Plus means added to this account (debit).
301307"# ,
302- ) ;
308+ )
303309}
304310
305311#[ test]
@@ -330,8 +336,8 @@ fn transaction_with_shares() {
330336"# ,
331337 r#"
3323382024-01-15 buy some shares, in two lots ; Cost can be noted.
333- assets:investments:2024-01-15 2.0 AAAA @ $1.50 ; @ means per-unit cost
334- assets:investments:2024-01-15-02 3.0 AAAA @@ $4 ; @@ means total cost
339+ assets:investments:2024-01-15 2.0 AAAA @ $1.50 ; @ means per-unit cost
340+ assets:investments:2024-01-15-02 3.0 AAAA @@ $4 ; @@ means total cost
335341 ; ^ Per-lot subaccounts are sometimes useful.
336342 assets:checking $-7
337343"# ,
@@ -409,7 +415,7 @@ fn separate_transactions() {
409415}
410416
411417#[ test]
412- fn assert_balance_transaction ( ) {
418+ fn balance_transaction ( ) {
413419 // assert balance transactions are formatted aligning the equal sign
414420 assert_format (
415421 r#"
@@ -436,8 +442,8 @@ fn assert_balance_transaction() {
436442 assets:bank:gold 0 gold = -10 gold
437443 assets:pouch 0 gold = 4 gold
438444 assets:pouch 0 "Chocolate Frogs" = 3 "Chocolate Frogs"
439- assets:investments:2024-01-15 0.0 AAAA = 2.0 AAAA @ $1.50
440- assets:investments:2024-01-15-02 0.0 AAAA = 3.0 AAAA @@ $4
445+ assets:investments:2024-01-15 0.0 AAAA = 2.0 AAAA @ $1.50
446+ assets:investments:2024-01-15-02 0.0 AAAA = 3.0 AAAA @@ $4
441447 liabilities:credit card $0 = $-500
442448"# ,
443449 ) ;
@@ -448,15 +454,17 @@ fn complex_transaction() {
448454 assert_format (
449455 r#"
4504562024-01-15 hello ; a comment
457+ assets:checking 10000,00€ @ 32543.000345€ ==* $56424324€ ; posting
451458 assets:checking 10000€ @ 32543.000345€ ==* $56424324€ ; comments
452459 expenses:food $10.010000 @@ $33.3 = 56€ ; must be
453460 foo 50000000.0000000000€ @@ 65579€ == $78.7 ; aligned
454461"# ,
455462 r#"
4564632024-01-15 hello ; a comment
457- assets:checking 10000€ @ 32543.000345€ ==* $56424324€ ; comments
458- expenses:food $10.010000 @@ $33.3 = 56€ ; must be
459- foo 50000000.0000000000€ @@ 65579€ == $78.7 ; aligned
464+ assets:checking 10000,00€ @ 32543.000345€ ==* $56424324€ ; posting
465+ assets:checking 10000€ @ 32543.000345€ ==* $56424324€ ; comments
466+ expenses:food $10.010000 @@ $33.3 = 56€ ; must be
467+ foo 50000000.0000000000€ @@ 65579€ == $78.7 ; aligned
460468"# ,
461469 ) ;
462470}
@@ -485,8 +493,8 @@ fn lots() {
485493 assets:investments:2024-01-15-02 0.0 AAAA = 3.0 AAAA @@ $4
486494"# ,
487495 r#"2024-01-15 foobar
488- assets:investments:2024-01-15 0.0 AAAA = 2.0 AAAA @ $1.50
489- assets:investments:2024-01-15-02 0.0 AAAA = 3.0 AAAA @@ $4
496+ assets:investments:2024-01-15 0.0 AAAA = 2.0 AAAA @ $1.50
497+ assets:investments:2024-01-15-02 0.0 AAAA = 3.0 AAAA @@ $4
490498"# ,
491499 ) ;
492500}
@@ -511,14 +519,15 @@ fn issue_27() {
511519 assets:cash USDT 120
512520"# ,
513521 r#"2024-01-02 exchange imaginary currency
514- income:cash EUR-100 @@ USDT120
515- assets:cash USDT120
522+ income:cash EUR -100 @@ USDT 120
523+ assets:cash USDT 120
516524"# ,
517525 )
518526}
519527
528+ // https://github.com/mondeja/hledger-fmt/issues/32
520529#[ test]
521- fn issue_32_unicode ( ) {
530+ fn unicode_in_entry_name ( ) {
522531 assert_noop_format (
523532 r#"2025-09-23 * Zakupy
524533 a.ca -106,98
@@ -608,3 +617,31 @@ fn transaction_with_multi_spaced_description_and_valid_comment() {
608617"# ,
609618 ) ;
610619}
620+
621+ // https://github.com/mondeja/hledger-fmt/issues/32
622+ #[ test]
623+ fn transaction_with_multiple_currency_formatting ( ) {
624+ assert_noop_format (
625+ r#"2025-01-01 Example transaction
626+ assets:acc1 £10,000.00
627+ assets:acc2 1.000,00€
628+ assets:acc3 £1000,00
629+ assets:acc3 £1000€
630+ equity
631+ "# ,
632+ )
633+ }
634+
635+ // https://github.com/mondeja/hledger-fmt/issues/32
636+ #[ test]
637+ fn space_as_thousands_separator ( ) {
638+ assert_noop_format (
639+ r#"2025-09-21 * Example transaction
640+ a.bankaccount -2 049,44
641+ e.expanse 116,99
642+ e.someotherexpense $1 018,99
643+ e.anotherexpense 1,99
644+ e.thirdexpense
645+ "# ,
646+ )
647+ }
0 commit comments