Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added line item model and created a migration to add taxes

  • Loading branch information...
commit 10772c0bb7120a3bd223f72cc52b646b209f6ea6 1 parent 7d4fe37
@florida authored
View
3  app/models/lineitem.rb
@@ -0,0 +1,3 @@
+class Lineitem < ActiveRecord::Base
+ attr_accessible :order_id, :product_id, :quantity, :unit_price
+end
View
12 db/migrate/20121108232607_create_lineitems.rb
@@ -0,0 +1,12 @@
+class CreateLineitems < ActiveRecord::Migration
+ def change
+ create_table :lineitems do |t|
+ t.reference :product_id
+ t.reference :order_id
+ t.integer :quantity
+ t.float :unit_price
+
+ t.timestamps
+ end
+ end
+end
View
7 db/migrate/20121108232840_add_taxes_column_to_orders.rb
@@ -0,0 +1,7 @@
+class AddTaxesColumnToOrders < ActiveRecord::Migration
+ def change
+ add_column :orders, :hst, :float
+ add_column :orders, :gst, :float
+ add_column :orders, :pst, :float
+ end
+end
View
13 test/fixtures/lineitems.yml
@@ -0,0 +1,13 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
+
+one:
+ product_id:
+ order_id:
+ quantity: 1
+ unit_price: 1.5
+
+two:
+ product_id:
+ order_id:
+ quantity: 1
+ unit_price: 1.5
View
7 test/unit/lineitem_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class LineitemTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.