【问题标题】:How to query Document directives in beancount query language?beancount查询语言如何查询Document指令?
【发布时间】:2023-01-26 08:02:47
【问题描述】:

我是文本文件复式记账的忠实粉丝,使用 beancount:https://github.com/beancount/beancount 使用 beancount 查询语言,我可以轻松地从我的文本文件创建报告(例如税收)。

在 beancount 中,可以在交易报表中添加文档链接(例如收据的 PDF),如

2020-02-04 * "Google" "Server" #tax
  document: "2020-02-04 3688657551.pdf"
  Liabilities:ErsteBank:Credit  -30.40 EUR
  Expenses:Professional:Server   30.40 EUR

在年底,我使用以下查询获取所有与税收相关的费用:

SELECT 
    account,  date, number as value, currency, description
FROM
    year = 2020
WHERE
    account ~ "Expenses:"
    AND 'tax' IN tags
ORDER BY date, account, betrag

是否可以在查询中包含文档指令的文件名,即“2020-02-04 3688657551.pdf”?

【问题讨论】:

    标签: accounting beancount


    【解决方案1】:

    @罗伯特, 尝试使用 post 中简要介绍的 any_meta('document')

    账本:

    2020-01-01 open Liabilities:ErsteBank:Credit
    2020-01-01 open Expenses:Professional:Server
    option "operating_currency" "EUR"
    
    
    2020-02-04 * "Google" "Server" #tax
      document: "2020-02-04 3688657551.pdf"
      Liabilities:ErsteBank:Credit  -30.40 EUR
      Expenses:Professional:Server   30.40 EUR
    

    询问:

    SELECT
        account, date, number as value, payee, any_meta('document') as document
    FROM
        year = 2020
    WHERE
        account ~ "Expenses:"
        AND 'tax' IN tags
    ORDER BY date, account
    

    结果:

    account date value payee document
    Expenses:Professional:Server 2020-02-04 30.40 Google 2020-02-04 3688657551.pdf

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多