From 914069e3af3c8ce96c5a3c4c1ef2d94b7bf945fd Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Wed, 14 Jun 2017 15:58:41 +0630 Subject: [PATCH] update customer and sale --- app/assets/javascripts/origami.js | 2 +- app/controllers/crm/customers_controller.rb | 26 +- .../transactions/sales_controller.rb | 13 +- app/views/crm/customers/index.html.erb | 19 +- app/views/crm/customers/show.html.erb | 83 ++++-- app/views/transactions/orders/show.html.erb | 6 +- app/views/transactions/sales/show.html.erb | 245 ++++++++++++------ app/views/transactions/sales/show__.html.erb | 112 ++++++++ 8 files changed, 378 insertions(+), 128 deletions(-) create mode 100644 app/views/transactions/sales/show__.html.erb diff --git a/app/assets/javascripts/origami.js b/app/assets/javascripts/origami.js index fbf641df..7c79a6c7 100644 --- a/app/assets/javascripts/origami.js +++ b/app/assets/javascripts/origami.js @@ -218,7 +218,7 @@ $(document).ready(function(){ '' + data["response_data"]["data"][i]["accountable_type"] +'' +'' + balance + ''; - $(".rebate_amount").append(row); + $(".rebate_amount").html(row); } } diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index eac87e1e..96e76574 100644 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -17,9 +17,9 @@ class Crm::CustomersController < BaseCrmController @crm_customers = Kaminari.paginate_array(@crm_customers).page(params[:page]).per(50) @crm_customer = Customer.new - if flash["errors"] - @crm_customer.valid? - end + # if flash["errors"] + # @crm_customer.valid? + # end # @membership = Customer.get_member_group # if @membership["status"] == true # @member_group = @membership["data"] @@ -65,15 +65,19 @@ class Crm::CustomersController < BaseCrmController 'Accept' => 'application/json' } ) - - @type = "-" - @balance = 0.00 - response["data"].each do |res| - if res["accountable_type"] == "RebateAccount" - @balance = res["balance"] - @type = "RebateAccount" - end + if(response["status"] == true) + @membership = response["data"] + else + @membership = 0 end + # @type = "-" + # @balance = 0.00 + # response["data"].each do |res| + # if res["accountable_type"] == "RebateAccount" + # @balance = res["balance"] + # @type = "RebateAccount" + # end + # end #end customer amount diff --git a/app/controllers/transactions/sales_controller.rb b/app/controllers/transactions/sales_controller.rb index edafb1db..36b2be3d 100644 --- a/app/controllers/transactions/sales_controller.rb +++ b/app/controllers/transactions/sales_controller.rb @@ -10,7 +10,7 @@ class Transactions::SalesController < ApplicationController today = Date.today if receipt_no.nil? - @sales = Sale.order("sale_id").page(params[:page]) + @sales = Sale.order("sale_id") #@products = Product.order("name").page(params[:page]).per(5) else @sales = Sale.search(receipt_no) @@ -27,7 +27,16 @@ class Transactions::SalesController < ApplicationController def show @sale = Sale.find(params[:id]) - # @sale_receivables = SaleReceivable.where('sale_id = ?', @sale.id) + + @order_items = [] + @sale.sale_orders.each do |sale_order| + order = Order.find(sale_order.order_id) + #if (order.status == "new") + @order_items = @order_items + order.order_items + #end + end + + @sale_receivables = SalePayment.where('sale_id = ?', @sale.id) respond_to do |format| format.html # show.html.erb format.json { render json: @sale } diff --git a/app/views/crm/customers/index.html.erb b/app/views/crm/customers/index.html.erb index bff00d82..36008efb 100644 --- a/app/views/crm/customers/index.html.erb +++ b/app/views/crm/customers/index.html.erb @@ -74,22 +74,29 @@ <%= f.hidden_field :id, :class => "form-control col-md-6 " %> -
+
"> <%= f.input :name, :class => "form-control col-md-6 name" %> - + <% flash.each do |name, msg| %> + <%= msg['name'] %> + <% end -%>
<%= f.input :company, :class => "form-control col-md-6 company" %>
-
+
"> <%= f.input :contact_no, :class => "form-control col-md-6 contact_no" %> - + <% flash.each do |name, msg| %> + <%= msg['contact_no'] %> + <% end -%>
-
+
"> <%= f.input :email, :class => "form-control col-md-6 email" %> - + + <% flash.each do |name, msg| %> + <%= msg['email'] %> + <% end -%>
diff --git a/app/views/crm/customers/show.html.erb b/app/views/crm/customers/show.html.erb index e3530017..b909a1c8 100644 --- a/app/views/crm/customers/show.html.erb +++ b/app/views/crm/customers/show.html.erb @@ -19,31 +19,64 @@
-
- - - - - - - - - - - - - - - - - - - - - - - -
Name<%= @crm_customer.name %>
Email<%= @crm_customer.email %>
Contact no<%= @crm_customer.contact_no %>
Company<%= @crm_customer.company %>
Date Of Birth<%= @crm_customer.date_of_birth %>
+
+
+
+
+

