diff --git a/app/controllers/api/orders_controller.rb b/app/controllers/api/orders_controller.rb index e3184ecc..8c7d7396 100644 --- a/app/controllers/api/orders_controller.rb +++ b/app/controllers/api/orders_controller.rb @@ -68,10 +68,10 @@ class Api::OrdersController < Api::ApiController if booking.dining_facility_id.to_i == params[:table_id].to_i && booking.booking_status != 'moved' if !booking.sale_id.nil? sale_status = check_order_with_booking(booking) - puts "WWwwWWWWWWww" - puts sale_status + # puts "WWwwWWWWWWww" + # puts sale_status if sale_status - return false , @message = "bill requested" + return return_json_status_with_code(400, "bill requested") end else @order.new_booking = false @@ -79,43 +79,46 @@ class Api::OrdersController < Api::ApiController end else sale_status = check_order_with_table(params[:table_id]) - puts "OOOOOOOOO" - puts sale_status + # puts "OOOOOOOOO" + # puts sale_status if sale_status - return false , @message = "bill requested" + return return_json_status_with_code(400, "bill requested") end end end #booking exists else sale_status = check_order_with_table(params[:table_id]) - puts "MMMMMMMM" - puts sale_status + # puts "MMMMMMMM" + # puts sale_status if sale_status - return false , @message = "bill requested" + # return false , @message = "bill requested" + return return_json_status_with_code(400, "bill requested") end end - @status, @booking = @order.generate + @status, @booking = @order.generate end - # render json for http status code 202 - def return_json_status_with_code(code, msg, booking_id) + # render json for http status code + def return_json_status_with_code(code, msg) render status: code, json: { message: msg, booking_id: booking_id - }.to_json + }.to_json end def check_order_with_table(table_id) table = DiningFacility.find(table_id) if table booking = table.get_current_booking - puts booking + # puts booking if booking - if booking.sale.sale_status == "completed" || booking.sale.sale_status == "billed" + if !booking.sale_id.nil? + if booking.sale.sale_status == "completed" || booking.sale.sale_status == "new" @order.new_booking = true - return true - else + return false + end + else @order.new_booking = false @order.booking_id = booking.booking_id return false @@ -124,10 +127,11 @@ class Api::OrdersController < Api::ApiController end end + # this can always true def check_order_with_booking(booking) - if booking.sale.sale_status == "completed" || booking.sale.sale_status == "billed" + if booking.sale.sale_status == "completed" || booking.sale.sale_status == "new" @order.new_booking = true - return true + return false else @order.new_booking = false @order.booking_id = params[:booking_id] diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index f2846c12..f8a80cb8 100644 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -6,12 +6,12 @@ class Crm::CustomersController < BaseCrmController # GET /crm/customers.json def index filter = params[:filter] - + if filter.nil? @crm_customers = Customer.all else - @crm_customers = Customer.search(filter) - + @crm_customers = Customer.search(filter) + end #@crm_customers = Customer.all @crm_customers = Kaminari.paginate_array(@crm_customers).page(params[:page]).per(50) @@ -32,7 +32,7 @@ class Crm::CustomersController < BaseCrmController def show @orders = Order.where("customer_id=?", params[:id]) @sales = Sale.where("customer_id=?", params[:id]) - + if @orders @order_items = [] @orders.each do |order| @@ -70,7 +70,7 @@ class Crm::CustomersController < BaseCrmController def create @crm_customers = Customer.new(customer_params) - + respond_to do |format| if @crm_customers.save name = customer_params[:name] @@ -81,7 +81,7 @@ class Crm::CustomersController < BaseCrmController nrc = customer_params[:nrc_no] card_no = customer_params[:card_no] member_group_id = params[:member_group_id] - + if !member_group_id.nil? membership = MembershipSetting.find_by_membership_type("paypar_url") memberaction = MembershipAction.find_by_membership_type("create_membership_customer") @@ -90,7 +90,7 @@ class Crm::CustomersController < BaseCrmController url = membership.gateway_url.to_s + memberaction.gateway_url.to_s begin - response = HTTParty.post(url, + response = HTTParty.post(url, :body => {name: name,phone: phone,email: email, dob: dob,address: address,nrc:nrc,card_no:card_no, member_group_id: member_group_id, @@ -103,18 +103,24 @@ class Crm::CustomersController < BaseCrmController ) rescue Net::OpenTimeout response = { status: false } + + rescue OpenURI::HTTPError + response = { status: false} + + rescue SocketError + response = { status: false} end if response["status"] == true - + customer = Customer.find(@crm_customers.customer_id) status = customer.update_attributes(membership_id: response["customer_datas"]["id"],membership_type:member_group_id ) - + if params[:sale_id] format.html { redirect_to '/origami/'+params[:sale_id]+'/customers', notice: 'Customer was successfully created.' } else format.html { redirect_to crm_customers_path, notice: 'Customer was successfully created'} - end + end # format.json { render :index, status: :created, location: @crm_customers } else # @crm_customers.destroy @@ -129,7 +135,7 @@ class Crm::CustomersController < BaseCrmController if params[:sale_id] flash[:errors] = @crm_customers.errors - format.html { redirect_to '/origami/'+params[:sale_id]+'/customers'} + format.html { redirect_to '/origami/'+params[:sale_id]+'/customers'} format.json { render json: @crm_customers.errors, status: :unprocessable_entity } else flash[:errors] = @crm_customers.errors @@ -166,7 +172,7 @@ end url = membership.gateway_url.to_s + memberaction.gateway_url.to_s begin - response = HTTParty.post(url, + response = HTTParty.post(url, :body => { name: name,phone: phone,email: email, dob: dob,address: address,nrc:nrc, card_no:card_no,member_group_id: member_group_id, @@ -176,16 +182,22 @@ end 'Accept' => 'application/json' }, :timeout => 10 - ) + ) rescue Net::OpenTimeout response = { status: false } + + rescue OpenURI::HTTPError + response = { status: false} + + rescue SocketError + response = { status: false} end if response["status"] == true - + customer = Customer.find(@crm_customer.customer_id) status = customer.update_attributes(membership_id: response["customer_datas"]["id"],membership_type:member_group_id ) - + format.html { redirect_to crm_customers_path, notice: 'Customer was successfully updated'} else format.html { redirect_to crm_customers_path, notice: response["message"] } @@ -199,7 +211,7 @@ end auth_token = memberaction.auth_token.to_s url = membership.gateway_url.to_s + memberaction.gateway_url.to_s begin - response = HTTParty.post(url, + response = HTTParty.post(url, :body => {name: name,phone: phone,email: email, dob: dob,address: address,nrc:nrc,card_no:card_no, id: id,member_group_id:member_group_id,merchant_uid:merchant_uid,auth_token:auth_token}.to_json, @@ -211,6 +223,12 @@ end ) rescue Net::OpenTimeout response = { status: false } + + rescue OpenURI::HTTPError + response = { status: false} + + rescue SocketError + response = { status: false} end if response["status"] == true @@ -219,8 +237,8 @@ end else format.html { redirect_to crm_customers_path, notice: response["message"] } end - - end + + end else @@ -251,7 +269,7 @@ end # Never trust parameters from the scary internet, only allow the white list through. def customer_params - params.require(:customer).permit(:name, :company, :contact_no, :email, + params.require(:customer).permit(:name, :company, :contact_no, :email, :date_of_birth,:salutation,:gender,:nrc_no,:address,:card_no) end end diff --git a/app/controllers/origami/cash_ins_controller.rb b/app/controllers/origami/cash_ins_controller.rb index dd78bc1b..085f68b8 100644 --- a/app/controllers/origami/cash_ins_controller.rb +++ b/app/controllers/origami/cash_ins_controller.rb @@ -11,5 +11,8 @@ class Origami::CashInsController < BaseOrigamiController payment_method_reference = params[:payment_method_reference] p_jour = PaymentJournal.new p_jour.cash_in(reference, remark, amount, payment_method, payment_method_reference, current_user.id) + shift = ShiftSale.current_open_shift(current_user.id) + shift.cash_in = shift.cash_in + amount.to_i + shift.save end end diff --git a/app/controllers/origami/cash_outs_controller.rb b/app/controllers/origami/cash_outs_controller.rb index ac079a39..95ab97a2 100644 --- a/app/controllers/origami/cash_outs_controller.rb +++ b/app/controllers/origami/cash_outs_controller.rb @@ -9,5 +9,8 @@ class Origami::CashOutsController < BaseOrigamiController amount = params[:amount] p_jour = PaymentJournal.new p_jour.cash_out(reference, remark, amount, current_user.id) + shift = ShiftSale.current_open_shift(current_user.id) + shift.cash_out = shift.cash_out + amount.to_i + shift.save end end diff --git a/app/controllers/origami/other_charges_controller.rb b/app/controllers/origami/other_charges_controller.rb new file mode 100644 index 00000000..654f539a --- /dev/null +++ b/app/controllers/origami/other_charges_controller.rb @@ -0,0 +1,48 @@ +class Origami::OtherChargesController < BaseOrigamiController + authorize_resource :class => false + + def index + sale_id = params[:sale_id] + if Sale.exists?(sale_id) + @sale_data = Sale.find(sale_id) + end + end + + def create + sale_id = params[:sale_id] + other_charges_items = JSON.parse(params[:other_charges_items]) + sub_total = params[:sub_total] + + 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 + sale.total_amount = sub_total.to_f + sale.grand_total = sub_total.to_f + sale.total_tax; + sale.save + if other_charges_items.length > 0 + #save sale item for discount + other_charges_items.each do |di| + # origin_sale_item = SaleItem.find(di["id"]) + sale_item = SaleItem.new + + sale_item.sale_id = sale_id + sale_item.product_code = "Other Charges" + sale_item.product_name = di["name"] + sale_item.remark = "Other Charges" + + sale_item.qty = 1 + sale_item.unit_price = di["price"] + sale_item.taxable_price = di["price"] + sale_item.is_taxable = 0 + + sale_item.price = di["price"] + sale_item.save + end + end + end + + dining = {:table_id => table_id, :table_type => table_type } + render :json => dining.to_json + end +end \ No newline at end of file diff --git a/app/controllers/origami/shifts_controller.rb b/app/controllers/origami/shifts_controller.rb index 1a7a5289..3329aa0b 100644 --- a/app/controllers/origami/shifts_controller.rb +++ b/app/controllers/origami/shifts_controller.rb @@ -4,11 +4,13 @@ class Origami::ShiftsController < BaseOrigamiController end def show + puts current_user.id @shift = ShiftSale.current_open_shift(current_user.id) end def new @float = Lookup.where('lookup_type=?','float_value') + @terminal = CashierTerminal.all end def create @@ -18,13 +20,17 @@ class Origami::ShiftsController < BaseOrigamiController end def update_shift - @shift = ShiftSale.current_open_shift(current_user.id) + closing_balance = params[:closing_balance] + shift_id = params[:shift_id] + @shift = ShiftSale.find_by_id(shift_id) if @shift @shift.shift_closed_at = DateTime.now.utc + @shift.closing_balance = closing_balance.to_f @shift.save end end + def edit end end diff --git a/app/models/ability.rb b/app/models/ability.rb index c591fba8..066311af 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -40,6 +40,8 @@ class Ability can :add_customer, Customer can :update_sale_by_customer, Customer + can :index, :other_charges + can :create, :other_charges can :index, :discount can :create, :discount can :remove_discount_items, :discount diff --git a/app/models/customer.rb b/app/models/customer.rb index e6afca08..a26d857e 100644 --- a/app/models/customer.rb +++ b/app/models/customer.rb @@ -31,6 +31,12 @@ class Customer < ApplicationRecord ) rescue Net::OpenTimeout response = { status: false } + + rescue OpenURI::HTTPError + response = { status: false} + + rescue SocketError + response = { status: false} end return response; @@ -55,6 +61,12 @@ class Customer < ApplicationRecord ) rescue Net::OpenTimeout response = { status: false } + + rescue OpenURI::HTTPError + response = { status: false} + + rescue SocketError + response = { status: false} end return response; diff --git a/app/models/dining_facility.rb b/app/models/dining_facility.rb index 0e10307b..510da53d 100644 --- a/app/models/dining_facility.rb +++ b/app/models/dining_facility.rb @@ -39,6 +39,16 @@ class DiningFacility < ApplicationRecord end end + def get_moved_booking + booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='moved' and checkin_at between '#{DateTime.now.utc - 5.hours}' and '#{DateTime.now.utc}' and checkout_at is null").limit(1) + + if booking.count > 0 then + return booking[0] + else + return nil + end + end + def get_new_booking # query for new # if status diff --git a/app/models/order.rb b/app/models/order.rb index 29267965..249e82ea 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -38,6 +38,7 @@ class Order < ApplicationRecord booking.save! self.default_values + # cashier already opened? if self.save! self.adding_line_items @@ -54,7 +55,7 @@ class Order < ApplicationRecord end - return false, @message = "booking fail" + return false end diff --git a/app/models/payment_journal.rb b/app/models/payment_journal.rb index 6105a574..0f0c3ce5 100644 --- a/app/models/payment_journal.rb +++ b/app/models/payment_journal.rb @@ -19,4 +19,25 @@ class PaymentJournal < ApplicationRecord self.created_by = current_user self.save end + + # def self.today_cash_in(current_user) + # credit = 0.0 + # today_date = DateTime.now.strftime("%Y-%m-%d") + # pj_credit = PaymentJournal.where("TO_CHAR(created_at, 'YYYY-MM-DD')=? and created_by=?",today_date, current_user) + # pj_credit.each do |obj| + # credit += obj.credit_amount + # end + # return credit + # end + # + # def self.today_cash_out(current_user) + # debit = 0.0 + # today_date = DateTime.now.strftime("%Y-%m-%d") + # pj_debit = PaymentJournal.where("TO_CHAR(created_at, 'YYYY-MM-DD')=? and created_by=?",today_date, current_user) + # pj_debit.each do |obj| + # debit += obj.debit_amount + # end + # return debit + # end + end diff --git a/app/models/sale.rb b/app/models/sale.rb index 313a6f80..deb9be9e 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -25,7 +25,7 @@ class Sale < ApplicationRecord SALE_STATUS_OUTSTANDING = "outstanding" SALE_STATUS_COMPLETED = "completed" - def generate_invoice_from_booking(booking_id, requested_by, cashier) + def generate_invoice_from_booking(booking_id, requested_by, cashier) booking = Booking.find(booking_id) status = false Rails.logger.debug "Booking -> " + booking.id.to_s @@ -66,7 +66,7 @@ class Sale < ApplicationRecord #Default Tax - Values self.tax_type = "exclusive" - # set cashier + # set cashier if cashier != nil self.cashier_id = cashier[0].id self.cashier_name = cashier[0].name @@ -270,8 +270,6 @@ class Sale < ApplicationRecord end - private - def product_get_unit_price(item_code) menu_item_hash =MenuItem.search_by_item_code(item_code) if (menu_instance_code) @@ -444,6 +442,7 @@ def self.get_by_range_by_saleitems(from,to,status,report_type) end + def self.get_by_shiftsales(from,to) return ShiftSale.where("(shift_started_at between ? and ? OR shift_closed_at between ? and ? )", from, to, from, to) end @@ -504,7 +503,46 @@ end # return sale_arr # end - + + def get_cash_amount + cash = 0.0 + self.sale_payments.each do |pay| + if pay.payment_method == 'cash' + cash = pay.payment_amount + end + end + return cash + end + + def get_credit_amount + credit = 0.0 + self.sale_payments.each do |pay| + if pay.payment_method == 'creditnote' + credit = pay.payment_amount + end + end + return credit + end + + def get_other_amount + other = 0.0 + self.sale_payments.each do |pay| + if pay.payment_method != 'cash' && pay.payment_method != 'creditnote' + other += pay.payment_amount + end + end + return other + end + + def get_commerical_tax + tax = 0.0 + self.sale_taxes.each do |tax| + if tax.tax_name == "Commerical Tax" + tax += tax.tax_payable_amount + end + end + end + private def generate_custom_id diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 7a835618..c78b6cd8 100644 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -77,6 +77,12 @@ class SalePayment < ApplicationRecord ) rescue Net::OpenTimeout response = { status: false } + + rescue OpenURI::HTTPError + response = { status: false} + + rescue SocketError + response = { status: false} end return response; end @@ -110,6 +116,12 @@ class SalePayment < ApplicationRecord ) rescue Net::OpenTimeout response = false + + rescue OpenURI::HTTPError + response = { status: false} + + rescue SocketError + response = { status: false} end else response = false; @@ -131,7 +143,6 @@ class SalePayment < ApplicationRecord self.payment_status = "paid" payment_method = self.save! sale_update_payment_status(self.received_amount) - return payment_status end @@ -146,7 +157,6 @@ class SalePayment < ApplicationRecord payment_method = self.save! sale_update_payment_status(self.received_amount) - return payment_status end @@ -161,7 +171,6 @@ class SalePayment < ApplicationRecord payment_method = self.save! sale_update_payment_status(self.received_amount) - return payment_status end @@ -175,7 +184,6 @@ class SalePayment < ApplicationRecord self.outstanding_amount = self.sale.grand_total- self.received_amount self.payment_status = "paid" payment_method = self.save! - sale_update_payment_status(self.received_amount) return payment_status @@ -192,7 +200,6 @@ class SalePayment < ApplicationRecord self.outstanding_amount = self.sale.grand_total- self.received_amount self.payment_status = "paid" payment_method = self.save! - sale_update_payment_status(self.received_amount) return payment_status @@ -220,7 +227,6 @@ class SalePayment < ApplicationRecord else sale_update_payment_status(0) end - return payment_status end @@ -249,16 +255,20 @@ class SalePayment < ApplicationRecord self.sale.save! table_update_status(sObj) rebat(sObj) - shift = ShiftSale.current_open_shift(self.sale.cashier_id) - puts shift - if !shift.nil? - puts ">>>> shift >>>>>>" - shift.update(self.sale) + if paid_amount != "0.0" + update_shift end end end + def update_shift + shift = ShiftSale.current_open_shift(self.sale.cashier_id) + if !shift.nil? + shift.update(self.sale) + end + end + def table_update_status(sale_obj) status = true booking = Booking.find_by_sale_id(sale_obj.id) @@ -314,6 +324,12 @@ class SalePayment < ApplicationRecord }, :timeout => 10) rescue Net::OpenTimeout response = { status: false } + + rescue OpenURI::HTTPError + response = { status: false} + + rescue SocketError + response = { status: false} end return response # puts response.to_json @@ -321,6 +337,8 @@ class SalePayment < ApplicationRecord end end + + private def generate_custom_id self.sale_payment_id = SeedGenerator.generate_id(self.class.name, "SPI") diff --git a/app/models/shift_sale.rb b/app/models/shift_sale.rb index 2d6b795e..a897de2b 100644 --- a/app/models/shift_sale.rb +++ b/app/models/shift_sale.rb @@ -21,7 +21,7 @@ class ShiftSale < ApplicationRecord #find open shift where is open today and is not closed and login by current cashier today_date = DateTime.now.strftime("%Y-%m-%d") puts today_date - shift = ShiftSale.where("DATE(shift_started_at)= #{ today_date } and shift_started_at is not null and shift_closed_at is null and employee_id = #{current_user}").take + shift = ShiftSale.where("TO_CHAR(shift_started_at, 'YYYY-MM-DD')=? and shift_started_at is not null and shift_closed_at is null and employee_id = #{current_user}", today_date).take return shift #end @@ -37,16 +37,26 @@ class ShiftSale < ApplicationRecord def update(sale) saleobj = Sale.find_by_sale_id(sale) - self.total_revenue = self.total_revenue + saleobj.total_amount + cash = saleobj.get_cash_amount + credit = saleobj.get_credit_amount + other_sales = saleobj.get_other_amount + tax = saleobj.get_commerical_tax + self.total_revenue = self.total_revenue.to_f + saleobj.total_amount.to_f self.total_discounts = self.total_discounts + saleobj.total_discount self.total_taxes = self.total_taxes + saleobj.total_tax self.grand_total = self.grand_total + saleobj.grand_total - # self.nett_sales = - # self.cash_sales = - # self.credit_sales = - # self.other_sales = - # self.commercial_taxes = + self.cash_sales = self.cash_sales.to_f + cash.to_f + self.credit_sales = self.credit_sales.to_i + credit.to_f + self.other_sales = self.other_sales.to_i + other_sales.to_f + self.nett_sales = self.grand_total.to_i - self.commercial_taxes + self.commercial_taxes = self.commercial_taxes.to_i + tax.to_f self.save end + + def get_closing_balance(shift) + shiftobj = ShiftSale.find(shift) + closing_balance = shiftobj.grand_total + shiftobj.cash_in - shiftobj.cash_out + shiftobj.total_cash + return closing_balance + end end diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index dde68c48..f89560f3 100644 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -303,7 +303,8 @@ <% if @status_order == 'order' && @status_sale != 'sale' %> - + + @@ -313,6 +314,7 @@ + @@ -390,6 +392,25 @@ $(document).ready(function(){ return false; }); + // Add Other Charges + $('#other-charges').click(function() { + var sale = $('#sale_id').val(); + if (sale!="") { + var sale_id = sale + }else{ + var sale_id = $('#save_order_id').attr('data-order'); + } + + if(sale_id!=""){ + window.location.href = '/origami/' + sale_id + '/other_charges' + } + else { + alert("Please select an table!"); + } + + return false; + }); + // Discount for Payment $('#discount').click(function() { var sale = $('#sale_id').val(); @@ -408,7 +429,6 @@ $(document).ready(function(){ return false; }); - }); // Print for first bill diff --git a/app/views/origami/other_charges/index.html.erb b/app/views/origami/other_charges/index.html.erb new file mode 100644 index 00000000..129aa0e0 --- /dev/null +++ b/app/views/origami/other_charges/index.html.erb @@ -0,0 +1,331 @@ +
+ +
+ +
+ +
+
+
+ +

