diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/beancount-gs.iml b/.idea/beancount-gs.iml new file mode 100644 index 0000000..5e764c4 --- /dev/null +++ b/.idea/beancount-gs.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..ebe4216 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/example/.beancount-ns/account_type.json b/example/.beancount-ns/account_type.json new file mode 100644 index 0000000..a04147d --- /dev/null +++ b/example/.beancount-ns/account_type.json @@ -0,0 +1,20 @@ +{ + "Assets:Fixed": "固定资产", + "Assets:Invest": "投资", + "Assets:Invest:Fund": "基金", + "Assets:Flow": "现金流", + "Expenses:Life:Food": "饮食", + "Expenses:Life:Travel": "出行", + "Expenses:Life:Shopping": "购物", + "Expenses:Life:House": "居住", + "Expenses:Life:Subscribe": "订阅", + "Expenses:Life:Other": "其他", + "Expenses:Life:Hobby": "爱好", + "Expenses:Work": "工作支出", + "Expenses:Life": "生活消费", + "Income:Work": "工作收入", + "Income:Gov": "财政补贴", + "Income:Invest": "投资收益", + "Liabilities:Cycle": "周期性贷款", + "Liabilities:Life": "消费贷款" +} \ No newline at end of file diff --git a/example/account/assets.bean b/example/account/assets.bean new file mode 100644 index 0000000..0c97b79 --- /dev/null +++ b/example/account/assets.bean @@ -0,0 +1,9 @@ +%startDate% open Assets:Fixed:House:商品房 %operatingCurrency% +%startDate% open Assets:Invest:Stock:股票 %operatingCurrency% +%startDate% open Assets:Invest:Fund:自定义基金 SHR +%startDate% open Assets:Invest:Deposit:定期 %operatingCurrency% +%startDate% open Assets:Invest:Gold:黄金 %operatingCurrency% +%startDate% open Assets:Flow:Bank:ICBC:工商银行 %operatingCurrency% +%startDate% open Assets:Flow:EBank:AliPay:支付宝 %operatingCurrency% +%startDate% open Assets:Flow:EBank:WxPay:微信支付 %operatingCurrency% +%startDate% open Assets:Flow:Cash:现金 %operatingCurrency% \ No newline at end of file diff --git a/example/account/equity.bean b/example/account/equity.bean new file mode 100644 index 0000000..361553b --- /dev/null +++ b/example/account/equity.bean @@ -0,0 +1 @@ +%startDate% open Equity:OpeningBalances \ No newline at end of file diff --git a/example/account/expenses.bean b/example/account/expenses.bean new file mode 100644 index 0000000..3b4f6fe --- /dev/null +++ b/example/account/expenses.bean @@ -0,0 +1,33 @@ +%startDate% open Expenses:Life:Food:Meal:早餐 %operatingCurrency% +%startDate% open Expenses:Life:Food:Meal:午餐 %operatingCurrency% +%startDate% open Expenses:Life:Food:Meal:晚餐 %operatingCurrency% +%startDate% open Expenses:Life:Food:Meal:聚餐 %operatingCurrency% +%startDate% open Expenses:Life:Food:Coffee:咖啡 %operatingCurrency% +%startDate% open Expenses:Life:Food:Drink:饮料 %operatingCurrency% +%startDate% open Expenses:Life:Food:Fruit:水果 %operatingCurrency% +%startDate% open Expenses:Life:Food:Snack:零食 %operatingCurrency% +%startDate% open Expenses:Life:Travel:Bus:公交地铁 %operatingCurrency% +%startDate% open Expenses:Life:Travel:Taxi:出租车 %operatingCurrency% +%startDate% open Expenses:Life:Travel:Train:火车 %operatingCurrency% +%startDate% open Expenses:Life:Travel:Airplane:飞机 %operatingCurrency% +%startDate% open Expenses:Life:Travel:Bike:共享单车 %operatingCurrency% +%startDate% open Expenses:Life:Shopping:Clothes:衣服 %operatingCurrency% +%startDate% open Expenses:Life:Shopping:Shoe:鞋 %operatingCurrency% +%startDate% open Expenses:Life:Shopping:Sock:袜子 %operatingCurrency% +%startDate% open Expenses:Life:Shopping:购物 %operatingCurrency% +%startDate% open Expenses:Life:House:Rent:房租 %operatingCurrency% +%startDate% open Expenses:Life:House:Hotel:酒店 %operatingCurrency% +%startDate% open Expenses:Life:House:Water:用水 %operatingCurrency% +%startDate% open Expenses:Life:House:Gas:天然气 %operatingCurrency% +%startDate% open Expenses:Life:House:Electricity:用电 %operatingCurrency% +%startDate% open Expenses:Life:Subscribe:Mobile:手机话费 %operatingCurrency% +%startDate% open Expenses:Life:Subscribe:会员订阅 %operatingCurrency% +%startDate% open Expenses:Life:Other:Exchange:红包转账 %operatingCurrency% +%startDate% open Expenses:Life:Other:Commission:手续费 %operatingCurrency% +%startDate% open Expenses:Life:Hobby:Book:图书 %operatingCurrency% +%startDate% open Expenses:Life:Hobby:Camera:摄影 %operatingCurrency% +%startDate% open Expenses:Life:Hobby:Travel:Ticket:门票 %operatingCurrency% +%startDate% open Expenses:Life:Hobby:Travel:Souvenir:纪念品 %operatingCurrency% +%startDate% open Expenses:Work:Tax:个人所得税 %operatingCurrency% +%startDate% open Expenses:Work:Insurance:三险 %operatingCurrency% +%startDate% open Expenses:Work:Punish:考勤 %operatingCurrency% \ No newline at end of file diff --git a/example/account/income.bean b/example/account/income.bean new file mode 100644 index 0000000..fdfffb7 --- /dev/null +++ b/example/account/income.bean @@ -0,0 +1,6 @@ +%startDate% open Income:Work:Salary:工作收入 %operatingCurrency% +%startDate% open Income:Work:Bonus:奖金 %operatingCurrency% +%startDate% open Income:Work:HouseFund:单位公积金 %operatingCurrency% +%startDate% open Income:Gov:退税 %operatingCurrency% +%startDate% open Income:Gov:政府补贴 %operatingCurrency% +%startDate% open Income:Invest:投资收益 %operatingCurrency% \ No newline at end of file diff --git a/example/account/liabilities.bean b/example/account/liabilities.bean new file mode 100644 index 0000000..88f7e95 --- /dev/null +++ b/example/account/liabilities.bean @@ -0,0 +1,4 @@ +%startDate% open Liabilities:Cycle:ICBC:房贷 %operatingCurrency% +%startDate% open Liabilities:Life:JD:京东白条 %operatingCurrency% +%startDate% open Liabilities:Life:Huabei:花呗 %operatingCurrency% +%startDate% open Liabilities:Life:CreditCard:信用卡 %operatingCurrency% \ No newline at end of file diff --git a/example/history.bean b/example/history.bean new file mode 100644 index 0000000..e69de29 diff --git a/example/includes.bean b/example/includes.bean new file mode 100644 index 0000000..5ca73bc --- /dev/null +++ b/example/includes.bean @@ -0,0 +1,12 @@ +; 账户定义 +include "./account/assets.bean" +include "./account/equity.bean" +include "./account/expenses.bean" +include "./account/income.bean" +include "./account/liabilities.bean" +; 多币种配置 +include "./price/prices.bean" +; 历史数据(用于 导入 之前的数据) +include "./history.bean" +; 新的数据(按月拆分) +include "./month/months.bean" \ No newline at end of file diff --git a/example/index.bean b/example/index.bean new file mode 100644 index 0000000..a63b54d --- /dev/null +++ b/example/index.bean @@ -0,0 +1,11 @@ +option "title" "我的账本" +option "operating_currency" "%operatingCurrency%" +option "render_commas" "TRUE" + +; fava 配置 +1970-01-01 custom "fava-option" "interval" "day" +1970-01-01 custom "fava-option" "language" "zh_CN" + +include "./includes.bean" + + diff --git a/example/month/months.bean b/example/month/months.bean new file mode 100644 index 0000000..e69de29 diff --git a/example/price/commodities.bean b/example/price/commodities.bean new file mode 100644 index 0000000..e69de29 diff --git a/example/price/prices.bean b/example/price/prices.bean new file mode 100644 index 0000000..70a911e --- /dev/null +++ b/example/price/prices.bean @@ -0,0 +1,3 @@ +include "./commodities.bean" + +%startDate% price SHR 2.00 %operatingCurrency% \ No newline at end of file diff --git a/server.go b/server.go index 62db591..6776f9b 100644 --- a/server.go +++ b/server.go @@ -6,8 +6,28 @@ import ( "github.com/gin-gonic/gin" ) -func main() { - route := gin.Default() - route.StaticFS("/", http.Dir("./public")) - _ = http.ListenAndServe(":3001", nil) +func InitLedgerFiles() { + +} + +func LoadLedgerCache() { + +} + +func RegisterRoute(route *gin.Engine) { + route.StaticFS("/", http.Dir("./public")) +} + +func main() { + // 默认端口号 + var port = ":3001" + // 初始化账本文件结构 + InitLedgerFiles() + // 加载缓存 + LoadLedgerCache() + // 启动服务 + route := gin.Default() + // 注册路由 + RegisterRoute(route) + _ = http.ListenAndServe(port, nil) }