diff --git a/app/controllers/transactions/shift_sales_controller.rb b/app/controllers/transactions/shift_sales_controller.rb new file mode 100644 index 00000000..1f765d21 --- /dev/null +++ b/app/controllers/transactions/shift_sales_controller.rb @@ -0,0 +1,61 @@ +class Transactions::ShiftSalesController < ApplicationController + load_and_authorize_resource except: [:create] + before_action :set_transactions_shift_sale, only: [:show, :edit, :update, :destroy] + + def index + + filter = params[:filter] + from = params[:from] + to = params[:to] + + if filter.nil? && from.nil? && to.nil? + @shift_sales = ShiftSale.all.order("id desc") + @shift_sales = Kaminari.paginate_array(@shift_sales).page(params[:page]).per(20) + else + shift_sale = ShiftSale.search(filter,from,to) + if shift_sale.count > 0 + @shift_sales = shift_sale + @shift_sales = Kaminari.paginate_array(@shift_sales).page(params[:page]).per(20) + else + @shift_sales = 0 + end + end + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @shift_sales } + end + + end + + # GET /transactions/shift_sales/1 + # GET /transactions/shift_sales/1.json + def show + + @shift = ShiftSale.find(params[:id]) + + #get tax + shift_obj = ShiftSale.where('id =?',@shift.id) + @sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='') + #other payment details for mpu or visa like card + @other_payment = ShiftSale.get_by_shift_other_payment(@shift) + + # Calculate price_by_accounts + @total_amount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'amount') + @total_discount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'discount') + @total_member_discount = ShiftSale.get_total_member_discount(@shift) + + + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @shift } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_transactions_shift_sale + @transactions_shift_sale = ShiftSale.find(params[:id]) + end +end diff --git a/app/models/shift_sale.rb b/app/models/shift_sale.rb index e9a6dd44..7546daa5 100755 --- a/app/models/shift_sale.rb +++ b/app/models/shift_sale.rb @@ -135,4 +135,20 @@ class ShiftSale < ApplicationRecord end + def self.search(filter,from,to) + if filter.blank? + keyword = '' + else + keyword = "booking_id LIKE ? OR checkin_by LIKE ? OR booking_status LIKE? OR checkout_by LIKE? OR sale_id ='#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%","%#{filter}%" + end + + if from.present? && to.present? + booking = ShiftSale.where("DATE_FORMAT(created_at,'%d-%m-%Y') >= ?" + " AND DATE_FORMAT(created_at,'%d-%m-%Y') <= ? and NOT booking_status = 'void' ", from,to) + query = booking.where(keyword) + else + where("booking_id LIKE ? OR checkin_by LIKE ? OR booking_status LIKE? OR checkout_by LIKE? OR sale_id ='#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%","%#{filter}%") + end + + end + end diff --git a/app/views/transactions/shift_sales/index.html.erb b/app/views/transactions/shift_sales/index.html.erb new file mode 100755 index 00000000..2ef296e9 --- /dev/null +++ b/app/views/transactions/shift_sales/index.html.erb @@ -0,0 +1,105 @@ + +
+
+
+
+ + + + + + +
+ <%= form_tag transactions_shift_sales_path, :method => :get do %> +
+
+ + +
+
+ + +
+
+ + +
+ +
+ +
+
+
+ <% end %> +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + <% if @shift_sales != 0 %> + <% @shift_sales.each do |shift_sale| %> + + + + + + + + + + + + + + + + <% end %> + <% else %> + + <% end %> + +
Cashier NameCashier Terminal Opening Time Closing Time Opening float Closing Amount Cast In Cast Out Total Receipt Dining Count Takeaway Count Total VoidAction
<%= shift_sale.employee.name%><%=shift_sale.cashier_terminal.name%><%= shift_sale.shift_started_at.utc.getlocal.strftime('%d-%m-%Y %I:%M %p') %> + <%= shift_sale.shift_started_at.utc.getlocal.strftime('%d-%m-%Y %I:%M %p') rescue '-' %> + <%=shift_sale.opening_balance %><%=shift_sale.closing_balance %><%=shift_sale.cash_in %><%=shift_sale.cash_out %><%= shift_sale.total_receipt %><%= shift_sale.dining_count %><%= shift_sale.takeaway_count %>(<%= shift_sale.total_void.round(2) %>)<%= link_to t("views.btn.show"), transactions_shift_sale_path(shift_sale),:class => 'btn btn-info btn-sm waves-effect' %>

