BaoXuebin / beancount-gs

基于 beancount 提供个人记账财务管理的 RESTful API 服务(包含前端页面)
https://www.yuque.com/chuyi-ble7p/beancount-gs
MIT License
317 stars 42 forks source link

一个月出现复数次汇率变化后报错:账目不匹配 #82

Closed mikumiku52099 closed 3 months ago

mikumiku52099 commented 4 months ago

基本报错信息: /data/beancount/364dcf1d38a5de6a98030f449d62a129b298d81d/month/2024-06.bean:307: No position matches "Posting(account='Liabilities:Life:中国银行信用卡', units=3.19 USD, cost=CostSpec(number_per=Decimal('7.2789'), number_total=None, currency='CNY', date=None, label=None, merge=False), price=None, flag=None, meta={'filename': '/data/beancount/364dcf1d38a5de6a98030f449d62a129b298d81d/month/2024-06.bean', 'lineno': 310})" against balance (-3.19 USD {7.242 CNY, 2024-06-02})

经查询后发现,在6月出现两次外币交易,两次外币交易的汇率不一致,分别为7.2789和7.242,但是我一旦修改汇率,整月的汇率都会统一,从而导致 No position matches 错误

请问该如何解决报错?

BaoXuebin commented 4 months ago
2024-07-01 * "" "汇率验证1"
 Assets:Flow:Cash:现金 -2.00 USD {7.2789 CNY}
 Expenses:Life:Food:Fruit:水果 14.56 CNY

2024-07-08 * "" "汇率验证2"
 Assets:Flow:Cash:现金 -2.00 USD
 Expenses:Life:Food:Coffee:咖啡 2.00 CNY

你可以查看下账本的源文件,是类似这种吗,这个看上去应该是记录的时候,没有识别到 USD 的汇率信息。

你可以手动尝试修改为:

2024-07-08 * "" "汇率验证2"
 Assets:Flow:Cash:现金 -2.00 USD {7.242 CNY}
 Expenses:Life:Food:Coffee:咖啡
mikumiku52099 commented 4 months ago

2 这是两次账目的情况。 这是报错的账目,应该是没有您说的那个情况。

BaoXuebin commented 4 months ago

这个可能是你相关的外币账户 Liabilities:Life:中国银行信用卡 或者 Expenses:Life:Subscribe:境外订阅、购物 设置了 FIFO 的换算方式。

image

删除这个 "FIFO" 试试

https://beancount.github.io/docs//how_inventories_work.html#fifo-and-lifo-booking

mikumiku52099 commented 4 months ago

您好,我删除了FIFO后依然出现报错 /data/beancount/364dcf1d38a5de6a98030f449d62a129b298d81d/month/2024-06.bean:327: No position matches "Posting(account='Liabilities:Life:中国银行信用卡', units=3.19 USD, cost=CostSpec(number_per=Decimal('7.2789'), number_total=None, currency='CNY', date=None, label=None, merge=False), price=None, flag=None, meta={'filename': '/data/beancount/364dcf1d38a5de6a98030f449d62a129b298d81d/month/2024-06.bean', 'lineno': 330})" against balance (-3.19 USD {7.2425 CNY, 2024-06-02})

2024-06-20 * "还信用卡" Assets:Flow:美元 3.19 USD {7.2789 CNY} Assets:Flow:中国银行 -23.22 CNY Liabilities:Life:中国银行信用卡 3.19 USD {7.2789 CNY} Assets:Flow:美元 -3.19 USD {7.2789 CNY}