From 46f9bef2464610221d81830e80464f7fbf9667c2 Mon Sep 17 00:00:00 2001 From: Nweni Date: Sun, 4 Jun 2017 14:50:50 +0630 Subject: [PATCH 1/6] fixed conflict --- Gemfile | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Gemfile b/Gemfile index 985d976c..4daa7759 100644 --- a/Gemfile +++ b/Gemfile @@ -9,19 +9,17 @@ end # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '~> 5.1.0' # Use mysql as the database for Active Record -<<<<<<< HEAD + #gem 'mysql2', '>= 0.3.18', '< 0.5' gem 'pg' -======= + gem 'mysql2', '>= 0.3.18', '< 0.5' #Use PosgreSQL -gem 'pg' + # redis server for cable # gem 'redis', '~> 3.0' - ->>>>>>> a2c9996b765666db4cbcbef188fcfa2d27a7a6e2 # Use Puma as the app server gem 'puma', '~> 3.0' # Use SCSS for stylesheets From cd3177c6829ca2a5c36b1d63f94bc3eff729d2c2 Mon Sep 17 00:00:00 2001 From: Nweni Date: Mon, 19 Jun 2017 15:22:50 +0630 Subject: [PATCH 2/6] order --- app/assets/stylesheets/origami.scss | 4 ++++ app/models/order.rb | 2 +- dump.rdb | Bin 18163 -> 17902 bytes 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/assets/stylesheets/origami.scss b/app/assets/stylesheets/origami.scss index 71a9915e..c96237fa 100644 --- a/app/assets/stylesheets/origami.scss +++ b/app/assets/stylesheets/origami.scss @@ -95,6 +95,10 @@ background-color:#7a62d3; } +.orange{ + background-color:#FF7F50; +} + .red { background-color:#ff0000; } diff --git a/app/models/order.rb b/app/models/order.rb index 14fd8cda..96382c07 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -246,7 +246,7 @@ class Order < ApplicationRecord .joins("left join orders on orders.order_id = booking_orders.order_id") .joins("left join sales on sales.sale_id = bookings.sale_id") .where("sales.sale_status='completed'") - .group("sales.sale_id") + .group("sales.sale_id,bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status,orders.order_id") # For PG #bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status,orders.order_id end diff --git a/dump.rdb b/dump.rdb index 211fd505548a6a60b85596d4201ab6d1155b4f22..e6612cd4d745c3a266a4b581523a7577e82df134 100644 GIT binary patch delta 571 zcmey|%lNLFae}12;V-VD)RfF(-K5Nt;sXx9Sd&XKb5jpJh;fhn#Zg+EnxdPVntN!1 z1V6(+hTlRAlM|W56-;!E3=SwTh!vM4mRO}FX6B@(SQ!}@n(G>v=^C0HkOwM~lmjvp zu`4mKIFJfb!fI%G@D;=4>x?RFU=tZ8*D)zg)?_ka0jZdnWHhl%j?GNh!2CeqWJV_8 z&427Jvdc2D6_%!!rWP}?r=+GOmgbZ&=NA?;vlgY66jjP^erxf8k@>2V^W;Fjmd%?C z(-! zzU1Tr)YP(BMJ1V$@itieArDXq#FDwjIgFd-Mcy-R{xANDaq|L}*Nn^$fzA>XYuTJ2 zQ^Gj;qeaVR6D6RdZcNVC?ARP{o65+1*zp?JoGW}8jLeUmg29feHZNghzV75cxlprh z^AqhfM&=t(=jKagF>cP&dz>% delta 735 zcmY+AO-vI}6oq>`Q!65C{e<%tsGfc)=K3|DM%UC!Vo>(Bn1mBWUH6Wtk{S$frV+)}mtasY9{N!ArCUf&;x0%rBADis*Oy1<{Ko!6yYhL07=bva*uQE{ETS-*FF6 zDy!*=l)*?urW^4{(bZOY>XSDk& zc6wPu9hVf{*~`VVO59LYti7#eN-4;(#WV}_P5TG$wt^d@(W&F>e4o{%62Zg)e#HfG3J zwth6}5mg*kgyqxp|6=G1H)Yi6N~#A-cs0AyvdW178&l-A8geXKiB>>vebFH}(j zV^guN=DFp*Qsf4C(eRkgwdR11_k0I3UpGao$5KFdoV&oRMWW zGSIEQO<+oq!CLl52{UF|yqE^!XrH1@ji$#HssNp@EB`}z7}kIe`pRH- kbD9k-E?CUAT9`nQql@s#zONn)74h$ldmlE+(;YAW0K#ksk^lez From 6035e6612adc475feb381bb21e6ebd3764adf516 Mon Sep 17 00:00:00 2001 From: Nweni Date: Tue, 20 Jun 2017 07:40:24 +0630 Subject: [PATCH 3/6] udpate --- app/views/origami/home/show.html.erb | 216 +++++++++++++++++++++++++++ 1 file changed, 216 insertions(+) create mode 100644 app/views/origami/home/show.html.erb diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb new file mode 100644 index 00000000..4c784627 --- /dev/null +++ b/app/views/origami/home/show.html.erb @@ -0,0 +1,216 @@ +
+ +
+ + + + + +
+ +
+
+ +
+
+ + +
+
+
+
+ + +
+
+ <% @tables.each do |table| %> + <% if table.status == 'occupied' %> +
+
+ <%= table.name %> +
+
+ <% else %> +
+
+ <%= table.name %> +
+
+ <% end %> + <% end %> +
+
+ + +
+
+ <% @rooms.each do |room| %> + <% if room.status == 'occupied' %> +
+
+ <%= room.name %> +
+
+ <% else %> +
+
+ <%= room.name %> +
+
+ <% end %> + <% end %> +
+
+ + +
+
+ +
+
+ +
+
+
+ +
+
+ +
+ + + +
+
+
+
ORDER DETAILS
+
+
+
+
+

