Merge branch 'master' of bitbucket.org:code2lab/sxrestaurant into crm
This commit is contained in:
3
app/assets/javascripts/cash_mgmt.coffee
Normal file
3
app/assets/javascripts/cash_mgmt.coffee
Normal 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/
|
||||
3
app/assets/javascripts/origami/shifts.coffee
Normal file
3
app/assets/javascripts/origami/shifts.coffee
Normal 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/
|
||||
3
app/assets/stylesheets/cash_mgmt.scss
Normal file
3
app/assets/stylesheets/cash_mgmt.scss
Normal 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/
|
||||
3
app/assets/stylesheets/origami/shifts.scss
Normal file
3
app/assets/stylesheets/origami/shifts.scss
Normal 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/
|
||||
@@ -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
|
||||
|
||||
10
app/controllers/origami/cash_mgmt_controller.rb
Normal file
10
app/controllers/origami/cash_mgmt_controller.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
class Origami::CashMgmtController < ApplicationController
|
||||
def index
|
||||
end
|
||||
|
||||
def new
|
||||
end
|
||||
|
||||
def create
|
||||
end
|
||||
end
|
||||
13
app/controllers/origami/shifts_controller.rb
Normal file
13
app/controllers/origami/shifts_controller.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
class Origami::ShiftsController < ApplicationController
|
||||
def index
|
||||
end
|
||||
|
||||
def show
|
||||
end
|
||||
|
||||
def new
|
||||
end
|
||||
|
||||
def edit
|
||||
end
|
||||
end
|
||||
16
app/forms/open_shift_form.rb
Normal file
16
app/forms/open_shift_form.rb
Normal 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
|
||||
2
app/helpers/cash_mgmt_helper.rb
Normal file
2
app/helpers/cash_mgmt_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module CashMgmtHelper
|
||||
end
|
||||
2
app/helpers/origami/shifts_helper.rb
Normal file
2
app/helpers/origami/shifts_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module Origami::ShiftsHelper
|
||||
end
|
||||
2
app/models/payment_journal.rb
Normal file
2
app/models/payment_journal.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
class PaymentJournal < ApplicationRecord
|
||||
end
|
||||
25
app/models/shift_sale.rb
Normal file
25
app/models/shift_sale.rb
Normal 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
|
||||
2
app/views/origami/cash_mgmt/create.html.erb
Normal file
2
app/views/origami/cash_mgmt/create.html.erb
Normal file
@@ -0,0 +1,2 @@
|
||||
<h1>CashMgmt#create</h1>
|
||||
<p>Find me in app/views/cash_mgmt/create.html.erb</p>
|
||||
2
app/views/origami/cash_mgmt/index.html.erb
Normal file
2
app/views/origami/cash_mgmt/index.html.erb
Normal file
@@ -0,0 +1,2 @@
|
||||
<h1>CashMgmt#index</h1>
|
||||
<p>Find me in app/views/cash_mgmt/index.html.erb</p>
|
||||
2
app/views/origami/cash_mgmt/new.html.erb
Normal file
2
app/views/origami/cash_mgmt/new.html.erb
Normal file
@@ -0,0 +1,2 @@
|
||||
<h1>CashMgmt#new</h1>
|
||||
<p>Find me in app/views/cash_mgmt/new.html.erb</p>
|
||||
2
app/views/origami/shifts/edit.html.erb
Normal file
2
app/views/origami/shifts/edit.html.erb
Normal file
@@ -0,0 +1,2 @@
|
||||
<h1>Origami::Shifts#edit</h1>
|
||||
<p>Find me in app/views/origami/shifts/edit.html.erb</p>
|
||||
2
app/views/origami/shifts/index.html.erb
Normal file
2
app/views/origami/shifts/index.html.erb
Normal file
@@ -0,0 +1,2 @@
|
||||
<h1>Origami::Shifts#index</h1>
|
||||
<p>Find me in app/views/origami/shifts/index.html.erb</p>
|
||||
2
app/views/origami/shifts/new.html.erb
Normal file
2
app/views/origami/shifts/new.html.erb
Normal file
@@ -0,0 +1,2 @@
|
||||
<h1>Origami::Shifts#new</h1>
|
||||
<p>Find me in app/views/origami/shifts/new.html.erb</p>
|
||||
2
app/views/origami/shifts/show.html.erb
Normal file
2
app/views/origami/shifts/show.html.erb
Normal file
@@ -0,0 +1,2 @@
|
||||
<h1>Origami::Shifts#show</h1>
|
||||
<p>Find me in app/views/origami/shifts/show.html.erb</p>
|
||||
@@ -96,6 +96,19 @@ Rails.application.routes.draw do
|
||||
|
||||
post "/:id/request_bills" => "request_bills#print",:as => "request_bill" ,:defaults => { :format => 'json' }
|
||||
get '/:sale_id/reprint' => 'payments#reprint' ,:defaults => { :format => 'json' }
|
||||
|
||||
#---------Shift ---------------#
|
||||
resources :shifts, only: [:index, :show, :new, :create, :edit, :update]
|
||||
#shift - index (open/close shift landing page)
|
||||
#shift - show (sales summary display)
|
||||
#shift - new (open shift)
|
||||
#shift - edit (close shift)
|
||||
|
||||
resources :cash_mgmt, only: [:new, :create]
|
||||
#payment - accepting or expending money from cashier - [Cash Journal]
|
||||
#payment - Incoming payments - [accept all payment types (cash, other payments (except rebate))
|
||||
#payment - Outing payments - Cash only [ *Misc expeness tracking]
|
||||
|
||||
#--------- Payment ------------#
|
||||
get 'sale/:sale_id/payment' => 'payments#show'
|
||||
|
||||
|
||||
25
db/migrate/20170626191519_create_shift_sales.rb
Normal file
25
db/migrate/20170626191519_create_shift_sales.rb
Normal file
@@ -0,0 +1,25 @@
|
||||
class CreateShiftSales < ActiveRecord::Migration[5.1]
|
||||
def change
|
||||
create_table :shift_sales do |t|
|
||||
t.references :cashier_terminal, foreign_key: true, :null => false
|
||||
t.datetime :shift_started_at
|
||||
t.datetime :shift_closed_at
|
||||
t.references :employee, foreign_key: true #cashier
|
||||
t.decimal :opening_balance, :precision => 10, :scale => 2, :null => false, :default => 0.00
|
||||
t.decimal :closing_balance, :precision => 10, :scale => 2, :null => false, :default => 0.00
|
||||
t.decimal :total_revenue, :precision => 10, :scale => 2, :null => false, :default => 0.00
|
||||
t.decimal :total_discounts, :precision => 10, :scale => 2, :null => false, :default => 0.00
|
||||
t.decimal :total_taxes, :precision => 10, :scale => 2, :null => false, :default => 0.00
|
||||
t.decimal :grand_total, :precision => 10, :scale => 2, :null => false, :default => 0.00
|
||||
t.decimal :nett_sales, :precision => 10, :scale => 2, :null => false, :default => 0.00
|
||||
t.decimal :cash_sales, :precision => 10, :scale => 2, :null => false, :default => 0.00
|
||||
t.decimal :credit_sales, :precision => 10, :scale => 2, :null => false, :default => 0.00
|
||||
t.json :other_sales
|
||||
t.decimal :commercial_taxes, :precision => 10, :scale => 2, :null => false, :default => 0.00
|
||||
t.decimal :cash_in, :precision => 10, :scale => 2, :null => false, :default => 0.00
|
||||
t.decimal :cash_out, :precision => 10, :scale => 2, :null => false, :default => 0.00
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
15
db/migrate/20170627035218_create_payment_journals.rb
Normal file
15
db/migrate/20170627035218_create_payment_journals.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
class CreatePaymentJournals < ActiveRecord::Migration[5.1]
|
||||
def change
|
||||
create_table :payment_journals do |t|
|
||||
t.string :payment_references,:null => false
|
||||
t.string :remark
|
||||
t.decimal :credit_amount, :precision => 10, :scale => 2, :null => false, :default => 0.00
|
||||
t.decimal :debit_amount, :precision => 10, :scale => 2, :null => false, :default => 0.00
|
||||
t.string :payment_method,:null => false, :default => "CASH"
|
||||
t.string :payment_status,:null => false, :default => "NEW"
|
||||
t.string :payment_method_references
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -22,3 +22,5 @@ rails generate scaffold_controller Setup/CashierTerminal name:string is_active:b
|
||||
rails generate scaffold_controller Settings/OrderQueueStation station_name:string is_active:boolean processing_items:json print_copy:boolean printer_name:string font_size:integer cut_per_item:boolean use_alternate_name:boolean created_by:string --no-migration
|
||||
|
||||
rails generate scaffold_controller transactions/Sale cashier:references cashier_name:string requested_by:string requested_at:datetime receipt_no:string receipt_date:datetime customer:references payment_status:string sale_status:string total_amount:decimal total_discount:decimal total_tax:decimal tax_type:string grand_total:decimal rounding_adjustment:decimal amount_received:decimal amount_changed:decimal --no-migration
|
||||
|
||||
rails g model shift_sale cashier_terminal:references shift_started_at:datetime shift_closed_at:datetime employee:references opening_balance:decimal closing_balance:decimal total_revenue:decimal total_discounts:decimal total_taxes:decimal grand_total:decimal nett_sales:decimal cash_sales:decimal credit_sales:decimal other_sales:decimal commercial_taxes:decimal cash_in:decimal cash_out:decimal
|
||||
|
||||
26
spec/controllers/cash_mgmt_controller_spec.rb
Normal file
26
spec/controllers/cash_mgmt_controller_spec.rb
Normal file
@@ -0,0 +1,26 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe CashMgmtController, type: :controller do
|
||||
|
||||
describe "GET #index" do
|
||||
it "returns http success" do
|
||||
get :index
|
||||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET #new" do
|
||||
it "returns http success" do
|
||||
get :new
|
||||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET #create" do
|
||||
it "returns http success" do
|
||||
get :create
|
||||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
33
spec/controllers/origami/shifts_controller_spec.rb
Normal file
33
spec/controllers/origami/shifts_controller_spec.rb
Normal file
@@ -0,0 +1,33 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Origami::ShiftsController, type: :controller do
|
||||
|
||||
describe "GET #index" do
|
||||
it "returns http success" do
|
||||
get :index
|
||||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET #show" do
|
||||
it "returns http success" do
|
||||
get :show
|
||||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET #new" do
|
||||
it "returns http success" do
|
||||
get :new
|
||||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET #edit" do
|
||||
it "returns http success" do
|
||||
get :edit
|
||||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
15
spec/helpers/cash_mgmt_helper_spec.rb
Normal file
15
spec/helpers/cash_mgmt_helper_spec.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
require 'rails_helper'
|
||||
|
||||
# Specs in this file have access to a helper object that includes
|
||||
# the CashMgmtHelper. For example:
|
||||
#
|
||||
# describe CashMgmtHelper do
|
||||
# describe "string concat" do
|
||||
# it "concats two strings with spaces" do
|
||||
# expect(helper.concat_strings("this","that")).to eq("this that")
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
RSpec.describe CashMgmtHelper, type: :helper do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
15
spec/helpers/origami/shifts_helper_spec.rb
Normal file
15
spec/helpers/origami/shifts_helper_spec.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
require 'rails_helper'
|
||||
|
||||
# Specs in this file have access to a helper object that includes
|
||||
# the Origami::ShiftsHelper. For example:
|
||||
#
|
||||
# describe Origami::ShiftsHelper do
|
||||
# describe "string concat" do
|
||||
# it "concats two strings with spaces" do
|
||||
# expect(helper.concat_strings("this","that")).to eq("this that")
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
RSpec.describe Origami::ShiftsHelper, type: :helper do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
5
spec/models/payment_journal_spec.rb
Normal file
5
spec/models/payment_journal_spec.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe PaymentJournal, type: :model do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
5
spec/models/shift_sale_spec.rb
Normal file
5
spec/models/shift_sale_spec.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe ShiftSale, type: :model do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
5
spec/views/cash_mgmt/create.html.erb_spec.rb
Normal file
5
spec/views/cash_mgmt/create.html.erb_spec.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "cash_mgmt/create.html.erb", type: :view do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
5
spec/views/cash_mgmt/index.html.erb_spec.rb
Normal file
5
spec/views/cash_mgmt/index.html.erb_spec.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "cash_mgmt/index.html.erb", type: :view do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
5
spec/views/cash_mgmt/new.html.erb_spec.rb
Normal file
5
spec/views/cash_mgmt/new.html.erb_spec.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "cash_mgmt/new.html.erb", type: :view do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
5
spec/views/origami/shifts/edit.html.erb_spec.rb
Normal file
5
spec/views/origami/shifts/edit.html.erb_spec.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "shifts/edit.html.erb", type: :view do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
5
spec/views/origami/shifts/index.html.erb_spec.rb
Normal file
5
spec/views/origami/shifts/index.html.erb_spec.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "shifts/index.html.erb", type: :view do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
5
spec/views/origami/shifts/new.html.erb_spec.rb
Normal file
5
spec/views/origami/shifts/new.html.erb_spec.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "shifts/new.html.erb", type: :view do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
5
spec/views/origami/shifts/show.html.erb_spec.rb
Normal file
5
spec/views/origami/shifts/show.html.erb_spec.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "shifts/show.html.erb", type: :view do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
Reference in New Issue
Block a user