Customer Profile

+
+ + + + + + + + + + + + + + + + + + + + + + + +
Name<%= @crm_customer.name %>
Email<%= @crm_customer.email %>
Contact no<%= @crm_customer.contact_no %>
Company<%= @crm_customer.company %>
Date Of Birth<%= @crm_customer.date_of_birth %>
+
+
+
+
+
+
+
+

Membership Detail

+
+ + + <% if @membership == 0 %> + + + + <% else %> + <% @membership.each do |member| %> + + + + + <% end %> + + <% end %> + +
"There is no membership data"
<%= member["accountable_type"] %><%= member["balance"] %>
+
+
diff --git a/app/views/transactions/orders/show.html.erb b/app/views/transactions/orders/show.html.erb index bd17dadb..dc5bae88 100644 --- a/app/views/transactions/orders/show.html.erb +++ b/app/views/transactions/orders/show.html.erb @@ -3,10 +3,10 @@
@@ -70,7 +70,7 @@ <% end %> - + Back
diff --git a/app/views/transactions/sales/show.html.erb b/app/views/transactions/sales/show.html.erb index b149ebe7..a96c63db 100644 --- a/app/views/transactions/sales/show.html.erb +++ b/app/views/transactions/sales/show.html.erb @@ -3,101 +3,186 @@
-
-
-
-
-
- - - - - - - - - - +
+ -
- - - - - - - - - - - - - - - <% @sale.sale_items.each do |s| %> + + + - - - - - - - - <% end %> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
+ +
+
+
Receipt Date Receipt noCashierSales statusReceipt generated at
<%= @sale.receipt_date.strftime("%d-%M-%Y") %><%= @sale.receipt_no %><%= @sale.cashier rescue '-' %> <%= @sale.sale_status %> <%= @sale.requested_at.strftime("%d-%m-%Y") %>
Sale item name QtyUnit priceTotal pirce Created at
<%=s.product_name rescue ' '%><%=s.qty rescue ' '%><%= number_with_precision(s.price, :precision => 2, :delimiter => ',') rescue ' '%><%= number_with_precision(s.qty * s.price, :precision => 2, :delimiter => ',') rescue ' '%><%=l s.created_at.utc.getlocal , :format => :short rescue ' ' %>
Total<%= number_with_precision(@sale.total_amount, :precision => 2, :delimiter => ',') rescue ' '%>
Tax<%= number_with_precision(@sale.total_tax, :precision => 2, :delimiter => ',') rescue ' '%>
Discount<%= number_with_precision(@sale.total_discount, :precision => 2, :delimiter => ',') rescue ' '%>
Grand Total<%= number_with_precision(@sale.grand_total, :precision => 2, :delimiter => ',') rescue ' '%>
 
Pay Amount<%= number_with_precision(@sale.amount_received, :precision => 2, :delimiter => ',') rescue ' '%>
Change<%= number_with_precision(@sale.amount_changed, :precision => 2, :delimiter => ',') rescue ' '%>
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + <% @sale.sale_items.each do |s| %> + + + + + + + + + <% end %> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <% @sale_receivables.each do |r|%> + + + + + + + <% end %> + + +
 