There is no data for search....

+
+ <% if @shift_sales != 0 %> + <%= paginate @shift_sales %> + <% end %> +
+
+
+ +
+
+ + + + + diff --git a/app/views/transactions/shift_sales/index.json.jbuilder b/app/views/transactions/shift_sales/index.json.jbuilder new file mode 100755 index 00000000..a67adc38 --- /dev/null +++ b/app/views/transactions/shift_sales/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @transactions_sales, partial: 'transactions_sales/transactions_sale', as: :transactions_sale diff --git a/app/views/transactions/shift_sales/indexback.html.erb b/app/views/transactions/shift_sales/indexback.html.erb new file mode 100755 index 00000000..fe8c820a --- /dev/null +++ b/app/views/transactions/shift_sales/indexback.html.erb @@ -0,0 +1,59 @@ +

<%= notice %>

+ +

<%= t("views.right_panel.header.transactions_sales") %>

+ + + + + + + + + + + + + + + + + + + + + + + + + + + <% @transactions_sales.each do |transactions_sale| %> + + + + + + + + + + + + + + + + + + + + + + + <% end %> + +
<%= t :cashier %><%= t :cashier %> <%= t("views.right_panel.detail.name_txt2") %><%= t("views.right_panel.detail.requested_by") %><%= t("views.right_panel.detail.requested_at") %><%= t("views.right_panel.detail.receipt_no") %><%= t("views.right_panel.detail.receipt_date") %><%= t :customer %><%= t("views.right_panel.detail.payment_status") %><%= t("views.right_panel.detail.sale_status") %><%= t("views.right_panel.detail.total_amount") %><%= t("views.right_panel.detail.total_discount") %><%= t("views.right_panel.detail.total_tax") %><%= t("views.right_panel.detail.tax_type") %><%= t("views.right_panel.detail.grand_total") %><%= t("views.right_panel.detail.rnd_adj") %><%= t("views.right_panel.detail.amt_received") %><%= t("views.right_panel.detail.amt_changed") %>
<%= transactions_sale.cashier %><%= transactions_sale.cashier_name %><%= transactions_sale.requested_by %><%= transactions_sale.requested_at %><%= transactions_sale.receipt_no %><%= transactions_sale.receipt_date %><%= transactions_sale.customer %><%= transactions_sale.payment_status %><%= transactions_sale.sale_status %><%= transactions_sale.total_amount %><%= transactions_sale.total_discount %><%= transactions_sale.total_tax %><%= transactions_sale.tax_type %><%= transactions_sale.grand_total %><%= transactions_sale.rounding_adjustment %><%= transactions_sale.amount_received %><%= transactions_sale.amount_changed %><%= link_to t("views.btn.show"), transactions_sale %><%= link_to t("views.btn.edit"), edit_transactions_sale_path(transactions_sale) %><%= link_to t("views.btn.delete"), transactions_sale, method: :delete, data: { confirm: 'Are you sure?' } %>
+ +
+ +<%= link_to 'New Transactions Sale', new_transactions_sale_path %> diff --git a/app/views/transactions/shift_sales/show.html.erb b/app/views/transactions/shift_sales/show.html.erb new file mode 100755 index 00000000..3b2b6c6d --- /dev/null +++ b/app/views/transactions/shift_sales/show.html.erb @@ -0,0 +1,196 @@ + +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Cashier Cashier Terminal Opening Date Opening float Received Amount Cast In Cast Out Total Receipt Dining Count Takeaway Count Total Void
<%= @shift.employee.name%><%=@shift.cashier_terminal.name%><%= @shift.shift_started_at.utc.getlocal.strftime('%d-%m-%Y %I:%M %p') %> + <%=@shift.opening_balance %><%=@shift.closing_balance %><%=@shift.cash_in %><%=@shift.cash_out %><%= @shift.total_receipt %><%= @shift.dining_count %><%= @shift.takeaway_count %>(<%= @shift.total_void.round(2) %>)
+ + <% @total_amount_by_account.each do |amount| %> + + + + + + <%end%> + + + + + + + <% @total_discount_by_account.each do |amount| %> + + + + + + <%end%> + + <% if !@total_member_discount[0].member_discount.nil? + @member_discount = @total_member_discount[0].member_discount rescue 0.0 + @overall = @shift.total_discounts - @member_discount + %> + + + + + + <%else @overall = @shift.total_discounts %> + + <%end%> + + + + + + + + + + + + <% @sale_taxes.each do |tax| %> + + + + + + <%end%> + + + + + + + + + + + + + + + +
Total <%= amount.account_name %> Amount<%= amount.total_price.round(2) %>
Net Sales<%=@shift.nett_sales %>
Total <%= amount.account_name %> Discount<%= amount.total_price.round(2) %>
Total Member Discount<%= @member_discount %>
Total Overall Discount<%= @overall %>
Total Discount<%= @shift.total_discounts %>
<%= tax.tax_name %> <%= tax.st_amount.round(2) %>
Total Tax <%=@shift.total_taxes %>
Rounding Adj <%= @shift.total_rounding.round(2) %>
Grand Total <%= @shift.grand_total.round(2) %>
+
+ + + + + + + + + + + + <% @total_amount = 0 + + @other_payment.each do |other| %> + + + + + + + + + + <% @total_amount = @total_amount+other.mpu_amount rescue 0.0 %> + + + + + + <% @total_amount = @total_amount+other.visa_amount rescue 0.0 %> + + + + + + <% @total_amount = @total_amount+other.master_amount rescue 0.0 %> + + + + + + <% @total_amount = @total_amount+other.jcb_amount rescue 0.0 %> + + + + + + <% @total_amount = @total_amount+other.paypar_amount rescue 0.0 %> + + + + + + <% @total_amount = @total_amount+other.foc_amount rescue 0.0 %> + + <%end%> + + + + + + + + + + + + +
Cash Payment <%=@shift.cash_sales %>
Credit Payment <%=@shift.credit_sales %>
Other Payment Detail
MPU Payment <%=other.mpu_amount.round(2) rescue 0.0 %>
VISA Payment <%=other.visa_amount.round(2) rescue 0.0 %>
JCB Payment <%=other.master_amount.round(2) rescue 0.0 %>
Master Payment <%=other.jcb_amount.round(2) rescue 0.0 %>
Reedem Payment <%=other.paypar_amount.round(2) rescue 0.0 %>
FOC <%=other.foc_amount.round(2) rescue 0.0 %>
Total Other Payment <%=@shift.other_sales %>
Total Payment <%= @total_amount+@shift.cash_sales+@shift.credit_sales %>
+
+
+
+
+
+
diff --git a/app/views/transactions/shift_sales/show.json.jbuilder b/app/views/transactions/shift_sales/show.json.jbuilder new file mode 100755 index 00000000..48c70528 --- /dev/null +++ b/app/views/transactions/shift_sales/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "transactions_sales/transactions_sale", transactions_sale: @transactions_sale diff --git a/config/locales/en.yml b/config/locales/en.yml index 69f0904c..242c60cf 100755 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -28,6 +28,7 @@ en: hourly: "Hourly" top: "Top" orders: "Orders" + shiftsale: "ShiftSale" credit: "Credit" bookings: "Booking" home: "Home" diff --git a/config/locales/mm.yml b/config/locales/mm.yml index d103a5c0..5becd44b 100755 --- a/config/locales/mm.yml +++ b/config/locales/mm.yml @@ -28,6 +28,7 @@ mm: hourly: "နာရီအလိုက်" top: "အရောင်းရဆုံး" orders: "အော်ဒါများ" + shiftsale: "အော်ဒါများ" bookings: "အော်ဒါများ" credit: "အကြွေး" home: "မူလစာမျက်နှာ" diff --git a/config/routes.rb b/config/routes.rb index 64f68262..0adeb4bc 100755 --- a/config/routes.rb +++ b/config/routes.rb @@ -336,6 +336,7 @@ scope "(:locale)", locale: /en|mm/ do resources :orders resources :credit_notes resources :bookings + resources :shift_sales get "/sales/:sale_id/manual_complete_sale" => "manual_sales#manual_complete_sale", :as => "manual_complete_sale" get "/sales/:sale_id/void" => "manual_sales#void", :as => "void"