shift close and payment journal

This commit is contained in:
Min Zeya Phyo
2017-06-28 10:34:42 +06:30
parent c1646b812e
commit ee651763b7
36 changed files with 308 additions and 1 deletions

View File

@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/

View File

@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/

View File

@@ -0,0 +1,3 @@
// Place all the styles related to the cash_mgmt controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View File

@@ -0,0 +1,3 @@
// Place all the styles related to the origami/shifts controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View File

@@ -19,7 +19,8 @@ class HomeController < ApplicationController
if @employee != nil
session[:session_token] = @employee.token_session
redirect_to origami_root_path
route_by_role(@employee)
else
render :show, flash[:notice] => "Invalid PIN for Employee. Please try again!"
end
@@ -74,4 +75,25 @@ class HomeController < ApplicationController
def settings_home_params
params.require(:login_form).permit(:emp_id, :password)
end
def route_by_role(employee)
if employee.role == "administrator"
redirect_to dashboard_path
elsif employee.role == "cashier"
#check if cashier has existing open cashier
# if !ShiftSale.current_open_shift(employee).nil?
# redirect_to origami_root_path
# else
redirect_to new_origami_shift_path
# end
elsif employee.role == "checker"
redirect_to oqs_root_path
elsif employee.role == "waiter"
redirect_to oqs_root_path
elsif employee.role == "crm"
redirect_to crm_root_path
end
end
end

View File

@@ -0,0 +1,10 @@
class Origami::CashMgmtController < ApplicationController
def index
end
def new
end
def create
end
end

View File

@@ -0,0 +1,13 @@
class Origami::ShiftsController < ApplicationController
def index
end
def show
end
def new
end
def edit
end
end

View File

@@ -0,0 +1,16 @@
class LoginForm
include ActiveModel::Model
include ActiveModel::Validations
attr_accessor :float_amount
validates_presence_of :float_amount
def persisted?
false
end
def initialize(attributes={})
super
end
end

View File

@@ -0,0 +1,2 @@
module CashMgmtHelper
end

View File

@@ -0,0 +1,2 @@
module Origami::ShiftsHelper
end

View File

@@ -0,0 +1,2 @@
class PaymentJournal < ApplicationRecord
end

25
app/models/shift_sale.rb Normal file
View File

@@ -0,0 +1,25 @@
#Description
#total_revenue = sum of all sub-total from sales table
#total_discounts = sum of all discount (overall) from sales tables
#total_taxes = sum of all taxes from sales table (Service + Goverment Tax (commercial_taxes))
#grand_total = total_revenue - total_discounts + total_taxes
#nett_sales = grand_total - commercial_taxes
#cash_sales = cash payment total revenue
#credit_sales = credit payment total revenue
#others_sales = [Sum of each of other payment type --- mpu, jcb, visa,master, rebate, vochure]
#commercial_taxes = Total Goverment tax due
#cash_in = Payment receive
#Cash_out = Payment issues for misc payments
class ShiftSale < ApplicationRecord
belongs_to :cashier_terminal
belongs_to :employee
def self.current_open_shift(current_user)
#if current_user
#find open shift where is open today and is not closed and login by current cashier
@shift = ShiftSale.where("cast(shift_started_at as date) = #{DateTime.now.to_date} and shift_started_at is null and employee_id = #{current_user.id}").limit(1)
#end
end
end

View File

@@ -0,0 +1,2 @@
<h1>CashMgmt#create</h1>
<p>Find me in app/views/cash_mgmt/create.html.erb</p>

View File

@@ -0,0 +1,2 @@
<h1>CashMgmt#index</h1>
<p>Find me in app/views/cash_mgmt/index.html.erb</p>

View File

@@ -0,0 +1,2 @@
<h1>CashMgmt#new</h1>
<p>Find me in app/views/cash_mgmt/new.html.erb</p>

View File

@@ -0,0 +1,2 @@
<h1>Origami::Shifts#edit</h1>
<p>Find me in app/views/origami/shifts/edit.html.erb</p>

View File

@@ -0,0 +1,2 @@
<h1>Origami::Shifts#index</h1>
<p>Find me in app/views/origami/shifts/index.html.erb</p>

View File

@@ -0,0 +1,2 @@
<h1>Origami::Shifts#new</h1>
<p>Find me in app/views/origami/shifts/new.html.erb</p>

View File

@@ -0,0 +1,2 @@
<h1>Origami::Shifts#show</h1>
<p>Find me in app/views/origami/shifts/show.html.erb</p>