update shift sale detail

This commit is contained in:
Aung Myo
2017-11-16 10:03:01 +06:30
parent bf0a8135f6
commit ccbdd5b2c8
10 changed files with 442 additions and 0 deletions

View File

@@ -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

View File

@@ -135,4 +135,20 @@ class ShiftSale < ApplicationRecord
end 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 end

View File

@@ -0,0 +1,105 @@
<div class="page-header">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="<%= dashboard_path %>"><%= t("views.right_panel.button.home") %></a></li>
<li class="breadcrumb-item active"><%= t :shiftsale %></li>
<span class="float-right">
<%= link_to 'Back', dashboard_path %>
</span>
</ol>
</div>
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<div class="main-box-body clearfix p-l-5 p-r-5">
<div class="table-responsive">
<table class="table table-">
<tbody>
<tr>
<td colspan="8">
<%= form_tag transactions_shift_sales_path, :method => :get do %>
<div class="row clearfix">
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-4">
<label><%= t("views.right_panel.detail.enter_keyboards") %></label>
<input type="text" name="receipt_no" class="form-control" placeholder="" style="margin-right: 10px">
</div>
<div class="col-lg-3 col-md-3 col-sm-3 col-xs-3">
<label class=""><%= t("views.right_panel.detail.from") %></label>
<input class="form-control datepicker" name="from" id="from date" type="text" placeholder="From date">
</div>
<div class="col-lg-3 col-md-3 col-sm-3 col-xs-3">
<label class=""><%= t("views.right_panel.detail.to") %></label>
<input class="form-control datepicker" name="to" id="to date" type="text" placeholder="To date">
</div>
<div class="col-lg-1 col-md-1 col-sm-1 col-xs-1">
<label></label>
<br><input type="submit" value="Search" class='btn btn-primary btn-md'>
</div>
</div>
<% end %>
</td>
</tr>
</tbody>
</table>
</div>
<div class="card">
<div class="table-responsive">
<table class="table table-bordered table-striped table-hover">
<thead>
<tr>
<th>Cashier Name</th>
<th>Cashier Terminal </th>
<th>Opening Time </th>
<th>Closing Time </th>
<th>Opening float </th>
<th>Closing Amount </th>
<th>Cast In </th>
<th>Cast Out </th>
<th>Total Receipt </th>
<th>Dining Count </th>
<th>Takeaway Count </th>
<th>Total Void</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<% if @shift_sales != 0 %>
<% @shift_sales.each do |shift_sale| %>
<tr>
<td><%= shift_sale.employee.name%></td>
<td><%=shift_sale.cashier_terminal.name%></td>
<td><%= shift_sale.shift_started_at.utc.getlocal.strftime('%d-%m-%Y %I:%M %p') %>
</td>
<td><%= shift_sale.shift_started_at.utc.getlocal.strftime('%d-%m-%Y %I:%M %p') rescue '-' %>
</td>
<td><%=shift_sale.opening_balance %></td>
<td><%=shift_sale.closing_balance %></td>
<td><%=shift_sale.cash_in %></td>
<td><%=shift_sale.cash_out %></td>
<th><%= shift_sale.total_receipt %></th>
<th><%= shift_sale.dining_count %></th>
<th><%= shift_sale.takeaway_count %></th>
<th>(<%= shift_sale.total_void.round(2) %>)</th>
<td><%= link_to t("views.btn.show"), transactions_shift_sale_path(shift_sale),:class => 'btn btn-info btn-sm waves-effect' %></td>
</tr>
<% end %>
<% else %>
<tr><td colspan="8"><strong><p style="text-align: center">There is no data for search....</p></strong></td></tr>
<% end %>
</tbody>
</table>
<br>
<% if @shift_sales != 0 %>
<%= paginate @shift_sales %>
<% end %>
</div>
</div>
</div>
</div>
</div>

View File

@@ -0,0 +1 @@
json.array! @transactions_sales, partial: 'transactions_sales/transactions_sale', as: :transactions_sale

View File

