Skip to content

Instantly share code, notes, and snippets.

@antillas21
Last active December 17, 2015 22:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save antillas21/5680197 to your computer and use it in GitHub Desktop.
Save antillas21/5680197 to your computer and use it in GitHub Desktop.
AndreBadi random ideas
  • customer has many transactions
  • transactions can be payments or purchases
  • transaction fields: [ customer_id, created_at, amount, transaction_type ]
  • purchases has many line_items
  • line_item fields: [ name, color, size, cost, price, qty: { default: 1}, item_total ]
  • customer has one balance ( difference between purchases and payments )

Reset option

  • customer transactions are not preserved forever
  • admin settings include a 'reset transaction data' feature that will delete all transaction history for all customers
# /customers.json
[
{
:id, :name, :email, :phone, :balance
},
{
:id, :name, :email, :phone, :balance
}
]
# /customers/1.json
{
:id, :name, :email, :phone, :balance,
:transactions => [
{
:id, :created_at, :customer_id, :amount, :transaction_type
},
{
:id, :created_at, :customer_id, :amount, :transaction_type
}
]
}
# /purchases.json
[
{
:id, :customer_id, :created_at, :amount, :transaction_type,
customer: {
:id, :name
}
},
{
:id, :customer_id, :created_at, :amount, :transaction_type,
customer: {
:id, :name
}
}
]
# /purchases/1.json
{
:id, :customer_id, :created_at, :amount, :transaction_type,
line_items: [
{
:id, :purchase_id, :name, :color, :size, :qty, :cost, :price, :item_total
}
],
customer: {
:id, :name, :email, :phone
}
}
# /payments.json
[
{
:id, :customer_id, :created_at, :amount,
customer: {
:id, :name
}
}
]
# /payments/1.json
{
:id, :customer_id, :created_at, :amount,
customer: {
:id, :name, :email, :phone
}
}
@ecoreng
Copy link

ecoreng commented May 30, 2013

/purchases/1.json

{
  :id, :customer_id, :created_at, :amount, :transaction_type,
  line_items: [
    {
      :id, :purchase_id, :name, :color, :size, :qty, :cost, :price, :item_total
    }
  ],
  customer: {
    :id, :name, :email, :phone
  }
}

/purchases/1.json

{
  :id,
  customer: {
    :id, :name, :email, :phone
  },
 :created_at, :amount, :transaction_type,
  line_items: [
    {
      :id, :purchase_id, :name, :color, :size, :qty, :cost, :price, :item_total
    }
  ],
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment