-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
34 lines (24 loc) · 839 Bytes
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
h1. Tab
Keep track of office tabs.
h2. Models
Users: id, name
Orders: id, LineItems
LineItems: id, order_id, name, cost, quantity
Transactions (Debits, Credits): id, type, line_item_id, user_id, amount, balance
h2. Scenarios
* Bob orders a pizza. Bob, Joe, and Clint split the cost.
o = Order.create
li = LineItem.create( :order => o,
:name => "Lg Antico Pizza",
:cost => 20_00, :quantity => 1 )
# Bob has paid $20 into the system, giving him credit
Credit.create(:line_item => li,
:user => bob,
:amount => 20_00)
# Each person owes $20 / 3, including Bob (he did eat, right?)
individual_cost = li.cost / users.size # $20.00 / 3
users.each do |u|
Debit.create( :line_item => li,
:user => u,
:amount => individual_cost)
end