Receipt No: <%=@sale_data.receipt_no rescue ' '%>

+ +
+
+

Date: <%=@sale_data.receipt_date.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%>

+
+
+
+ + + + + + + + <% sub_total = 0 %> + <% @sale_data.sale_items.each do |sale_item| %> + <% + sub_total += sale_item.qty*sale_item.unit_price + unless sale_item.price == 0 + %> + > + + + + + <% + end + end + %> + +
ItemsQTY + Price +
+ + <%=sale_item.product_name%>@<%=sale_item.unit_price%> + + <%=sale_item.qty%> + + <%=(sale_item.qty*sale_item.unit_price)%> +
+
+ +
+
+
+ + + +
+ +
+
+
Other Charges Control
+
+
+
+
+
+
+ +
+
+ +
+
+
+
+ +
+ +
+
+
+
+
3000
+
+
+
1
+
2
+
3
+
+
+ +
+
+
5000
+
+
+
4
+
5
+
6
+
+
+ +
+
+
10000
+
+
+
7
+
8
+
9
+
+
+ +
+
+
15000
+
+
+
0
+
.
+
00
+
+
+ +
+
+
20000
+
+
+
+
DEL
+
CLR
+
+
+
+ +
+
+ + +
+
+
+
+
+
+ + +
+ +
+ + +
+
+
+ + diff --git a/app/views/origami/shifts/new.html.erb b/app/views/origami/shifts/new.html.erb index 16c2aa10..2903a8ae 100644 --- a/app/views/origami/shifts/new.html.erb +++ b/app/views/origami/shifts/new.html.erb @@ -1,5 +1,9 @@

