diff --git a/app/assets/javascripts/origami.js b/app/assets/javascripts/origami.js index f4bb9488..1cbc63ed 100755 --- a/app/assets/javascripts/origami.js +++ b/app/assets/javascripts/origami.js @@ -344,7 +344,7 @@ function resCBPay(resMsg,card_sale_trans_id,cmd_type,payment_type,bnk_bill_amoun if(jobj.STATUS == "Approved"){ $.ajax({type: "POST", url: "/origami/payment/"+payment_type, - data: "amount="+ bnk_bill_amount + "&sale_id="+ sale_id, + data: "amount="+ bnk_bill_amount + "&sale_id="+ sale_id + "&ref_no=" + jobj.REFNUM, success:function(result){ if(result){ swal({ diff --git a/app/controllers/api/payments_controller.rb b/app/controllers/api/payments_controller.rb index 39219c6b..459589ed 100755 --- a/app/controllers/api/payments_controller.rb +++ b/app/controllers/api/payments_controller.rb @@ -84,6 +84,17 @@ class Api::PaymentsController < ActionController::API sale_payment.payment_reference = params[:payment_reference] #TODO: implement paypar implementation @status, @invoice = sale_payment.process_payment(sale_payment, current_login_employee.name) + when "JunctionPay" + sale_payment.payment_method = "JunctionPay" + sale_payment.received_amount = params[:amount] + sale_payment.customer_id = params[:customer_id] + sale_payment.payment_reference = params[:vochure_no] + @status, @invoice = sale_payment.process_payment(sale_payment, current_login_employee.name) + when "alipay" + sale_payment.payment_method = "alipay" + sale_payment.received_amount = params[:amount] + sale_payment.payment_reference = params[:payment_reference] + @status, @invoice = sale_payment.process_payment(sale_payment, current_login_employee.name) end end end diff --git a/app/controllers/origami/alipay_controller.rb b/app/controllers/origami/alipay_controller.rb new file mode 100644 index 00000000..3f449856 --- /dev/null +++ b/app/controllers/origami/alipay_controller.rb @@ -0,0 +1,77 @@ +class Origami::AlipayController < BaseOrigamiController + def index + @sale_id = params[:sale_id] + @cashier_type = params[:type] + # limit alipay_amount + sale_data = Sale.find_by_sale_id(@sale_id) + total = 0 + @alipaycount = 0 + @shop = Shop::ShopDetail + @rounding_adj = 0 + @can_alipay = 0 + @member_discount = 0 + @sub_total = 0 + @membership_id = nil + @receipt_no = nil + if !sale_data.nil? + total = sale_data.grand_total + + others = 0 + + if @shop.is_rounding_adj + new_total = Sale.get_rounding_adjustment(sale_data.grand_total) + else + new_total = sale_data.grand_total + end + @rounding_adj = new_total-sale_data.grand_total + + sale_data.sale_payments.each do |sale_payment| + if sale_payment.payment_method == "alipay" + @alipaycount = @alipaycount + sale_payment.payment_amount + else + others = others + sale_payment.payment_amount + end + end + @can_alipay = total - @alipaycount - others + + @member_discount = MembershipSetting.find_by_discount(1) + @sub_total = sale_data.total_amount + @membership_id = sale_data.customer.membership_id + #for bank integration + @receipt_no = sale_data.receipt_no + end + + bank_integration = Lookup.collection_of('bank_integration') + @bank_integration = 0 + if !bank_integration[0].nil? + @bank_integration = bank_integration[0][1] + end + end + + def create + cash = params[:amount] + sale_id = params[:sale_id] + ref_no = params[:ref_no] + if(Sale.exists?(sale_id)) + saleObj = Sale.find(sale_id) + shop_details = Shop::ShopDetail + + # rounding adjustment + # if shop_details.is_rounding_adj + # new_total = Sale.get_rounding_adjustment(saleObj.grand_total) + # rounding_adj = new_total-saleObj.grand_total + # saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj) + # end + + # saleObj = Sale.find(sale_id) + sale_payment = SalePayment.new + @status, @sale = sale_payment.process_payment(saleObj, @user, cash, "alipay",ref_no) + end + end + + #Shop Name in Navbor + helper_method :shop_detail + def shop_detail + @shop = Shop.first + end +end diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index a8e2818c..759cb1b6 100755 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -95,7 +95,7 @@ class Origami::HomeController < BaseOrigamiController @status_order = 'order' else sale = Sale.find(booking.sale_id) - if sale.sale_status != "completed" && sale.sale_status != 'void' + if sale.sale_status != "completed" && sale.sale_status != 'void' && sale.sale_status != 'spoile' && sale.sale_status != 'waste' @sale_array.push(sale) if @status_order == 'order' @status_order = 'sale' diff --git a/app/controllers/origami/jcb_controller.rb b/app/controllers/origami/jcb_controller.rb index 7d8ea46b..fd79f6d8 100644 --- a/app/controllers/origami/jcb_controller.rb +++ b/app/controllers/origami/jcb_controller.rb @@ -53,6 +53,7 @@ class Origami::JcbController < BaseOrigamiController def create cash = params[:amount] sale_id = params[:sale_id] + ref_no = params[:ref_no] if(Sale.exists?(sale_id)) saleObj = Sale.find(sale_id) shop_details = Shop::ShopDetail @@ -66,7 +67,7 @@ class Origami::JcbController < BaseOrigamiController # saleObj = Sale.find(sale_id) sale_payment = SalePayment.new - @status, @sale = sale_payment.process_payment(saleObj, @user, cash, "jcb") + @status, @sale = sale_payment.process_payment(saleObj, @user, cash, "jcb",ref_no) end end diff --git a/app/controllers/origami/master_controller.rb b/app/controllers/origami/master_controller.rb index 747da493..cca8a2c4 100644 --- a/app/controllers/origami/master_controller.rb +++ b/app/controllers/origami/master_controller.rb @@ -50,6 +50,7 @@ class Origami::MasterController < BaseOrigamiController def create cash = params[:amount] sale_id = params[:sale_id] + ref_no = params[:ref_no] if(Sale.exists?(sale_id)) saleObj = Sale.find(sale_id) shop_details = Shop::ShopDetail @@ -63,7 +64,7 @@ class Origami::MasterController < BaseOrigamiController # saleObj = Sale.find(sale_id) sale_payment = SalePayment.new - @status, @sale = sale_payment.process_payment(saleObj, @user, cash, "master") + @status, @sale = sale_payment.process_payment(saleObj, @user, cash, "master",ref_no) end end diff --git a/app/controllers/origami/mpu_controller.rb b/app/controllers/origami/mpu_controller.rb index 1b125bda..7d3ded34 100644 --- a/app/controllers/origami/mpu_controller.rb +++ b/app/controllers/origami/mpu_controller.rb @@ -51,6 +51,7 @@ class Origami::MpuController < BaseOrigamiController def create cash = params[:amount] sale_id = params[:sale_id] + ref_no = params[:ref_no] if(Sale.exists?(sale_id)) saleObj = Sale.find(sale_id) shop_details = Shop::ShopDetail @@ -64,7 +65,7 @@ class Origami::MpuController < BaseOrigamiController # saleObj = Sale.find(sale_id) sale_payment = SalePayment.new - @status, @sale = sale_payment.process_payment(saleObj, @user, cash, "mpu") + @status, @sale = sale_payment.process_payment(saleObj, @user, cash, "alipay",ref_no) end end diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index c2797047..cdb8752f 100755 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -113,8 +113,6 @@ class Origami::PaymentsController < BaseOrigamiController end end #end rounding adjustment - puts "sale" - puts saleObj.to_json sale_payment = SalePayment.new sale_payment.process_payment(saleObj, current_user.name, cash, "cash") @@ -228,6 +226,7 @@ class Origami::PaymentsController < BaseOrigamiController @jcbcount= 0.0 @mastercount = 0.0 @unionpaycount = 0.0 + @alipaycount = 0.0 @junctionpaycount = 0.0 @credit = 0.0 @sale_data = Sale.find_by_sale_id(sale_id) @@ -348,6 +347,8 @@ class Origami::PaymentsController < BaseOrigamiController @junctionpaycount += spay.payment_amount elsif spay.payment_method == "creditnote" @credit += spay.payment_amount + elsif spay.payment_method == "alipay" + @alipaycount += spay.payment_amount end end end diff --git a/app/controllers/origami/rooms_controller.rb b/app/controllers/origami/rooms_controller.rb index 11a7f93d..5c0cd454 100755 --- a/app/controllers/origami/rooms_controller.rb +++ b/app/controllers/origami/rooms_controller.rb @@ -79,8 +79,7 @@ class Origami::RoomsController < BaseOrigamiController @status_order = 'order' else sale = Sale.find(booking.sale_id) - if sale.sale_status != "completed" && sale.sale_status != 'void' - puts "enter" + if sale.sale_status != "completed" && sale.sale_status != 'void' && sale.sale_status != 'spoile' && sale.sale_status != 'waste' @sale_array.push(sale) if @status_order == 'order' @status_order = 'sale' diff --git a/app/controllers/origami/unionpay_controller.rb b/app/controllers/origami/unionpay_controller.rb index 7213af6d..ec941a20 100644 --- a/app/controllers/origami/unionpay_controller.rb +++ b/app/controllers/origami/unionpay_controller.rb @@ -48,6 +48,7 @@ class Origami::UnionpayController < BaseOrigamiController def create cash = params[:amount] sale_id = params[:sale_id] + ref_no = params[:ref_no] if(Sale.exists?(sale_id)) saleObj = Sale.find(sale_id) shop_details = Shop::ShopDetail @@ -62,7 +63,7 @@ class Origami::UnionpayController < BaseOrigamiController # saleObj = Sale.find(sale_id) #end rounding adjustment sale_payment = SalePayment.new - @status, @sale = sale_payment.process_payment(saleObj, @user, cash, "unionpay") + @status, @sale = sale_payment.process_payment(saleObj, @user, cash, "unionpay",ref_no) end end diff --git a/app/controllers/origami/visa_controller.rb b/app/controllers/origami/visa_controller.rb index 94f58a99..17b70010 100644 --- a/app/controllers/origami/visa_controller.rb +++ b/app/controllers/origami/visa_controller.rb @@ -48,6 +48,7 @@ class Origami::VisaController < BaseOrigamiController def create cash = params[:amount] sale_id = params[:sale_id] + ref_no = params[:ref_no] if(Sale.exists?(sale_id)) saleObj = Sale.find(sale_id) shop_details = Shop::ShopDetail @@ -62,7 +63,7 @@ class Origami::VisaController < BaseOrigamiController # saleObj = Sale.find(sale_id) #end rounding adjustment sale_payment = SalePayment.new - @status, @sale = sale_payment.process_payment(saleObj, @user, cash, "visa") + @status, @sale = sale_payment.process_payment(saleObj, @user, cash, "visa",ref_no) end end diff --git a/app/controllers/origami/void_controller.rb b/app/controllers/origami/void_controller.rb index 74e495ca..83dce707 100755 --- a/app/controllers/origami/void_controller.rb +++ b/app/controllers/origami/void_controller.rb @@ -48,7 +48,7 @@ class Origami::VoidController < BaseOrigamiController table.bookings.each do |booking| if booking.booking_status != 'moved' if booking.sale_id - if booking.sale.sale_status != 'completed' && booking.sale.sale_status != 'void' + if booking.sale.sale_status != 'completed' && booking.sale.sale_status != 'void' && booking.sale.sale_status != 'spoile' && booking.sale.sale_status != 'waste' table_avaliable = false table_count += 1 else diff --git a/app/controllers/origami/waste_spoile_controller.rb b/app/controllers/origami/waste_spoile_controller.rb new file mode 100755 index 00000000..c94b33bb --- /dev/null +++ b/app/controllers/origami/waste_spoile_controller.rb @@ -0,0 +1,128 @@ +class Origami::WasteSpoileController < BaseOrigamiController + def waste_and_spoilage + + sale_id = params[:sale_id] + remark = params[:remark] + order_source = params[:type] #tax profile source + if Sale.exists?(sale_id) + sale = Sale.find_by_sale_id(sale_id) + SaleTax.where("sale_id='#{sale_id}'").find_each do |existing_tax| + existing_tax.delete + end + sale.update_attributes(total_discount: 0,total_tax: 0,grand_total: sale.total_amount,rounding_adjustment:0) + sale.payment_status = remark + sale.sale_status = remark + sale.save + + # sale.compute_by_sale_items(sale_id, sale.sale_items,0,order_source) + # add to sale item with foc + # sale_items = SaleItem.where("sale_id='#{ sale_id }' and status is null") + + sale.sale_items.each do|item| + # SaleItem.update_existing_item(item.qty, item, sale_id, remark, item.unit_price, item.price) + item.status = remark + item.remark = remark + item.save + end + + if sale.bookings[0].dining_facility_id.to_i > 0 + table_avaliable = true + table_count = 0 + table = sale.bookings[0].dining_facility + table.bookings.each do |booking| + if booking.booking_status != 'moved' + if booking.sale_id + if booking.sale.sale_status != 'completed' && booking.sale.sale_status != 'void' && booking.sale.sale_status != 'spoile' && booking.sale.sale_status != 'waste' + table_avaliable = false + table_count += 1 + else + table_avaliable = true + end + else + table_avaliable = false + table_count += 1 + end + end + end + if table_avaliable && table_count == 0 + table.status = 'available' + table.save + end + else + table = nil + end + + # FOr Sale Audit + action_by = current_user.name + # 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,remark ) + + # For Print + + member_info = nil + rebate_amount = nil + current_balance = nil + + # For Cashier by Zone + bookings = Booking.where("sale_id='#{sale_id}'") + if bookings.count > 1 + # for Multiple Booking + if bookings[0].dining_facility_id.to_i>0 + table = DiningFacility.find(bookings[0].dining_facility_id) + end + end + + if bookings[0].dining_facility_id.to_i > 0 + cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id) + cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id) + else + shift = ShiftSale.find(sale.shift_sale_id) + cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id) + end + + + # if ENV["SERVER_MODE"] != "cloud" #no print in cloud server + unique_code = "ReceiptBillPdf" + customer= Customer.find(sale.customer_id) + + #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,sale.receipt_no) + current_balance = SaleAudit.paymal_search(sale_id) + end + + # get printer info + print_settings=PrintSetting.find_by_unique_code(unique_code) + # Calculate Food and Beverage Total + item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale.sale_items) + discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items) + + printer = Printer::ReceiptPrinter.new(print_settings) + filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, remark,current_balance,nil) + result = { + :filepath => filename, + :printer_model => print_settings.brand_name, + :printer_url => print_settings.api_settings + } + + # Mobile Print + render :json => result.to_json + # end + + #end print + + # 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| + aoi.delivery_status = 1 + aoi.save + end + end + end + end + +end \ No newline at end of file diff --git a/app/controllers/reports/waste_and_spoilage_controller.rb b/app/controllers/reports/waste_and_spoilage_controller.rb new file mode 100755 index 00000000..369c6860 --- /dev/null +++ b/app/controllers/reports/waste_and_spoilage_controller.rb @@ -0,0 +1,19 @@ +class Reports::WasteAndSpoilageController < BaseReportController +authorize_resource :class => false + def index + from, to = get_date_range_from_params + @sale_type = params[:sale_type] + @sale_data = Sale.get_wastes_and_spoilages(from,to,@sale_type) + @from = from + @to = to + # get printer info + @print_settings = PrintSetting.get_precision_delimiter() + + respond_to do |format| + format.html + format.xls + end + end + + +end \ No newline at end of file diff --git a/app/models/ability.rb b/app/models/ability.rb index 0b1edcc3..b1930e1b 100755 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -179,6 +179,11 @@ class Ability can :remove_all_discount, :discount can :member_discount, :discount + can :move_dining, :movetable + can :moving, :movetable + + can :move_dining, :moveroom + can :manage, Customer can :manage, DiningQueue diff --git a/app/models/sale.rb b/app/models/sale.rb index 970896bf..883fbad4 100755 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -950,7 +950,7 @@ def self.get_menu_item_query(order_by) " LEFT JOIN sale_items si ON si.item_instance_code = mii.item_instance_code" + " LEFT JOIN sales s ON s.sale_id = si.sale_id") .where("(CASE WHEN s.sale_status IS NOT NULL THEN s.sale_status='completed' ELSE 1 END)") - .group("mc.id, (CASE WHEN si.product_name IS NOT NULL THEN si.product_name ELSE mii.item_instance_name END)") + .group("mc.id, (CASE WHEN si.product_name IS NOT NULL THEN si.product_name ELSE CONCAT(menu_items.name,' - ',mii.item_instance_name) END)") .order("si.qty #{order_by}, menu_items.menu_category_id #{order_by}") end #product sale report query @@ -1109,6 +1109,16 @@ def self.get_payment_method_by_shift(shift_sale_range,shift,from,to,payment_type return all_total,sale_type end +def self.get_wastes_and_spoilages(from,to,status) + if status == "spoile" + type = "and sales.sale_status = 'spoile'" + else + type = "and sales.sale_status = 'waste'" + end + query = Sale.all.where("sales.receipt_date between ? and ? #{type}",from,to) + .group("sales.receipt_no") +end + # def self.get_separate_tax(from,to,payment_method=nil) # query = SaleTax.select("SUM(tax_payable_amount) AS st_amount,tax_name") diff --git a/app/models/sale_item.rb b/app/models/sale_item.rb index 64e0ec73..fc32098f 100755 --- a/app/models/sale_item.rb +++ b/app/models/sale_item.rb @@ -38,7 +38,8 @@ class SaleItem < ApplicationRecord sale_item.product_alt_name = item.product_alt_name sale_item.account_id = item.account_id sale_item.status = type - if type == "foc" || type == "promotion" || type == "void" + sale_item.remark = type + if type == "foc" || type == "promotion" || type == "void" || type == "waste" || type == "spoile" sale_item.qty = qty * (-1) else sale_item.qty = qty diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 3ff4697e..cceee884 100755 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -51,6 +51,8 @@ class SalePayment < ApplicationRecord payment_status = foc_payment when "JunctionPay" payment_status = junction_pay_payment + when "alipay" + payment_status = external_terminal_card_payment(:alipay) else puts "it was something else" end @@ -230,7 +232,7 @@ class SalePayment < ApplicationRecord payment_status = false self.payment_method = method self.payment_amount = self.received_amount - self.payment_reference = self.card_payment_reference + # self.payment_reference = self.card_payment_reference self.outstanding_amount = self.sale.grand_total.to_f - self.received_amount.to_f self.payment_status = "paid" payment_method = self.save! @@ -418,7 +420,7 @@ class SalePayment < ApplicationRecord bookings.each do |tablebooking| if tablebooking.booking_status != 'moved' if tablebooking.sale_id - if tablebooking.sale.sale_status != 'completed' && tablebooking.sale.sale_status != 'void' + if tablebooking.sale.sale_status != 'completed' && tablebooking.sale.sale_status != 'void' && tablebooking.sale.sale_status != 'spoile' && tablebooking.sale.sale_status != 'waste' status = false sale_count += 1 else diff --git a/app/views/layouts/_left_sidebar.html.erb b/app/views/layouts/_left_sidebar.html.erb index 63067ec0..ea3a7b61 100644 --- a/app/views/layouts/_left_sidebar.html.erb +++ b/app/views/layouts/_left_sidebar.html.erb @@ -144,6 +144,9 @@
  • Void Sales
  • +
  • + Wastes & Spoilages +
  • Payment Method
  • diff --git a/app/views/origami/alipay/create.json.jbuilder b/app/views/origami/alipay/create.json.jbuilder new file mode 100755 index 00000000..9767a7d8 --- /dev/null +++ b/app/views/origami/alipay/create.json.jbuilder @@ -0,0 +1,5 @@ +if(@status) + json.status @status +else + json.status false +end diff --git a/app/views/origami/alipay/index.html.erb b/app/views/origami/alipay/index.html.erb new file mode 100755 index 00000000..a9959512 --- /dev/null +++ b/app/views/origami/alipay/index.html.erb @@ -0,0 +1,258 @@ +
    + + +
    +
    + + + +
    +
    +
    + <% if @bank_integration == '1' %> +
    +
    + + +
    +
    +
    + <% end %> +
    +
    + + <%@can_alipay = @can_alipay +@rounding_adj%> + +
    +
    +
    + <% if @alipaycount != 0 %> +
    +
    + + +
    +
    +
    + <% end %> +
    +
    + + +
    +
    +
    +
    +
    +
    + +
    0.0
    +
    +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    1
    +
    2
    +
    3
    +
    +
    +
    4
    +
    5
    +
    6
    +
    +
    +
    7
    +
    8
    +
    9
    +
    +
    +
    0
    +
    .
    +
    00
    +
    +
    +
    Nett
    +
    Del
    +
    Clr
    +
    +
    +
    +
    +
    1000
    +
    3000
    +
    +
    +
    5000
    +
    10000
    +
    +
    +
    Pay
    +
    +
    +
    +
    +
    + +
    + + +
    +
    +
    + + diff --git a/app/views/origami/customers/index.html.erb b/app/views/origami/customers/index.html.erb index 00f5694f..503cb01f 100755 --- a/app/views/origami/customers/index.html.erb +++ b/app/views/origami/customers/index.html.erb @@ -26,7 +26,7 @@ <% end %> --> - <% path ="/origami/#{@sale_id}/customers" %> + <% path ="/origami/#{@sale_id}/#{@cashier_type}/customers/#{@page}" %> <%= form_tag path, :id => "filter_form", :method => :get do %>
    diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index 7afa2769..4810cf13 100755 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -488,6 +488,11 @@ +
    +
    + +
    +
    + +
    +
    + + + + + diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb index 8226c75a..bca79e11 100755 --- a/app/views/origami/payments/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -182,103 +182,125 @@
    <% if @other != 0.0 %> -
    -
    -
    MPU
    -
    <%= number_with_precision(@other, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
    -
    +
    <% else %> - + <% if @ppamount != 0.0 %>
    -
    -
    Redeem
    -
    <%= number_with_precision(@ppamount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
    -
    <% else %> - <% end %> + <% if @visacount != 0.0 %>
    -
    -
    VISA
    -
    <%= number_with_precision(@visacount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
    -
    <% else %> - <% end %> + <% if @jcbcount != 0.0 %>
    -
    -
    JCB
    -
    <%= number_with_precision(@jcbcount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
    -
    <% else %> - <% end %> + <% if @mastercount != 0.0 %>
    -
    -
    MASTER
    -
    <%= number_with_precision(@mastercount, precision: precision.to_i) rescue number_with_precision(0, precision: precision.to_i ) %>
    -
    <% else %> - <% end %> + <% if @unionpaycount != 0.0 %>
    -
    -
    UNIONPAY
    -
    <%= number_with_precision(@unionpaycount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
    -
    <% else %> + + + <% if @alipaycount != 0.0 %> +
    + <% else %> + + <% if @junctionpaycount != 0.0 %>
    -
    -
    JUNCTION PAY
    -
    <%= number_with_precision(@junctionpaycount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
    -
    <% else %> - <% end %> + +
    Balance
    <%= number_with_precision(@sale_data.grand_total, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
    @@ -585,6 +607,9 @@ var customer_name = "<%= @customer.name %>"; else if(payment_type == "UNIONPAY" && $('#unionpaycount').text()==0 && sub_total != 0.0){ swal("Oops","Please Pay with UNIONPAY Payment","warning"); } + else if(payment_type == "Alipay" && $('#alipaycount').text()==0 && sub_total != 0.0){ + swal("Oops","Please Pay with Alipay Payment","warning"); + } else if(payment_type == "JUNCTIONPAY" && $('#junctionpaycount').text()==0 && sub_total != 0.0){ swal("Oops","Please Pay with JUNCTIONPAY Payment","warning"); } @@ -867,8 +892,9 @@ var customer_name = "<%= @customer.name %>"; var jcb1 = $('#jcbcount').text(); var master1 = $('#mastercount').text(); var unionpay1 = $('#unionpaycount').text(); + var alipay1 = $('#alipaycount').text(); var junctionpay1 = $('#junctionpaycount').text(); - var othertotal = parseFloat(credit1) + parseFloat(card1) + parseFloat(paypar1) + parseFloat(visa1) + parseFloat(jcb1) + parseFloat(master1) + parseFloat(unionpay1) + parseFloat(junctionpay1); + var othertotal = parseFloat(credit1) + parseFloat(card1) + parseFloat(paypar1) + parseFloat(visa1) + parseFloat(jcb1) + parseFloat(master1) + parseFloat(unionpay1) + parseFloat(alipay1) + parseFloat(junctionpay1); var total = $('#amount_due').text(); var amt = 0; <% if precision.to_i > 0 %>; @@ -896,9 +922,10 @@ var customer_name = "<%= @customer.name %>"; var jcb = $('#jcbcount').text(); var master = $('#mastercount').text(); var unionpay = $('#unionpaycount').text(); + var alipay = $('#alipaycount').text(); var junctionpay = $('#junctionpaycount').text(); var amount_due = $('#amount_due').text(); - var total = parseFloat(cash) + parseFloat(credit) + parseFloat(card) + parseFloat(paypar) + parseFloat(visa) + parseFloat(jcb) + parseFloat(master) + parseFloat(unionpay) + parseFloat(junctionpay) + var total = parseFloat(cash) + parseFloat(credit) + parseFloat(card) + parseFloat(paypar) + parseFloat(visa) + parseFloat(jcb) + parseFloat(master) + parseFloat(unionpay) + parseFloat(alipay) + parseFloat(junctionpay) var result = parseFloat(amount_due) - parseFloat(total); <% if precision.to_i > 0 %> $('#balance').text(parseFloat(result).toFixed(<%= precision %>)); diff --git a/app/views/origami/rooms/show.html.erb b/app/views/origami/rooms/show.html.erb index 424690ff..e2f04018 100755 --- a/app/views/origami/rooms/show.html.erb +++ b/app/views/origami/rooms/show.html.erb @@ -450,10 +450,11 @@ <% if current_login_employee.role != "waiter" %> - - - +
    +
    + +
    +
    + +
    +
    +
    + +
    + + + diff --git a/app/views/reports/product_sale/index.html.erb b/app/views/reports/product_sale/index.html.erb old mode 100755 new mode 100644 index f614fbb9..4670f6b3 --- a/app/views/reports/product_sale/index.html.erb +++ b/app/views/reports/product_sale/index.html.erb @@ -45,41 +45,58 @@ <%= t("views.right_panel.detail.code") %> <%= t("views.right_panel.detail.product") %> <%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.item") %> - <%= t("views.right_panel.detail.unit_price") %> + <%= t("views.right_panel.detail.total") %> <% unless @sale_data.blank? %> <% acc_arr = Array.new %> - <% cate_arr = Array.new %> - + <% cate_arr = Array.new %> <% grand_total = 0 %> <% total_qty = 0 %> + <% total_item = {} %> + <% total_data = {} %> + <% @sale_data.each do |sale| + if !total_item.has_key?(sale.item_code) + total_item[sale.item_code] = sale.total_item + total_data[sale.item_code] = sale.grand_total + else + if sale.status_type == "void" + total_item[sale.item_code] += sale.total_item + end + if sale.status_type == "void" || sale.status_type == "Discount" || sale.status_type == "foc" + total_data[sale.item_code] += sale.grand_total + end + end + end %> <% @sale_data.each do |sale| %> <% grand_total += sale.grand_total %> <% if sale.status_type != "Discount" && sale.status_type != "foc" - total_qty += sale.total_item + total_qty += sale.total_item end %> <% if sale.status_type == "foc" && sale.price > 0 total_qty += sale.total_item end %> - <% if !sale.status_type %> + + <% if sale.status_type != "Discount" && sale.price.to_f >= 0 %>   <% if !cate_arr.include?(sale.menu_category_id) %> <%= sale.menu_category_name %> - <% cate_arr.push(sale.menu_category_id) %> + <% cate_arr.push(sale.menu_category_id) %> <% else %> - <% cate_arr = Array.new %> + <% if sale.total_item > 0 %> + <% cate_arr = Array.new %> + <% end %>   <% end %> <%= sale.item_code rescue '-' %> <%= sale.product_name rescue '-' %> - <%= sale.total_item rescue '-' %> - <%= number_with_precision(sale.unit_price , precision:precision.to_i,delimiter:delimiter) rescue '-'%> - <%= number_with_precision(sale.grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-' %> + <%= total_item[sale.item_code] rescue '-' %> + + <%= number_with_precision(total_data[sale.item_code] , precision:precision.to_i,delimiter:delimiter) rescue '-' %> @@ -89,7 +106,6 @@ Total <%= total_qty %> - <%= number_with_precision(grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-' %> diff --git a/app/views/reports/product_sale/index.xls.erb b/app/views/reports/product_sale/index.xls.erb old mode 100755 new mode 100644 index eb7f50f8..0ff60964 --- a/app/views/reports/product_sale/index.xls.erb +++ b/app/views/reports/product_sale/index.xls.erb @@ -11,7 +11,7 @@ <%= t("views.right_panel.detail.code") %> <%= t("views.right_panel.detail.product") %> <%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.item") %> - <%= t("views.right_panel.detail.unit_price") %> + <%= t("views.right_panel.detail.total") %> @@ -21,6 +21,21 @@ <% cate_arr = Array.new %> <% grand_total = 0 %> <% total_qty = 0 %> + <% total_item = {} %> + <% total_data = {} %> + <% @sale_data.each do |sale| + if !total_item.has_key?(sale.item_code) + total_item[sale.item_code] = sale.total_item + total_data[sale.item_code] = sale.grand_total + else + if sale.status_type == "void" + total_item[sale.item_code] += sale.total_item + end + if sale.status_type == "void" || sale.status_type == "Discount" || sale.status_type == "foc" + total_data[sale.item_code] += sale.grand_total + end + end + end %> <% @sale_data.each do |sale| %> <% grand_total += sale.grand_total %> @@ -31,21 +46,23 @@ total_qty += sale.total_item end %> - <% if !sale.status_type %> + <% if sale.status_type != "Discount" && sale.price.to_f >= 0 %>   <% if !cate_arr.include?(sale.menu_category_id) %> <%= sale.menu_category_name %> <% cate_arr.push(sale.menu_category_id) %> <% else %> - <% cate_arr = Array.new %> + <% if sale.total_item > 0 %> + <% cate_arr = Array.new %> + <% end %>   <% end %> <%= sale.item_code rescue '-' %> <%= sale.product_name rescue '-' %> - <%= sale.total_item rescue ' ' %> - <%= sale.unit_price rescue ' ' %> - <%= sale.grand_total rescue ' ' %> + <%= total_item[sale.item_code] rescue ' ' %> + + <%= total_data[sale.item_code] rescue ' ' %> @@ -55,7 +72,6 @@ Total <%= total_qty rescue ' ' %> - <%= grand_total rescue ' ' %> <% end %> diff --git a/app/views/reports/waste_and_spoilage/_shift_sale_report_filter.html.erb b/app/views/reports/waste_and_spoilage/_shift_sale_report_filter.html.erb new file mode 100755 index 00000000..1c403afc --- /dev/null +++ b/app/views/reports/waste_and_spoilage/_shift_sale_report_filter.html.erb @@ -0,0 +1,73 @@ +
    + <%= form_tag report_path, :method => :get, :id=>"frm_report", :class => "form" do %> + <% if period_type != false %> +
    +
    + + +
    +
    + + +
    + +
    + + + +
    +
    + + +
    + +
    +
    + +
    +
    + <% end %> + + <% end %> +
    + + diff --git a/app/views/reports/waste_and_spoilage/index.html.erb b/app/views/reports/waste_and_spoilage/index.html.erb new file mode 100755 index 00000000..f74f99e0 --- /dev/null +++ b/app/views/reports/waste_and_spoilage/index.html.erb @@ -0,0 +1,75 @@ +
    + +
    +
    + <%= render :partial=>'shift_sale_report_filter', + :locals=>{ :period_type => true, :shift_name => true,:payments => true, :report_path =>reports_waste_and_spoilage_index_path} %> +
    + +
    +
    + + +
    Report For <%= @sale_type? @sale_type : 'Waste' %>
    + <% @sale_data.each do |sale| %> + <% waste_and_spoil_item_count = 0%> + + + + + + + + + + + + + + + + + <% sale.sale_items.each do |item| %> + <% if !item.item_instance_code.nil?%> + <% waste_and_spoil_item_count += item.qty.to_i%> + + + + + + + + <% end %> + <% end %> + + + + + + + + <% end %> +
    + Receipt No :<%= sale.receipt_no %> + Date : <%= sale.created_at.utc.getlocal.strftime("%e,%b %Y %I:%M %p") %>
    Item NameItem CodeQtyPriceTotal Price
    <%= item.product_name %><%= item.product_code %><%= item.qty %><%= item.price %><%= item.price %>
    Total Qty: + <%= waste_and_spoil_item_count %> + Grand Total: + + <%= sale.grand_total %> + +
    +
    +
    +
    +
    +
    \ No newline at end of file diff --git a/app/views/reports/waste_and_spoilage/index.xls.erb b/app/views/reports/waste_and_spoilage/index.xls.erb new file mode 100755 index 00000000..4b4fa0a3 --- /dev/null +++ b/app/views/reports/waste_and_spoilage/index.xls.erb @@ -0,0 +1,58 @@ +
    +
    +
    +
    + + +
    Report For <%= @sale_type? @sale_type : 'Waste' %>
    + <% @sale_data.each do |sale| %> + <% waste_and_spoil_item_count = 0%> + + + + + + + + + + + + + + + + + <% sale.sale_items.each do |item| %> + <% if !item.item_instance_code.nil?%> + <% waste_and_spoil_item_count += item.qty.to_i%> + + + + + + + + <% end %> + <% end %> + + + + + + + + <% end %> +
    + Receipt No :<%= sale.receipt_no %> + Date : <%= sale.created_at.utc.getlocal.strftime("%e,%b %Y %I:%M %p") %>
    Item NameItem CodeQtyPriceTotal Price
    <%= item.product_name %><%= item.product_code %><%= item.qty %><%= item.price %><%= item.price %>
    Total Qty: + <%= waste_and_spoil_item_count %> + Grand Total: + + <%= sale.grand_total %> + +
    +
    +
    +
    +
    \ No newline at end of file diff --git a/config/locales/en.yml b/config/locales/en.yml index 84a7b03a..dba88aee 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -122,6 +122,8 @@ en: mpu: "MPU" jcb: "JCB" visa: "VISA" + master: "MASTER" + alipay: "Alipay" credit: "CREDIT" other_payment: "Other Payment" percentage: "PERCENTAGE" @@ -412,6 +414,7 @@ en: redeem_sales: "Redeem Sales" cash_sales: "Cash Sales" credit_sales: "Credit Sales" + alipay_sales: "Alipay Sales" foc_sales: "FOC Sales" foc_item: "Item FOC" net_amount: "Net Amount" diff --git a/config/locales/mm.yml b/config/locales/mm.yml index f18136c4..e06733e9 100644 --- a/config/locales/mm.yml +++ b/config/locales/mm.yml @@ -117,6 +117,8 @@ mm: mpu: "MPU" jcb: "JCB" visa: "VISA" + master: "MASTER" + alipay: "Alipay" credit: "အကြွေး" other_payment: "အခြားငွေပေးဆောင်မှုများ" percentage: "ရာခိုင်နှုန်း" @@ -404,6 +406,7 @@ mm: master_sales: "Master ရောင်းရငွေ" visa_sales: "Visa ရောင်းရငွေ" jcb_sales: "JCB ရောင်းရငွေ" + alipay_sales: "Alipay ရောင်းရငွေ" redeem_sales: "ဆုကြေးပြန်သုံးငွေနှင့် ရောင်းရငွေ" cash_sales: "ငွေသား ရောင်းရငွေ" credit_sales: "အကြွေး ရောင်းရငွေ" diff --git a/config/routes.rb b/config/routes.rb index 4293a341..43c3d885 100755 --- a/config/routes.rb +++ b/config/routes.rb @@ -84,7 +84,8 @@ scope "(:locale)", locale: /en|mm/ do end #--------- Cashier ------------# - namespace :origami do + namespace :origami do + get "dashboard" => "dashboard#index" get "quick_service" => "quick_service#index" @@ -178,6 +179,8 @@ scope "(:locale)", locale: /en|mm/ do post 'payment/paypar' => 'paypar_payments#create' post 'payment/credit' => 'credit_payments#create' post 'payment/voucher' => 'voucher_payments#create' + post 'payment/alipay' => 'alipay#create' + post 'payment/junctionpay' => 'junctionpay#create' get 'sale/:sale_id/:type/payment/credit_payment' => "credit_payments#index" get 'sale/:sale_id/:type/payment/others_payment' => "others_payments#index" @@ -188,10 +191,14 @@ scope "(:locale)", locale: /en|mm/ do get 'sale/:sale_id/:type/payment/others_payment/UNIONPAY' => "unionpay#index" get 'sale/:sale_id/:type/payment/others_payment/Redeem' => "redeem_payments#index" get 'sale/:sale_id/:type/payment/others_payment/Voucher' => "voucher#index" + get 'sale/:sale_id/:type/payment/others_payment/JunctionPay' => "junction_pay#index" + get 'sale/:sale_id/:type/payment/others_payment/Alipay' => "alipay#index" #---------Void --------------# post 'sale/:sale_id/:type/void' => 'void#overall_void' + post 'sale/:sale_id/:type/waste_and_spoilage' => "waste_spoile#waste_and_spoilage" + #---------Multiple Invoices --------------# get 'table/:table_id/table_invoices' => "table_invoices#index", :as => "table_invoice_index" get 'table/:table_id/table_invoice/:invoice_id' => "table_invoices#show", :as => "table_invoice_show" @@ -245,6 +252,7 @@ scope "(:locale)", locale: /en|mm/ do resources :second_display #second display routes post '/customer_view' => "second_display#customer_view",:as => "customer_view", :defaults => { :format => 'json' } + end #--------- Waiter/Ordering Station ------------# @@ -398,6 +406,7 @@ scope "(:locale)", locale: /en|mm/ do resources :shiftsale, :only => [:index, :show] resources :credit_payment, :only => [:index, :show] resources :void_sale, :only => [:index, :show] + resources :waste_and_spoilage, :only => [:index, :show] resources :commission, :only => [:index, :show] resources :stock_check, :only => [:index, :show] resources :payment_method diff --git a/db/migrate/20170403183755_create_tax_profiles.rb b/db/migrate/20170403183755_create_tax_profiles.rb index f5210bbb..2c96fd0d 100755 --- a/db/migrate/20170403183755_create_tax_profiles.rb +++ b/db/migrate/20170403183755_create_tax_profiles.rb @@ -2,7 +2,7 @@ class CreateTaxProfiles < ActiveRecord::Migration[5.1] def change create_table :tax_profiles do |t| t.string :name, :null => false - t.string :group_type, :null => false + t.string :group_type t.decimal :rate, :precision => 10, :scale => 2, :null => false, :default => 0.00 t.boolean :inclusive, :null => false, :default => false t.integer :order_by, :null => false, :default => 1 diff --git a/spec/controllers/origami/alipay_controller_spec.rb b/spec/controllers/origami/alipay_controller_spec.rb new file mode 100644 index 00000000..5994c9fa --- /dev/null +++ b/spec/controllers/origami/alipay_controller_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Origami::AlipayController, type: :controller do + +end