From 05c8f6ce88f5cc0f66689f1dbd3f9927997a2b31 Mon Sep 17 00:00:00 2001 From: "adam.harbas@a-net.ba" Date: Fri, 8 Jan 2016 09:36:28 +0100 Subject: [PATCH] Adding payment method --- .../app/models/delivery_destination.rb | 14 ++++++++++- back-office/app/views/carts/_show.html.erb | 23 +++++++------------ ..._payment_method_to_delivery_destination.rb | 5 ++++ front-api/db/schema.rb | 7 +++--- front-api/models/delivery_destination.rb | 15 +++++++++++- front-api/views/cart_trello.erb | 17 ++++---------- 6 files changed, 49 insertions(+), 32 deletions(-) create mode 100644 front-api/db/migrate/20160108081208_add_payment_method_to_delivery_destination.rb diff --git a/back-office/app/models/delivery_destination.rb b/back-office/app/models/delivery_destination.rb index ecb39d0..0ba1066 100644 --- a/back-office/app/models/delivery_destination.rb +++ b/back-office/app/models/delivery_destination.rb @@ -1,2 +1,14 @@ -class DeliveryDestination < ActiveRecord::Base +class DeliveryDestination < ActiveRecord::Base + def get_payment_string + case self.payment_method + when 'cash_on_delivery' + 'Pouzecem' + when 'paypal' + 'Paypal' + when 'pikpay' + 'Pikpay' + else + 'Nepoznato' + end + end end diff --git a/back-office/app/views/carts/_show.html.erb b/back-office/app/views/carts/_show.html.erb index eb9c5fc..5352327 100644 --- a/back-office/app/views/carts/_show.html.erb +++ b/back-office/app/views/carts/_show.html.erb @@ -3,14 +3,14 @@ .tg td{ } .tg th{ } -<% +<% dd = @record.delivery_destination c = @record %>

Ime: <%= dd.name %>

-

Adresa:
+

Adresa:
<%= dd.address %>
<%= dd.place.to_s.strip %> <%= Place.name_from_code(dd.place.to_s) %>
Bosna i Hercegovina

@@ -22,6 +22,8 @@ Bosna i Hercegovina

Telefon: +387 <%= dd.phone %>

+

Plaćanje: <%= dd.get_payment_string %>


+

Napomena:
<%= dd.note %>

@@ -29,8 +31,8 @@ Bosna i Hercegovina

Naručeno: <%= c.confirmed_at.in_time_zone("Europe/Sarajevo").strftime("%A %d.%m.%Y. %H:%M") %> -
-
+
+

<% if dd.instant_delivery %>

@@ -47,7 +49,7 @@ OVO JE NARUDŽBA ZA INSTANT DOSTAVU Total <% @record.item_in_carts.each do |iic| %> - + <%= iic.item.code %> <%= iic.item.name %> <%= iic.count %> @@ -70,15 +72,6 @@ OVO JE NARUDŽBA ZA INSTANT DOSTAVU <%= money(c.total) %> - +

- - - - - - - - - diff --git a/front-api/db/migrate/20160108081208_add_payment_method_to_delivery_destination.rb b/front-api/db/migrate/20160108081208_add_payment_method_to_delivery_destination.rb new file mode 100644 index 0000000..0c55649 --- /dev/null +++ b/front-api/db/migrate/20160108081208_add_payment_method_to_delivery_destination.rb @@ -0,0 +1,5 @@ +class AddPaymentMethodToDeliveryDestination < ActiveRecord::Migration + def change + add_column :delivery_destinations, :payment_method, :string, default: 'cash_on_delivery' + end +end diff --git a/front-api/db/schema.rb b/front-api/db/schema.rb index 8c9037a..4339239 100644 --- a/front-api/db/schema.rb +++ b/front-api/db/schema.rb @@ -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| diff --git a/front-api/models/delivery_destination.rb b/front-api/models/delivery_destination.rb index 95437dc..8237eaa 100644 --- a/front-api/models/delivery_destination.rb +++ b/front-api/models/delivery_destination.rb @@ -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 diff --git a/front-api/views/cart_trello.erb b/front-api/views/cart_trello.erb index 8e1f0df..f26709e 100644 --- a/front-api/views/cart_trello.erb +++ b/front-api/views/cart_trello.erb @@ -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 %>) - - - - - - - - -