Adding payment method

This commit is contained in:
adam.harbas@a-net.ba
2016-01-08 09:36:28 +01:00
parent 2a0e326862
commit 05c8f6ce88
6 changed files with 49 additions and 32 deletions

View File

@@ -0,0 +1,5 @@
class AddPaymentMethodToDeliveryDestination < ActiveRecord::Migration
def change
add_column :delivery_destinations, :payment_method, :string, default: 'cash_on_delivery'
end
end

View File

@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20151124061357) do
ActiveRecord::Schema.define(version: 20160108081208) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -62,11 +62,12 @@ ActiveRecord::Schema.define(version: 20151124061357) do
t.boolean "phone_verified"
t.string "phone_verification_code"
t.string "email_verification_code"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "user_id"
t.string "anonymous_id_string"
t.boolean "instant_delivery", default: false
t.string "payment_method", default: "cash_on_delivery"
end
create_table "delivery_time_estimations", force: :cascade do |t|

View File

@@ -1,4 +1,4 @@
class DeliveryDestination < ActiveRecord::Base
class DeliveryDestination < ActiveRecord::Base
has_one :cart
belongs_to :user
@@ -11,4 +11,17 @@ class DeliveryDestination < ActiveRecord::Base
result = DeliveryDestination.create!(attributes)
return result
end
def get_payment_string
case self.payment_method
when 'cash_on_delivery'
'Pouzecem'
when 'paypal'
'Paypal'
when 'pikpay'
'Pikpay'
else
'Nepoznato'
end
end
end

View File

@@ -1,10 +1,10 @@
<%
<%
dd = @cart.delivery_destination
c = @cart
%>
**Ime:** <%= dd.name %>
**Ime:** <%= dd.name %>
**Adresa:**
<%= dd.address %>
@@ -17,6 +17,8 @@ Bosna i Hercegovina
**Telefon: ** +387 <%= dd.phone %>
**Plaćanje: ** <%= dd.get_payment_string %>
**Napomena: **
<%= dd.note %>
@@ -37,16 +39,7 @@ Bosna i Hercegovina
Dostava
1 x <%= Helper.money(c.delivery_cost) %> = <%= Helper.money(c.delivery_cost) %>
**UKUPNO:** <%= Helper.money(c.total) %>
[Pogledati OVAJ LINK](https://www.ribica.ba/backoffice/carts/<%= @cart.id %>)