@@ -0,0 +1,59 @@
<p id="notice"><%= notice %></p>
<h1><%= t("views.right_panel.header.transactions_sales") %></h1>
<table>
<thead>
<tr>
<th><%= t :cashier %></th>
<th><%= t :cashier %> <%= t("views.right_panel.detail.name_txt2") %></th>
<th><%= t("views.right_panel.detail.requested_by") %></th>
<th><%= t("views.right_panel.detail.requested_at") %></th>
<th><%= t("views.right_panel.detail.receipt_no") %></th>
<th><%= t("views.right_panel.detail.receipt_date") %></th>
<th><%= t :customer %></th>
<th><%= t("views.right_panel.detail.payment_status") %></th>
<th><%= t("views.right_panel.detail.sale_status") %></th>
<th><%= t("views.right_panel.detail.total_amount") %></th>
<th><%= t("views.right_panel.detail.total_discount") %></th>
<th><%= t("views.right_panel.detail.total_tax") %></th>
<th><%= t("views.right_panel.detail.tax_type") %></th>
<th><%= t("views.right_panel.detail.grand_total") %></th>
<th><%= t("views.right_panel.detail.rnd_adj") %></th>
<th><%= t("views.right_panel.detail.amt_received") %></th>
<th><%= t("views.right_panel.detail.amt_changed") %></th>
<th colspan="3"></th>
</tr>
</thead>
<tbody>
<% @transactions_sales.each do |transactions_sale| %>
<tr>
<td><%= transactions_sale.cashier %></td>
<td><%= transactions_sale.cashier_name %></td>
<td><%= transactions_sale.requested_by %></td>
<td><%= transactions_sale.requested_at %></td>
<td><%= transactions_sale.receipt_no %></td>
<td><%= transactions_sale.receipt_date %></td>
<td><%= transactions_sale.customer %></td>
<td><%= transactions_sale.payment_status %></td>
<td><%= transactions_sale.sale_status %></td>
<td><%= transactions_sale.total_amount %></td>
<td><%= transactions_sale.total_discount %></td>
<td><%= transactions_sale.total_tax %></td>
<td><%= transactions_sale.tax_type %></td>
<td><%= transactions_sale.grand_total %></td>
<td><%= transactions_sale.rounding_adjustment %></td>
<td><%= transactions_sale.amount_received %></td>
<td><%= transactions_sale.amount_changed %></td>
<td><%= link_to t("views.btn.show"), transactions_sale %></td>
<td><%= link_to t("views.btn.edit"), edit_transactions_sale_path(transactions_sale) %></td>
<td><%= link_to t("views.btn.delete"), transactions_sale, method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</tbody>
</table>
<br>
<%= link_to 'New Transactions Sale', new_transactions_sale_path %>

View File

