diff --git a/Gemfile b/Gemfile index 8f16e924..227cfa72 100644 --- a/Gemfile +++ b/Gemfile @@ -12,7 +12,7 @@ gem 'rails', '~> 5.1.0' gem 'mysql2', '>= 0.3.18', '< 0.5' #Use PosgreSQL -#gem 'pg' +gem 'pg' # redis server for cable # gem 'redis', '~> 3.0' diff --git a/app/assets/stylesheets/origami.scss b/app/assets/stylesheets/origami.scss index 8c478a1a..2ba6fe52 100644 --- a/app/assets/stylesheets/origami.scss +++ b/app/assets/stylesheets/origami.scss @@ -148,6 +148,10 @@ background-color:#7a62d3; } +.orange{ + background-color:#FF7F50; +} + .red { background-color:#ff0000; } diff --git a/app/controllers/origami/sale_edit_controller.rb b/app/controllers/origami/sale_edit_controller.rb index 88cdf315..575cc008 100644 --- a/app/controllers/origami/sale_edit_controller.rb +++ b/app/controllers/origami/sale_edit_controller.rb @@ -1,11 +1,13 @@ class Origami::SaleEditController < BaseOrigamiController + # Index for sale item void OR edit def edit sale_id = params[:sale_id] @table_id = params[:table_id] @saleobj = Sale.find(sale_id) end + # create item void. make duplicate old record and update qty and price def item_void saleitemId = params[:sale_item_id] saleitemObj = SaleItem.find(saleitemId) @@ -19,4 +21,36 @@ class Origami::SaleEditController < BaseOrigamiController @newsaleitem.product_name = saleitemObj.product_name + " - void" @newsaleitem.save end + + # make cancel void item + def item_void_cancel + saleitemId = params[:sale_item_id] + saleitemObj = SaleItem.find(saleitemId) + both = SaleItem.where('product_code=?',saleitemObj.product_code) + both.each do |item| + if item.qty.to_i > 0 + item.remark = nil + item.save + end + end + saleitemObj.destroy + end + + # remove all void items + def cancel_all_void + sale_id = params[:sale_id] + saleobj = Sale.find(sale_id) + saleobj.sale_items.each do |item| + if item.qty.to_i < 0 + item.destroy + else + item.remark = nil + end + item.save + end + end + + def apply_void + + end end diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb index 76f481a9..08f833a2 100644 --- a/app/views/origami/payments/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -241,8 +241,10 @@
Date: <%= @saleobj.created_at.utc.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%>
+Date: <%= @saleobj.created_at.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%>
| # | @@ -49,13 +49,23 @@||||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| <%= count %> | <%= sale_item.product_name %> | + <% if sale_item.remark != 'void' %>- <% if sale_item.remark != 'void' || sale_item.qty.to_i > 0 %> | + <% elsif sale_item.qty.to_i < 0 %> + | + | + | + + | + <% else %> ++ | + | <% end %> | |
| Sub Total: | <%= sub_total %> | -|||||||||
| Discount: | -(<%= @saleobj.total_discount rescue 0%>) | -|||||||||
| Tax: | -<%= @saleobj.total_tax rescue 0%> | -|||||||||
| Grand Total: | -<%= @saleobj.grand_total rescue 0%> | |||||||||