Receipt Date Receipt noCashierSales statusReceipt generated at
<%= @sale.receipt_date.strftime("%d-%M-%Y") %><%= @sale.receipt_no %><%= @sale.cashier rescue '-' %> <%= @sale.sale_status %> <%= @sale.requested_at.strftime("%d-%m-%Y") %>
Sale item name QtyUnit priceTotal pirce Created at
<%=s.product_name rescue ' '%><%=s.qty rescue ' '%><%= number_with_precision(s.price, :precision => 2, :delimiter => ',') rescue ' '%><%= number_with_precision(s.qty * s.price, :precision => 2, :delimiter => ',') rescue ' '%><%=l s.created_at.utc.getlocal , :format => :short rescue ' ' %>
Total<%= number_with_precision(@sale.total_amount, :precision => 2, :delimiter => ',') rescue ' '%>
Discount<%= number_with_precision(@sale.total_discount, :precision => 2, :delimiter => ',') rescue ' '%>
Tax<%= number_with_precision(@sale.total_tax, :precision => 2, :delimiter => ',') rescue ' '%>
Grand Total<%= number_with_precision(@sale.grand_total, :precision => 2, :delimiter => ',') rescue ' '%>
 
Pay Amount<%= number_with_precision(@sale.amount_received, :precision => 2, :delimiter => ',') rescue ' '%>
Change<%= number_with_precision(@sale.amount_changed, :precision => 2, :delimiter => ',') rescue ' '%>
Payment <%= r.payment_method rescue ' '%><%= number_with_precision(r.payment_amount, :precision => 2, :delimiter => ',') rescue ' '%> +
+ +
+
+ +
+
+ + + + + + + + + + + + + + + + <% @order_items.each do |order_item| %> + + + + + + + + + + + <% end %> + +
Order IDMenu ItemQTYUnit Price OptionStatusWaiterCreated at
<%= order_item.order_id %><%= order_item.item_name %><%= order_item.qty %><%= order_item.price %><%= order_item.options %><%= order_item.order_item_status %><%= order_item.item_order_by %> <%= order_item.created_at.strftime("%d-%m-%y") %>
+
+
+ +
+

Sale Details

+
+ +
+
- - - - - Back -
-
-
+
+ +
+ + + Back + + + + Void Sale + + + Complete Sale + +
+ + diff --git a/app/views/transactions/sales/show__.html.erb b/app/views/transactions/sales/show__.html.erb new file mode 100644 index 00000000..b9a57ed9 --- /dev/null +++ b/app/views/transactions/sales/show__.html.erb @@ -0,0 +1,112 @@ +
+
+ +
+
+ + +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <% @sale.sale_items.each do |s| %> + + + + + + + + + <% end %> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
 
Receipt Date Receipt noCashierSales statusReceipt generated at
<%= @sale.receipt_date.strftime("%d-%M-%Y") %><%= @sale.receipt_no %><%= @sale.cashier rescue '-' %> <%= @sale.sale_status %> <%= @sale.requested_at.strftime("%d-%m-%Y") %>
Sale item name QtyUnit priceTotal pirce Created at
<%=s.product_name rescue ' '%><%=s.qty rescue ' '%><%= number_with_precision(s.price, :precision => 2, :delimiter => ',') rescue ' '%><%= number_with_precision(s.qty * s.price, :precision => 2, :delimiter => ',') rescue ' '%><%=l s.created_at.utc.getlocal , :format => :short rescue ' ' %>
Total<%= number_with_precision(@sale.total_amount, :precision => 2, :delimiter => ',') rescue ' '%>
Discount<%= number_with_precision(@sale.total_discount, :precision => 2, :delimiter => ',') rescue ' '%>
Tax<%= number_with_precision(@sale.total_tax, :precision => 2, :delimiter => ',') rescue ' '%>
Grand Total<%= number_with_precision(@sale.grand_total, :precision => 2, :delimiter => ',') rescue ' '%>
 
Pay Amount<%= number_with_precision(@sale.amount_received, :precision => 2, :delimiter => ',') rescue ' '%>
Change<%= number_with_precision(@sale.amount_changed, :precision => 2, :delimiter => ',') rescue ' '%>
+ + +
+
+ +
+
+ + + + +