|
113 | 113 | t.integer :author_id |
114 | 114 | t.timestamps null: false |
115 | 115 | end |
| 116 | + |
| 117 | + create_table :customers, force: true do |t| |
| 118 | + t.string :name |
| 119 | + end |
| 120 | + |
| 121 | + create_table :purchase_orders, force: true do |t| |
| 122 | + t.date :order_date |
| 123 | + t.date :requested_delivery_date |
| 124 | + t.date :delivery_date |
| 125 | + t.integer :customer_id |
| 126 | + t.string :delivery_name |
| 127 | + t.string :delivery_address_1 |
| 128 | + t.string :delivery_address_2 |
| 129 | + t.string :delivery_city |
| 130 | + t.string :delivery_state |
| 131 | + t.string :delivery_postal_code |
| 132 | + t.float :delivery_fee |
| 133 | + t.float :tax |
| 134 | + t.float :total |
| 135 | + t.timestamps null: false |
| 136 | + end |
| 137 | + |
| 138 | + create_table :line_items, force: true do |t| |
| 139 | + t.integer :purchase_order_id |
| 140 | + t.string :part_number |
| 141 | + t.string :quantity |
| 142 | + t.float :item_cost |
| 143 | + t.timestamps null: false |
| 144 | + end |
116 | 145 | end |
117 | 146 |
|
118 | 147 | ### MODELS |
@@ -239,7 +268,15 @@ def add(breed) |
239 | 268 | def remove(id) |
240 | 269 | @breeds.delete(id) |
241 | 270 | end |
| 271 | +end |
242 | 272 |
|
| 273 | +class CustomerOrder < ActiveRecord::Base |
| 274 | +end |
| 275 | + |
| 276 | +class PurchaseOrder < ActiveRecord::Base |
| 277 | +end |
| 278 | + |
| 279 | +class LineItem < ActiveRecord::Base |
243 | 280 | end |
244 | 281 |
|
245 | 282 | ### PORO Data - don't do this in a production app |
@@ -369,6 +406,14 @@ class ExpenseEntriesController < JSONAPI::ResourceController |
369 | 406 | class IsoCurrenciesController < JSONAPI::ResourceController |
370 | 407 | end |
371 | 408 | end |
| 409 | + |
| 410 | + module V6 |
| 411 | + class PurchaseOrdersController < JSONAPI::ResourceController |
| 412 | + end |
| 413 | + |
| 414 | + class LineItemsController < JSONAPI::ResourceController |
| 415 | + end |
| 416 | + end |
372 | 417 | end |
373 | 418 |
|
374 | 419 | ### RESOURCES |
@@ -721,6 +766,42 @@ def fetchable_fields |
721 | 766 | end |
722 | 767 | end |
723 | 768 |
|
| 769 | +module Api |
| 770 | + module V6 |
| 771 | + class CustomerResource < JSONAPI::Resource |
| 772 | + attribute :name |
| 773 | + |
| 774 | + has_many :purchase_orders |
| 775 | + end |
| 776 | + |
| 777 | + class PurchaseOrderResource < JSONAPI::Resource |
| 778 | + attribute :order_date |
| 779 | + attribute :requested_delivery_date |
| 780 | + attribute :delivery_date |
| 781 | + attribute :delivery_name |
| 782 | + attribute :delivery_address_1 |
| 783 | + attribute :delivery_address_2 |
| 784 | + attribute :delivery_city |
| 785 | + attribute :delivery_state |
| 786 | + attribute :delivery_postal_code |
| 787 | + attribute :delivery_fee |
| 788 | + attribute :tax |
| 789 | + attribute :total |
| 790 | + |
| 791 | + has_one :customer |
| 792 | + has_many :line_items |
| 793 | + end |
| 794 | + |
| 795 | + class LineItemResource < JSONAPI::Resource |
| 796 | + attribute :part_number |
| 797 | + attribute :quantity |
| 798 | + attribute :item_cost |
| 799 | + |
| 800 | + has_one :purchase_order |
| 801 | + end |
| 802 | + end |
| 803 | +end |
| 804 | + |
724 | 805 | warn 'start testing Name Collisions' |
725 | 806 | # The name collisions only emmit warnings. Exceptions would change the flow of the tests |
726 | 807 |
|
|
0 commit comments