diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 958de2f8..4cdbe61f 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,14 +2,28 @@ - - - - + + + + - - + + + + + + + + + + + + + + + + @@ -25,21 +39,21 @@ - + - - + + - + - + @@ -49,11 +63,21 @@ + + + + + + + + + + - + @@ -63,8 +87,34 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -625,12 +675,12 @@ 1498458293643 - + - @@ -640,7 +690,7 @@ - + @@ -947,14 +997,6 @@ - - - - - - - - @@ -997,16 +1039,34 @@ - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1021,7 +1081,7 @@ - + @@ -1029,7 +1089,7 @@ - + @@ -1038,5 +1098,21 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/controllers/origami/voucher_controller.rb b/app/controllers/origami/voucher_controller.rb index a9bdcc2b..7eda6084 100644 --- a/app/controllers/origami/voucher_controller.rb +++ b/app/controllers/origami/voucher_controller.rb @@ -22,10 +22,50 @@ class Origami::VoucherController < BaseOrigamiController def create cash = params[:amount] sale_id = params[:sale_id] + sale_id = params[:refnumber] if(Sale.exists?(sale_id)) - saleObj = Sale.find(sale_id) - sale_payment = SalePayment.new - @status, @sale = sale_payment.process_payment(saleObj, @user, cash, "voucher") + customer_data= Customer.find_by_customer_id(sale_data.customer_id) + if customer_data + membership_id = customer_data.membership_id + membership_setting = MembershipSetting.find_by_membership_type("paypar_url") + if membership_setting.gateway_url + member_actions =MembershipAction.find_by_membership_type("get_account_balance") #need to modify here + if member_actions.gateway_url + campaign_type_id = member_actions.additional_parameter["campaign_type_id"] + url = membership_setting.gateway_url.to_s + member_actions.gateway_url.to_s + merchant_uid= member_actions.merchant_account_id + auth_token = member_actions.auth_token.to_s + # membership_data = SalePayment.get_paypar_account(url,membership_setting.auth_token,@membership_id,@campaign_type_id,merchant_uid,auth_token) + # if membership_data["status"]==true + begin + response = HTTParty.get(url, + :body => { app_token: token,membership_id:membership_id, + campaign_type_id:campaign_type_id,merchant_uid:merchant_uid, + auth_token:auth_token + }.to_json, + :headers => { + 'Content-Type' => 'application/json', + 'Accept' => 'application/json' + }, :timeout => 10 + ) + rescue Net::OpenTimeout + response = { status: false } + + rescue OpenURI::HTTPError + response = { status: false} + + rescue SocketError + response = { status: false} + end + # end + end + end + end + if( response["status"]==true ) + saleObj = Sale.find(sale_id) + sale_payment = SalePayment.new + @status, @sale = sale_payment.process_payment(saleObj, @user, cash, "voucher") + end end end diff --git a/app/controllers/print_settings_controller.rb b/app/controllers/print_settings_controller.rb index 8efb9dd5..5bf654ef 100644 --- a/app/controllers/print_settings_controller.rb +++ b/app/controllers/print_settings_controller.rb @@ -70,6 +70,6 @@ class PrintSettingsController < ApplicationController # Never trust parameters from the scary internet, only allow the white list through. def print_setting_params - params.require(:print_setting).permit(:name, :unique_code, :template, :db_name, :db_type, :db_username, :db_password, :printer_name, :api_settings, :page_width, :page_height, :print_copies,:precision,:delimiter,:heading_space) + params.require(:print_setting).permit(:name, :unique_code, :template, :printer_name, :api_settings, :page_width, :page_height, :print_copies,:precision,:delimiter,:heading_space) end end diff --git a/app/controllers/settings/dining_charges_controller.rb b/app/controllers/settings/dining_charges_controller.rb index 6de504bf..2c8e3b7e 100644 --- a/app/controllers/settings/dining_charges_controller.rb +++ b/app/controllers/settings/dining_charges_controller.rb @@ -29,7 +29,11 @@ class Settings::DiningChargesController < ApplicationController @dining_charge.dining_facility_id = @settings_dining_facility.id respond_to do |format| if @dining_charge.save - format.html { redirect_to edit_settings_zone_table_path(@zone,@settings_dining_facility), notice: 'Dining charge was successfully created.' } + if @table + format.html { redirect_to edit_settings_zone_table_path(@zone,@settings_dining_facility), notice: 'Dining charge was successfully created.' } + else + format.html { redirect_to edit_settings_zone_room_path(@zone,@settings_dining_facility), notice: 'Dining charge was successfully created.' } + end format.json { render :show, status: :created, location: @dining_charge } else format.html { render :new } @@ -44,7 +48,11 @@ class Settings::DiningChargesController < ApplicationController respond_to do |format| @dining_charge.dining_facility_id = @settings_dining_facility.id if @dining_charge.update(dining_charge_params) - format.html { redirect_to edit_settings_zone_table_path(@zone,@settings_dining_facility), notice: 'Dining charge was successfully updated.' } + if @table + format.html { redirect_to edit_settings_zone_table_path(@zone,@settings_dining_facility), notice: 'Dining charge was successfully updated.' } + else + format.html { redirect_to edit_settings_zone_room_path(@zone,@settings_dining_facility), notice: 'Dining charge was successfully updated.' } + end format.json { render :show, status: :ok, location: @dining_charge } else format.html { render :edit } diff --git a/app/models/dining_charge.rb b/app/models/dining_charge.rb index 0c52811f..e1d70278 100644 --- a/app/models/dining_charge.rb +++ b/app/models/dining_charge.rb @@ -1,4 +1,41 @@ class DiningCharge < ApplicationRecord belongs_to :table belongs_to :room + + def amount_calculate(dining_charges_obj, checkin , checkout) + + if !checkin.nil? && !checkout.nil? && !dining_charges_obj.nil? + + minutes = ((checkin - checkout) * 24 * 60).to_i # stay minutes + dining_minutes = minutes - dining_charges_obj.minimum_free_time # stayminutes - free minutes + charge_type = dining_charges_obj.charge_type + if charge_type == 'hr' + + elsif charge_type == 'day' + price = charge_by_day + end + end + + end + + def charge_by_hour + + end + + def charge_by_day(chargesObj, dining_minutes) + minues_per_day = 12 * 60 + result = dining_minutes / minues_per_day + if result < 1 + return chargesObj.unit_price + elsif result > 1 + solid_price = result * chargesObj.unit_price + + remain_value = dining_minutes % minues_per_day + roundingblock = remain_value / chargesObj.time_rounding_block + if roundingblock > 1 + + end + end + end + end diff --git a/app/pdf/close_cashier_pdf.rb b/app/pdf/close_cashier_pdf.rb index 4eadf007..133d9c48 100644 --- a/app/pdf/close_cashier_pdf.rb +++ b/app/pdf/close_cashier_pdf.rb @@ -1,8 +1,8 @@ class CloseCashierPdf < Prawn::Document attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width,:text_width def initialize(printer_settings, shift_sale,shop_details,sale_taxes) - self.page_width = 210 - self.page_height = 7000 + self.page_width = PrintSetting.where("name = ?","Close Cashier").first.page_width + self.page_height = PrintSetting.where("name = ?","Close Cashier").first.page_height self.margin = 5 self.price_width = 40 self.qty_width = 20 diff --git a/app/pdf/crm_order_pdf.rb b/app/pdf/crm_order_pdf.rb index 55d08ecc..a7f85098 100644 --- a/app/pdf/crm_order_pdf.rb +++ b/app/pdf/crm_order_pdf.rb @@ -1,8 +1,8 @@ class CrmOrderPdf < Prawn::Document attr_accessor :receipt_width,:price_column_width,:p_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_column_width,:item_description_width def initialize(booking,order_items,printer_settings) - self.p_width = 200 - self.page_height = 1450 + self.page_width = PrintSetting.where("name = ?","CRM Order").first.page_width + self.page_height = PrintSetting.where("name = ?","CRM Order").first.page_height self.margin = 10 # self.price_width = self.p_width / 2 self.price_width=80 diff --git a/app/pdf/order_item_pdf.rb b/app/pdf/order_item_pdf.rb index 20a4537c..7b2e350b 100644 --- a/app/pdf/order_item_pdf.rb +++ b/app/pdf/order_item_pdf.rb @@ -2,8 +2,8 @@ class OrderItemPdf < Prawn::Document include ActionView::Helpers::NumberHelper attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width def initialize(print_settings,order_item, print_status, options, alt_name) - self.page_width = 185 - self.page_height = 1450 + self.page_width = PrintSetting.where("name = ?","OrderItemPdf").first.page_width + self.page_height = PrintSetting.where("name = ?","OrderItemPdf").first.page_height self.margin = 0 self.price_width = 40 # No Need for item self.qty_width = 40 diff --git a/app/pdf/order_summary_pdf.rb b/app/pdf/order_summary_pdf.rb index 244fbdfa..902c68ad 100644 --- a/app/pdf/order_summary_pdf.rb +++ b/app/pdf/order_summary_pdf.rb @@ -2,8 +2,8 @@ class OrderSummaryPdf < Prawn::Document include ActionView::Helpers::NumberHelper attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width def initialize(print_settings,order, print_status, order_items = nil,alt_name) - self.page_width = 190 - self.page_height = 1450 + self.page_width = PrintSetting.where("name = ?","Order Summary").first.page_width + self.page_height = PrintSetting.where("name = ?","Order Summary").first.page_height self.margin = 0 self.price_width = 40 # No Need for item self.qty_width = 40 diff --git a/app/pdf/queue_no_pdf.rb b/app/pdf/queue_no_pdf.rb index 0963f55e..cda410ca 100644 --- a/app/pdf/queue_no_pdf.rb +++ b/app/pdf/queue_no_pdf.rb @@ -1,8 +1,8 @@ class QueueNoPdf < Prawn::Document attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width def initialize(printer_settings, queue) - self.page_width = 210 - self.page_height = 1450 + self.page_width = PrintSetting.where("name = ?","Queue No").first.page_width + self.page_height = PrintSetting.where("name = ?","Queue No").first.page_height self.margin = 5 self.price_width = 35 self.qty_width = 20 diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index 2dca6d16..3027fb60 100644 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -2,8 +2,8 @@ class ReceiptBillPdf < Prawn::Document include ActionView::Helpers::NumberHelper attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width, :description_width, :price_num_width def initialize(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details, printed_status) - self.page_width = 210 - self.page_height = 1450 + self.page_width = PrintSetting.where("name = ?","Receipt Bill").first.page_width + self.page_height = PrintSetting.where("name = ?","Receipt Bill").first.page_height self.margin = 5 self.price_width = 40 self.qty_width = 20 diff --git a/app/views/origami/voucher/index.html.erb b/app/views/origami/voucher/index.html.erb index 809793ce..db4de245 100644 --- a/app/views/origami/voucher/index.html.erb +++ b/app/views/origami/voucher/index.html.erb @@ -28,14 +28,15 @@
- +

