From ed3f97a2af1189812fb19832f8d600fc8ba52f37 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Thu, 15 Jun 2017 13:17:58 +0630 Subject: [PATCH] upadte customer and sale void --- .../origami/customers_controller.rb | 7 +- .../transactions/sales_controller.rb | 14 ++- app/views/origami/customers/index.html.erb | 20 +++-- app/views/transactions/sales/show.html.erb | 4 +- .../transactions/sales/showback.html.erb | 89 ------------------- app/views/transactions/sales/void.html.erb | 50 +++++++++-- 6 files changed, 76 insertions(+), 108 deletions(-) delete mode 100644 app/views/transactions/sales/showback.html.erb diff --git a/app/controllers/origami/customers_controller.rb b/app/controllers/origami/customers_controller.rb index 3215f9e6..601055e5 100644 --- a/app/controllers/origami/customers_controller.rb +++ b/app/controllers/origami/customers_controller.rb @@ -28,11 +28,10 @@ class Origami::CustomersController < BaseOrigamiController @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 - respond_to do |format| # format.html { render :template => "crm/customers/index" } format.html { render action: "index"} diff --git a/app/controllers/transactions/sales_controller.rb b/app/controllers/transactions/sales_controller.rb index b1c28e98..82be6f59 100644 --- a/app/controllers/transactions/sales_controller.rb +++ b/app/controllers/transactions/sales_controller.rb @@ -104,7 +104,19 @@ class Transactions::SalesController < ApplicationController end def manual_void_sale - sale_id = params[:sale_id] + + sale_id = params[:sale_id] + reason = params[:reason] + sale = Sale.find(sale_id) + sale.sales_status = 'void' + sale.remarks = reason + sale.void_by = current_user.id + if sale.save + sale =SaleAudit.record_audit_void(sale_id, current_user.id, current_user.id, reason) + end + respond_to do |format| + format.html { redirect_to transactions_sales_url, notice: 'Sale was successfully void.' } + end end diff --git a/app/views/origami/customers/index.html.erb b/app/views/origami/customers/index.html.erb index b58ca35a..a180bda6 100644 --- a/app/views/origami/customers/index.html.erb +++ b/app/views/origami/customers/index.html.erb @@ -77,19 +77,29 @@ <%= f.error_notification %> <%= 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" %> +
"> + <%= f.input :email, :class => "form-control col-md-6 email" %> + + <% flash.each do |name, msg| %> + <%= msg['email'] %> + <% end -%>
diff --git a/app/views/transactions/sales/show.html.erb b/app/views/transactions/sales/show.html.erb index 56887410..05514c7b 100644 --- a/app/views/transactions/sales/show.html.erb +++ b/app/views/transactions/sales/show.html.erb @@ -51,7 +51,7 @@ <%= @sale.receipt_date.strftime("%d-%M-%Y") %> <%= @sale.receipt_no %> - <%= @sale.cashier rescue '-' %> + <%= @sale.cashier_name rescue '-' %> <%= @sale.sale_status %> <%= @sale.requested_at.strftime("%d-%m-%Y") %> @@ -175,7 +175,7 @@ Void Sale - + Complete Sale -->
diff --git a/app/views/transactions/sales/showback.html.erb b/app/views/transactions/sales/showback.html.erb deleted file mode 100644 index c82c2c5e..00000000 --- a/app/views/transactions/sales/showback.html.erb +++ /dev/null @@ -1,89 +0,0 @@ -

<%= notice %>

- -

- Cashier: - <%= @transactions_sale.cashier %> -

- -

- Cashier name: - <%= @transactions_sale.cashier_name %> -

- -

- Requested by: - <%= @transactions_sale.requested_by %> -

- -

- Requested at: - <%= @transactions_sale.requested_at %> -

- -

- Receipt no: - <%= @transactions_sale.receipt_no %> -

- -

- Receipt date: - <%= @transactions_sale.receipt_date %> -

- -

- Customer: - <%= @transactions_sale.customer %> -

- -

- Payment status: - <%= @transactions_sale.payment_status %> -

- -

- Sale status: - <%= @transactions_sale.sale_status %> -

- -

- Total amount: - <%= @transactions_sale.total_amount %> -

- -

- Total discount: - <%= @transactions_sale.total_discount %> -

- -

- Total tax: - <%= @transactions_sale.total_tax %> -

- -

- Tax type: - <%= @transactions_sale.tax_type %> -

- -

- Grand total: - <%= @transactions_sale.grand_total %> -

- -

- Rounding adjustment: - <%= @transactions_sale.rounding_adjustment %> -

- -

- Amount received: - <%= @transactions_sale.amount_received %> -

- -

- Amount changed: - <%= @transactions_sale.amount_changed %> -

- -<%= link_to 'Edit', edit_transactions_sale_path(@transactions_sale) %> | -<%= link_to 'Back', transactions_sales_path %> diff --git a/app/views/transactions/sales/void.html.erb b/app/views/transactions/sales/void.html.erb index d8091876..aef0aa40 100644 --- a/app/views/transactions/sales/void.html.erb +++ b/app/views/transactions/sales/void.html.erb @@ -15,12 +15,16 @@
-

Choose your reason

- +

Choose Reason For Void

+
+ +
<% @reason.each do |r| %> - + + @@ -29,10 +33,13 @@
- <%= check_box_tag "reason", "#{r.name}" rescue '-' %> + + <%= label_tag "reasons[#{r.id}]", r.name, :style=>'font-weight:bold;font-size:18px;' rescue '-' %>
-
+ +