{"id":17126384,"url":"https://github.com/kellpossible/doublecount","last_synced_at":"2025-06-11T03:07:00.260Z","repository":{"id":57621646,"uuid":"244234430","full_name":"kellpossible/doublecount","owner":"kellpossible","description":"A double entry accounting system/library for Rust","archived":false,"fork":false,"pushed_at":"2020-06-27T10:09:13.000Z","size":128,"stargazers_count":16,"open_issues_count":5,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-18T11:18:48.985Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kellpossible.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-03-01T22:34:11.000Z","updated_at":"2024-06-02T11:24:35.000Z","dependencies_parsed_at":"2022-08-26T23:50:32.956Z","dependency_job_id":null,"html_url":"https://github.com/kellpossible/doublecount","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kellpossible%2Fdoublecount","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kellpossible%2Fdoublecount/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kellpossible%2Fdoublecount/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kellpossible%2Fdoublecount/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kellpossible","download_url":"https://codeload.github.com/kellpossible/doublecount/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kellpossible%2Fdoublecount/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259189677,"owners_count":22819092,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-14T18:47:50.879Z","updated_at":"2025-06-11T03:07:00.210Z","avatar_url":"https://github.com/kellpossible.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Doublecount [![crates.io badge](https://img.shields.io/crates/v/doublecount.svg)](https://crates.io/crates/doublecount) [![docs.rs badge](https://docs.rs/doublecount/badge.svg)](https://docs.rs/doublecount/) [![license badge](https://img.shields.io/github/license/kellpossible/doublecount)](https://github.com/kellpossible/doublecount/blob/master/LICENSE.txt) [![github action badge](https://github.com/kellpossible/doublecount/workflows/Rust/badge.svg)](https://github.com/kellpossible/doublecount/actions?query=workflow%3ARust)\n\nA double entry accounting system/library for Rust.\n\nThis project is very much inspired by [beancount](http://furius.ca/beancount/),\nhowever it currently presents a much simpler model. It has been designed to\nembed within other applications for the purpose of running accounting\ncalculations.\n\nCommodities within the system are represented using the primitives provided by\nthe [commodity](https://crates.io/crates/commodity) library, which is in turn\nbacked by [rust_decimal](https://crates.io/crates/rust_decimal).\n\nThis library is under active development, however it should already be usable\nfor some simple purposes. There's likely to be some API changes in the future to\nallow transactions/actions to be streamed into the system, and also to support\nparallel computations of transactions to allow large programs to efficiently\nexecuted on multi-core computers.\n\n**[Changelog](./CHANGELOG.md)**\n\n## Optional Features\n\nThe following features can be enabled to provide extra functionality:\n\n+ `serde-support`\n  + Enables support for serialization/de-serialization via `serde`\n\n## Usage\n\n```rust\nuse doublecount::{\n    AccountStatus, EditAccountStatus, Account, Program, Action,\n    ProgramState, Transaction, TransactionElement, BalanceAssertion,\n    ActionTypeValue,\n};\nuse commodity::{CommodityType, Commodity};\nuse chrono::NaiveDate;\nuse std::rc::Rc;\nuse std::str::FromStr;\n\n// create a commodity from a currency's iso4317 alphanumeric code\nlet aud = Rc::from(CommodityType::from_str(\"AUD\", \"Australian Dollar\").unwrap());\n\n// Create a couple of accounts\nlet account1 = Rc::from(Account::new_with_id(Some(\"Account 1\"), aud.id, None));\nlet account2 = Rc::from(Account::new_with_id(Some(\"Account 2\"), aud.id, None));\n\n// create a new program state, with accounts starting Closed\nlet mut program_state = ProgramState::new(\n    \u0026vec![account1.clone(), account2.clone()],\n    AccountStatus::Closed\n);\n\n// open account1\nlet open_account1 = EditAccountStatus::new(\n    account1.id,\n    AccountStatus::Open,\n    NaiveDate::from_str(\"2020-01-01\").unwrap(),\n);\n\n// open account2\nlet open_account2 = EditAccountStatus::new(\n    account2.id,\n    AccountStatus::Open,\n    NaiveDate::from_str(\"2020-01-01\").unwrap(),\n);\n\n// create a transaction to transfer some commodity\n// from account1 to account2.\nlet transaction1 = Transaction::new(\n    Some(String::from(\"Transaction 1\")),\n    NaiveDate::from_str(\"2020-01-02\").unwrap(),\n    vec![\n        TransactionElement::new(\n            account1.id,\n            Some(Commodity::from_str(\"-2.52 AUD\").unwrap()),\n            None,\n        ),\n        TransactionElement::new(\n            account2.id,\n            Some(Commodity::from_str(\"2.52 AUD\").unwrap()),\n            None,\n        ),\n    ],\n);\n\n// create a balance assertion (that will cause the program to return an error\n// if it fails), to check that the balance of account1 matches the expected\n// value of -1.52 AUD at the start of the date of 2020-01-03\nlet balance_assertion1 = BalanceAssertion::new(\n    account1.id,\n    NaiveDate::from_str(\"2020-01-03\").unwrap(),\n    Commodity::from_str(\"-2.52 AUD\").unwrap()\n);\n\n// create another transaction to transfer commodity from\n// account2 to account1, using the simpler syntax.\nlet transaction2 =  Transaction::new_simple(\n   Some(\"Transaction 2\"),\n   NaiveDate::from_str(\"2020-01-03\").unwrap(),\n   account2.id,\n   account1.id,\n   Commodity::from_str(\"1.0 AUD\").unwrap(),\n   None,\n);\n\nlet balance_assertion2 = BalanceAssertion::new(\n    account1.id,\n    NaiveDate::from_str(\"2020-01-04\").unwrap(),\n    Commodity::from_str(\"-1.52 AUD\").unwrap()\n);\n\nlet balance_assertion3 = BalanceAssertion::new(\n    account2.id,\n    NaiveDate::from_str(\"2020-01-04\").unwrap(),\n    Commodity::from_str(\"1.52 AUD\").unwrap()\n);\n\nlet actions: Vec\u003cRc\u003cActionTypeValue\u003e\u003e = vec![\n    Rc::new(open_account1.into()),\n    Rc::new(open_account2.into()),\n    Rc::new(transaction1.into()),\n    Rc::new(balance_assertion1.into()),\n    Rc::new(transaction2.into()),\n    Rc::new(balance_assertion2.into()),\n    Rc::new(balance_assertion3.into()),\n];\n\n// create a program from the actions\nlet program = Program::new(actions);\n\n// run the program\nprogram_state.execute_program(\u0026program).unwrap();\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkellpossible%2Fdoublecount","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkellpossible%2Fdoublecount","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkellpossible%2Fdoublecount/lists"}