Receipt No: + <% if @status == 'sale' %> + <%= @obj.receipt_no rescue '' %> + <% end %> +

+
+
+

Date: <%= @obj.created_at.utc.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%>

+
+
+
+
+

Customer :

+
+ +
+
+ + + + + + + + <% + # For Sale Items + sub_total = 0 + if @status == "sale" + @obj.sale_items.each do |sale_item| + sub_total = sub_total + sale_item.price + %> + <% unless sale_item.price <= 0 %> + + + + + + <% + end + end + end + %> + + <% + # For Order Items + if @selected_item_type == "order" + @selected_item.order_items.each do |order_item| + sub_total = sub_total + (order_item.qty*order_item.price) + %> + + + + + + <% + end + end + %> + +
ItemsQTY + Price +
<%= sale_item.product_name %><%= sale_item.qty %><%= sale_item.price %>
<%= order_item.item_name %><%= order_item.qty %><%= order_item.qty*order_item.price %>
+
+ +
+
+
+ + +
+ + + + + + + + + + + +
+
+ From 618a89472aa33e20b33e4f6f8dd836908108e4bd Mon Sep 17 00:00:00 2001 From: Nweni Date: Thu, 29 Jun 2017 13:35:09 +0630 Subject: [PATCH 4/6] shift open/close --- app/controllers/api/bill_controller.rb | 2 +- app/controllers/home_controller.rb | 2 +- .../origami/cash_ins_controller.rb | 15 +++ .../origami/cash_outs_controller.rb | 13 +++ app/controllers/origami/home_controller.rb | 1 + .../origami/request_bills_controller.rb | 2 +- app/controllers/origami/shifts_controller.rb | 11 ++- app/models/employee.rb | 1 + app/models/payment_journal.rb | 20 ++++ app/models/sale_payment.rb | 10 +- app/models/shift_sale.rb | 6 +- app/views/origami/cash_ins/new.html.erb | 79 ++++++++++++++++ app/views/origami/cash_outs/new.html.erb | 44 +++++++++ app/views/origami/home/index.html.erb | 19 +++- app/views/origami/shifts/edit.html.erb | 3 +- app/views/origami/shifts/show.html.erb | 94 ++++++++++++++++++- .../origami/shifts/update_shift.json.jbuilder | 1 + config/routes.rb | 6 +- .../20170627035218_create_payment_journals.rb | 2 +- db/seeds.rb | 7 ++ 20 files changed, 320 insertions(+), 18 deletions(-) create mode 100644 app/controllers/origami/cash_ins_controller.rb create mode 100644 app/controllers/origami/cash_outs_controller.rb create mode 100644 app/views/origami/cash_ins/new.html.erb create mode 100644 app/views/origami/cash_outs/new.html.erb create mode 100644 app/views/origami/shifts/update_shift.json.jbuilder diff --git a/app/controllers/api/bill_controller.rb b/app/controllers/api/bill_controller.rb index 4fdd0c35..9671ba47 100644 --- a/app/controllers/api/bill_controller.rb +++ b/app/controllers/api/bill_controller.rb @@ -38,7 +38,7 @@ class Api::BillController < Api::ApiController item_price_by_accounts = SaleItem.calculate_price_by_accounts(@sale_items) printer = Printer::ReceiptPrinter.new(print_settings) - printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, item_price_by_accounts) + # printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, item_price_by_accounts) end diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 0700ce0b..3136417f 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -80,7 +80,7 @@ class HomeController < ApplicationController redirect_to dashboard_path elsif employee.role == "cashier" #check if cashier has existing open cashier - shift = ShiftSale.current_open_shift(employee) + shift = ShiftSale.current_open_shift(employee.id) if !shift.nil? redirect_to origami_root_path else diff --git a/app/controllers/origami/cash_ins_controller.rb b/app/controllers/origami/cash_ins_controller.rb new file mode 100644 index 00000000..dd78bc1b --- /dev/null +++ b/app/controllers/origami/cash_ins_controller.rb @@ -0,0 +1,15 @@ +class Origami::CashInsController < BaseOrigamiController + + def new + end + + def create + reference = params[:reference] + remark = params[:remark] + amount = params[:amount] + payment_method = params[:payment_method] + payment_method_reference = params[:payment_method_reference] + p_jour = PaymentJournal.new + p_jour.cash_in(reference, remark, amount, payment_method, payment_method_reference, current_user.id) + end +end diff --git a/app/controllers/origami/cash_outs_controller.rb b/app/controllers/origami/cash_outs_controller.rb new file mode 100644 index 00000000..ac079a39 --- /dev/null +++ b/app/controllers/origami/cash_outs_controller.rb @@ -0,0 +1,13 @@ +class Origami::CashOutsController < BaseOrigamiController + + def new + end + + def create + reference = params[:reference] + remark = params[:remark] + amount = params[:amount] + p_jour = PaymentJournal.new + p_jour.cash_out(reference, remark, amount, current_user.id) + end +end diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index 1b0aa491..32f4ab12 100644 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -6,6 +6,7 @@ class Origami::HomeController < BaseOrigamiController @rooms = Room.all.active.order('status desc') @complete = Sale.all @orders = Order.all.order('date desc') + # @shift = ShiftSale.current_open_shift(current_user.id) end # origami table detail diff --git a/app/controllers/origami/request_bills_controller.rb b/app/controllers/origami/request_bills_controller.rb index 314835a2..a04936fc 100644 --- a/app/controllers/origami/request_bills_controller.rb +++ b/app/controllers/origami/request_bills_controller.rb @@ -38,7 +38,7 @@ class Origami::RequestBillsController < BaseOrigamiController printer = Printer::ReceiptPrinter.new(print_settings) - printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, item_price_by_accounts,member_info,shop_details) + # printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, item_price_by_accounts,member_info,shop_details) # redirect_to origami_path(@sale_data.sale_id) end diff --git a/app/controllers/origami/shifts_controller.rb b/app/controllers/origami/shifts_controller.rb index b20c4d7b..1a7a5289 100644 --- a/app/controllers/origami/shifts_controller.rb +++ b/app/controllers/origami/shifts_controller.rb @@ -4,10 +4,11 @@ class Origami::ShiftsController < BaseOrigamiController end def show + @shift = ShiftSale.current_open_shift(current_user.id) end def new - @float = Lookup.where('lookup_type=?','float') + @float = Lookup.where('lookup_type=?','float_value') end def create @@ -16,6 +17,14 @@ class Origami::ShiftsController < BaseOrigamiController @shift.create(opening_balance,current_user) end + def update_shift + @shift = ShiftSale.current_open_shift(current_user.id) + if @shift + @shift.shift_closed_at = DateTime.now.utc + @shift.save + end + end + def edit end end diff --git a/app/models/employee.rb b/app/models/employee.rb index 1816c2e3..2d70768d 100644 --- a/app/models/employee.rb +++ b/app/models/employee.rb @@ -1,6 +1,7 @@ class Employee < ApplicationRecord has_secure_password + has_many :shit_sales validates_presence_of :name, :role validates_presence_of :password, :on => [:create] validates :emp_id, uniqueness: true, numericality: true, length: {in: 1..4}, allow_blank: true diff --git a/app/models/payment_journal.rb b/app/models/payment_journal.rb index 237f9cd4..6105a574 100644 --- a/app/models/payment_journal.rb +++ b/app/models/payment_journal.rb @@ -1,2 +1,22 @@ class PaymentJournal < ApplicationRecord + + def cash_in(reference, remark, amount, payment_method, payment_method_reference, current_user) + self.payment_references = reference + self.remark = remark + self.credit_amount = amount + self.payment_method = payment_method + self.payment_status = 'paid' + self.payment_method_references = payment_method_reference + self.created_by = current_user + self.save + end + + def cash_out(payment_reference, remark, amount, current_user) + self.payment_references = payment_reference + self.remark = remark + self.debit_amount = amount + self.payment_status = 'paid' + self.created_by = current_user + self.save + end end diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 7f39aa18..7a835618 100644 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -247,12 +247,14 @@ class SalePayment < ApplicationRecord end self.sale.sale_status = "completed" self.sale.save! - shift = ShiftSale.current_open_shift(self.sale.cashier_id) - if shift - shift.update(self.sale) - end table_update_status(sObj) rebat(sObj) + shift = ShiftSale.current_open_shift(self.sale.cashier_id) + puts shift + if !shift.nil? + puts ">>>> shift >>>>>>" + shift.update(self.sale) + end end end diff --git a/app/models/shift_sale.rb b/app/models/shift_sale.rb index ea7f1132..c8bdf7a7 100644 --- a/app/models/shift_sale.rb +++ b/app/models/shift_sale.rb @@ -14,13 +14,14 @@ class ShiftSale < ApplicationRecord belongs_to :cashier_terminal - belongs_to :employee + belongs_to :employee, :foreign_key => 'employee_id' def self.current_open_shift(current_user) #if current_user #find open shift where is open today and is not closed and login by current cashier today_date = DateTime.now.strftime("%Y-%m-%d") - shift = ShiftSale.where("TO_CHAR(shift_started_at, 'YYYY-MM-DD')=? and shift_started_at is not null and shift_closed_at is null and employee_id = #{current_user.id}",today_date).take + puts today_date + shift = ShiftSale.where("TO_CHAR(shift_started_at, 'YYYY-MM-DD')=? and shift_started_at is not null and shift_closed_at is null and employee_id = #{current_user}",today_date).take return shift #end @@ -35,6 +36,7 @@ class ShiftSale < ApplicationRecord end def update(sale) + puts ">>>>>> shift sale update" saleobj = Sale.find(sale) self.total_revenue = self.total_revenue + saleobj.total_amount self.total_discounts = self.total_discounts + saleobj.total_discount diff --git a/app/views/origami/cash_ins/new.html.erb b/app/views/origami/cash_ins/new.html.erb new file mode 100644 index 00000000..1c513895 --- /dev/null +++ b/app/views/origami/cash_ins/new.html.erb @@ -0,0 +1,79 @@ + +
+
+

