Last active
March 20, 2018 18:28
-
-
Save gjaldon/33f2e00aaa330fc150b71ce37c821721 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
``` | |
Order schema | |
- has_many order_items | |
- has_many taxes | |
- has_many fees | |
- has_many discounts | |
- id | |
- timestamps | |
- print_count (for storing number of times order was printed) | |
- note - string | |
- subtotal - price of all selected items without fees and taxes applied | |
- total_price - price of all selected items with fees and taxes applied | |
- completed - timestamp. to keep track of how long before an order is fulfilled | |
- snapshot - json field - stores all relevant data at the time of order | |
Tax schema | |
- value - decimal | |
- percentage - boolean | |
- name | |
Fee schema | |
- value - decimal | |
- name | |
Discount schema | |
- value - decimal | |
- percentage - boolean | |
- name | |
OrderItem schema | |
- has_one selected_item | |
- has_many selected_modifiers - must be selected from modifiers of the selected_item | |
- has_many taxes | |
- price - store price of selected item with modifiers selected | |
- note | |
SelectedItem | |
- belongs_to item - must be a combo_option or an item_option | |
- price | |
SelectedModifier | |
- belongs_to modifier | |
- price | |
Refund schema - should have at least one association. associations here represent the refunded item | |
- timestamps | |
- has_many order_items | |
- has_many selected_items | |
- has_many selected_modifiers | |
- has_one order | |
- reason | |
Comp - should have at least one comp. comps here represent the comped item | |
- timestamps | |
- has_many order_items | |
- has_many selected_items | |
- has_many selected_modifiers | |
- has_one order | |
- reason | |
``` |
@gjaldon this accounts for multiple partial refunds on a single order too though, right?
@ian-bateman yes, it does. If a Refund has no order association but has at least one selected or order_item or selected_modifier, this will mean partial refund of the order.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If a Refund has_one order, then the whole order is refunded. If a refund has one selected_item, then only that one selected item is refunded. Did it this way instead to avoid columns that would usually be null anyway.