帐号管理
出自Opentaps Wiki
重要: 记账帐号(Billing accounts) 原先是在 ofbiz 框架下开发的. 目前它有几个问题: billing accounts 没有一个明确的事务(transactions) 或 授权记录, 没办法办理一个billing account的多货币处理, 并且一个billing account 仅能被一个订单使用. 因此, 它们目前仅为向后兼容而维护. 我们推荐你使用 Credit Limits 特性对接收帐号 (accounts receivable) 和为信用卡准备的礼物卡(gift cards for store credits). 如下的信息将会为需要和 legacy billing accounts工作的用户提供(早期版本的opentaps).
一个 billing account 可以被用来给客户贷款这样他们可以从你那里购买和过后支付. 一个 billing account 也可以用来 跟踪 store credits, 例如那些用来给客户为了返回订单的. 注意 可以跟踪 客户的 balances 而无需一个 billing account, 这样无需为接收帐号的工作正确(accounts receivables to work correctly)建立一个billing accounts.
一个 billing account 有一个accountLimit 而且可以和 订单关联 通过 OrderHeader 和 发票 以及通过PaymentApplication的支付(payments). 帐户的限制字段控制可以支付到billing account的最大值并且等于这个帐号的信贷额度(credit limit for this account). 支付 (发票) 和 billing account相关联通过 PaymentApplication 增加 (或减少) 可以被支付到这个帐号的数量 而且 减少 (增加) 顾客的帐号上的平衡(balance on the account).
如果一个billing account 在 OrderHeader中, 这样它将是第一个用来支付订单的方法. captureOrderPayments 服务会试图首先消耗 billing account ,在使用其他的支付方法之前.
Billing 帐号有表格(from) 和 经过日期,来控制它的合法性. 对于一个 对客户有效的billing account, 客户需要对“Bill To Customer”有BillingAccountRole的角色.
对于 billing accounts,有三种平衡表(balances):
- 净(Net) balance 汇总所有的发票,减去所有的支出(payments)它是 customer’s 突出的(outstanding) balance的综合.
- “Billing account balance” 是净 balance 减去 所有 outstanding的总和 (不完整的或取消的) 对于 billing account的orders 作为一种支付方法来限制.
- 可用的(Available) balance 是 account limit 减去 billing account balance.
例如, 如果你有一个限额为$1,000的credit card . 你目前的 balance 是 $500, 同时你用$200 消费, 厂家授权给你的卡,但还没有支付. 在这个例子里, 你的帐号有一个 "限额" 是 $1,000, 净 balance 是 $500, a billing account balance 是 $700, 同时 available balance of $300.
目录 |
使用 Billing Account
- orderHeader 实体值有一个 billingAccountId 字段 而且它被连接到BillingAccount 实体(entity). 使用 orderHeader.getRelatedOne("BillingAccount") 来得到订单的Billing Account.
- billsettings.ftl (或它的相同的): 得到输入参数 checkOutPaymentId = 'EXT_BILLACT' 和 billingAccountId = '10000'
- billingAccount 对于一个订单是设置org.ofbiz.order.shoppingcart.Shoppingcart.setBillingAccount 方法, 设置它给购物车(shopping cart). 这个 billing account 在最终的检查前被设置并且 createOrder 方法 被调用来建立订单. 还有一个相匹配的 ShoppingCart.getBillingAccountId 方法.
- the setBillingAccount org.ofbiz.order.shoppingcart.CheckOutEvents: setCheckOutOptions 和setCheckOutPages – 这两个方法使用 request.getParameter("billingAccountId") 来设置 billing account. 它们应该调用 CheckOutHelper 方法(这个方法里调用 setCheckOutPaymentInternal 方法来设置 billing account).
- 订单经理使用 finalizeOrderEntry (它不处理billingAccountId 参数).
Billing Account Balances 是如何被计算的
- BillingAccountWorker.getBillingAccountBalance 用来计算出billing account可以支付的总额.
- 它当前执行这个计算:
BillingAccount 限额: $10,000 减去 所有的没有完成的订单 (Not COMPLETED or CANCELED): $334.58 减去 所有的没有被支付的发票: $60.83 加 任何对于发票的支付 (在这个例子中没有) 对于金额为$9,604.59的 balance, 这是电子商务程序显示的信息.
“Charge” 更多到 Billing Account
建立一个给你的客户的发票, 然后建立一个支付(Payment)给你的客户, 然后让这些金额 charged(被支付) 到 PaymentApplication (在 Applications tab中) 同时输入 invoiceId 和billingAccountId. 这将让invoice 可以被支付(同时带上billing account 和增加它的outstanding balance).
“Pay Down” 到Billing Account
为你的客户,建立一个 Payment, 然后,为了总量(配合billingAccountId),建立一个 PaymentApplication (在 Applications tab下面). 这将让 billing account's outstanding balance 减少.