Payment Credit

+
+ + + + + + + + + + + + + +
Payment Reference +
Remark +
Payment Method + + + + + +
+
+
+
Reference Number
+
+
+
+
+
+
Amount
+
+
+

+
+
+
+
+
+
+ +
+
+ + diff --git a/app/views/origami/cash_outs/new.html.erb b/app/views/origami/cash_outs/new.html.erb new file mode 100644 index 00000000..17f9bdf8 --- /dev/null +++ b/app/views/origami/cash_outs/new.html.erb @@ -0,0 +1,44 @@ +

Payment Debit

+
+
+ + + + + + + + + + + + + +
Payment Reference +
Remark +
Amount +
+ +
+ +
+

+
+
+
+
+ diff --git a/app/views/origami/home/index.html.erb b/app/views/origami/home/index.html.erb index cd451e68..99fa713e 100644 --- a/app/views/origami/home/index.html.erb +++ b/app/views/origami/home/index.html.erb @@ -1,6 +1,6 @@
-
+
-
+
+ + +
@@ -193,4 +196,16 @@ $(function() { } } }); + +$('#cash_in').on('click',function(){ + window.location.href = '/origami/cash_ins/new'; +}) + +$('#cash_out').on('click',function(){ + window.location.href = '/origami/cash_outs/new'; +}) + +$('#close_cashier').on('click',function(){ + window.location.href = '/origami/shift/close'; +}) diff --git a/app/views/origami/shifts/edit.html.erb b/app/views/origami/shifts/edit.html.erb index 26d96cb5..60d5c6d8 100644 --- a/app/views/origami/shifts/edit.html.erb +++ b/app/views/origami/shifts/edit.html.erb @@ -1,2 +1 @@ -

