merge with august_spring

This commit is contained in:
Yan
2017-08-15 17:04:28 +06:30
30 changed files with 1089 additions and 1270 deletions

3
.gitignore vendored
View File

@@ -51,3 +51,6 @@ dump.rdb
# Fonts # Fonts
public/fonts/* public/fonts/*
# Ruby-Mine IDE folder
/.idea

2
.idea/.generators generated
View File

@@ -5,4 +5,4 @@ You are allowed to:
2. Remove generators 2. Remove generators
3. Add installed generators 3. Add installed generators
To add new installed generators automatically delete this file and reload the project. To add new installed generators automatically delete this file and reload the project.
--><GeneratorsGroup><Generator name="active_record:migration" /><Generator name="active_record:model" /><Generator name="active_record:observer" /><Generator name="active_record:session_migration" /><Generator name="controller" /><Generator name="erb:controller" /><Generator name="erb:mailer" /><Generator name="erb:scaffold" /><Generator name="generator" /><Generator name="helper" /><Generator name="integration_test" /><Generator name="mailer" /><Generator name="metal" /><Generator name="migration" /><Generator name="model" /><Generator name="model_subclass" /><Generator name="observer" /><Generator name="performance_test" /><Generator name="plugin" /><Generator name="resource" /><Generator name="scaffold" /><Generator name="scaffold_controller" /><Generator name="session_migration" /><Generator name="stylesheets" /><Generator name="test_unit:controller" /><Generator name="test_unit:helper" /><Generator name="test_unit:integration" /><Generator name="test_unit:mailer" /><Generator name="test_unit:model" /><Generator name="test_unit:observer" /><Generator name="test_unit:performance" /><Generator name="test_unit:plugin" /><Generator name="test_unit:scaffold" /></GeneratorsGroup></Settings> --><GeneratorsGroup><Generator name="assets" /><Generator name="cancan:ability" /><Generator name="channel" /><Generator name="coffee:assets" /><Generator name="controller" /><Generator name="factory_girl:model" /><Generator name="generator" /><Generator name="helper" /><Generator name="integration_test" /><Generator name="jbuilder" /><Generator name="job" /><Generator name="js:assets" /><Generator name="kaminari:config" /><Generator name="kaminari:views" /><Generator name="mailer" /><Generator name="migration" /><Generator name="model" /><Generator name="resource" /><Generator name="rspec:controller" /><Generator name="rspec:feature" /><Generator name="rspec:helper" /><Generator name="rspec:install" /><Generator name="rspec:integration" /><Generator name="rspec:job" /><Generator name="rspec:mailer" /><Generator name="rspec:model" /><Generator name="rspec:observer" /><Generator name="rspec:request" /><Generator name="rspec:scaffold" /><Generator name="rspec:view" /><Generator name="scaffold" /><Generator name="scaffold_controller" /><Generator name="sidekiq:worker" /><Generator name="simple_form:install" /><Generator name="system_test" /><Generator name="task" /><Generator name="test_unit:controller" /><Generator name="test_unit:generator" /><Generator name="test_unit:helper" /><Generator name="test_unit:integration" /><Generator name="test_unit:job" /><Generator name="test_unit:mailer" /><Generator name="test_unit:model" /><Generator name="test_unit:plugin" /><Generator name="test_unit:scaffold" /><Generator name="test_unit:system" /></GeneratorsGroup></Settings>

2
.idea/.rakeTasks generated

File diff suppressed because one or more lines are too long

28
.idea/sxrestaurant.iml generated
View File

@@ -124,14 +124,14 @@
</content> </content>
<orderEntry type="inheritedJdk" /> <orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="PROVIDED" name="actioncable (v5.1.1, rbenv: 2.3.3) [gem]" level="application" /> <orderEntry type="library" scope="PROVIDED" name="actioncable (v5.1.3, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="actionmailer (v5.1.1, rbenv: 2.3.3) [gem]" level="application" /> <orderEntry type="library" scope="PROVIDED" name="actionmailer (v5.1.3, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="actionpack (v5.1.1, rbenv: 2.3.3) [gem]" level="application" /> <orderEntry type="library" scope="PROVIDED" name="actionpack (v5.1.3, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="actionview (v5.1.1, rbenv: 2.3.3) [gem]" level="application" /> <orderEntry type="library" scope="PROVIDED" name="actionview (v5.1.3, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="activejob (v5.1.1, rbenv: 2.3.3) [gem]" level="application" /> <orderEntry type="library" scope="PROVIDED" name="activejob (v5.1.3, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="activemodel (v5.1.1, rbenv: 2.3.3) [gem]" level="application" /> <orderEntry type="library" scope="PROVIDED" name="activemodel (v5.1.3, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="activerecord (v5.1.1, rbenv: 2.3.3) [gem]" level="application" /> <orderEntry type="library" scope="PROVIDED" name="activerecord (v5.1.3, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="activesupport (v5.1.1, rbenv: 2.3.3) [gem]" level="application" /> <orderEntry type="library" scope="PROVIDED" name="activesupport (v5.1.3, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="arel (v8.0.0, rbenv: 2.3.3) [gem]" level="application" /> <orderEntry type="library" scope="PROVIDED" name="arel (v8.0.0, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="autoprefixer-rails (v7.1.1.2, rbenv: 2.3.3) [gem]" level="application" /> <orderEntry type="library" scope="PROVIDED" name="autoprefixer-rails (v7.1.1.2, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="bcrypt (v3.1.11, rbenv: 2.3.3) [gem]" level="application" /> <orderEntry type="library" scope="PROVIDED" name="bcrypt (v3.1.11, rbenv: 2.3.3) [gem]" level="application" />
@@ -142,6 +142,7 @@
<orderEntry type="library" scope="PROVIDED" name="bundler (v1.14.6, rbenv: 2.3.3) [gem]" level="application" /> <orderEntry type="library" scope="PROVIDED" name="bundler (v1.14.6, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="byebug (v9.0.6, rbenv: 2.3.3) [gem]" level="application" /> <orderEntry type="library" scope="PROVIDED" name="byebug (v9.0.6, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="cancancan (v1.17.0, rbenv: 2.3.3) [gem]" level="application" /> <orderEntry type="library" scope="PROVIDED" name="cancancan (v1.17.0, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="chronic (v0.10.2, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="coffee-rails (v4.2.2, rbenv: 2.3.3) [gem]" level="application" /> <orderEntry type="library" scope="PROVIDED" name="coffee-rails (v4.2.2, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="coffee-script (v2.4.1, rbenv: 2.3.3) [gem]" level="application" /> <orderEntry type="library" scope="PROVIDED" name="coffee-script (v2.4.1, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="coffee-script-source (v1.12.2, rbenv: 2.3.3) [gem]" level="application" /> <orderEntry type="library" scope="PROVIDED" name="coffee-script-source (v1.12.2, rbenv: 2.3.3) [gem]" level="application" />
@@ -150,7 +151,7 @@
<orderEntry type="library" scope="PROVIDED" name="cups (v0.0.7, rbenv: 2.3.3) [gem]" level="application" /> <orderEntry type="library" scope="PROVIDED" name="cups (v0.0.7, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="database_cleaner (v1.6.1, rbenv: 2.3.3) [gem]" level="application" /> <orderEntry type="library" scope="PROVIDED" name="database_cleaner (v1.6.1, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.3, rbenv: 2.3.3) [gem]" level="application" /> <orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.3, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="erubi (v1.6.0, rbenv: 2.3.3) [gem]" level="application" /> <orderEntry type="library" scope="PROVIDED" name="erubi (v1.6.1, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="execjs (v2.7.0, rbenv: 2.3.3) [gem]" level="application" /> <orderEntry type="library" scope="PROVIDED" name="execjs (v2.7.0, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="factory_girl (v4.8.0, rbenv: 2.3.3) [gem]" level="application" /> <orderEntry type="library" scope="PROVIDED" name="factory_girl (v4.8.0, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="factory_girl_rails (v4.8.0, rbenv: 2.3.3) [gem]" level="application" /> <orderEntry type="library" scope="PROVIDED" name="factory_girl_rails (v4.8.0, rbenv: 2.3.3) [gem]" level="application" />
@@ -160,7 +161,7 @@
<orderEntry type="library" scope="PROVIDED" name="font-awesome-rails (v4.7.0.2, rbenv: 2.3.3) [gem]" level="application" /> <orderEntry type="library" scope="PROVIDED" name="font-awesome-rails (v4.7.0.2, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="globalid (v0.4.0, rbenv: 2.3.3) [gem]" level="application" /> <orderEntry type="library" scope="PROVIDED" name="globalid (v0.4.0, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="httparty (v0.15.5, rbenv: 2.3.3) [gem]" level="application" /> <orderEntry type="library" scope="PROVIDED" name="httparty (v0.15.5, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="i18n (v0.8.4, rbenv: 2.3.3) [gem]" level="application" /> <orderEntry type="library" scope="PROVIDED" name="i18n (v0.8.6, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="jbuilder (v2.7.0, rbenv: 2.3.3) [gem]" level="application" /> <orderEntry type="library" scope="PROVIDED" name="jbuilder (v2.7.0, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="jquery-rails (v4.3.1, rbenv: 2.3.3) [gem]" level="application" /> <orderEntry type="library" scope="PROVIDED" name="jquery-rails (v4.3.1, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="jquery-ui-rails (v6.0.1, rbenv: 2.3.3) [gem]" level="application" /> <orderEntry type="library" scope="PROVIDED" name="jquery-ui-rails (v6.0.1, rbenv: 2.3.3) [gem]" level="application" />
@@ -175,7 +176,7 @@
<orderEntry type="library" scope="PROVIDED" name="mime-types (v3.1, rbenv: 2.3.3) [gem]" level="application" /> <orderEntry type="library" scope="PROVIDED" name="mime-types (v3.1, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="mime-types-data (v3.2016.0521, rbenv: 2.3.3) [gem]" level="application" /> <orderEntry type="library" scope="PROVIDED" name="mime-types-data (v3.2016.0521, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="mini_portile2 (v2.2.0, rbenv: 2.3.3) [gem]" level="application" /> <orderEntry type="library" scope="PROVIDED" name="mini_portile2 (v2.2.0, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="minitest (v5.10.2, rbenv: 2.3.3) [gem]" level="application" /> <orderEntry type="library" scope="PROVIDED" name="minitest (v5.10.3, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="multi_json (v1.12.1, rbenv: 2.3.3) [gem]" level="application" /> <orderEntry type="library" scope="PROVIDED" name="multi_json (v1.12.1, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="multi_xml (v0.6.0, rbenv: 2.3.3) [gem]" level="application" /> <orderEntry type="library" scope="PROVIDED" name="multi_xml (v0.6.0, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="mysql2 (v0.4.6, rbenv: 2.3.3) [gem]" level="application" /> <orderEntry type="library" scope="PROVIDED" name="mysql2 (v0.4.6, rbenv: 2.3.3) [gem]" level="application" />
@@ -190,10 +191,10 @@
<orderEntry type="library" scope="PROVIDED" name="rack-cors (v0.4.1, rbenv: 2.3.3) [gem]" level="application" /> <orderEntry type="library" scope="PROVIDED" name="rack-cors (v0.4.1, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="rack-protection (v2.0.0, rbenv: 2.3.3) [gem]" level="application" /> <orderEntry type="library" scope="PROVIDED" name="rack-protection (v2.0.0, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="rack-test (v0.6.3, rbenv: 2.3.3) [gem]" level="application" /> <orderEntry type="library" scope="PROVIDED" name="rack-test (v0.6.3, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="rails (v5.1.1, rbenv: 2.3.3) [gem]" level="application" /> <orderEntry type="library" scope="PROVIDED" name="rails (v5.1.3, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="rails-dom-testing (v2.0.3, rbenv: 2.3.3) [gem]" level="application" /> <orderEntry type="library" scope="PROVIDED" name="rails-dom-testing (v2.0.3, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="rails-html-sanitizer (v1.0.3, rbenv: 2.3.3) [gem]" level="application" /> <orderEntry type="library" scope="PROVIDED" name="rails-html-sanitizer (v1.0.3, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="railties (v5.1.1, rbenv: 2.3.3) [gem]" level="application" /> <orderEntry type="library" scope="PROVIDED" name="railties (v5.1.3, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="rake (v12.0.0, rbenv: 2.3.3) [gem]" level="application" /> <orderEntry type="library" scope="PROVIDED" name="rake (v12.0.0, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="rb-fsevent (v0.9.8, rbenv: 2.3.3) [gem]" level="application" /> <orderEntry type="library" scope="PROVIDED" name="rb-fsevent (v0.9.8, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="rb-inotify (v0.9.10, rbenv: 2.3.3) [gem]" level="application" /> <orderEntry type="library" scope="PROVIDED" name="rb-inotify (v0.9.10, rbenv: 2.3.3) [gem]" level="application" />
@@ -228,6 +229,7 @@
<orderEntry type="library" scope="PROVIDED" name="web-console (v3.5.1, rbenv: 2.3.3) [gem]" level="application" /> <orderEntry type="library" scope="PROVIDED" name="web-console (v3.5.1, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="websocket-driver (v0.6.5, rbenv: 2.3.3) [gem]" level="application" /> <orderEntry type="library" scope="PROVIDED" name="websocket-driver (v0.6.5, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="websocket-extensions (v0.1.2, rbenv: 2.3.3) [gem]" level="application" /> <orderEntry type="library" scope="PROVIDED" name="websocket-extensions (v0.1.2, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="whenever (v0.9.7, rbenv: 2.3.3) [gem]" level="application" />
</component> </component>
<component name="RModuleSettingsStorage"> <component name="RModuleSettingsStorage">
<LOAD_PATH number="0" /> <LOAD_PATH number="0" />

900
.idea/workspace.xml generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,31 +1,50 @@
class Origami::SaleEditController < BaseOrigamiController class Origami::SaleEditController < BaseOrigamiController
authorize_resource :class => false authorize_resource :class => false
# Index for sale item void OR edit # Index for sale item void OR edit
def edit def edit
sale_id = params[:sale_id] sale_id = params[:sale_id]
@table_id = params[:table_id] @table_id = params[:table_id]
@saleobj = Sale.find(sale_id) @saleobj = Sale.find(sale_id)
end end
# create item void. make duplicate old record and update qty and price # create item void. make duplicate old record and update qty and price
def item_void def item_void
saleitemId = params[:sale_item_id] saleitemId = params[:sale_item_id]
saleitemObj = SaleItem.find(saleitemId) saleitemObj = SaleItem.find(saleitemId)
saleitemObj.remark = 'void' saleitemObj.remark = 'void'
saleitemObj.save saleitemObj.save
@newsaleitem = SaleItem.new @newsaleitem = SaleItem.new
@newsaleitem = saleitemObj.dup @newsaleitem = saleitemObj.dup
@newsaleitem.save @newsaleitem.save
@newsaleitem.qty = saleitemObj.qty * -1 @newsaleitem.qty = saleitemObj.qty * -1
@newsaleitem.price = saleitemObj.price * -1 @newsaleitem.price = saleitemObj.price * -1
@newsaleitem.is_taxable = 1 @newsaleitem.is_taxable = 1
@newsaleitem.product_name = saleitemObj.product_name + " - void" @newsaleitem.product_name = saleitemObj.product_name + " - void"
@newsaleitem.save @newsaleitem.save
# re-calc tax # re-calc tax
saleObj = Sale.find(saleitemObj.sale_id) saleObj = Sale.find(saleitemObj.sale_id)
saleObj.compute_without_void saleObj.compute_without_void
end end
def item_foc
saleitemId = params[:sale_item_id]
saleitemObj = SaleItem.find(saleitemId)
saleitemObj.remark = 'foc'
saleitemObj.save
@newsaleitem = SaleItem.new
@newsaleitem = saleitemObj.dup
@newsaleitem.save
@newsaleitem.qty = saleitemObj.qty * -1
@newsaleitem.price = saleitemObj.price * -1
@newsaleitem.is_taxable = 1
@newsaleitem.product_name = saleitemObj.product_name + ' foc'
@newsaleitem.save
# re-calc tax
saleObj = Sale.find(saleitemObj.sale_id)
saleObj.compute_without_void
end
# def item_edit # def item_edit
# saleitemId = params[:sale_item_id] # saleitemId = params[:sale_item_id]
@@ -48,63 +67,63 @@ class Origami::SaleEditController < BaseOrigamiController
# end # end
def item_edit def item_edit
saleitemId = params[:sale_item_id] saleitemId = params[:sale_item_id]
update_qty = params[:update_qty] update_qty = params[:update_qty]
update_price = params[:update_price] update_price = params[:update_price]
saleitemObj = SaleItem.find(saleitemId) saleitemObj = SaleItem.find(saleitemId)
saleitemObj.qty = update_qty saleitemObj.qty = update_qty
saleitemObj.price = update_qty.to_f * update_price.to_f saleitemObj.price = update_qty.to_f * update_price.to_f
saleitemObj.unit_price = update_price saleitemObj.unit_price = update_price
saleitemObj.taxable_price = update_qty.to_f * update_price.to_f saleitemObj.taxable_price = update_qty.to_f * update_price.to_f
# saleitemObj.remark = 'edit' # saleitemObj.remark = 'edit'
saleitemObj.product_name = saleitemObj.product_name + " - updated" saleitemObj.product_name = saleitemObj.product_name + " - updated"
saleitemObj.save saleitemObj.save
# re-calc tax # re-calc tax
saleObj = Sale.find(saleitemObj.sale_id) saleObj = Sale.find(saleitemObj.sale_id)
saleObj.compute_without_void saleObj.compute_without_void
end end
# make cancel void item # make cancel void item
def item_void_cancel def item_void_cancel
saleitemId = params[:sale_item_id] saleitemId = params[:sale_item_id]
saleitemObj = SaleItem.find(saleitemId) saleitemObj = SaleItem.find(saleitemId)
both = SaleItem.where('product_code=?',saleitemObj.product_code) both = SaleItem.where('product_code=?', saleitemObj.product_code)
both.each do |item| both.each do |item|
if item.qty.to_i > 0 if item.qty.to_i > 0
item.remark = nil item.remark = nil
item.save item.save
end end
end end
saleitemObj.destroy saleitemObj.destroy
# re-calc tax # re-calc tax
saleObj = Sale.find(saleitemObj.sale_id) saleObj = Sale.find(saleitemObj.sale_id)
saleObj.compute_without_void saleObj.compute_without_void
end end
# remove all void items # remove all void items
def cancel_all_void def cancel_all_void
sale_id = params[:sale_id] sale_id = params[:sale_id]
saleObj = Sale.find(sale_id) saleObj = Sale.find(sale_id)
saleObj.sale_items.each do |item| saleObj.sale_items.each do |item|
if item.qty.to_i < 0 if item.qty.to_i < 0
item.destroy item.destroy
else else
item.remark = nil item.remark = nil
end end
item.save item.save
end end
# re-calc tax # re-calc tax
saleObj.compute_without_void saleObj.compute_without_void
end end
def apply_void def apply_void
sale_id = params[:sale_id] sale_id = params[:sale_id]
saleObj = Sale.find(sale_id) saleObj = Sale.find(sale_id)
saleObj.compute_without_void saleObj.compute_without_void
end end
end end

View File

@@ -70,6 +70,6 @@ class PrintSettingsController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through. # Never trust parameters from the scary internet, only allow the white list through.
def print_setting_params def print_setting_params
params.require(:print_setting).permit(:name, :unique_code, :template, :db_name, :db_type, :db_username, :db_password, :printer_name, :api_settings, :page_width, :page_height, :print_copies,:precision,:delimiter,:heading_space) params.require(:print_setting).permit(:name, :unique_code, :template, :printer_name, :api_settings, :page_width, :page_height, :print_copies,:precision,:delimiter,:heading_space)
end end
end end

View File

@@ -16,6 +16,9 @@ class Settings::DiningChargesController < ApplicationController
# GET /dining_charges/new # GET /dining_charges/new
def new def new
@dining_charge = DiningCharge.new @dining_charge = DiningCharge.new
@dining_charge.minimum_free_time="00:30"
@dining_charge.charge_block="02:00"
@dining_charge.time_rounding_block="00:15"
end end
# GET /dining_charges/1/edit # GET /dining_charges/1/edit
@@ -29,7 +32,11 @@ class Settings::DiningChargesController < ApplicationController
@dining_charge.dining_facility_id = @settings_dining_facility.id @dining_charge.dining_facility_id = @settings_dining_facility.id
respond_to do |format| respond_to do |format|
if @dining_charge.save if @dining_charge.save
format.html { redirect_to edit_settings_zone_table_path(@zone,@settings_dining_facility), notice: 'Dining charge was successfully created.' } if @table
format.html { redirect_to edit_settings_zone_table_path(@zone,@settings_dining_facility), notice: 'Dining charge was successfully created.' }
else
format.html { redirect_to edit_settings_zone_room_path(@zone,@settings_dining_facility), notice: 'Dining charge was successfully created.' }
end
format.json { render :show, status: :created, location: @dining_charge } format.json { render :show, status: :created, location: @dining_charge }
else else
format.html { render :new } format.html { render :new }
@@ -44,7 +51,11 @@ class Settings::DiningChargesController < ApplicationController
respond_to do |format| respond_to do |format|
@dining_charge.dining_facility_id = @settings_dining_facility.id @dining_charge.dining_facility_id = @settings_dining_facility.id
if @dining_charge.update(dining_charge_params) if @dining_charge.update(dining_charge_params)
format.html { redirect_to edit_settings_zone_table_path(@zone,@settings_dining_facility), notice: 'Dining charge was successfully updated.' } if @table
format.html { redirect_to edit_settings_zone_table_path(@zone,@settings_dining_facility), notice: 'Dining charge was successfully updated.' }
else
format.html { redirect_to edit_settings_zone_room_path(@zone,@settings_dining_facility), notice: 'Dining charge was successfully updated.' }
end
format.json { render :show, status: :ok, location: @dining_charge } format.json { render :show, status: :ok, location: @dining_charge }
else else
format.html { render :edit } format.html { render :edit }

View File

@@ -5,11 +5,8 @@ class Ability
user ||= Employee.new user ||= Employee.new
if user.role == "administrator" if user.role == "administrator"
can :manage, :all can :manage, :all
elsif user.role == "manager" elsif user.role == "manager"
can :manage, Menu can :manage, Menu
can :manage, MenuCategory can :manage, MenuCategory
can :manage, MenuItemAttribute can :manage, MenuItemAttribute
@@ -98,7 +95,6 @@ class Ability
can :create, :payment can :create, :payment
can :reprint, :payment can :reprint, :payment
can :rounding_adj, :payment can :rounding_adj, :payment
can :foc, :payment
can :move_dining, :movetable can :move_dining, :movetable
can :moving, :movetable can :moving, :movetable
@@ -132,7 +128,5 @@ class Ability
can :reprint, :payment can :reprint, :payment
can :rounding_adj, :payment can :rounding_adj, :payment
end end
end end
end end

View File

@@ -2,40 +2,75 @@ class DiningCharge < ApplicationRecord
belongs_to :table belongs_to :table
belongs_to :room belongs_to :room
def amount_calculate(dining_charges_obj, checkin , checkout) def self.amount_calculate(dining_charges_obj, checkin , checkout)
if !checkin.nil? && !checkout.nil? && !dining_charges_obj.nil? if !checkin.nil? && !checkout.nil? && !dining_charges_obj.nil?
price = 0
minutes = ((checkin - checkout) * 24 * 60).to_i # stay minutes minutes = DiningCharge.time_diff(checkout, checkin)
dining_minutes = minutes - dining_charges_obj.minimum_free_time # stayminutes - free minutes free_time = DiningCharge.convert_to_minutes(dining_charges_obj.minimum_free_time.strftime('%H:%M'))
dining_minutes = minutes - free_time # stayminutes - free minutes
charge_type = dining_charges_obj.charge_type charge_type = dining_charges_obj.charge_type
if charge_type == 'hr' if charge_type == 'hr'
price = DiningCharge.charges(dining_charges_obj, dining_minutes, 'hr')
elsif charge_type == 'day' elsif charge_type == 'day'
price = charge_by_day price = charges(dining_charges_obj, dining_minutes, 'day')
end end
return price
else
puts "<<<<<<<< NO"
end end
end end
def charge_by_hour def self.charges(chargesObj, dining_minutes, type)
solid_price = 0
end block = DiningCharge.convert_to_minutes(chargesObj.charge_block.strftime('%H:%M'))
result = dining_minutes / block
def charge_by_day(chargesObj, dining_minutes) if result.to_i < 1
minues_per_day = 12 * 60
result = dining_minutes / minues_per_day
if result < 1
return chargesObj.unit_price return chargesObj.unit_price
elsif result > 1 elsif result.to_i >= 1
solid_price = result * chargesObj.unit_price solid_price = result * chargesObj.unit_price
remain_value = dining_minutes % block
remain_value = dining_minutes % minues_per_day rounding_block = DiningCharge.convert_to_minutes(chargesObj.time_rounding_block.strftime('%H:%M'))
roundingblock = remain_value / chargesObj.time_rounding_block roundingblock = remain_value / rounding_block
if roundingblock > 1 if roundingblock.to_i < 1
return DiningCharge.check_rounding(chargesObj, solid_price)
else
solid_price += roundingblock * chargesObj.time_rounding_block_price
remain_rounding = dining_minutes % block
if remain_rounding.to_i < 1
return DiningCharge.check_rounding(chargesObj, solid_price)
else
return solid_price
end
end end
end end
end end
def self.check_rounding(chargesObj)
if chargesObj.time_rounding == "down"
return solid_price
else
return solid_price += chargesObj.time_rounding_block_price
end
end
def self.time_diff(start_time, end_time)
seconds_diff = (start_time - end_time).to_i.abs
hours = seconds_diff / 3600
seconds_diff -= hours * 3600
minutes = seconds_diff / 60
seconds_diff -= minutes * 60
seconds = seconds_diff
return hours * 60 + minutes
end
def self.convert_to_minutes(time)
arr = time.split(":")
hour = arr[0].to_i * 60
return hour + arr[1].to_i
end
end end

View File

@@ -109,6 +109,14 @@ class Sale < ApplicationRecord
booking.checkout_by = requested_by.name booking.checkout_by = requested_by.name
booking.save booking.save
# dining charges
charges = DiningCharge.where('dining_facility_id=?',booking.dining_facility_id).take
if !charges.nil?
diningprice = DiningCharge.amount_calculate(charges, booking.checkin_at, booking.checkout_at)
dining_time = booking.checkin_at.strftime('%H:%M %p').to_s + " - " + booking.checkout_at.strftime('%H:%M %p').to_s
create_saleitem_diningcharges(charges, diningprice, booking.dining_facility.name, dining_time)
end
return true, self.id return true, self.id
end end
@@ -162,6 +170,20 @@ class Sale < ApplicationRecord
self.sale_items << sale_item self.sale_items << sale_item
end end
def create_saleitem_diningcharges(chargeObj, diningprice, dining_name, dining_time)
sale_item = SaleItem.new
sale_item.product_code = chargeObj.item_code
sale_item.product_name = dining_name.to_s + " ( " + dining_time.to_s + " )"
# sale_item.account_id = item.account_id
sale_item.product_alt_name = "-"
sale_item.qty = 1
sale_item.unit_price = chargeObj.unit_price
sale_item.taxable_price = diningprice
sale_item.is_taxable = chargeObj.taxable
sale_item.sale_id = self.id
sale_item.price = diningprice
sale_item.save
end
def update_item (item) def update_item (item)
#save sale_audit #save sale_audit
@@ -245,7 +267,7 @@ class Sale < ApplicationRecord
rounding_adjustment = 0 rounding_adjustment = 0
sales_items.each do |item| sales_items.each do |item|
if item.remark != 'void' if item.remark != 'void' && item.remark != 'foc'
#compute each item and added to total #compute each item and added to total
subtotal_price = subtotal_price + item.price subtotal_price = subtotal_price + item.price
total_taxable = total_taxable + item.price total_taxable = total_taxable + item.price
@@ -318,7 +340,8 @@ class Sale < ApplicationRecord
tax_profiles = TaxProfile.all.order("order_by asc") tax_profiles = TaxProfile.all.order("order_by asc")
customer = Customer.find(self.customer_id) customer = Customer.find(self.customer_id)
# #Create new tax records
#Create new tax records
tax_profiles.each do |tax| tax_profiles.each do |tax|
customer.tax_profiles.each do |cus_tax| customer.tax_profiles.each do |cus_tax|
if cus_tax.to_i == tax.id if cus_tax.to_i == tax.id
@@ -575,77 +598,75 @@ def self.get_item_query()
query = query.group('i.product_code ').order("mi.account_id, mi.menu_category_id") query = query.group('i.product_code ').order("mi.account_id, mi.menu_category_id")
end end
def self.get_by_shift_items(shift_sale_range, shift, from, to, status)
# date_type_selection = get_sql_function_for_report_type(report_type)
def self.get_by_shift_items(shift_sale_range, shift, from, to, status) query = self.get_item_query()
discount_query = 0
total_card_amount = 0
total_cash_amount = 0
total_credit_amount = 0
total_foc_amount = 0
total_grand_total = 0
# date_type_selection = get_sql_function_for_report_type(report_type) if shift.present?
query = query.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a)
discount_query = Sale.where("sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:total_discount)
change_amount = Sale.where("sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:amount_changed)
sale_cash = Sale.select("SUM(case when (sale_payments.payment_method ='mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar') then (sale_payments.payment_amount) else 0 end) as card_amount,
SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount,
SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount")
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
.where("sales.shift_sale_id in (?) and sale_status = 'completed' and sale_payments.payment_amount != 0 ", shift.to_a)
sale_cash.each do |s_c|
total_cash_amount += s_c.cash_amount.to_f
total_card_amount += s_c.card_amount.to_f
total_credit_amount += s_c.credit_amount.to_f
total_foc_amount += s_c.foc_amount.to_f
end
total_grand_total = total_cash_amount.to_f + total_card_amount.to_f + total_credit_amount.to_f
query = self.get_item_query() ### => get all sales range in shift_sales
discount_query = 0 elsif shift_sale_range.present?
total_card_amount = 0 query = query.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a)
total_cash_amount = 0 discount_query = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:total_discount)
total_credit_amount = 0 change_amount = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:amount_changed)
total_foc_amount = 0 sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar') then (sale_payments.payment_amount) else 0 end) as card_amount,
total_grand_total = 0 SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount,
SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount")
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
.where("sales.shift_sale_id in (?) and sale_status = 'completed' and sale_payments.payment_amount != 0 ", shift_sale_range.to_a)
sale_cash.each do |s_c|
total_cash_amount += s_c.cash_amount.to_f
total_card_amount += s_c.card_amount.to_f
total_credit_amount += s_c.credit_amount.to_f
total_foc_amount += s_c.foc_amount.to_f
end
total_grand_total = total_cash_amount.to_f + total_card_amount.to_f + total_credit_amount.to_f
if shift.present? else
query = query.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a) query = query.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to)
discount_query = Sale.where("sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:total_discount) discount_query = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:total_discount)
change_amount = Sale.where("sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:amount_changed) change_amount = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:amount_changed)
sale_cash = Sale.select("SUM(case when (sale_payments.payment_method ='mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar') then (sale_payments.payment_amount) else 0 end) as card_amount, sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar') then (sale_payments.payment_amount) else 0 end) as card_amount,
SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount, SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount,
SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount, SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount") SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount")
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id") .joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
.where("sales.shift_sale_id in (?) and sale_status = 'completed' and sale_payments.payment_amount != 0 ", shift.to_a) .where("sales.receipt_date between ? and ? and sale_status = 'completed' and sale_payments.payment_amount != 0 ", from,to)
sale_cash.each do |s_c| sale_cash.each do |s_c|
total_cash_amount += s_c.cash_amount.to_f total_cash_amount += s_c.cash_amount.to_f
total_card_amount += s_c.card_amount.to_f total_card_amount += s_c.card_amount.to_f
total_credit_amount += s_c.credit_amount.to_f total_credit_amount += s_c.credit_amount.to_f
total_foc_amount += s_c.foc_amount.to_f total_foc_amount += s_c.foc_amount.to_f
end end
total_grand_total = total_cash_amount.to_f + total_card_amount.to_f + total_credit_amount.to_f total_grand_total = total_cash_amount.to_f + total_card_amount.to_f + total_credit_amount.to_f
### => get all sales range in shift_sales end
elsif shift_sale_range.present?
query = query.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a)
discount_query = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:total_discount)
change_amount = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:amount_changed)
sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar') then (sale_payments.payment_amount) else 0 end) as card_amount,
SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount,
SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount")
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
.where("sales.shift_sale_id in (?) and sale_status = 'completed' and sale_payments.payment_amount != 0 ", shift_sale_range.to_a)
sale_cash.each do |s_c|
total_cash_amount += s_c.cash_amount.to_f
total_card_amount += s_c.card_amount.to_f
total_credit_amount += s_c.credit_amount.to_f
total_foc_amount += s_c.foc_amount.to_f
end
total_grand_total = total_cash_amount.to_f + total_card_amount.to_f + total_credit_amount.to_f
else return query, discount_query , total_cash_amount , total_card_amount , total_credit_amount , total_foc_amount , total_grand_total , change_amount
query = query.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to)
discount_query = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:total_discount)
change_amount = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:amount_changed)
sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar') then (sale_payments.payment_amount) else 0 end) as card_amount,
SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount,
SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount")
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
.where("sales.receipt_date between ? and ? and sale_status = 'completed' and sale_payments.payment_amount != 0 ", from,to)
sale_cash.each do |s_c|
total_cash_amount += s_c.cash_amount.to_f
total_card_amount += s_c.card_amount.to_f
total_credit_amount += s_c.credit_amount.to_f
total_foc_amount += s_c.foc_amount.to_f
end
total_grand_total = total_cash_amount.to_f + total_card_amount.to_f + total_credit_amount.to_f
end
return query, discount_query , total_cash_amount , total_card_amount , total_credit_amount , total_foc_amount , total_grand_total , change_amount
end end
def self.get_shift_sales_by_receipt_no(shift_sale_range,shift,from,to,payment_type) def self.get_shift_sales_by_receipt_no(shift_sale_range,shift,from,to,payment_type)
@@ -750,6 +771,15 @@ def self.get_separate_tax(shift_sale_range=nil,shift,from,to,payment_type)
end end
end end
# def self.get_separate_tax(from,to,payment_method=nil)
# query = SaleTax.select("SUM(tax_payable_amount) AS st_amount,tax_name")
# .joins("INNER JOIN sales ON sales.sale_id = sale_taxes.sale_id")
# .group("sale_taxes.tax_name")
# return query = query.where("sale_status=? and receipt_date between ? and ?","completed",from,to)
# end
def grand_total_after_rounding def grand_total_after_rounding
return self.old_grand_total.to_f + self.rounding_adjustment.to_f return self.old_grand_total.to_f + self.rounding_adjustment.to_f
end end

View File

@@ -1,8 +1,9 @@
class CloseCashierPdf < Prawn::Document class CloseCashierPdf < Prawn::Document
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width,:text_width attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width,:text_width
def initialize(printer_settings, shift_sale,shop_details,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount)
self.page_width = 210 def initialize(printer_settings, shift_sale,shop_details,sale_taxes)
self.page_height = 7000 self.page_width = printer_settings.page_width #PrintSetting.where("name = ?","Close Cashier").first.page_width
self.page_height = printer_settings.page_height
self.margin = 5 self.margin = 5
self.price_width = 40 self.price_width = 40
self.qty_width = 20 self.qty_width = 20
@@ -170,11 +171,9 @@ class CloseCashierPdf < Prawn::Document
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{shift_sale.credit_sales}", :size => self.item_font_size, :align => :right text "#{shift_sale.credit_sales}", :size => self.item_font_size, :align => :right
end end
#start other payment details #start other payment details
if shift_sale.other_sales > 0 if shift_sale.other_sales > 0
other_payment.each do |other| other_payment.each do |other|
y_position = cursor y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Other Payment Details", :size => self.item_font_size, :align => :right text "Other Payment Details", :size => self.item_font_size, :align => :right
@@ -232,9 +231,7 @@ class CloseCashierPdf < Prawn::Document
end end
end end
else else
y_position = cursor y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Other Payment :", :size => self.item_font_size, :align => :right text "Other Payment :", :size => self.item_font_size, :align => :right
@@ -242,15 +239,14 @@ class CloseCashierPdf < Prawn::Document
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{shift_sale.other_sales}", :size => self.item_font_size, :align => :right text "#{shift_sale.other_sales}", :size => self.item_font_size, :align => :right
end end
end end
# end other payment details # end other payment details
move_down -5 move_down -5
stroke_horizontal_rule stroke_horizontal_rule
move_down 7 move_down 7
#start total amount by Account Like Food / Beverage /.. #start total amount by Account Like Food / Beverage /..
total_amount_by_account.each do |amount| total_amount_by_account.each do |amount|
y_position = cursor y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total #{amount.account_name} Amount:", :size => self.item_font_size, :align => :right text "Total #{amount.account_name} Amount:", :size => self.item_font_size, :align => :right
@@ -381,8 +377,6 @@ class CloseCashierPdf < Prawn::Document
stroke_horizontal_rule stroke_horizontal_rule
move_down 5 move_down 5
move_down 5 move_down 5
end end
end end

View File

@@ -1,8 +1,8 @@
class CrmOrderPdf < Prawn::Document class CrmOrderPdf < Prawn::Document
attr_accessor :receipt_width,:price_column_width,:p_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_column_width,:item_description_width attr_accessor :receipt_width,:price_column_width,:p_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_column_width,:item_description_width
def initialize(booking,order_items,printer_settings) def initialize(booking,order_items,printer_settings)
self.p_width = 200 self.page_width = PrintSetting.where("name = ?","CRM Order").first.page_width
self.page_height = 1450 self.page_height = PrintSetting.where("name = ?","CRM Order").first.page_height
self.margin = 10 self.margin = 10
# self.price_width = self.p_width / 2 # self.price_width = self.p_width / 2
self.price_width=80 self.price_width=80

View File

@@ -2,8 +2,8 @@ class OrderItemPdf < Prawn::Document
include ActionView::Helpers::NumberHelper include ActionView::Helpers::NumberHelper
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width
def initialize(print_settings,order_item, print_status, options, alt_name) def initialize(print_settings,order_item, print_status, options, alt_name)
self.page_width = 185 self.page_width = PrintSetting.where("name = ?","OrderItemPdf").first.page_width
self.page_height = 1450 self.page_height = PrintSetting.where("name = ?","OrderItemPdf").first.page_height
self.margin = 0 self.margin = 0
self.price_width = 40 # No Need for item self.price_width = 40 # No Need for item
self.qty_width = 40 self.qty_width = 40

View File

@@ -2,8 +2,8 @@ class OrderSummaryPdf < Prawn::Document
include ActionView::Helpers::NumberHelper include ActionView::Helpers::NumberHelper
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width
def initialize(print_settings,order, print_status, order_items = nil,alt_name) def initialize(print_settings,order, print_status, order_items = nil,alt_name)
self.page_width = 190 self.page_width = PrintSetting.where("name = ?","Order Summary").first.page_width
self.page_height = 1450 self.page_height = PrintSetting.where("name = ?","Order Summary").first.page_height
self.margin = 0 self.margin = 0
self.price_width = 40 # No Need for item self.price_width = 40 # No Need for item
self.qty_width = 40 self.qty_width = 40

View File

@@ -1,8 +1,8 @@
class QueueNoPdf < Prawn::Document class QueueNoPdf < Prawn::Document
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width
def initialize(printer_settings, queue) def initialize(printer_settings, queue)
self.page_width = 210 self.page_width = PrintSetting.where("name = ?","Queue No").first.page_width
self.page_height = 1450 self.page_height = PrintSetting.where("name = ?","Queue No").first.page_height
self.margin = 5 self.margin = 5
self.price_width = 35 self.price_width = 35
self.qty_width = 20 self.qty_width = 20

View File

@@ -2,8 +2,8 @@ class ReceiptBillPdf < Prawn::Document
include ActionView::Helpers::NumberHelper include ActionView::Helpers::NumberHelper
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width, :description_width, :price_num_width attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width, :description_width, :price_num_width
def initialize(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details, printed_status) def initialize(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details, printed_status)
self.page_width = 210 self.page_width = PrintSetting.where("name = ?","Receipt Bill").first.page_width
self.page_height = 1450 self.page_height = PrintSetting.where("name = ?","Receipt Bill").first.page_height
self.margin = 5 self.margin = 5
self.price_width = 40 self.price_width = 40
self.qty_width = 20 self.qty_width = 20

View File

@@ -1,21 +1,228 @@
<div class="row"> <div class="row">
<div class="col-md-4 col-sm-6 col-md-offset-4 col-sm-offset-3"> <div class="col-md-4 col-sm-6 col-md-offset-4 col-sm-offset-3">
<% if current_login_employee.role = "admin" %> <% if current_login_employee.role = "admin" %>
<% elsif current_login_employee.role = "cashier" %> <% elsif current_login_employee.role = "cashier" %>
<%= link_to "Cashier Station", origami_path %> <%= link_to "Cashier Station", origami_path %>
<% elsif current_login_employee = "account" %>
<%= link_to "Cashier Station", oishi_path %>
<% else %>
<%= link_to "Cashier Station", oishi_path %>
<% end %>
<% shop = Shop.first %>
<% elsif current_login_employee = "account" %> </div>
<%= link_to "Cashier Station", oishi_path %>
<% else %>
<%= link_to "Cashier Station", oishi_path %>
<% end %>
<% shop = Shop.first %>
</div>
</div> </div>
<div class="col-md-2 container pull-right" style="margin: 0px !important;">
<div class="row">
<div class="col-md-12">
<div class="card" id="oqs" onclick="location.href='<%= oqs_root_path %>'">
<div class="card-content">
<span class="card-title">OQS</span>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="card" id="origami" onclick="location.href='<%= origami_root_path %>'">
<div class="card-content">
<span class="card-title">Origami</span>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="card" id="crm" onclick="location.href='<%= crm_root_path %>'">
<div class="card-content">
<span class="card-title">CRM</span>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="card" id="backend" onclick="location.href='<%= dashboard_path %>'">
<div class="card-content">
<span class="card-title">Backend</span>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-8 col-lg-8">
<div class="" style="max-height:550px; overflow:auto;padding: 15px">
<h4 class="card-title"><strong>Role Features</strong></h4>
<!-- <p><strong>Note:</strong> The <strong>data-parent</strong> attribute makes sure that all collapsible elements under the specified parent will be closed when one of the collapsible item is shown.</p> -->
<div class="panel-group" id="accordion">
<% if current_user.role == 'administrator' %>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#admin">Administrator
<span class="glyphicon glyphicon-plus"></span></a>
</h4>
</div>
<div id="admin" class="panel-collapse collapse in">
<div class="panel-body">
<ul class="col-md-4">
<li class="">All Settings</li>
<ul class="">
<li>Zone</li>
<li>OQS</li>
<li>Menu</li>
<li>Cashier Terminal</li>
<li>Payment</li>
<li>Merbership</li>
<li>Print</li>
<li>Employees</li>
<li>Accounts</li>
</ul>
</ul>
<ul class="col-md-4">
<li class="">Transactions</li>
<ul class="">
<li>Order</li>
<li>Sale</li>
<li>Credit Note</li>
</ul><br>
<li>Reports</li>
<ul class="">
<li>Daily Sale</li>
<li>Sale Item</li>
<li>Receipt</li>
<li>Shift Sale</li>
<li>Credit Sale</li>
<li>Void Sale</li>
</ul>
</ul>
<ul class="col-md-4">
<li>OQS</li><br>
<li>Origami</li><br>
<li>CRM</li>
</ul>
</div>
</div>
</div>
<% elsif current_user.role == 'manager' %>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#manager">Manager
<span class="glyphicon glyphicon-plus"></span></a>
</h4>
</div>
<div id="admin" class="panel-collapse collapse in">
<div class="panel-body">
<ul class="col-md-4">
<li class="">All Settings</li>
<ul class="">
<li>Zone</li>
<li>OQS</li>
<li>Menu</li>
<li>Cashier Terminal</li>
<li>Print</li>
<li>Employees</li>
<li>Accounts</li>
</ul>
</ul>
<ul class="col-md-4">
<li class="">Transactions</li>
<ul class="">
<li>Order</li>
<li>Sale</li>
<li>Credit Note</li>
</ul><br>
<li>Reports</li>
<ul class="">
<li>Daily Sale</li>
<li>Sale Item</li>
<li>Receipt</li>
<li>Shift Sale</li>
<li>Credit Sale</li>
<li>Void Sale</li>
</ul>
</ul>
<ul class="col-md-4">
<li>OQS</li><br>
<li>Origami</li><br>
<li>CRM</li>
</ul>
</div>
</div>
</div>
<% elsif current_user.role == 'supervisour' %>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#supervisor">Supervisor
<span class="glyphicon glyphicon-plus"></span></a>
</h4>
</div>
<div id="supervisor" class="panel-collapse collapse in">
<div class="panel-body">
<ul class="">
<li>OQS</li>
<ul>
<li class="">Void</li>
<li class="">FOC</li>
<li class="">Edit</li>
<li class="">Credit</li>
<li class="">Payment</li>
</ul>
</ul>
</div>
</div>
</div>
<% elsif current_user.role == 'cashier' %>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#cashier">Cashier
<span class="glyphicon glyphicon-plus"></span></a>
</h4>
</div>
<div id="cashier" class="panel-collapse collapse in">
<div class="panel-body">
<ul class="">
<li class="">Orgami Panel except Edit and Void</li>
<li class="">Sale and Order</li>
<li class="">and Queue in CRM</li>
</ul>
</div>
</div>
</div>
<% elsif current_user.role == 'account' %>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#accountant">Accountant
<span class="glyphicon glyphicon-plus"></span></a>
</h4>
</div>
<div id="accountant" class="panel-collapse collapse in">
<div class="panel-body">
<ul class="">
<li class="">Daily Sale Report</li>
<li class="">Sale Item Report</li>
<li class="">Receipt No Report</li>
<li class="">ShiftSale Report</li>
</ul>
</div>
</div>
</div>
<% end %>
</div> <!-- end accordion id -->
</div>
</div> <!-- end col-md-4 -->
<div class="footer"> <div class="footer">
<div class="card"> <div class="card">
<div class="page-header center-text"> <div class="page-header center-text">
@@ -32,3 +239,44 @@
</div> </div>
</div> </div>
<style type="text/css">
.card {
margin-top: 10px;
box-sizing: border-box;
border-radius: 2px;
background-clip: padding-box;
transition: 0.3s ease;
background-color: white;
box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.16), 0 2px 10px 0 rgba(0, 0, 0, 0.12);
}
.card span.card-title {
color: purple;
font-size: 28px;
font-weight: 400;
text-transform: uppercase;
transition: color 0.3s ease;
line-height: 48px;
}
.card .card-content {
padding: 15%;
border-radius: 0 0 2px 2px;
background-clip: padding-box;
box-sizing: border-box;
height: 120px;
transition: color 0.3s ease;
text-align: center;
}
.card .card-content p {
margin: 0;
color: inherit;
}
.card:hover {
box-shadow: 0 10px 20px 0 rgba(0, 0, 0, 0.16), 0 10px 20px 0 rgba(0, 0, 0, 0.12);
}
</style>

View File

@@ -1,86 +1,91 @@
<style> <style>
.pin_pad { .pin_pad {
width: 30%; width: 30%;
height:70px; height: 70px;
line-height:70px; line-height: 70px;
text-align:center; text-align: center;
background:#54A5AF; background: #54A5AF;
font-size:20px; font-size: 20px;
color:white; color: white;
} }
.bottom{
margin-bottom: 1px; .bottom {
margin-bottom: 1px;
} }
.left{
margin-left:1px; .left {
margin-left: 1px;
} }
.orange{
background-color:#FF7F50; .orange {
background-color: #FF7F50;
} }
.purple { .purple {
background-color:#7a62d3; background-color: #7a62d3;
} }
</style> </style>
<div class="row"> <div class="row">
<div class="col-md-4 col-sm-6 col-md-offset-4 col-sm-offset-3"> <div class="col-md-4 col-sm-6 col-md-offset-4 col-sm-offset-3">
<%= simple_form_for(@login_form, url: emp_login_update_path, method: "PATCH") do |f| %> <%= simple_form_for(@login_form, url: emp_login_update_path, method: "PATCH") do |f| %>
<div class="card"> <div class="card">
<div class="content" style="margin:10px"> <div class="content" style="margin:10px">
<div class="form-group"> <div class="form-group">
<%= f.input :emp_id,as: :hidden, label: "Access PIN", required: false, class: "form-control" %> <%= f.input :emp_id, as: :hidden, label: "Access PIN", required: false, class: "form-control" %>
<%= f.input :password, label: "Access PIN", required: false, class: "form-control" %> <%= f.input :password, label: "Access PIN", required: false, class: "form-control" %>
</div> </div>
</div> </div>
<div class="content row" style="padding-left:10px;margin-left:10px; margin-top:0px; text-align:center"> <div class="content row" style="padding-left:10px;margin-left:10px; margin-top:0px; text-align:center">
<div class='col-md-12'> <div class='col-md-12'>
<div class='row bottom'> <div class='row bottom'>
<div class="pin_pad " data-value="1">1</div> <div class="pin_pad " data-value="1">1</div>
<div class="pin_pad left" data-value="2">2</div> <div class="pin_pad left" data-value="2">2</div>
<div class="pin_pad left" data-value="3">3</div> <div class="pin_pad left" data-value="3">3</div>
</div>
<div class='row bottom'>
<div class="pin_pad" data-value="4">4</div>
<div class="pin_pad left" data-value="5">5</div>
<div class="pin_pad left" data-value="6">6</div>
</div>
<div class='row bottom'>
<div class="pin_pad" data-value="7">7</div>
<div class="pin_pad left" data-value="8">8</div>
<div class="pin_pad left" data-value="9">9</div>
</div>
<div class='row bottom'>
<div class="pin_pad orange" data-value="CLR">CLR</div>
<div class="pin_pad left" data-value="0">0</div>
<div class="pin_pad left purple" data-value="ENT">ENT</div>
</div>
</div> </div>
<div class="footer text-center" style="margin:10px"> <div class='row bottom'>
<div class="pin_pad" data-value="4">4</div>
</div> <div class="pin_pad left" data-value="5">5</div>
<div class="pin_pad left" data-value="6">6</div>
</div>
<div class='row bottom'>
<div class="pin_pad" data-value="7">7</div>
<div class="pin_pad left" data-value="8">8</div>
<div class="pin_pad left" data-value="9">9</div>
</div>
<div class='row bottom'>
<div class="pin_pad orange" data-value="CLR">CLR</div>
<div class="pin_pad left" data-value="0">0</div>
<div class="pin_pad left purple" data-value="ENT">ENT</div>
</div>
</div>
<div class="footer text-center" style="margin:10px">
</div> </div>
<% end %> </div>
<% end %>
</div> </div>
</div>
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
$(document).on('turbolinks:load', function() { $(document).on('turbolinks:load', function () {
$(".pin_pad").click(function(event){ $(".pin_pad").click(function (event) {
event.preventDefault(); event.preventDefault();
console.log($(this).data("value")); console.log($(this).data("value"));
var value = $(this).data("value"); var value = $(this).data("value");
if (value == "CLR") { if (value == "CLR") {
$("#login_form_password").val(""); $("#login_form_password").val("");
} else if(value == "ENT") { } else if (value == "ENT") {
$("#new_login_form").submit(); $("#new_login_form").submit();
} else { } else {
var old_value = $("#login_form_password").val(); var old_value = $("#login_form_password").val();
$("#login_form_password").val(old_value + value); $("#login_form_password").val(old_value + value);
} }
}); });
}); });
</script> </script>

View File

@@ -1,216 +1,235 @@
<div class="row"> <div class="row">
<!-- Column Two --> <!-- Column Two -->
<div class="col-lg-10 col-md-10 col-sm-10"> <div class="col-lg-10 col-md-10 col-sm-10">
<div class="card" > <div class="card">
<div class="card-header"> <div class="card-header">
<div><strong id="order-title">INVOICE DETAILS </strong></div> <div><strong id="order-title">INVOICE DETAILS </strong></div>
</div> </div>
<div class="card-block"> <div class="card-block">
<div class="card-title row"> <div class="card-title row">
<div class="col-lg-6 col-md-6 col-sm-6"> <div class="col-lg-6 col-md-6 col-sm-6">
<p> Receipt No: <span id="receipt_no"> <p> Receipt No: <span id="receipt_no">
<%= @saleobj.receipt_no rescue '' %> <%= @saleobj.receipt_no rescue '' %>
</span></p> </span></p>
</div> </div>
<div class="col-lg-6 col-md-6 col-sm-6 text-right"> <div class="col-lg-6 col-md-6 col-sm-6 text-right">
<p>Date: <span id="receipt_date"><%= @saleobj.created_at.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%></span></p> <p>Date:
</div> <span id="receipt_date"><%= @saleobj.created_at.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-' %></span>
</div> </p>
<div class="card-title row customer_detail hide"> </div>
<div class="col-lg-6 col-md-6 col-sm-6"> </div>
<p>Customer : <span id="customer_name"></span></p> <div class="card-title row customer_detail hide">
</div> <div class="col-lg-6 col-md-6 col-sm-6">
<p>Customer : <span id="customer_name"></span></p>
</div>
</div> </div>
<div class="card-text" style="min-height:500px; max-height:500px; overflow-x:scroll"> <div class="card-text" style="min-height:500px; max-height:500px; overflow-x:scroll">
<table class="table " id="order-items-table"> <table class="table " id="order-items-table">
<thead> <thead>
<tr> <tr>
<th width="4%">#</th> <th width="4%">#</th>
<th class="" width="30%">Items</th> <th class="" width="30%">Items</th>
<th style="" width="13%">QTY</td> <th style="" width="13%">QTY
<th class="" width="13%">Price</td> </td>
<!-- <th class='' width="17%"> Total </th> --> <th class="" width="13%">Price
<th class='' width="17%"> Action </th> </td>
</tr> <!-- <th class='' width="17%"> Total </th> -->
</thead> <th class='' width="17%"> Action</th>
<tbody> </tr>
<% </thead>
count = 0 <tbody>
sub_total = 0 <%
@saleobj.sale_items.each do |sale_item| count = 0
count += 1 sub_total = 0
sub_total = sub_total + sale_item.price @saleobj.sale_items.each do |sale_item|
%> count += 1
<input type="hidden" id="sale_id" value="<%= @saleobj.sale_id %>"> sub_total = sub_total + sale_item.price
<% %>
# Can't check for discount <input type="hidden" id="sale_id" value="<%= @saleobj.sale_id %>">
unless sale_item.price == 0 <%
# Can't check for discount
unless sale_item.price == 0
%> %>
<tr> <tr>
<td width="4%"><%= count %></td> <td width="4%"><%= count %></td>
<td class='' width="30%"> <td class='' width="30%">
<%= sale_item.product_name %> <%= sale_item.product_name %>
</td> </td>
<% if sale_item.remark != 'void' && sale_item.remark != 'edit' %> <% if sale_item.remark != 'void' && sale_item.remark != 'edit' && sale_item.remark != 'foc' %>
<td class='' width="13%"> <td class='' width="13%">
<input id="<%= sale_item.id%>_qty" data-id ="<%= sale_item.id %>" type="text" value="<%= sale_item.qty %>" class="form-control "/> <input id="<%= sale_item.id %>_qty" data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.qty %>" class="form-control "/>
</td> </td>
<td class='' width="13%"> <td class='' width="13%">
<input id="<%= sale_item.id%>_price" data-id ="<%= sale_item.id %>" type="text" value="<%= sale_item.unit_price %>" class="form-control"/> <input id="<%= sale_item.id %>_price" data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.unit_price %>" class="form-control"/>
</td> </td>
<!-- <td class='' width="17%"> <!-- <td class='' width="17%">
<input id="<%= sale_item.id%>_price" data-id ="<%= sale_item.id %>" type="text" value="<%= sale_item.price %>" class="form-control"/> <input id="<%= sale_item.id %>_price" data-id ="<%= sale_item.id %>" type="text" value="<%= sale_item.price %>" class="form-control"/>
</td> --> </td> -->
<td class='' width="17%"> <td class='' width="17%">
<button data-id ="<%= sale_item.id %>" class='btn btn-primary btn-md update'>Update <button data-id="<%= sale_item.id %>" class='btn btn-primary btn-md update'>Update</button>
</button> <button data-id="<%= sale_item.id %>" class='btn btn-danger btn-md void'>Void</button>
<button data-id ="<%= sale_item.id %>" class='btn btn-danger btn-md void'>Void</button> <button data-id="<%= sale_item.id %>" class='btn btn-info btn-md foc'>FOC</button>
</td> </td>
<% elsif sale_item.qty.to_i < 0 || sale_item.remark == 'edit' %> <% elsif sale_item.qty.to_i < 0 || sale_item.remark == 'edit' %>
<td class='' width="13%"> <td class='' width="13%">
<input data-id ="<%= sale_item.id %>" type="text" value="<%= sale_item.qty %>" class="form-control" disabled/> <input data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.qty %>" class="form-control" disabled/>
</td> </td>
<td class='' width="13%"> <td class='' width="13%">
<input data-id ="<%= sale_item.id %>" type="text" value="<%= sale_item.unit_price %>" class="form-control" disabled/> <input data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.unit_price %>" class="form-control" disabled/>
</td> </td>
<!-- <td class='' width="17%"> <!-- <td class='' width="17%">
<input data-id ="<%= sale_item.id %>" type="text" value="<%= sale_item.price %>" class="form-control" disabled/> <input data-id ="<%= sale_item.id %>" type="text" value="<%= sale_item.price %>" class="form-control" disabled/>
</td> --> </td> -->
<td class='' width="17%"> <td class='' width="17%">
<button data-id ="<%= sale_item.id %>" class='btn btn-primary btn-md cancel'>Cancel Void/Update</button> <button data-id="<%= sale_item.id %>" class='btn btn-primary btn-md cancel'>Cancel
</td> Void/Update
<% else %> </button>
<td class='' width="13%"> </td>
<input data-id ="<%= sale_item.id %>" type="text" value="<%= sale_item.qty %>" class="form-control" disabled/> <% else %>
</td> <td class='' width="13%">
<td class='' width="13%"> <input data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.qty %>" class="form-control" disabled/>
<input data-id ="<%= sale_item.id %>" type="text" value="<%= sale_item.price %>" class="form-control" disabled/> </td>
</td> <td class='' width="13%">
<td></td> <input data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.price %>" class="form-control" disabled/>
<% end %> </td>
</tr> <td></td>
<% <% end %>
end </tr>
end <%
%> end
</tbody> end
</table> %>
</div> </tbody>
<div class="card-footer"> </table>
<table class="table" id="order-charges-table" border="0"> </div>
<tr> <div class="card-footer">
<td class="charges-name"><strong>Sub Total:</strong></td> <table class="table" id="order-charges-table" border="0">
<td class="item-attr"><strong id="order-sub-total"><%= sub_total %></strong></td> <tr>
</tr> <td class="charges-name"><strong>Sub Total:</strong></td>
<tr class="rebate_amount"></tr> <td class="item-attr"><strong id="order-sub-total"><%= sub_total %></strong></td>
</table> </tr>
</div> <tr class="rebate_amount"></tr>
</div> </table>
</div> </div>
</div>
</div>
</div> </div>
<!-- Column Three --> <!-- Column Three -->
<div class="col-lg-2 col-md-2 col-sm-2"> <div class="col-lg-2 col-md-2 col-sm-2">
<!-- Waiter Buttons --> <!-- Waiter Buttons -->
<button type="button" class="btn btn-primary btn-block" id='back' >Back</button> <button type="button" class="btn btn-primary btn-block" id='back'>Back</button>
<button type="button" class="btn btn-primary btn-block" id='cancel_all_void' >Cancel All Void</button> <button type="button" class="btn btn-primary btn-block" id='cancel_all_void'>Cancel All Void</button>
<button type="button" class="btn btn-primary btn-block" id='apply' >Apply</button> <button type="button" class="btn btn-primary btn-block" id='apply'>Apply</button>
</div> </div>
</div> </div>
<script> <script>
// Bill Request // Bill Request
$(document).ready(function(){ $(document).ready(function () {
$(".update").on('click',function() { $(".update").on('click', function () {
var sale_item_id = $(this).attr('data-id'); var sale_item_id = $(this).attr('data-id');
var qty = $('#'+sale_item_id + "_qty").val(); var qty = $('#' + sale_item_id + "_qty").val();
var price = $('#'+ sale_item_id + "_price").val(); var price = $('#' + sale_item_id + "_price").val();
console.log(qty + "|" + price) console.log(qty + "|" + price)
var ajax_url = "/origami/item_edit"; var ajax_url = "/origami/item_edit";
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: ajax_url, url: ajax_url,
data: 'sale_item_id='+ sale_item_id + "&update_qty="+qty + "&update_price="+ price, data: 'sale_item_id=' + sale_item_id + "&update_qty=" + qty + "&update_price=" + price,
success:function(result){ success: function (result) {
$.confirm({ $.confirm({
title: 'Alert!', title: 'Alert!',
content: 'Qty and Price was successfully Updated', content: 'Qty and Price was successfully Updated',
buttons: { buttons: {
confirm: { confirm: {
text: 'Ok', text: 'Ok',
btnClass: 'btn-green btn-lg', btnClass: 'btn-green btn-lg',
action: function(){ action: function () {
location.reload(); location.reload();
}
}
}
});
}
});
});
$('.void').on('click', function () {
var sale_item_id = $(this).attr('data-id');
var ajax_url = "/origami/item_void";
$.ajax({
type: "POST",
url: ajax_url,
data: 'sale_item_id=' + sale_item_id,
success: function (result) {
location.reload();
}
});
})
$('.foc').on('click', function () {
var sale_item_id = $(this).attr('data-id');
var ajax_url = "/origami/item_foc";
$.ajax({
type: "POST",
url: ajax_url,
data: 'sale_item_id=' + sale_item_id,
success: function (result) {
location.reload();
}
});
})
$('.cancel').on('click', function () {
var sale_item_id = $(this).attr('data-id');
var ajax_url = "/origami/item_void_cancel";
$.ajax({
type: "POST",
url: ajax_url,
data: 'sale_item_id=' + sale_item_id,
success: function (result) {
location.reload();
}
});
})
})
$('#back').on('click', function () {
var table_id = '<%= @table_id %>'
window.location.href = '/origami/table/' + table_id;
})
$('#cancel_all_void').on('click', function () {
var sale_id = "<%= @saleobj.sale_id %>"
var ajax_url = "/origami/cancel_all_void";
$.ajax({
type: "POST",
url: ajax_url,
data: 'sale_id=' + sale_id,
success: function (result) {
location.reload();
} }
} });
} })
});
} $('#apply').on('click', function () {
}); var sale_id = "<%= @saleobj.sale_id %>"
}); var ajax_url = "/origami/apply_void";
var table_id = '<%= @table_id %>'
$('.void').on('click',function(){ $.ajax({
var sale_item_id = $(this).attr('data-id'); type: "POST",
var ajax_url = "/origami/item_void"; url: ajax_url,
$.ajax({ data: 'sale_id=' + sale_id,
type: "POST", success: function (result) {
url: ajax_url, window.location.href = '/origami/table/' + table_id;
data: 'sale_item_id='+ sale_item_id, }
success:function(result){ });
location.reload(); })
}
});
})
$('.cancel').on('click',function(){
var sale_item_id = $(this).attr('data-id');
var ajax_url = "/origami/item_void_cancel";
$.ajax({
type: "POST",
url: ajax_url,
data: 'sale_item_id='+ sale_item_id,
success:function(result){
location.reload();
}
});
})
})
$('#back').on('click',function(){
var table_id = '<%= @table_id %>'
window.location.href = '/origami/table/'+ table_id;
})
$('#cancel_all_void').on('click',function(){
var sale_id = "<%= @saleobj.sale_id %>"
var ajax_url = "/origami/cancel_all_void";
$.ajax({
type: "POST",
url: ajax_url,
data: 'sale_id='+ sale_id,
success:function(result){
location.reload();
}
});
})
$('#apply').on('click',function(){
var sale_id = "<%= @saleobj.sale_id %>"
var ajax_url = "/origami/apply_void";
var table_id = '<%= @table_id %>'
$.ajax({
type: "POST",
url: ajax_url,
data: 'sale_id='+ sale_id,
success:function(result){
window.location.href = '/origami/table/'+ table_id ;
}
});
})
</script> </script>

View File

@@ -5,10 +5,6 @@
<%= f.input :name %> <%= f.input :name %>
<%= f.input :unique_code %> <%= f.input :unique_code %>
<%= f.input :template %> <%= f.input :template %>
<%= f.input :db_name %>
<%= f.input :db_type %>
<%= f.input :db_username %>
<%= f.input :db_password %>
<%= f.input :printer_name %> <%= f.input :printer_name %>
<%= f.input :api_settings %> <%= f.input :api_settings %>
<%= f.input :page_width %> <%= f.input :page_width %>

View File

@@ -16,11 +16,7 @@
<tr> <tr>
<th>Name</th> <th>Name</th>
<th>Unique code</th> <th>Unique code</th>
<!--<th>Template</th> <th>Template</th>
<th>Db name</th>
<th>Db type</th>
<th>Db username</th>
<th>Db password</th> -->
<th>Printer name</th> <th>Printer name</th>
<th>Api settings</th> <th>Api settings</th>
<th>Page width</th> <th>Page width</th>
@@ -38,11 +34,7 @@
<tr> <tr>
<td><%= print_setting.name %></td> <td><%= print_setting.name %></td>
<td><%= print_setting.unique_code %></td> <td><%= print_setting.unique_code %></td>
<!--<td><%= print_setting.template %></td> <td><%= print_setting.template %></td>
<td><%= print_setting.db_name %></td>
<td><%= print_setting.db_type %></td>
<td><%= print_setting.db_username %></td>
<td><%= print_setting.db_password %></td> -->
<td><%= print_setting.printer_name %></td> <td><%= print_setting.printer_name %></td>
<td><%= print_setting.api_settings %></td> <td><%= print_setting.api_settings %></td>
<td><%= print_setting.page_width %></td> <td><%= print_setting.page_width %></td>

View File

@@ -29,22 +29,6 @@
<th>Template</th> <th>Template</th>
<td><%= @print_setting.template %></td> <td><%= @print_setting.template %></td>
</tr> </tr>
<tr>
<th>Db name</th>
<td><%= @print_setting.db_name %></td>
</tr>
<tr>
<th>Db type</th>
<td><%= @print_setting.db_type %></td>
</tr>
<tr>
<th>Db username</th>
<td><%= @print_setting.db_username %></td>
</tr>
<tr>
<th>Db password</th>
<td><%= @print_setting.db_password %></td>
</tr>
<tr> <tr>
<th>Printer name</th> <th>Printer name</th>
<td><%= @print_setting.printer_name %></td> <td><%= @print_setting.printer_name %></td>

View File

@@ -2,10 +2,10 @@
<%= f.error_notification %> <%= f.error_notification %>
<div class="form-inputs"> <div class="form-inputs">
<%= f.input :item_code %> <%= f.input :item_code, :input_html => { :id => 'item_code' } %>
<%= f.input :unit_price %> <%= f.input :unit_price %>
<%= f.input :taxable %> <%= f.input :taxable %>
<%= f.input :charge_type %> <%= f.input :charge_type, :collection => [:hr, :day] %>
<%= f.input :minimum_free_time %> <%= f.input :minimum_free_time %>
<%= f.input :charge_block %> <%= f.input :charge_block %>
<%= f.input :time_rounding %> <%= f.input :time_rounding %>
@@ -16,3 +16,4 @@
<%= f.button :submit %> <%= f.button :submit %>
</div> </div>
<% end %> <% end %>

View File

@@ -16,3 +16,17 @@
</div> </div>
<%= render 'form', dining_charge: @dining_charge %> <%= render 'form', dining_charge: @dining_charge %>
</div> </div>
<script>
function randomNumber(len) {
var randomNumber;
var n = '';
for(var count = 0; count < len; count++) {
randomNumber = Math.floor(Math.random() * 10);
n += randomNumber.toString();
}
return n;
}
document.getElementById("item_code").value = "<%= @zone.id %>"+"<%= @settings_dining_facility.id %>"+"_"+randomNumber(5);
</script>

View File

@@ -7,6 +7,28 @@
<%= f.input :seater %> <%= f.input :seater %>
<%= f.input :order_by %> <%= f.input :order_by %>
<%= f.input :is_active %> <%= f.input :is_active %>
<% if @settings_room.dining_charges.length == 0 %>
<% if @settings_room.id != nil %>
<div class="div-border">
<div class="col-md-10">
<%= link_to 'Add For Extra Charges', new_settings_zone_room_dining_charge_path(@zone,@settings_room),:class => 'btn btn-primary' %>
</div>
</div>
<% end %>
<% else %>
<% @settings_room.dining_charges.each do |dc| %>
<div class="div-border">
<div class="col-md-10"><b><u>Dining Charge</u></b></div>
<div class="col-md-10">item code : <%= dc.item_code %></div>
<div class="col-md-10">Unit price : <%= dc.unit_price %></div>
<div class="col-md-10">Charge type : <%= dc.charge_type %></div>
<div class="col-md-10">
<%= link_to 'Edit Charges', edit_settings_zone_room_dining_charge_path(@zone,@settings_room,dc),:class => 'btn btn-primary' %>
<!-- <button class="btn btn-primary" src="<%= edit_settings_zone_room_dining_charge_path(@zone,@settings_room,dc) %>">Edit Charge</button> -->
</div>
</div>
<% end %>
<% end %>
</div> </div>
<div class="form-actions"> <div class="form-actions">

View File

@@ -8,11 +8,13 @@
<%= f.input :order_by %> <%= f.input :order_by %>
<%= f.input :is_active %> <%= f.input :is_active %>
<% if @settings_table.dining_charges.length == 0 %> <% if @settings_table.dining_charges.length == 0 %>
<div class="div-border"> <% if @settings_table.id != nil %>
<div class="col-md-10"> <div class="div-border">
<%= link_to 'Add For Extra Charges', new_settings_zone_table_dining_charge_path(@zone,@settings_table),:class => 'btn btn-primary' %> <div class="col-md-10">
</div> <%= link_to 'Add For Extra Charges', new_settings_zone_table_dining_charge_path(@zone,@settings_table),:class => 'btn btn-primary' %>
</div> </div>
</div>
<% end %>
<% else %> <% else %>
<% @settings_table.dining_charges.each do |dc| %> <% @settings_table.dining_charges.each do |dc| %>
<div class="div-border"> <div class="div-border">

View File

@@ -80,6 +80,7 @@ Rails.application.routes.draw do
post 'moving' => "movetable#moving" post 'moving' => "movetable#moving"
get "/table/:table_id/sale/:sale_id/edit" => "sale_edit#edit" get "/table/:table_id/sale/:sale_id/edit" => "sale_edit#edit"
post 'item_void' => "sale_edit#item_void" post 'item_void' => "sale_edit#item_void"
post 'item_foc' => "sale_edit#item_foc"
post 'item_edit' => "sale_edit#item_edit" post 'item_edit' => "sale_edit#item_edit"
post 'item_void_cancel' => "sale_edit#item_void_cancel" post 'item_void_cancel' => "sale_edit#item_void_cancel"
post 'cancel_all_void' => 'sale_edit#cancel_all_void' post 'cancel_all_void' => 'sale_edit#cancel_all_void'

View File

@@ -10,6 +10,7 @@ class CreateDiningCharges < ActiveRecord::Migration[5.1]
t.time :charge_block t.time :charge_block
t.string :time_rounding, :default => "down" t.string :time_rounding, :default => "down"
t.time :time_rounding_block t.time :time_rounding_block
t.integer :time_rounding_block_price, :default => 0
t.timestamps t.timestamps
end end
end end

View File

@@ -0,0 +1,8 @@
class RemoveDBcolsFromPrintSettings < ActiveRecord::Migration[5.1]
def change
remove_column :print_settings, :db_name, :string
remove_column :print_settings, :db_type, :string
remove_column :print_settings, :db_username, :string
remove_column :print_settings, :db_password, :string
end
end