@@ -0,0 +1,196 @@
<div class="page-header">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="<%= dashboard_path %>"><%= t("views.right_panel.button.home") %></a></li>
<li class="breadcrumb-item"><a href="<%= transactions_shift_sales_path %>"><%= t :shiftsale %></a></li>
<li class="breadcrumb-item active"><%= t :details %></li>
<span class="float-right">
<%= link_to 'Back', transactions_shift_sales_path %>
</span>
</ol>
</div>
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<div class="main-box-body clearfix p-l-5 p-r-5">
<div class="card">
<div class="table-responsive">
<table class="table table-bordered table-striped table-hover">
<tbody>
<tr>
<th>Cashier </th>
<th>Cashier Terminal </th>
<th>Opening Date </th>
<th>Opening float </th>
<th>Received Amount </th>
<th>Cast In </th>
<th>Cast Out </th>
<th>Total Receipt </th>
<th>Dining Count </th>
<th>Takeaway Count </th>
<th>Total Void</th>
</tr>
<tr style="border-bottom:2px solid #000">
<td><%= @shift.employee.name%></td>
<td><%=@shift.cashier_terminal.name%></td>
<td><%= @shift.shift_started_at.utc.getlocal.strftime('%d-%m-%Y %I:%M %p') %>
</td>
<td><%=@shift.opening_balance %></td>
<td><%=@shift.closing_balance %></td>
<td><%=@shift.cash_in %></td>
<td><%=@shift.cash_out %></td>
<th><%= @shift.total_receipt %></th>
<th><%= @shift.dining_count %></th>
<th><%= @shift.takeaway_count %></th>
<th>(<%= @shift.total_void.round(2) %>)</th>
</tr>
<tr>
<td colspan="5">
<table width="100%">
<% @total_amount_by_account.each do |amount| %>
<tr>
<th></th>
<td style="text-align: right;"> Total <%= amount.account_name %> Amount</td>
<td><%= amount.total_price.round(2) %></td>
</tr>
<%end%>
<tr>
<th></th>
<th style="text-align: right;"> Net Sales</th>
<th><%=@shift.nett_sales %></th>
</tr>
<% @total_discount_by_account.each do |amount| %>
<tr>
<th></th>
<td style="text-align: right;"> Total <%= amount.account_name %> Discount</td>
<td><%= amount.total_price.round(2) %></td>
</tr>
<%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
%>
<tr>
<th></th>
<th style="text-align: right;"> Total Member Discount</th>
<th><%= @member_discount %></th>
</tr>
<%else @overall = @shift.total_discounts %>
<%end%>
<tr>
<th></th>
<th style="text-align: right;"> Total Overall Discount</th>
<th><%= @overall %></th>
</tr>
<tr>
<th></th>
<th style="text-align: right;"> Total Discount</th>
<th><%= @shift.total_discounts %></th>
</tr>
<% @sale_taxes.each do |tax| %>
<tr>
<th></th>
<td style="text-align: right;"> <%= tax.tax_name %> </td>
<td><%= tax.st_amount.round(2) %></td>
</tr>
<%end%>
<tr>
<th></th>
<th style="text-align: right;"> Total Tax </th>
<th><%=@shift.total_taxes %></th>
</tr>
<tr>
<th></th>
<th style="text-align: right;"> Rounding Adj </th>
<th><%= @shift.total_rounding.round(2) %></th>
</tr>
<tr>
<th></th>
<th style="text-align: right;"> Grand Total </th>
<th><%= @shift.grand_total.round(2) %></th>
</tr>
</table>
</td>
<td colspan="6">
<table width="100%">
<tr>
<th></th>
<th style="text-align: right;">Cash Payment </th>
<th><%=@shift.cash_sales %></th>
</tr>
<tr>
<th></th>
<th style="text-align: right;">Credit Payment </th>
<th><%=@shift.credit_sales %></th>
</tr>
<% @total_amount = 0
@other_payment.each do |other| %>
<tr>
<th></th>
<th style="text-align: right;">Other Payment Detail </th>
<th></th>
</tr>
<tr>
<th></th>
<td style="text-align: right;">MPU Payment </td>
<td><%=other.mpu_amount.round(2) rescue 0.0 %></td>
<% @total_amount = @total_amount+other.mpu_amount rescue 0.0 %>
</tr>
<tr>
<th></th>
<td style="text-align: right;">VISA Payment </td>
<td><%=other.visa_amount.round(2) rescue 0.0 %></td>
<% @total_amount = @total_amount+other.visa_amount rescue 0.0 %>
</tr>
<tr>
<th></th>
<td style="text-align: right;">JCB Payment </td>
<td><%=other.master_amount.round(2) rescue 0.0 %></td>
<% @total_amount = @total_amount+other.master_amount rescue 0.0 %>
</tr>
<tr>
<th></th>
<td style="text-align: right;">Master Payment </td>
<td><%=other.jcb_amount.round(2) rescue 0.0 %></td>
<% @total_amount = @total_amount+other.jcb_amount rescue 0.0 %>
</tr>
<tr>
<th></th>
<td style="text-align: right;">Reedem Payment </td>
<td><%=other.paypar_amount.round(2) rescue 0.0 %></td>
<% @total_amount = @total_amount+other.paypar_amount rescue 0.0 %>
</tr>
<tr>
<th></th>
<td style="text-align: right;"><strong>FOC </strong></td>
<td><%=other.foc_amount.round(2) rescue 0.0 %></td>
<% @total_amount = @total_amount+other.foc_amount rescue 0.0 %>
</tr>
<%end%>
<tr>
<th></th>
<th style="text-align: right;">Total Other Payment </th>
<th><%=@shift.other_sales %></th>
</tr>
<tr>
<th></th>
<th style="text-align: right;">Total Payment </th>
<th><%= @total_amount+@shift.cash_sales+@shift.credit_sales %></th>
</tr>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>

View File

@@ -0,0 +1 @@
json.partial! "transactions_sales/transactions_sale", transactions_sale: @transactions_sale

View File

@@ -28,6 +28,7 @@ en:
hourly: "Hourly" hourly: "Hourly"
top: "Top" top: "Top"
orders: "Orders" orders: "Orders"
shiftsale: "ShiftSale"
credit: "Credit" credit: "Credit"
bookings: "Booking" bookings: "Booking"
home: "Home" home: "Home"

View File

@@ -28,6 +28,7 @@ mm:
hourly: "နာရီအလိုက်" hourly: "နာရီအလိုက်"
top: "အရောင်းရဆုံး" top: "အရောင်းရဆုံး"
orders: "အော်ဒါများ" orders: "အော်ဒါများ"
shiftsale: "အော်ဒါများ"
bookings: "အော်ဒါများ" bookings: "အော်ဒါများ"
credit: "အကြွေး" credit: "အကြွေး"
home: "မူလစာမျက်နှာ" home: "မူလစာမျက်နှာ"

View File

@@ -336,6 +336,7 @@ scope "(:locale)", locale: /en|mm/ do
resources :orders resources :orders
resources :credit_notes resources :credit_notes
resources :bookings 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/manual_complete_sale" => "manual_sales#manual_complete_sale", :as => "manual_complete_sale"
get "/sales/:sale_id/void" => "manual_sales#void", :as => "void" get "/sales/:sale_id/void" => "manual_sales#void", :as => "void"