-
0.0
+ +

@@ -103,12 +104,17 @@ $(document).ready(function() { } }); // number key pad +var float_value = "" +var total = 0 + +$(document).on('focusout', '.float-value', function(event){ + float_value = $(this).attr("data-value"); $(document).on('click', '.cashier_number', function(event){ event.stopPropagation(); event.preventDefault(); if(event.handled !== true) { var original_value; - original_value = $('#amount').text(); + original_value = $('#'+float_value).val(); var input_value = $(this).attr("data-value"); @@ -116,28 +122,28 @@ $(document).on('click', '.cashier_number', function(event){ switch (input_type) { case 'num': if (original_value == "0.0"){ - $('#amount').text(input_value); + $('#'+float_value).val(input_value); }else{ - $('#amount').append(input_value); + $('#'+float_value).val(original_value+input_value); } break; case 'add': var input_value = $(this).attr("data-value"); amount = parseInt(input_value) + parseInt(original_value); - $('#amount').html(amount); + $('#'+float_value).val(amount); break; case 'clr': - $('#amount').html("0.0"); + $('#'+float_value).val("0.0"); break; case 'del' : - var cash=$('#amount').text(); - $('#amount').text(cash.substr(0,cash.length-1)); + var cash=$('#'+float_value).val(); + $('#'+float_value).val(cash.substr(0,cash.length-1)); break; case 'nett': var remain_amount = $('#validamount').val(); - $('#amount').text(remain_amount); + $('#'+float_value).val(remain_amount); break; } @@ -146,15 +152,19 @@ $(document).on('click', '.cashier_number', function(event){ return false; } }); +}) $('#voucher_pay').on('click',function(){ - var amount = $('#amount').text(); + var amount = $('#amount').val(); + var refnumber = $("#<%=@sale_id %>").val(); var sale_id = "<%= @sale_id %>"; if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) ){ + // alert(amount); + // alert(refnumber); $.ajax({type: "POST", - url: "<%= origami_payment_jcb_path %>", - data: "amount="+ amount + "&sale_id="+ sale_id, + url: "<%= origami_payment_voucher_path %>", + data: "amount="+ amount + "&sale_id="+ sale_id+ "&refnumber="+ refnumber, success:function(result){ if(result){ alert("Payment success") diff --git a/app/views/print_settings/_form.html.erb b/app/views/print_settings/_form.html.erb index ba703aae..f9079f99 100644 --- a/app/views/print_settings/_form.html.erb +++ b/app/views/print_settings/_form.html.erb @@ -5,10 +5,6 @@ <%= f.input :name %> <%= f.input :unique_code %> <%= f.input :template %> - <%= f.input :db_name %> - <%= f.input :db_type %> - <%= f.input :db_username %> - <%= f.input :db_password %> <%= f.input :printer_name %> <%= f.input :api_settings %> <%= f.input :page_width %> diff --git a/app/views/print_settings/index.html.erb b/app/views/print_settings/index.html.erb index 9c8ce0b0..c16a28c2 100644 --- a/app/views/print_settings/index.html.erb +++ b/app/views/print_settings/index.html.erb @@ -16,11 +16,7 @@ Name Unique code - + Template Printer name Api settings Page width @@ -38,11 +34,7 @@ <%= print_setting.name %> <%= print_setting.unique_code %> - + <%= print_setting.template %> <%= print_setting.printer_name %> <%= print_setting.api_settings %> <%= print_setting.page_width %> diff --git a/app/views/print_settings/show.html.erb b/app/views/print_settings/show.html.erb index 71d74950..46126c4b 100644 --- a/app/views/print_settings/show.html.erb +++ b/app/views/print_settings/show.html.erb @@ -29,22 +29,6 @@ Template <%= @print_setting.template %> - - Db name - <%= @print_setting.db_name %> - - - Db type - <%= @print_setting.db_type %> - - - Db username - <%= @print_setting.db_username %> - - - Db password - <%= @print_setting.db_password %> - Printer name <%= @print_setting.printer_name %> diff --git a/app/views/settings/employees/index.html.erb b/app/views/settings/employees/index.html.erb index b44a2dcd..7c1f2eb7 100644 --- a/app/views/settings/employees/index.html.erb +++ b/app/views/settings/employees/index.html.erb @@ -16,6 +16,7 @@ Name Role Created At + Updated At Action @@ -26,6 +27,7 @@ <%= link_to employee.name,settings_employee_path(employee) %> <%= employee.role %> <%= employee.created_at.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") %> + <%= employee.updated_at.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") %> <%= link_to 'Edit', edit_settings_employee_path(employee) %> <%if employee.role != "administrator"%> diff --git a/app/views/settings/employees/show.html.erb b/app/views/settings/employees/show.html.erb index cad7a6ad..1869fcde 100644 --- a/app/views/settings/employees/show.html.erb +++ b/app/views/settings/employees/show.html.erb @@ -2,7 +2,7 @@ @@ -15,7 +15,8 @@ Name Role - + Created At + Updated At Action @@ -24,6 +25,8 @@ <%= @employee.name %> <%= @employee.role %> + <%= @employee.created_at.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") %> + <%= @employee.updated_at.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") %> <%= link_to 'Edit', edit_settings_employee_path(@employee) %> @@ -34,4 +37,3 @@ - diff --git a/app/views/settings/rooms/_form.html.erb b/app/views/settings/rooms/_form.html.erb index 25af618c..a0118e61 100644 --- a/app/views/settings/rooms/_form.html.erb +++ b/app/views/settings/rooms/_form.html.erb @@ -7,6 +7,28 @@ <%= f.input :seater %> <%= f.input :order_by %> <%= f.input :is_active %> + <% if @settings_room.dining_charges.length == 0 %> + <% if @settings_room.id != nil %> +
+
+ <%= link_to 'Add For Extra Charges', new_settings_zone_room_dining_charge_path(@zone,@settings_room),:class => 'btn btn-primary' %> +
+
+ <% end %> + <% else %> + <% @settings_room.dining_charges.each do |dc| %> +
+
Dining Charge
+
item code : <%= dc.item_code %>
+
Unit price : <%= dc.unit_price %>
+
Charge type : <%= dc.charge_type %>
+
+ <%= link_to 'Edit Charges', edit_settings_zone_room_dining_charge_path(@zone,@settings_room,dc),:class => 'btn btn-primary' %> + +
+
+ <% end %> + <% end %>
diff --git a/app/views/settings/tables/_form.html.erb b/app/views/settings/tables/_form.html.erb index 3d641592..9736f523 100644 --- a/app/views/settings/tables/_form.html.erb +++ b/app/views/settings/tables/_form.html.erb @@ -8,11 +8,13 @@ <%= f.input :order_by %> <%= f.input :is_active %> <% if @settings_table.dining_charges.length == 0 %> -
-
- <%= link_to 'Add For Extra Charges', new_settings_zone_table_dining_charge_path(@zone,@settings_table),:class => 'btn btn-primary' %> -
-
+ <% if @settings_table.id != nil %> +
+
+ <%= link_to 'Add For Extra Charges', new_settings_zone_table_dining_charge_path(@zone,@settings_table),:class => 'btn btn-primary' %> +
+
+ <% end %> <% else %> <% @settings_table.dining_charges.each do |dc| %>
diff --git a/config/routes.rb b/config/routes.rb index b6af8698..9e62023c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -137,6 +137,7 @@ Rails.application.routes.draw do post 'payment/visa' => "visa#create" post 'payment/paypar' => 'paypar_payments#create' post 'payment/credit' => 'credit_payments#create' + post 'payment/voucher' => 'voucher_payments#create' get 'sale/:sale_id/payment/credit_payment' => "credit_payments#index" get 'sale/:sale_id/payment/others_payment' => "others_payments#index" diff --git a/db/migrate/20170814041543_remove_d_bcols_from_print_settings.rb b/db/migrate/20170814041543_remove_d_bcols_from_print_settings.rb new file mode 100644 index 00000000..48a7de5d --- /dev/null +++ b/db/migrate/20170814041543_remove_d_bcols_from_print_settings.rb @@ -0,0 +1,8 @@ +class RemoveDBcolsFromPrintSettings < ActiveRecord::Migration[5.1] + def change + remove_column :print_settings, :db_name, :string + remove_column :print_settings, :db_type, :string + remove_column :print_settings, :db_username, :string + remove_column :print_settings, :db_password, :string + end +end