0

I am creating an invoice table for the customers. Sometime they will have to send me the commission fees or sometime I send them fees (account balance). How to design a invoice table in this situation?

I have came up with this solution, im not sure if this is correct or what is the alternative way?

tbl_invoice
- invoice_id (PK)
- order_id (FK)
- invoice_date
- amount (copy the price from tbl_order.total table)
- status (Invoice Sent, Cancelled, Amount Received, Amount Sent)


tbl_Payments
 - invoice_id (FK)
 - amount_received (recieved commission fees from customer)
 - amount_sent (sent fees to customer)
 - date_received
 - date_sent

if the tbl_invoice.amount is -30.00 that mean customer will send me the fees.

if the tbl_invoice.amount is 30.00 then I will send the customer the fees.

Do I need tbl_invoice.amount field?

If you could redesign my tables how it should be that be great.

4

2 回答 2

2

一些东西:

  1. 将发票状态规范化为其自己的查找表,然后在发票表中放置一个状态 ID,而不是“已发送”、“已取消”等。

  2. 一定要保留发票金额。如果您需要考虑折扣,这可能必须与 tbl_order.total 中的价格值不同。在任何情况下,数字数据的存储成本都很低,如果您不必进行任何连接,查询速度会更快。

  3. 为 Payments 表提供其自己的 ID 列并将其设为 PK。

  4. 其余的看起来还可以。有两个表的情况,一个用于付款,另一个用于付款。如果你真的只需要保留金额和日期信息,那么我认为你不需要让它变得更复杂。

谢谢,克里斯。

于 2011-06-13T13:07:19.710 回答
0

您应该跟踪:

  • 应付金额
  • 发送金额
  • 收到的金额

这三个都很重要。在付款中,还要跟踪 fee_paid。

最后,通常最好使用 T-ledger 会计(即借方/贷方)来处理这类事情。如果您需要担心折扣、优惠券、退款、退单等问题,它会让事情变得更加整洁。

于 2011-06-13T11:05:23.440 回答