upgrade version

This commit is contained in:
Yan
2017-10-31 18:41:19 +06:30
4746 changed files with 442138 additions and 9031 deletions

5
app/controllers/origami/addorders_controller.rb Normal file → Executable file
View File

@@ -34,6 +34,7 @@ class Origami::AddordersController < ApplicationController#BaseOrigamiController
def get_menu_category ()
if (params[:id])
puts params[:id]
#Pull this menu
@menu = MenuCategory.find_by_id(params[:id])
# puts @menu.menu_items[1].item_attributes.to_json
@@ -43,6 +44,9 @@ class Origami::AddordersController < ApplicationController#BaseOrigamiController
end
end
def get_all_product()
@product = Product.all
end
def create
Rails.logger.debug "Order Source - " + params[:order_source].to_s
@@ -53,6 +57,7 @@ class Origami::AddordersController < ApplicationController#BaseOrigamiController
items = {"order_item_id": i["order_item_id"],"item_instance_code": i["item_instance_code"],"quantity": i["quantity"],"options": i["options"]}
items_arr.push(items)
}
# begin
@order = Order.new
@order.source = params[:order_source]

4
app/controllers/origami/card_payments_controller.rb Normal file → Executable file
View File

@@ -1,6 +1,4 @@
class Origami::CardPaymentsController < ApplicationController
class Origami::CardPaymentsController < BaseOrigamiController
def index
@membership_rebate_balance = 0
@membership_id = 0

3
app/controllers/origami/cash_ins_controller.rb Normal file → Executable file
View File

@@ -1,5 +1,4 @@
class Origami::CashInsController < ApplicationController
class Origami::CashInsController < BaseOrigamiController
def new
end

0
app/controllers/origami/cash_mgmt_controller.rb Normal file → Executable file
View File

3
app/controllers/origami/cash_outs_controller.rb Normal file → Executable file
View File

@@ -1,5 +1,4 @@
class Origami::CashOutsController < ApplicationController
class Origami::CashOutsController < BaseOrigamiController
def new
end

4
app/controllers/origami/credit_payments_controller.rb Normal file → Executable file
View File

@@ -1,6 +1,4 @@
class Origami::CreditPaymentsController < ApplicationController
class Origami::CreditPaymentsController < BaseOrigamiController
def index
@sale_id = params[:sale_id]

6
app/controllers/origami/customers_controller.rb Normal file → Executable file
View File

@@ -1,4 +1,4 @@
class Origami::CustomersController < ApplicationController
class Origami::CustomersController < BaseOrigamiController
load_and_authorize_resource
def index
end
@@ -104,6 +104,10 @@ class Origami::CustomersController < ApplicationController
order = Order.find(sale_order.order_id)
status = order.update_attributes(customer_id: customer_id,order_type:customer.customer_type)
end
action_by = current_user.id
remark = "Assign Customer Receipt No #{sale.receipt_no} | Sale ID #{sale.sale_id} | Customer ID ->#{customer.customer_id}- Customer Name ->#{customer.name}"
sale_audit = SaleAudit.record_audit_for_edit(sale.sale_id,sale.cashier_id, action_by,remark,"ASSIGNCUSTOMER" )
else
@booking = BookingOrder.find_by_order_id(params[:sale_id])
@orders = BookingOrder.where("booking_id = ? ", @booking.booking_id)

33
app/controllers/origami/discounts_controller.rb Normal file → Executable file
View File