Origami::Shifts#edit

-

Find me in app/views/origami/shifts/edit.html.erb

+

Close Cashier

diff --git a/app/views/origami/shifts/show.html.erb b/app/views/origami/shifts/show.html.erb index 189c3d62..9df112b9 100644 --- a/app/views/origami/shifts/show.html.erb +++ b/app/views/origami/shifts/show.html.erb @@ -1,2 +1,92 @@ -

Origami::Shifts#show

-

Find me in app/views/origami/shifts/show.html.erb

+ +
+
+

Close Cashier

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Shift Started At<%= @shift.shift_started_at.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-' %>
Cashier Name<%= @shift.employee.name rescue ''%>
Opening Balance<%= @shift.opening_balance rescue ''%>
Total Revenue<%= @shift.total_revenue rescue ''%>
Total Discount<%= @shift.total_discounts rescue ''%>
Total Tax<%= @shift.total_taxes rescue ''%>
Grand Total<%= @shift.grand_total rescue ''%>
Nett Sale<%= @shift.nett_sales rescue ''%>
Cash Sale<%= @shift.cash_sales rescue ''%>
Credit Sale<%= @shift.credit_sales rescue ''%>
Other Sale<%= @shift.other_sales rescue ''%>
Commercial Tax<%= @shift.commercial_taxes rescue ''%>
Cash In<%= @shift.cash_in rescue ''%>
Cash Out<%= @shift.cash_out rescue ''%>
+
+
+
+ Closing Balance +
+
+ <%= @shift.closing_balance rescue ''%> +
+
+
+
+ + +
+
+ diff --git a/app/views/origami/shifts/update_shift.json.jbuilder b/app/views/origami/shifts/update_shift.json.jbuilder new file mode 100644 index 00000000..08bf292c --- /dev/null +++ b/app/views/origami/shifts/update_shift.json.jbuilder @@ -0,0 +1 @@ +json.status true diff --git a/config/routes.rb b/config/routes.rb index cbd6b878..a56cd2e1 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -70,6 +70,8 @@ Rails.application.routes.draw do #--------- Cashier ------------# namespace :origami do + resources :cash_ins, only:[:new, :create] + resources :cash_outs, only:[:new, :create] root "home#index" get "table/:dining_id" => "home#show" do #origami/:booking_id will show # resources :discounts, only: [:index,:new, :create ] #add discount type @@ -98,7 +100,9 @@ Rails.application.routes.draw do get '/:sale_id/reprint' => 'payments#reprint' ,:defaults => { :format => 'json' } #---------Shift ---------------# - resources :shifts, only: [:index, :show, :new, :create, :edit, :update] + resources :shifts, only: [:index, :new, :create, :edit] + post 'close_shift' => 'shifts#update_shift' + get 'shift/close' => 'shifts#show' #shift - index (open/close shift landing page) #shift - show (sales summary display) #shift - new (open shift) diff --git a/db/migrate/20170627035218_create_payment_journals.rb b/db/migrate/20170627035218_create_payment_journals.rb index e7f4c903..e82dd788 100644 --- a/db/migrate/20170627035218_create_payment_journals.rb +++ b/db/migrate/20170627035218_create_payment_journals.rb @@ -8,7 +8,7 @@ class CreatePaymentJournals < ActiveRecord::Migration[5.1] t.string :payment_method,:null => false, :default => "CASH" t.string :payment_status,:null => false, :default => "NEW" t.string :payment_method_references - + t.integer :created_by, :null => false t.timestamps end end diff --git a/db/seeds.rb b/db/seeds.rb index 841495d4..da60ef3e 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -82,6 +82,12 @@ void_reason = Lookup.create([{lookup_type:'void_reason', name: 'Approve By Manag {lookup_type:'void_reason', name: 'Cashier Mistake', value: 'Cashier Mistake'}, {lookup_type:'void_reason', name: 'Waiter Mistake', value: 'Waiter Mistake'}]) + # sale void reason + float_value = Lookup.create([{lookup_type:'float_value', name: '500', value: '500'}, + {lookup_type:'float_value', name: '1000', value: '1000'}, + {lookup_type:'float_value', name: '5000', value: '5000'}, + {lookup_type:'float_value', name: '10000', value: '10000'}]) + #WALK CUSTOMER - Default CUSTOMER (take key 1) customer = Customer.create({name:"WALK-IN", email: "cus1@customer.com", contact_no:"000000000",card_no:"000"}) customer2 = Customer.create({name:"TAKEAWAY", email: "cus2@customer.com", contact_no:"111111111",card_no:"111"}) @@ -173,4 +179,5 @@ payment_methods = PaymentMethodSetting.create({payment_method:"JCB",gateway_url: payment_methods = PaymentMethodSetting.create({payment_method:"Master",gateway_url: "http://192.168.1.47:3006"}) payment_methods = PaymentMethodSetting.create({payment_method:"Redeem",gateway_url: "http://192.168.1.47:3006",merchant_account_id:"vWSsseoZCzxd6xcNf_uS"}) +cashier_terminal = CashierTerminal.create({name:"Terminal 1"}) puts " Finished System Default Set Up Data " From 8d09e5a9191a51c8e8414616459a99f6db9bb72a Mon Sep 17 00:00:00 2001 From: Nweni Date: Thu, 29 Jun 2017 13:48:14 +0630 Subject: [PATCH 5/6] shift sale update --- app/models/shift_sale.rb | 3 +-- app/views/origami/home/show.html.erb | 2 -- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/app/models/shift_sale.rb b/app/models/shift_sale.rb index c8bdf7a7..ee6885ae 100644 --- a/app/models/shift_sale.rb +++ b/app/models/shift_sale.rb @@ -36,8 +36,7 @@ class ShiftSale < ApplicationRecord end def update(sale) - puts ">>>>>> shift sale update" - saleobj = Sale.find(sale) + saleobj = Sale.find_by_sale_id(sale) self.total_revenue = self.total_revenue + saleobj.total_amount self.total_discounts = self.total_discounts + saleobj.total_discount self.total_taxes = self.total_taxes + saleobj.total_tax diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index 7e977b7e..2842c433 100644 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -520,6 +520,4 @@ function show_customer_details(customer_id){ } }); - -}) From 11c3be8f4a6b853a11b0e3f27e0fe60af75386d9 Mon Sep 17 00:00:00 2001 From: Nweni Date: Thu, 29 Jun 2017 14:05:03 +0630 Subject: [PATCH 6/6] Update --- app/models/sale_item.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/models/sale_item.rb b/app/models/sale_item.rb index 90222976..3cc0eb43 100644 --- a/app/models/sale_item.rb +++ b/app/models/sale_item.rb @@ -39,8 +39,8 @@ class SaleItem < ApplicationRecord # Check for actual sale items sale_items.each do |si| if si.account_id == a.id - account_price[:price] = account_price[:price] + si.price - end + account_price[:price] = account_price[:price] + si.price + end end price_accounts.push(account_price) end @@ -55,10 +55,10 @@ class SaleItem < ApplicationRecord discount_account = {:name => a.title, :price => 0} # Check for actual sale items - sale_items.where("is_taxable = 0 AND remark = 'Discount'").find_each do |si| + sale_items.where("is_taxable = false AND remark = 'Discount'").find_each do |si| if si.account_id == a.id - discount_account[:price] = (discount_account[:price] + si.price) * -1 - end + discount_account[:price] = (discount_account[:price] + si.price) * -1 + end end discount_accounts.push(discount_account) end