Open Cashier


+
+
+
+
@@ -21,7 +25,40 @@ +
+
+
+
+
1
+
2
+
3
+
+
+
4
+
5
+
6
+
+
+
7
+
8
+
9
+
+
+
0
+
.
+
00
+
+
+
Del
+
Clr
+
Ent
+
+
+ +
+
+ \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index e3a0d7a0..35669703 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -93,6 +93,11 @@ Rails.application.routes.draw do # post '/:booking_id' => 'home#item_show' + # Other Charges + get "/:sale_id/other_charges" => "other_charges#index" + post "/:sale_id/other_charges" => "other_charges#create" + + # Discount get "/:id/discount" => "discounts#index" post "/:id/discount" => "discounts#create" get "/:id/remove_all_discount" => "discounts#remove_all_discount" diff --git a/db/migrate/20170403160742_create_sales.rb b/db/migrate/20170403160742_create_sales.rb index 7e4850f1..ae806472 100644 --- a/db/migrate/20170403160742_create_sales.rb +++ b/db/migrate/20170403160742_create_sales.rb @@ -20,7 +20,7 @@ class CreateSales < ActiveRecord::Migration[5.1] t.decimal :rounding_adjustment, :precision => 10, :scale => 2, :null => false, :default => 0.00 t.decimal :amount_received, :precision => 10, :scale => 2, :null => false, :default => 0.00 t.decimal :amount_changed, :precision => 10, :scale => 2, :null => false, :default => 0.00 - + t.integer :shift_sale_id, :null => false t.timestamps end end diff --git a/db/migrate/20170626191519_create_shift_sales.rb b/db/migrate/20170626191519_create_shift_sales.rb index 762b4fc3..18323c9d 100644 --- a/db/migrate/20170626191519_create_shift_sales.rb +++ b/db/migrate/20170626191519_create_shift_sales.rb @@ -18,7 +18,9 @@ class CreateShiftSales < ActiveRecord::Migration[5.1] t.decimal :commercial_taxes, :precision => 10, :scale => 2, :null => false, :default => 0.00 t.decimal :cash_in, :precision => 10, :scale => 2, :null => false, :default => 0.00 t.decimal :cash_out, :precision => 10, :scale => 2, :null => false, :default => 0.00 - + t.integer :dining_count, :default => 0 + t.integer :takeaway_count, :default => 0 + t.integer :member_count, :default => 0 t.timestamps end end diff --git a/db/seeds.rb b/db/seeds.rb index 7095d528..2635ab4f 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -181,4 +181,6 @@ payment_methods = PaymentMethodSetting.create({payment_method:"Master",gateway_u payment_methods = PaymentMethodSetting.create({payment_method:"Redeem",gateway_url: "http://192.168.1.47:3006",merchant_account_id:"vWSsseoZCzxd6xcNf_uS"}) cashier_terminal = CashierTerminal.create({name:"Terminal 1"}) +cashier_terminal2 = CashierTerminal.create({name:"Terminal 2"}) +cashier_terminal3 = CashierTerminal.create({name:"Terminal 3"}) puts " Finished System Default Set Up Data " diff --git a/lib/tasks/menu_import.rake b/lib/tasks/menu_import.rake index 1979d364..47b84ef5 100644 --- a/lib/tasks/menu_import.rake +++ b/lib/tasks/menu_import.rake @@ -60,8 +60,8 @@ menu_category2 = MenuCategory.create({menu: menu, code:"C002", name: "Specialty menu_category3 = MenuCategory.create({menu: menu, code:"C003", name: "Beef & Mutton", alt_name: "Beef_and_mutton", order_by: 3,created_by: "SYSTEM DEFAULT"}) # Australia Angus Boneless Short Rib menu_category1_menu_item6 = SimpleMenuItem.create({item_code:"01007", name: "Australia Angus Boneless Short Rib", alt_name: "Twin Pot",menu_category: menu_category3 , min_selectable_item: 1, max_selectable_item:1, account: food }) - menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Half Potion",item_instance_code:"II0142", menu_item: menu_category1_menu_item5, price:12500.00, is_on_promotion:false}]) - menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Full Potion",item_instance_code:"II0141", menu_item: menu_category1_menu_item5, price:25000.00, is_on_promotion:false}]) + menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Half Potion",item_instance_code:"II0142", menu_item: menu_category1_menu_item6, price:12500.00, is_on_promotion:false}]) + menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Full Potion",item_instance_code:"II0141", menu_item: menu_category1_menu_item6, price:25000.00, is_on_promotion:false}]) # Spain Beef menu_category1_menu_item7 = SimpleMenuItem.create({item_code:"01008", name: "Spain Beef", alt_name: "Twin Pot",menu_category: menu_category3 , min_selectable_item: 1, max_selectable_item:1, account: food }) menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Half Potion",item_instance_code:"II0152", menu_item: menu_category1_menu_item7, price:8000.00, is_on_promotion:false}]) @@ -83,10 +83,13 @@ menu_category3 = MenuCategory.create({menu: menu, code:"C003", name: "Beef & Mut menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Half Potion",item_instance_code:"II0192", menu_item: menu_category1_menu_item11, price:7000.00, is_on_promotion:false}]) menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Full Potion",item_instance_code:"II0191", menu_item: menu_category1_menu_item11, price:14000.00, is_on_promotion:false}]) # Sliced Lamb - menu_category1_menu_item11 = SimpleMenuItem.create({item_code:"01012", name: "Sliced Lamb", alt_name: "Twin Pot",menu_category: menu_category3 , min_selectable_item: 1, max_selectable_item:1, account: food }) - menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Half Potion",item_instance_code:"II0202", menu_item: menu_category1_menu_item11, price:7000.00, is_on_promotion:false}]) - menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Full Potion",item_instance_code:"II0201", menu_item: menu_category1_menu_item11, price:14000.00, is_on_promotion:false}]) - + menu_category1_menu_item12 = SimpleMenuItem.create({item_code:"01013", name: "Sliced Lamb", alt_name: "Twin Pot",menu_category: menu_category3 , min_selectable_item: 1, max_selectable_item:1, account: food }) + menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Half Potion",item_instance_code:"II0202", menu_item: menu_category1_menu_item12, price:7000.00, is_on_promotion:false}]) + menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Full Potion",item_instance_code:"II0201", menu_item: menu_category1_menu_item12, price:14000.00, is_on_promotion:false}]) + # Sliced Beef ( Think ) + menu_category1_menu_item13 = SimpleMenuItem.create({item_code:"01014", name: "Sliced Beef ( Think )", alt_name: "Twin Pot",menu_category: menu_category3 , min_selectable_item: 1, max_selectable_item:1, account: food }) + menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Half Potion",item_instance_code:"II1432", menu_item: menu_category1_menu_item13, price:7000.00, is_on_promotion:false}]) + menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Full Potion",item_instance_code:"II1431", menu_item: menu_category1_menu_item13, price:14000.00, is_on_promotion:false}]) # Pork menu_category4 = MenuCategory.create({menu: menu, code:"C004", name: "Pork", alt_name: "Pork", order_by: 4,created_by: "SYSTEM DEFAULT"}) # Sliced Tenderloin Pork @@ -282,7 +285,7 @@ menu_category8 = MenuCategory.create({menu: menu, code:"C008", name: "Seafood", menu_category1_menu_item61 = SimpleMenuItem.create({item_code:"01062", name: "Live Lobster", alt_name: "Twin Pot",menu_category: menu_category7 , min_selectable_item: 1, max_selectable_item:1, account: food }) menu_item0_instance = MenuItemInstance.create([{item_instance_name:"",item_instance_code:"II0681", menu_item: menu_category1_menu_item61, price:10.00, is_on_promotion:false}]) # Live Mantis - menu_category1_menu_item62 = SimpleMenuItem.create({item_code:"01063", name: "Live Mantis", alt_name: "Twin Pot",menu_category: menu_category7 , min_selectable_item: 1, max_selectable_item:1, account: food }) + menu_category1_menu_item62 = SimpleMenuItem.create({item_code:"01063", name: "Live Mantis Prawn", alt_name: "Twin Pot",menu_category: menu_category7 , min_selectable_item: 1, max_selectable_item:1, account: food }) menu_item0_instance = MenuItemInstance.create([{item_instance_name:" ",item_instance_code:"II0691", menu_item: menu_category1_menu_item62, price:10.00, is_on_promotion:false}]) # Dumpling menu_category9 = MenuCategory.create({menu: menu, code:"C009", name: "Dumpling", alt_name: "Chicken", order_by: 9, created_by: "SYSTEM DEFAULT"}) @@ -567,20 +570,20 @@ menu_category19 = MenuCategory.create({menu: menu, code:"C0018", name: "Beer", a menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Can",item_instance_code:"II1392", menu_item: menu_category1_menu_item132, price:1500.00, is_on_promotion:false}]) menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Bottle",item_instance_code:"II1391", menu_item: menu_category1_menu_item132, price:3000.00, is_on_promotion:false}]) # # Tiger Beer -# menu_category1_menu_item133 = SimpleMenuItem.create({item_code:"01134", name: "Tiger Beer ", alt_name: "Twin Pot",menu_category: menu_category19 , min_selectable_item: 1, max_selectable_item:1, account: beverage }) -# menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Can",item_instance_code:"II1402", menu_item: menu_category1_menu_item133, price:1500.00, is_on_promotion:false}]) -# menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Bottle",item_instance_code:"II1401", menu_item: menu_category1_menu_item133, price:3000.00, is_on_promotion:false}]) + menu_category1_menu_item133 = SimpleMenuItem.create({item_code:"01134", name: "Tiger Beer ", alt_name: "Twin Pot",menu_category: menu_category19 , min_selectable_item: 1, max_selectable_item:1, account: beverage }) + menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Can",item_instance_code:"II1442", menu_item: menu_category1_menu_item133, price:1500.00, is_on_promotion:false}]) + menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Bottle",item_instance_code:"II1441", menu_item: menu_category1_menu_item133, price:3000.00, is_on_promotion:false}]) # Heineken Beer menu_category1_menu_item134 = SimpleMenuItem.create({item_code:"01135", name: "Heineken Beer", alt_name: "Twin Pot",menu_category: menu_category19 , min_selectable_item: 1, max_selectable_item:1, account: beverage }) menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Can",item_instance_code:"II1402", menu_item: menu_category1_menu_item134, price:1800.00, is_on_promotion:false}]) menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Bottle",item_instance_code:"II1401", menu_item: menu_category1_menu_item134, price:3600.00, is_on_promotion:false}]) # Tsing Tao Beer menu_category1_menu_item135 = SimpleMenuItem.create({item_code:"01136", name: "Tsing Tao Beer", alt_name: "Twin Pot",menu_category: menu_category19 , min_selectable_item: 1, max_selectable_item:1, account: beverage }) - menu_item0_instance = MenuItemInstance.create([{item_instance_name:"",item_instance_code:"II141", menu_item: menu_category1_menu_item135, price:2800.00, is_on_promotion:false}]) + menu_item0_instance = MenuItemInstance.create([{item_instance_name:"",item_instance_code:"II1411", menu_item: menu_category1_menu_item135, price:2800.00, is_on_promotion:false}]) # ABC Stout menu_category1_menu_item136 = SimpleMenuItem.create({item_code:"01137", name: "ABC Stout ", alt_name: "Twin Pot",menu_category: menu_category19 , min_selectable_item: 1, max_selectable_item:1, account: beverage }) - menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Can",item_instance_code:"II1432", menu_item: menu_category1_menu_item136, price:2000.00, is_on_promotion:false}]) - menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Bottle",item_instance_code:"II1431", menu_item: menu_category1_menu_item136, price:4000.00, is_on_promotion:false}]) + menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Can",item_instance_code:"II1422", menu_item: menu_category1_menu_item136, price:2000.00, is_on_promotion:false}]) + menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Bottle",item_instance_code:"II1421", menu_item: menu_category1_menu_item136, price:4000.00, is_on_promotion:false}]) # Signature Hot Tea" menu_category20 = MenuCategory.create({menu: menu, code:"C0019", name: "Signature Hot Tea", alt_name: "Chicken", order_by: 19, created_by: "SYSTEM DEFAULT"}) puts "Beauty in the pot's menu setup"