@@ -1,4 +1,4 @@
class Origami::DiscountsController < ApplicationController
class Origami::DiscountsController < BaseOrigamiController
authorize_resource :class => false
#discount page show from origami index with selected order
@@ -21,7 +21,7 @@ class Origami::DiscountsController < ApplicationController
if Sale.exists?(sale_id)
sale = Sale.find(sale_id)
table_id = sale.bookings[0].dining_facility_id
table_type = DiningFacility.find(table_id).type
table = DiningFacility.find(table_id)
# sale.total_discount = overall_discount.to_f
# sale.total_amount = sub_total.to_f
# sale.grand_total = (sub_total.to_f - overall_discount.to_f) + sale.total_tax;
@@ -46,14 +46,24 @@ class Origami::DiscountsController < ApplicationController
sale_item.price = di["price"]
sale_item.save
action_by = current_user.id
remark = "Discount Item Name ->#{sale_item.product_name}-Product Code ->#{sale_item.product_code} | Price [#{sale_item.price}] | Receipt No #{sale.receipt_no} "
sale_audit = SaleAudit.record_audit_discount(sale_item.sale_id,sale.cashier_id, action_by,remark,"ITEMDISCOUNT" )
end
end
# Re-calc All Amount in Sale
if overall_discount.to_f > 0
action_by = current_user.id
remark = "Discount Overall Price [#{overall_discount}]| Receipt No #{sale.receipt_no} | Table- #{table.name} "
sale_audit = SaleAudit.record_audit_discount(sale.sale_id,sale.cashier_id, action_by,remark,"OVERALLDISCOUNT" )
end
sale.compute_by_sale_items(sale_id, sale.sale_items, overall_discount.to_f)
result = {:status=> "Success", :table_id => table_id, :table_type => table_type }
result = {:status=> "Success", :table_id => table_id, :table_type => table.type }
else
result = {:status=> "Please, Check Again!", :table_id => table_id, :table_type => table_type }
result = {:status=> "Please, Check Again!", :table_id => table_id, :table_type => table.type }
end
@@ -67,13 +77,18 @@ class Origami::DiscountsController < ApplicationController
if Sale.exists?(sale_id)
sale = Sale.find(sale_id)
table_id = sale.bookings[0].dining_facility_id
table_type = DiningFacility.find(table_id).type
table = DiningFacility.find(table_id)
if discount_items.length > 0
#destroy sale item for discount
discount_items.each do |di|
sale_item = SaleItem.find(di["id"])
sale.total_amount = (sale.total_amount + sale_item.price.abs)
action_by = current_user.id
remark = "Remove Item Discount Item Name ->#{sale_item.product_name}-Product Code ->#{sale_item.product_code} | Price [#{sale_item.price}] | Receipt No #{sale.receipt_no} | Table- #{table.name} "
sale_audit = SaleAudit.record_audit_discount(sale.sale_id,sale.cashier_id, action_by,remark,"REMOVEITEMDISCOUNT" )
sale_item.destroy
end
end
@@ -82,9 +97,9 @@ class Origami::DiscountsController < ApplicationController
# sale.save
# Re-calc All Amount in Sale
sale.compute_by_sale_items(sale_id, sale.sale_items, sale.total_discount)
result = {:status=> "Success", :table_id => table_id, :table_type => table_type }
result = {:status=> "Success", :table_id => table_id, :table_type => table.type }
else
result = {:status=> "Please, Check Again!", :table_id => table_id, :table_type => table_type }
result = {:status=> "Please, Check Again!", :table_id => table_id, :table_type => table.type }
end
render :json => result.to_json
@@ -115,6 +130,10 @@ class Origami::DiscountsController < ApplicationController
#destroy in sale.sale_items
sale.sale_items.destroy(discount_items)
action_by = current_user.id
remark = "Remove Discount Sale Id [#{sale.sale_id}]| Receipt No #{sale.receipt_no} | Table- #{table.name} "
sale_audit = SaleAudit.record_audit_discount(sale.sale_id,sale.cashier_id, action_by,remark,"REMOVEALLDISCOUNT" )
# Re-calc All Amount in Sale
sale.compute_by_sale_items(sale_id, sale.sale_items, 0)
result = {:status=> "Success", :table_id => table_id, :table_type => table_type }

2
app/controllers/origami/home_controller.rb Normal file → Executable file
View File

@@ -1,4 +1,4 @@
class Origami::HomeController < ApplicationController
class Origami::HomeController < BaseOrigamiController
before_action :set_dining, only: [:show]
def index

0
app/controllers/origami/home_controller_bk.rb Normal file → Executable file
View File

22
app/controllers/origami/in_duties_controller.rb Normal file → Executable file
View File

@@ -1,4 +1,4 @@
class Origami::InDutiesController < ApplicationController
class Origami::InDutiesController < BaseOrigamiController
before_action :set_in_duty, only: %i[show edit update edit_in_duty update_for_in_duty destroy destroy_in_duty]
# GET /in_duties
@@ -63,10 +63,12 @@ class Origami::InDutiesController < ApplicationController
def create_for_in_duty
# this one use for create and update
in_duty = in_duty_params
in_time = DateTime.new in_duty['in_time(1i)'].to_i, in_duty['in_time(2i)'].to_i, in_duty['in_time(3i)'].to_i, in_duty['in_time(4i)'].to_i, in_duty['in_time(5i)'].to_i
in_time = in_time.change(offset: '+06:30')
out_time = DateTime.new in_duty['out_time(1i)'].to_i, in_duty['out_time(2i)'].to_i, in_duty['out_time(3i)'].to_i, in_duty['out_time(4i)'].to_i, in_duty['out_time(5i)'].to_i
out_time = out_time.change(offset: '+06:30')
# in_time = DateTime.new in_duty['in_time(1i)'].to_i, in_duty['in_time(2i)'].to_i, in_duty['in_time(3i)'].to_i, in_duty['in_time(4i)'].to_i, in_duty['in_time(5i)'].to_i
# in_time = in_time.change(offset: '+06:30')
# out_time = DateTime.new in_duty['out_time(1i)'].to_i, in_duty['out_time(2i)'].to_i, in_duty['out_time(3i)'].to_i, in_duty['out_time(4i)'].to_i, in_duty['out_time(5i)'].to_i
# out_time = out_time.change(offset: '+06:30')
puts in_duty.to_json
puts "sssssssssssssssssss"
@in_duty = InDuty.new
in_duty_id = in_duty[:id]
unless in_duty_id.empty?
@@ -75,16 +77,16 @@ class Origami::InDutiesController < ApplicationController
@in_duty.dinning_id = in_duty_params[:dinning_id]
@in_duty.commissioner_ids = in_duty_params[:commissioner_ids]
@in_duty.in_time = in_time
@in_duty.out_time = out_time
@in_duty.in_time = in_duty['in_time']
@in_duty.out_time = in_duty['out_time']
respond_to do |format|
if @in_duty.save
if in_duty_id.nil?
format.html { redirect_to origami_index_in_duty_path(in_duty_params[:dinning_id]), notice: 'In duty was successfully created.' }
format.html { redirect_to origami_index_in_duty_path, notice: 'In duty was successfully created.' }
format.json { render :show, status: :created, location: @in_duty }
else
format.html { redirect_to origami_index_in_duty_path(in_duty_params[:dinning_id]), notice: 'In duty was successfully updated.' }
format.html { redirect_to origami_index_in_duty_path, notice: 'In duty was successfully updated.' }
format.json { render :show, status: :created, location: @in_duty }
end
else
@@ -151,7 +153,7 @@ class Origami::InDutiesController < ApplicationController
@in_duty.destroy
respond_to do |format|
format.html { redirect_to origami_index_in_duty_path(@table_id), notice: 'In duty was successfully removed.' }
format.html { redirect_to origami_index_in_duty_path, notice: 'In duty was successfully removed.' }
format.json { head :no_content }
end
end

2
app/controllers/origami/jcb_controller.rb Normal file → Executable file
View File

@@ -1,4 +1,4 @@
class Origami::JcbController < ApplicationController
class Origami::JcbController < BaseOrigamiController
def index
@sale_id = params[:sale_id]

2
app/controllers/origami/master_controller.rb Normal file → Executable file
View File

@@ -1,4 +1,4 @@
class Origami::MasterController < ApplicationController
class Origami::MasterController < BaseOrigamiController
def index
@sale_id = params[:sale_id]

4
app/controllers/origami/moveroom_controller.rb Normal file → Executable file
View File

@@ -1,5 +1,5 @@
class Origami::MoveroomController < ApplicationController
class Origami::MoveroomController < BaseOrigamiController
authorize_resource :class => false
def move_dining

4
app/controllers/origami/movetable_controller.rb Normal file → Executable file
View File

@@ -1,5 +1,5 @@
class Origami::MovetableController < ApplicationController
class Origami::MovetableController < BaseOrigamiController
authorize_resource :class => false
def move_dining

3
app/controllers/origami/mpu_controller.rb Normal file → Executable file
View File

@@ -1,5 +1,4 @@
class Origami::MpuController < ApplicationController
class Origami::MpuController < BaseOrigamiController
def index
@sale_id = params[:sale_id]

3
app/controllers/origami/orders_controller.rb Normal file → Executable file
View File

@@ -1,5 +1,4 @@
class Origami::OrdersController < ApplicationController
class Origami::OrdersController < BaseOrigamiController
def show
@tables = Table.all.active.order('status desc')
@rooms = Room.all.active.order('status desc')

11
app/controllers/origami/other_charges_controller.rb Normal file → Executable file
View File

@@ -1,4 +1,4 @@
class Origami::OtherChargesController < ApplicationController
class Origami::OtherChargesController < BaseOrigamiController
authorize_resource :class => false
def index
@@ -16,7 +16,7 @@ class Origami::OtherChargesController < ApplicationController
if Sale.exists?(sale_id)
sale = Sale.find(sale_id)
table_id = sale.bookings[0].dining_facility_id
table_type = DiningFacility.find(table_id).type
table = DiningFacility.find(table_id)
# sale.total_amount = sub_total.to_f
# sale.grand_total = sub_total.to_f + sale.total_tax;
@@ -41,6 +41,11 @@ class Origami::OtherChargesController < ApplicationController
sale_item.price = di["price"]
sale_item.save
action_by = current_user.id
remark = "Add Other Charges - Receipt No #{sale.receipt_no} | Sale ID #{sale.sale_id} |Charges ->#{di["price"]} For ->#{di["name"]}- Table ->#{table.name}"
sale_audit = SaleAudit.record_audit_for_edit(sale.sale_id,sale.cashier_id, action_by,remark,"ADDOTHERCHARGES" )
end
end
@@ -48,7 +53,7 @@ class Origami::OtherChargesController < ApplicationController
sale.compute_by_sale_items(sale_id, sale.sale_items, sale.total_discount)
end
dining = {:table_id => table_id, :table_type => table_type }
dining = {:table_id => table_id, :table_type => table.type }
render :json => dining.to_json
end
end

6
app/controllers/origami/others_payments_controller.rb Normal file → Executable file
View File

@@ -1,12 +1,10 @@
class Origami::OthersPaymentsController < ApplicationController
class Origami::OthersPaymentsController < BaseOrigamiController
def index
@membership_rebate_balance = 0
@sale_id = params[:sale_id]
@payment_method_setting = PaymentMethodSetting.all
@rebate = MembershipSetting.find_by_rebate(1)
@rebate = MembershipSetting.find_by_rebate(1)
# @sale_id = params[:sale_id]
# sale_data = Sale.find_by_sale_id(@sale_id)

95
app/controllers/origami/payments_controller.rb Normal file → Executable file
View File

@@ -1,5 +1,4 @@
class Origami::PaymentsController < ApplicationController
class Origami::PaymentsController < BaseOrigamiController
authorize_resource :class => false
def index
end
@@ -10,8 +9,19 @@ class Origami::PaymentsController < ApplicationController
sale_items = SaleItem.where("sale_id=?",sale_id)
member_info = nil
# Print for First Bill to Customer
# For Cashier by Zone
bookings = Booking.where("sale_id='#{sale_id}'")
if bookings.count > 1
# for Multiple Booking
table = DiningFacility.find(bookings[0].dining_facility_id)
else
table = DiningFacility.find(bookings[0].dining_facility_id)
end
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)
# Print for First Bill to Customer
unique_code = "ReceiptBillPdf"
#shop detail
shop_details = Shop.find(1)
@@ -34,7 +44,7 @@ class Origami::PaymentsController < ApplicationController
printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_receipt_bill(print_settings,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, shop_details, "Frt")
printer.print_receipt_bill(print_settings,cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, shop_details, "Frt")
end
def create
@@ -50,6 +60,19 @@ class Origami::PaymentsController < ApplicationController
render json: JSON.generate({:status => saleObj.rebate_status, :message => "Can't Rebate coz of Sever Error "})
rebate_amount = nil
# For Cashier by Zone
bookings = Booking.where("sale_id='#{sale_id}'")
if bookings.count > 1
# for Multiple Booking
table = DiningFacility.find(bookings[0].dining_facility_id)
else
table = DiningFacility.find(bookings[0].dining_facility_id)
end
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)
# For Print
unique_code = "ReceiptBillPdf"
customer= Customer.find(saleObj.customer_id)
@@ -69,7 +92,7 @@ class Origami::PaymentsController < ApplicationController
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "Paid")
printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "Paid")
end
end
@@ -141,28 +164,40 @@ class Origami::PaymentsController < ApplicationController
sale_id = params[:sale_id]
member_info = nil
saleObj = Sale.find(sale_id)
saleObj = Sale.find(sale_id)
unique_code = "ReceiptBillPdf"
customer= Customer.find(saleObj.customer_id)
# For Cashier by Zone
bookings = Booking.where("sale_id='#{sale_id}'")
if bookings.count > 1
# for Multiple Booking
table = DiningFacility.find(bookings[0].dining_facility_id)
else
table = DiningFacility.find(bookings[0].dining_facility_id)
end
#shop detail
shop_details = Shop.find(1)
# get member information
rebate = MembershipSetting.find_by_rebate(1)
if customer.membership_id != nil && rebate
member_info = Customer.get_member_account(customer)
rebate_amount = Customer.get_membership_transactions(customer,saleObj.receipt_no)
end
# get printer info
print_settings=PrintSetting.find_by_unique_code(unique_code)
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)
# Calculate price_by_accounts
item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
unique_code = "ReceiptBillPdf"
customer= Customer.find(saleObj.customer_id)
printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "Re-print")
#shop detail
shop_details = Shop.find(1)
# get member information
rebate = MembershipSetting.find_by_rebate(1)
if customer.membership_id != nil && rebate
member_info = Customer.get_member_account(customer)
rebate_amount = Customer.get_membership_transactions(customer,saleObj.receipt_no)
end
# get printer info
print_settings=PrintSetting.find_by_unique_code(unique_code)
# Calculate price_by_accounts
item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "Re-print")
end
def foc
@@ -177,6 +212,18 @@ class Origami::PaymentsController < ApplicationController
sale_payment = SalePayment.new
sale_payment.process_payment(saleObj, @user, cash, "foc")
# For Cashier by Zone
bookings = Booking.where("sale_id='#{sale_id}'")
if bookings.count > 1
# for Multiple Booking
table = DiningFacility.find(bookings[0].dining_facility_id)
else
table = DiningFacility.find(bookings[0].dining_facility_id)
end
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)
unique_code = "ReceiptBillPdf"
customer= Customer.find(saleObj.customer_id)
@@ -190,7 +237,7 @@ class Origami::PaymentsController < ApplicationController
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "FOC")
printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "FOC")
end
end

2
app/controllers/origami/paypar_payments_controller.rb Normal file → Executable file
View File

@@ -1,4 +1,4 @@
class Origami::PayparPaymentsController < ApplicationController
class Origami::PayparPaymentsController < BaseOrigamiController
def create
sale_id = params[:sale_id]
redeem_amount = params[:redeem_amount]

View File

@@ -1,4 +1,4 @@
class Origami::ProductCommissionsController < ApplicationController
class Origami::ProductCommissionsController < BaseOrigamiController
before_action :set_product_commission, only: [:show, :edit, :update, :destroy]
# GET /product_commissions

2
app/controllers/origami/redeem_payments_controller.rb Normal file → Executable file
View File

@@ -1,4 +1,4 @@
class Origami::RedeemPaymentsController < ApplicationController
class Origami::RedeemPaymentsController < BaseOrigamiController
def index
@sale_id = params[:sale_id]
payment_method = params[:payment_method]

0
app/controllers/origami/request_bills_controller.rb Normal file → Executable file
View File

2
app/controllers/origami/room_invoices_controller.rb Normal file → Executable file
View File

@@ -1,4 +1,4 @@
class Origami::RoomInvoicesController < ApplicationController
class Origami::RoomInvoicesController < BaseOrigamiController
def index
@room = DiningFacility.find(params[:room_id])
puts "room bookig lenght"

3
app/controllers/origami/rooms_controller.rb Normal file → Executable file
View File

@@ -1,5 +1,4 @@
class Origami::RoomsController < ApplicationController
class Origami::RoomsController < BaseOrigamiController
def index
@tables = Table.all.active.order('status desc')
@rooms = Room.all.active.order('status desc')

28
app/controllers/origami/sale_edit_controller.rb Normal file → Executable file
View File

@@ -1,4 +1,4 @@
class Origami::SaleEditController < ApplicationController
class Origami::SaleEditController < BaseOrigamiController
authorize_resource class: false
# Index for sale item void OR edit
def edit
@@ -19,11 +19,16 @@ class Origami::SaleEditController < ApplicationController
@newsaleitem.qty = saleitemObj.qty * -1
@newsaleitem.price = saleitemObj.price * -1
@newsaleitem.is_taxable = 1
@newsaleitem.product_name = saleitemObj.product_name + ' - void'
@newsaleitem.product_name = saleitemObj.product_name + ' (VOID)'
@newsaleitem.save
# re-calc tax
saleObj = Sale.find(saleitemObj.sale_id)
action_by = current_user.id
remark = "Void Sale Item ID #{saleitemObj.sale_item_id} | Receipt No #{saleObj.receipt_no} | Item Name ->#{saleitemObj.product_name}-Product Code ->#{saleitemObj.product_code}-Instance Code ->#{saleitemObj.item_instance_code}"
sale_audit = SaleAudit.record_audit_for_edit(saleitemObj.sale_id,saleObj.cashier_id, action_by,remark,"SALEITEMVOID" )
saleObj.compute_without_void
ProductCommission.create_product_commission(@newsaleitem, saleitemObj)
end
@@ -39,11 +44,16 @@ class Origami::SaleEditController < ApplicationController
@newsaleitem.qty = saleitemObj.qty * -1
@newsaleitem.price = saleitemObj.price * -1
@newsaleitem.is_taxable = 1
@newsaleitem.product_name = saleitemObj.product_name + ' foc'
@newsaleitem.product_name = saleitemObj.product_name + ' (FOC)'
@newsaleitem.save
# re-calc tax
saleObj = Sale.find(saleitemObj.sale_id)
action_by = current_user.id
remark = "FOC Sale Item ID #{saleitemObj.sale_item_id} | Receipt No #{saleObj.receipt_no} | Item Name ->#{saleitemObj.product_name}-Product Code ->#{saleitemObj.product_code}-Instance Code ->#{saleitemObj.item_instance_code}Receipt No #{saleObj.receipt_no}"
sale_audit = SaleAudit.record_audit_for_edit(saleitemObj.sale_id,saleObj.cashier_id, action_by,remark,"SALEITEMFOC" )
saleObj.compute_without_void
ProductCommission.create_product_commission(@newsaleitem, saleitemObj)
end
@@ -73,15 +83,20 @@ class Origami::SaleEditController < ApplicationController
update_qty = params[:update_qty]
update_price = params[:update_price]
saleitemObj = SaleItem.find(saleitemId)
sale = Sale.find(saleitemObj.sale_id)
saleitemObj.qty = update_qty
saleitemObj.price = update_qty.to_f * update_price.to_f
saleitemObj.unit_price = update_price
saleitemObj.taxable_price = update_qty.to_f * update_price.to_f
action_by = current_user.id
remark = "Update Qty #{update_qty} Price [#{saleitemObj.price}]| Receipt No #{sale.receipt_no} | Item Name ->#{saleitemObj.product_name}-Product Code ->#{saleitemObj.product_code}-Instance Code ->#{saleitemObj.item_instance_code}"
sale_audit = SaleAudit.record_audit_for_edit(saleitemObj.sale_id,sale.cashier_id, action_by,remark,"SALEITEMEDIT" )
# saleitemObj.remark = 'edit'
unless saleitemObj.product_name.include? 'updated'
saleitemObj.product_name = saleitemObj.product_name + ' - updated'
saleitemObj.product_name = saleitemObj.product_name + ' (UPDATED)'
end
saleitemObj.save
@@ -108,6 +123,11 @@ class Origami::SaleEditController < ApplicationController
# re-calc tax
saleObj = Sale.find(saleitemObj.sale_id)
action_by = current_user.id
remark = "Cancle Void Sale Item ID #{saleitemObj.sale_item_id} | Item Name ->#{saleitemObj.product_name}-Product Code ->#{saleitemObj.product_code}-Instance Code ->#{saleitemObj.item_instance_code}|Receipt No #{saleObj.receipt_no}"
sale_audit = SaleAudit.record_audit_for_edit(saleitemObj.sale_id,saleObj.cashier_id, action_by,remark,"ITEMCANCELVOID" )
saleObj.compute_without_void
ProductCommission.remove_product_commission(saleitemObj)
end

3
app/controllers/origami/sales_controller.rb Normal file → Executable file
View File

@@ -1,5 +1,4 @@
class Origami::SalesController < ApplicationController
class Origami::SalesController < BaseOrigamiController
def show
@tables = Table.all.active.order('status desc')
@rooms = Room.all.active.order('status desc')

34
app/controllers/origami/shifts_controller.rb Normal file → Executable file
View File

@@ -1,5 +1,4 @@
class Origami::ShiftsController < ApplicationController
class Origami::ShiftsController < BaseOrigamiController
def index
end
@@ -9,14 +8,27 @@ class Origami::ShiftsController < ApplicationController
def new
@float = Lookup.where('lookup_type=?','float_value')
@terminal = CashierTerminal.all
@terminal = CashierTerminal.available
end
def create
opening_balance = params[:opening_balance]
cashier_terminal = params[:cashier_terminal]
@shift = ShiftSale.new
@shift.create(opening_balance,cashier_terminal, current_user)
cashier_terminal_param = params[:cashier_terminal]
# Multiple Cashier
cashier_terminal = CashierTerminal.find(cashier_terminal_param)
if cashier_terminal.is_currently_login
respond_to do |format|
format.html { redirect_to settings_order_queue_stations_url, notice: 'Cashier Terminal already signin!' }
end
end
# Update Cashier Terminal
cashier_terminal.is_currently_login = 1
cashier_terminal.save
@shift_sale = ShiftSale.new
@shift_sale.create(opening_balance,cashier_terminal_param, current_user)
end
def update_shift
@@ -25,9 +37,15 @@ class Origami::ShiftsController < ApplicationController
@shift = ShiftSale.find_by_id(shift_id)
if @shift
@shift.shift_closed_at = DateTime.now.utc
@shift.closing_balance = closing_balance.to_f
@shift.closing_balance = closing_balance.to_f
@shift.save
# Multiple Cashier
cashier_terminal = @shift.cashier_terminal
cashier_terminal.is_currently_login = 0
cashier_terminal.save
unique_code = "CloseCashierPdf"
shop_details = Shop.find(1)
#get tax
@@ -45,7 +63,7 @@ class Origami::ShiftsController < ApplicationController
printer = Printer::CashierStationPrinter.new(print_settings)
printer.print_close_cashier(print_settings,@shift,shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount)
printer.print_close_cashier(print_settings,cashier_terminal,@shift,shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount)
end

2
app/controllers/origami/table_invoices_controller.rb Normal file → Executable file
View File

@@ -1,4 +1,4 @@
class Origami::TableInvoicesController < ApplicationController
class Origami::TableInvoicesController < BaseOrigamiController
def index
@table = DiningFacility.find(params[:table_id])
puts "table bookig lenght"

3
app/controllers/origami/visa_controller.rb Normal file → Executable file
View File

@@ -1,5 +1,4 @@
class Origami::VisaController < ApplicationController
class Origami::VisaController < BaseOrigamiController
def index
@sale_id = params[:sale_id]

23
app/controllers/origami/void_controller.rb Normal file → Executable file
View File

@@ -1,4 +1,4 @@
class Origami::VoidController < ApplicationController
class Origami::VoidController < BaseOrigamiController
authorize_resource :class => false
def overall_void
@@ -19,13 +19,14 @@ class Origami::VoidController < ApplicationController
sale.sale_status = 'void'
sale.save
bookings = sale.bookings
bookings.each do |booking|
orders = booking.orders
orders.each do |order|
# order.status = 'void'
end
end
# No Need
# bookings = sale.bookings
# bookings.each do |booking|
# orders = booking.orders
# orders.each do |order|
# # order.status = 'void'
# end
# end
table_avaliable = true
table = sale.bookings[0].dining_facility
@@ -40,6 +41,12 @@ class Origami::VoidController < ApplicationController
table.save
end
# FOr Sale Audit
action_by = current_user.id
remark = "Void Sale ID #{sale_id} | Receipt No #{sale.receipt_no} | Receipt No #{sale.receipt_no} | Table ->#{table.name}"
sale_audit = SaleAudit.record_audit_for_edit(sale_id,sale.cashier_id, action_by,remark,"SALEVOID" )
# update complete order items in oqs
SaleOrder.where("sale_id = '#{ sale_id }'").find_each do |sodr|
AssignedOrderItem.where("order_id = '#{ sodr.order_id }'").find_each do |aoi|

3
app/controllers/origami/voucher_controller.rb Normal file → Executable file
View File

@@ -1,5 +1,4 @@
class Origami::VoucherController < ApplicationController
class Origami::VoucherController < BaseOrigamiController
def index
@sale_id = params[:sale_id]