简体   繁体   English

会计系统设计与数据库

[英]Accounting System design & databases

I am working on a simple invoicing and accounting applications, but I am totally lost on how to represent accounting-transactions(journal-entries) in a database. 我正在开发一个简单的发票和会计应用程序,但是我完全迷失了如何在数据库中表示会计交易(新闻条目)。 Using a separate debit and credit column in the database seems like one way, but most of the Open Source Accounting I have seen use a single amount column. 在数据库中使用单独的借方和贷方列似乎是一种方法,但是我见过的大多数开源会计都使用一个金额列。 This I assume simplifies the mathematics a lot. 我认为这大大简化了数学。 But then how do I convert debits, and credits to numerical values. 但是,然后我如何将借方和贷方转换为数值。 Wikipedia Helped a little , but when i tried to cross check with an accounting system, it doesn't looks how it's done. Wikipedia有所帮助 ,但是当我尝试与会计系统进行交叉核对时,它看起来并不怎么完成。

Here's the export from that accounting system: 这是该会计系统的出口

Take a look at journal 326. While the sum of amount in this case = 0, the sum of credits isn't equal to sum of debits (Debiting 29 from Consulting & Accounting(E), Debiting 31.39 from AP(L), and crediting 2.39 to Sales Tax(L)). 看一下日记帐326。在这种情况下,金额的总和= 0,而贷项的总和不等于借项的总和(从Consulting&Accounting(E)借29,从AP(L)借31.39,以及将2.39计入营业税(L))。

However if I look at it as Debiting -31.39 from AP, It does. 但是,如果我将其视为从AP借记-31.39,则可以。 However I am not sure if we could credit/debit negative values. 但是我不确定是否可以贷记/借记负值。

Can someone explain how databases and accounting principles go together? 有人可以解释数据库和会计原理如何结合在一起吗?

Martin Fowler's "Analysis Patterns" has a nice chapter on modeling accounting systems. 马丁·福勒(Martin Fowler)的“分析模式”在会计系统建模方面有一章不错。 Maybe it can help you. 也许可以帮到您。

I think you'll be better off thinking about the problem in terms of objects rather than trying to map it onto a relational database. 我认为您最好从对象的角度考虑问题,而不是尝试将其映射到关系数据库。 Databases are declarative and set-based; 数据库是声明性的且基于集合; objects encapsulate data with operations in components. 对象通过组件中的操作封装数据。 I think the latter will lend itself better to modeling accounting, especially if you marry it with aspect-oriented programming. 我认为后者将更适合于对会计建模,尤其是将它与面向方面的编程结合使用时。 Let the database just be the way you persist things and keep the logic in the middle tier. 让数据库成为您持久化事物并将逻辑保持在中间层的方式。

I think the problem of transaction 326 you mentioned about is that it seems you have done on the wrong side of Debit/Credit things. 我认为您提到的事务326的问题在于,您似乎在借方/贷方事务中做错了。

The correct one should be that : Debiting 29 from Consulting & Accounting, and Debiiting 2.39 from Sales Tax. 正确的选择应该是:从咨询和会计中扣除29,从营业税中扣除2.39。 (in case that this is the Tax you have to pay as a consumer) , then Crediiting 31.39 from AP, (如果这是您作为消费者必须支付的税款),然后从AP爬网31.39,

Normally, AP will be on the Credit side, except when you settle down your payment. 通常,除非您结清付款,否则AP将处于“信用”方。 Then the transaction would be Debiting xx.xx from AP, then Credit xx.xx from Cash/Bank 然后交易将是从AP借记xx.xx,然后从现金/银行贷记xx.xx

Handling these Debit/Credit things in separate columns may cause the database easier to read. 在单独的列中处理这些借项/贷项可能会使数据库更易于阅读。 By the way, UI that separate these columns is also more communicable with end users. 顺便说一下,分隔这些列的UI也可以与最终用户通信。 In my point of view, the more we put things in the resemble fashions of what users learned from accouting classes, the less time we need to spend on telling them how to use the software. 以我的观点,我们越是按照用户从结业课程中学到的东西来做事情,就越不用花时间告诉他们如何使用该软件。

We can't use negative value on accounting transactions. 我们不能在会计交易中使用负值。 But on the DBMS side, we can keep things in the same column if we use + for Debitings, and - for Creditings. 但是在DBMS方面,如果我们将+用于借记,将-用于贷记,则可以将其放在同一列中。 Anyhow, you still have to convert them back to absolutely positive value when exporting to accounting reports. 无论如何,您在导出到会计报告时仍必须将它们转换回绝对正值。

Check out SQL-Ledger , a free-software accounting system implemented with Perl and PostgreSQL. 查看SQL-Ledger ,这是一个由Perl和PostgreSQL实现的免费软件记帐系统。 Should give you a working example. 应该给你一个工作的例子。 (I have no affiliation with them but I've used it before and it was satisfactory for basic accounting.) (我与他们没有任何隶属关系,但我以前使用过它,对于基本会计来说是令人满意的。)

What I am going to outline is from memory, and quite possibly is an 'old fashioned' way to represent accounts. 我要概述的是内存中的内容,很可能是代表帐户的“老式”方式。

**Definition of Debit - any or all of these conditions ** **借方的定义-任何或所有这些条件**

  1. Increase of an asset (eg whenever you invoice someone) 资产增加(例如,每当您开具发票时)
  2. Increase of an Expense (buying stationary) 费用增加(购买固定费用)

**Definition of Credit - any or all of these conditions ** **信用额度-任何或所有这些条件**

  1. Increase of an income or Decrease of an asset 收入增加或资产减少
  2. Increase of an Liability 责任增加

In your account's table, you can have a flag-type column called 'Normal balance' or 'typical balance' - 在您帐户的表中,可以有一个标记类型的列,称为“正常余额”或“典型余额”-

  • for a/c receivable account - normal balance is "D" or debit. 对于应收帐款科目-正常余额为“ D”或借方。
  • for a/c payable account - normal balance is "C" or credit. 对于A / C应付帐款-正常余额为“ C”或贷项。

Whenever there is an invoice transaction - it posts against AR (accounts receivable) - and it posts a 'normal balance' ie it is treated as a debit ammount. 每当有发票交易时-都按应收帐款(应收帐款)过帐-并且过帐“正常余额”,即被视为借方金额。

Whenever a customer pays against an invoice (full or partial), its an (abnormal) against the AR account - hence it will be a credit. 每当客户用发票(全部或部分)付款时,就用AR帐户(异常)付款-因此它将是贷方。

Whenever a vendor sends you an invoice, you will post a normal balance on the AP account, ie a credit. 每当供应商向您发送发票时,您都将在AP帐户上过帐正常余额,即贷项。 Whenever you pay a vendor it will be an (abnormal -ie debit) posting against the AP account. 每当您付款给供应商时,这都是针对AP帐户的(异常借记)过帐。

Your invoice-class or your invoice transaction knows that it will post normally against AR (Accounts receivable account). 您的发票类或发票交易知道它将正常针对AR(应收帐款帐户)过帐。

Similarly your payment-transaction or payment-controller-model knows that it will post a credit against the AR . 同样,您的付款交易或付款控制器模型知道它将向AR贷记贷项。

Remember that when you invoice someone, you are "building an asset", by creating a "receivable" . 请记住,为某人开票时,您是在通过创建“应收款”来“建立资产”。 Hence ARs are treated as assets, unless of course they haven't been paid for years. 因此,应收账款被视为资产,除非它们当然已经多年没有付款了。

HTH. HTH。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM