This commit is contained in:
Moe Su
2017-06-11 13:58:34 +06:30
29 changed files with 232 additions and 334 deletions

View File

@@ -91,4 +91,4 @@ gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'httparty', '~> 0.15.5' gem 'httparty', '~> 0.15.5'
gem 'bootstrap-datepicker-rails' gem 'bootstrap-datepicker-rails'

View File

@@ -143,7 +143,7 @@ $(document).ready(function(){
}); });
// Payment for Bill // Payment for Bill
$('#pay').click(function() { $('#pay-bill').click(function() {
var sale_id=$(".selected-item").find(".orders-id").text(); var sale_id=$(".selected-item").find(".orders-id").text();
if(sale_id!=""){ if(sale_id!=""){
window.location.href = '/origami/sale/'+ sale_id + "/payment" window.location.href = '/origami/sale/'+ sale_id + "/payment"
@@ -160,52 +160,53 @@ $(document).ready(function(){
window.location.href = '/crm/customers/'+ sale_id + "/assign_sale_id" window.location.href = '/crm/customers/'+ sale_id + "/assign_sale_id"
return false; return false;
}); });
});
/* For Receipt - Calculate discount or tax */ /* For Receipt - Calculate discount or tax */
$(document).on('click', '.cashier_number', function(event){ $('.cashier_number').on('click', function(event){
if(event.handled !== true) { if(event.handled !== true) {
var original_value=0; var original_value=0;
original_value = $('#discount-amount').val(); original_value = $('#discount-amount').val();
var input_type = $(this).attr("data-type"); var input_type = $(this).attr("data-type");
switch (input_type) { switch (input_type) {
case 'num': case 'num':
var input_value = $(this).attr("data-value"); var input_value = $(this).attr("data-value");
if (original_value == "0.0"){ if (original_value == "0.0"){
$('#discount-amount').val(input_value); $('#discount-amount').val(input_value);
update_balance();
}
else{
$('#discount-amount').val(original_value + '' + input_value);
update_balance();
}
break;
case 'add':
var input_value = $(this).attr("data-value");
amount = parseInt(input_value) + parseInt(original_value);
$('#discount-amount').val(amount);
update_balance(); update_balance();
} break;
else{
$('#discount-amount').val(original_value + '' + input_value); case 'del' :
var discount_text=$('#discount-amount').val();
$('#discount-amount').val(discount_text.substr(0,discount_text.length-1));
update_balance(); update_balance();
} break;
break;
case 'add': case 'clr':
var input_value = $(this).attr("data-value"); $('#discount-amount').val("0.0");
amount = parseInt(input_value) + parseInt(original_value); update_balance();
$('#discount-amount').val(amount); break;
update_balance(); }
break;
case 'del' : event.handled = true;
var discount_text=$('#discount-amount').val(); } else {
$('#discount-amount').val(discount_text.substr(0,discount_text.length-1)); return false;
update_balance(); }
break; });
case 'clr':
$('#discount-amount').val("0.0");
update_balance();
break;
}
event.handled = true;
} else {
return false;
}
}); });
/* Button Control by Status */ /* Button Control by Status */

View File

@@ -1,113 +0,0 @@
// $(document).on('touchstart click', '.keypad', function(event){
// event.stopPropagation();
// event.preventDefault();
// if(event.handled !== true) {
//
// // Do your magic here.
// var input_value = $(this).attr("data-value");
// switch (input_value) {
//
// case 'delete':
// process_delete_payment();
// break;
//
// case 'foc':
// remove_input_action();
// $(".foc").attr("data-action","true");
// if(customerName.toString() != " "){ //if already chosen customer
// if($("#foc_reason_lists").attr("foc_reason") == ' '){
// alert("Please! Choose or Add FOC reason");
// foc_additional_form();
// }
// else{
// process_foc_payment();
// }
// }
// else{
// alert("Please! Choose or Save Customer");
// foc_additional_form();
// }
// break;
//
// case 'nett':
// remove_input_action();
// $(".nett").attr("data-action","true");
// if($(".credit_note_payment").hasClass("payment_selected")){
// if(customerName == " "){
// alert("Please! Choose or Save Customer");
// showCustomer();
// }
// else{
// $("#accept_payment_btn").attr("data-payment","credit");
// process_nett_payment();
// }
// }
// else{
// process_nett_payment();
// }
// break;
//
// case 'edit':
// process_edit_invoice();
// break;
//
// case 'cancel':
// remove_input_action();
// var status = $("#label_amountdue").attr("data-status");
// if (status != 'completed' && status != 'void'){
// $(".cancel").attr("data-action","true");
// var message = confirm("Are you sure to void? Please, add reason!");
// if (message == true) {
// $(".additional_form").hide();
// $("#void_sale_additional_form").show();
// process_cancel_payment();
// }
// }
// else{
// $(".cancel").addClass("dim");
// }
// break;
//
// case 'ent':
// amount_due = parseFloat($("#label_amountdue").attr("data-original"));
// other_amt = parseFloat($("#label_cash_amount").attr("data-value"));
// credit_amount = parseFloat($("#label_credit_note").text());
// if ($(".credit_note_payment").hasClass("payment_selected") && credit_amount > 0){
// if(customerName.toString() != " "){
// if(credit_amount > (amount_due - other_amt)){
// alert("You shouldn't exceed the amount due.");
// }
// else{
// $("#accept_payment_btn").attr("data-payment","credit");
// update_balance_due();
// }
// }
// else{
// alert("Please! Choose or Save Customer");
// }
// }
// else{
// update_balance_due();
// }
//
// break;
// case 'clear':
// process_clear_payment();
// break;
//
// default:
//
// var existing_value = $(".payment_selected span").text();
//
// if (existing_value == "0" || existing_value == "0.00") { existing_value = ""; }
// existing_value = existing_value + input_value;
// $(".payment_selected span").text(existing_value);
//
// }
//
//
// event.handled = true;
// } else {
// return false;
// }
// });

View File

@@ -1,3 +0,0 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/

View File

@@ -1,3 +0,0 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/

View File

@@ -1,3 +0,0 @@
// Place all the styles related to the origami/paypar controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View File

@@ -1,3 +0,0 @@
// Place all the styles related to the origami/RequestBills controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View File

@@ -9,11 +9,11 @@ class Api::BillController < Api::ApiController
#create Bill by Booking ID #create Bill by Booking ID
if (params[:booking_id]) if (params[:booking_id])
@sale = Sale.new @sale = Sale.new
@status = @sale.generate_invoice_from_booking(params[:booking_id], current_login_employee.name) @status, @sale_id = @sale.generate_invoice_from_booking(params[:booking_id], current_login_employee.name)
elsif (params[:order_id]) elsif (params[:order_id])
@sale = Sale.new @sale = Sale.new
@status = @sale.generate_invoice_from_order(params[:order_id], current_login_employee.name) @status, @sale_id = @sale.generate_invoice_from_order(params[:order_id], current_login_employee.name)
end end
end end

View File

@@ -38,10 +38,10 @@ class Crm::CustomersController < ApplicationController
def create def create
@crm_customers = Customer.new(customer_params) @crm_customers = Customer.new(customer_params)
respond_to do |format| respond_to do |format|
if @crm_customers.save if @crm_customers.save
name = customer_params[:name] name = customer_params[:name]
phone = customer_params[:contact_no] phone = customer_params[:contact_no]
@@ -63,12 +63,10 @@ class Crm::CustomersController < ApplicationController
) )
if response["status"] == true if response["status"] == true
puts "hhhhhhhhhhhhhhhhhh"
puts params[:sale_id]
customer = Customer.find(@crm_customers.customer_id) customer = Customer.find(@crm_customers.customer_id)
status = customer.update_attributes(membership_id: response["customer_datas"]["id"]) status = customer.update_attributes(membership_id: response["customer_datas"]["id"])
if params[:sale_id] != 0 if params[:sale_id] != 0
format.html { redirect_to crm_customers_path, notice: 'Customer was successfully created.' } format.html { redirect_to crm_customers_path, notice: 'Customer was successfully created.' }
else else
format.html { redirect_to '/crm/customers/'+params[:sale_id]+'/assign_sale_id', notice: 'Customer was successfully created.' } format.html { redirect_to '/crm/customers/'+params[:sale_id]+'/assign_sale_id', notice: 'Customer was successfully created.' }
end end
@@ -77,27 +75,27 @@ class Crm::CustomersController < ApplicationController
@crm_customers.destroy @crm_customers.destroy
if params[:sale_id] != 0 if params[:sale_id] != 0
format.html { redirect_to crm_customers_path, notice: response["message"] } format.html { redirect_to crm_customers_path, notice: response["message"] }
else else
format.html { redirect_to '/crm/customers/'+params[:sale_id]+'/assign_sale_id', notice: response["message"] } format.html { redirect_to '/crm/customers/'+params[:sale_id]+'/assign_sale_id', notice: response["message"] }
end end
end end
# format.json { render :index, status: :created, location: @crm_customers } # format.json { render :index, status: :created, location: @crm_customers }
else else
if params[:sale_id] != 0 if params[:sale_id] != 0
format.html { redirect_to crm_customers_path} format.html { redirect_to crm_customers_path}
format.json { render json: @crm_customers.errors, status: :unprocessable_entity } format.json { render json: @crm_customers.errors, status: :unprocessable_entity }
else else
format.html { redirect_to '/crm/customers/'+params[:sale_id]+'/assign_sale_id', notice: response["message"] } format.html { redirect_to '/crm/customers/'+params[:sale_id]+'/assign_sale_id', notice: response["message"] }
end end
end end
end end
end end
@@ -105,7 +103,7 @@ class Crm::CustomersController < ApplicationController
# PATCH/PUT /crm/customers/1 # PATCH/PUT /crm/customers/1
# PATCH/PUT /crm/customers/1.json # PATCH/PUT /crm/customers/1.json
def update def update
respond_to do |format| respond_to do |format|
if @crm_customer.update(customer_params) if @crm_customer.update(customer_params)
@@ -118,7 +116,7 @@ class Crm::CustomersController < ApplicationController
membership = MembershipSetting.find_by_membership_type("paypar_url") membership = MembershipSetting.find_by_membership_type("paypar_url")
app_token = membership.auth_token.to_s app_token = membership.auth_token.to_s
url = membership.gateway_url.to_s + "/api/update_membership_customer".to_s url = membership.gateway_url.to_s + "/api/update_membership_customer".to_s
response = HTTParty.post(url, :body => { name: name,phone: phone,email: email, response = HTTParty.post(url, :body => { name: name,phone: phone,email: email,
date_of_birth: date_of_birth, date_of_birth: date_of_birth,
id: id}.to_json, id: id}.to_json,
@@ -127,7 +125,7 @@ class Crm::CustomersController < ApplicationController
'Accept' => 'application/json' 'Accept' => 'application/json'
} }
) )
format.html { redirect_to crm_customers_path, notice: 'Customer was successfully updated.' } format.html { redirect_to crm_customers_path, notice: 'Customer was successfully updated.' }
format.json { render :show, status: :ok, location: @crm_customer } format.json { render :show, status: :ok, location: @crm_customer }
@@ -153,7 +151,7 @@ class Crm::CustomersController < ApplicationController
# DELETE /crm/customers/1 # DELETE /crm/customers/1
# DELETE /crm/customers/1.json # DELETE /crm/customers/1.json
def get_sale_id def get_sale_id
@sale_id = params[:sale_id] @sale_id = params[:sale_id]
@crm_customers = Customer.all @crm_customers = Customer.all
@crm_customer = Customer.new @crm_customer = Customer.new
@@ -179,5 +177,3 @@ class Crm::CustomersController < ApplicationController
params.require(:customer).permit(:name, :company, :contact_no, :email, :date_of_birth, :membership_type, :membership_authentication_code) params.require(:customer).permit(:name, :company, :contact_no, :email, :date_of_birth, :membership_type, :membership_authentication_code)
end end
end end

View File

@@ -10,7 +10,7 @@ class Origami::PaymentsController < BaseOrigamiController
if(Sale.exists?(sale_id)) if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id) saleObj = Sale.find(sale_id)
sale_payment = SalePayment.new sale_payment = SalePayment.new
sale_payment.process_payment(saleObj, @user, cash) sale_payment.process_payment(saleObj, @user, cash, "cash")
end end
end end
@@ -18,6 +18,11 @@ class Origami::PaymentsController < BaseOrigamiController
sale_id = params[:sale_id] sale_id = params[:sale_id]
if Sale.exists?(sale_id) if Sale.exists?(sale_id)
@sale_data = Sale.find_by_sale_id(sale_id) @sale_data = Sale.find_by_sale_id(sale_id)
@sale_data.sale_payments.each do |spay|
if spay.payment_method == "cash"
@cash = spay.payment_amount
end
end
end end
end end

View File

@@ -18,4 +18,4 @@ class Origami::PayparPaymentsController < BaseOrigamiController
end end
end end
end end

View File

@@ -14,13 +14,15 @@ class Settings::MembershipActionsController < ApplicationController
if !membership_actions_data.nil? if !membership_actions_data.nil?
url = params[:gateway_url].to_s + membership_actions_data.gateway_url.to_s url = params[:gateway_url].to_s + membership_actions_data.gateway_url.to_s
puts url.to_json puts url.to_json
sale_data = Sale.find_by_sale_id(@sale_id) sale_data = Sale.find_by_sale_id(@sale_id)
if sale_data.customer_id if sale_data.customer_id
customer_data= Customer.find_by_customer_id(sale_data.customer_id) customer_data= Customer.find_by_customer_id(sale_data.customer_id)
puts customer_data.to_json
@membership_id = customer_data.membership_id @membership_id = customer_data.membership_id
@campaign_type_id =1 @campaign_type_id =1
if !@membership_id.nil? if !@membership_id.nil?
membership_setting = MembershipSetting.find_by_membership_type("paypar_url") membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
puts membership_setting
membership_data = SalePayment.get_paypar_account(url,membership_setting.auth_token,@membership_id,@campaign_type_id) membership_data = SalePayment.get_paypar_account(url,membership_setting.auth_token,@membership_id,@campaign_type_id)
if membership_data["status"]==true if membership_data["status"]==true
@membership_rebate_balance=membership_data["balance"] @membership_rebate_balance=membership_data["balance"]
@@ -41,7 +43,7 @@ class Settings::MembershipActionsController < ApplicationController
end end
render :json => @out.to_json render :json => @out.to_json
end end
end end
# GET /settings/membership_actions/1 # GET /settings/membership_actions/1

View File

@@ -3,7 +3,6 @@ class Sale < ApplicationRecord
#primary key - need to be unique generated for multiple shops #primary key - need to be unique generated for multiple shops
before_create :generate_custom_id before_create :generate_custom_id
#before_create :generate_receipt_no #before_create :generate_receipt_no
belongs_to :cashier, :optional => true belongs_to :cashier, :optional => true
belongs_to :customer, :optional => true belongs_to :customer, :optional => true
@@ -17,7 +16,6 @@ class Sale < ApplicationRecord
scope :open_invoices, -> { where("sale_status = 'new' and receipt_date BETWEEN '#{DateTime.now.utc.end_of_day}' AND '#{DateTime.now.utc.beginning_of_day}'") } scope :open_invoices, -> { where("sale_status = 'new' and receipt_date BETWEEN '#{DateTime.now.utc.end_of_day}' AND '#{DateTime.now.utc.beginning_of_day}'") }
def generate_invoice_from_booking(booking_id, requested_by) def generate_invoice_from_booking(booking_id, requested_by)
puts "get invoice from booking"
booking = Booking.find(booking_id) booking = Booking.find(booking_id)
status = false status = false
Rails.logger.debug "Booking -> " + booking.id.to_s Rails.logger.debug "Booking -> " + booking.id.to_s
@@ -33,7 +31,6 @@ class Sale < ApplicationRecord
booking.sale_id = sale_id booking.sale_id = sale_id
end end
order = booking.booking_orders.take.order order = booking.booking_orders.take.order
puts "add sale order"
link_order_sale(order.id) link_order_sale(order.id)
return status, sale_id return status, sale_id
end end
@@ -231,9 +228,10 @@ class Sale < ApplicationRecord
def link_order_sale(order_id) def link_order_sale(order_id)
#create if it doesn't exist #create if it doesn't exist
saleOrder = SaleOrder.where("sale_id=? and order_id=?", self.id, order_id).take saleOrder = SaleOrder.where("sale_id=? and order_id=?", self.id, order_id).take
if saleOrder.nil? if saleOrder.nil?
SaleOrder.create(:sale_id => self.id, :order_id => order_id) sale_order = SaleOrder.new
sale_order.create_sale_order(self.id, order_id)
end end
# if (SaleOrder.where("sale_id = #{self.id} and order_id=#{order_id}").nil?) # if (SaleOrder.where("sale_id = #{self.id} and order_id=#{order_id}").nil?)
# SaleOrder.create(:sale_id => self.id, :order_id => order_id) # SaleOrder.create(:sale_id => self.id, :order_id => order_id)
@@ -261,6 +259,7 @@ class Sale < ApplicationRecord
end end
private private
def generate_custom_id def generate_custom_id
self.sale_id = SeedGenerator.generate_id(self.class.name, "SAL") self.sale_id = SeedGenerator.generate_id(self.class.name, "SAL")
end end

View File

@@ -2,13 +2,22 @@ class SaleOrder < ApplicationRecord
self.primary_key = "sale_order_id" self.primary_key = "sale_order_id"
#primary key - need to be unique generated for multiple shops #primary key - need to be unique generated for multiple shops
before_create :generate_custom_id before_create :generate_sale_order_id
belongs_to :sale belongs_to :sale
belongs_to :order belongs_to :order
def create_sale_order(sale, order)
self.sale_id = sale
self.order_id = order
self.save
end
private private
def generate_custom_id def generate_sale_order_id
self.sale_order_id = SeedGenerator.generate_id(self.class.name, "SOI") self.class.name
saleOrderId = SeedGenerator.generate_id(self.class.name, "SOI")
self.sale_order_id = saleOrderId
end end
end end

View File

@@ -8,7 +8,7 @@ class SalePayment < ApplicationRecord
attr_accessor :received_amount, :card_payment_reference, :voucher_no, :giftcard_no, :customer_id, :external_payment_status attr_accessor :received_amount, :card_payment_reference, :voucher_no, :giftcard_no, :customer_id, :external_payment_status
def process_payment(invoice, action_by, cash_amount,payment_method) def process_payment(invoice, action_by, cash_amount, payment_method)
self.sale = invoice self.sale = invoice
self.received_amount = cash_amount self.received_amount = cash_amount
@@ -75,7 +75,7 @@ class SalePayment < ApplicationRecord
} }
) )
return response; return response;
end end
def self.redeem(paypar_url,token,membership_id,received_amount,sale_id,campaign_type_id) def self.redeem(paypar_url,token,membership_id,received_amount,sale_id,campaign_type_id)
@@ -93,9 +93,9 @@ class SalePayment < ApplicationRecord
else else
response =false; response =false;
end end
return response; return response;
end end
private private
@@ -103,7 +103,7 @@ class SalePayment < ApplicationRecord
payment_status = false payment_status = false
self.payment_method = "cash" self.payment_method = "cash"
self.payment_amount = self.received_amount self.payment_amount = self.received_amount
self.outstanding_amount = self.sale.grand_total - self.received_amount self.outstanding_amount = self.sale.grand_total.to_f - self.received_amount.to_f
self.payment_status = "paid" self.payment_status = "paid"
payment_method = self.save! payment_method = self.save!
@@ -195,21 +195,33 @@ class SalePayment < ApplicationRecord
if membership_data["status"]==true if membership_data["status"]==true
SalePayment.where(:sale_payment_id => self.sale_payment_id).update_all(:payment_status => 'paid') SalePayment.where(:sale_payment_id => self.sale_payment_id).update_all(:payment_status => 'paid')
sale_update_payment_status(self.received_amount.to_f) sale_update_payment_status(self.received_amount.to_f)
else else
sale_update_payment_status(0) sale_update_payment_status(0)
end end
return payment_status return payment_status
end end
def sale_update_payment_status(paid_amount) def sale_update_payment_status(paid_amount)
puts "sale update"
#update amount_outstanding #update amount_outstanding
self.sale.amount_received = self.sale.amount_received + paid_amount self.sale.amount_received = self.sale.amount_received.to_f + paid_amount.to_f
self.sale.amount_changed = paid_amount - self.sale.amount_received
if (self.sale.grand_total <= self.sale.amount_received && self.sale.amount_changed > 0) self.sale.amount_changed = paid_amount.to_f - self.sale.amount_received.to_f
all_received_amount = 0.0
sObj = self.sale
sObj.sale_payments.each do |spay|
puts spay
puts spay.payment_amount
all_received_amount += spay.payment_amount.to_f
end
puts all_received_amount
puts self.sale.grand_total
if (self.sale.grand_total <= all_received_amount)
puts " sale update ......"
self.sale.payment_status = "paid" self.sale.payment_status = "paid"
self.sale.sale_status = "completed" self.sale.sale_status = "completed"
self.sale.save! self.sale.save!

View File

@@ -1,7 +1,9 @@
class SeedGenerator < ApplicationRecord class SeedGenerator < ApplicationRecord
def self.generate_id(model, prefix) def self.generate_id(model, prefix)
seed = SeedGenerator.find_by_model(model) seed = SeedGenerator.find_by_model(model)
new_receipt_no = 0 new_receipt_no = 0
if (seed.nil?) if (seed.nil?)
seed = SeedGenerator.new() seed = SeedGenerator.new()
seed.model = model seed.model = model
@@ -16,8 +18,8 @@ class SeedGenerator < ApplicationRecord
end end
padding_len = 15 - prefix.length padding_len = 15 - prefix.length
saleOrderId = prefix +"-"+ seed.current.to_s.to_s.rjust((14-prefix.length)+1,'0')
return prefix +"-"+ seed.current.to_s.to_s.rjust((14-prefix.length)+1,'0') return saleOrderId
end end

View File

@@ -20,6 +20,7 @@
<li><%= link_to "Membership Setting",settings_membership_settings_path, :tabindex =>"-1" %></li> <li><%= link_to "Membership Setting",settings_membership_settings_path, :tabindex =>"-1" %></li>
<li><%= link_to "Payment Method", settings_payment_method_settings_path, :tabindex =>"-1" %></li> <li><%= link_to "Payment Method", settings_payment_method_settings_path, :tabindex =>"-1" %></li>
<li><%= link_to "Tax Profile", settings_tax_profiles_path, :tabindex =>"-1" %></li> <li><%= link_to "Tax Profile", settings_tax_profiles_path, :tabindex =>"-1" %></li>
<li><%= link_to "Print Setting", print_settings_path, :tabindex =>"-1" %></li>
</ul> </ul>
</li> </li>
@@ -30,9 +31,14 @@
<li><%= link_to "Sales ", crm_root_path, :tabindex =>"-1" %></li> <li><%= link_to "Sales ", crm_root_path, :tabindex =>"-1" %></li>
</ul> </ul>
</li> </li>
<!-- <li class="navbar-nav mr-auto"> <li class="navbar-nav mr-auto dropdown">
Reports <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">&nbsp;&nbsp;&nbsp;Reports</a>
</li> --> <ul class="dropdown-menu">
<li><%= link_to "Daily Sale Report", origami_root_path, :tabindex =>"-1" %></li>
<li><%= link_to "Sales Item Report", origami_root_path, :tabindex =>"-1" %></li>
<li><%= link_to "Receipt Report", origami_root_path, :tabindex =>"-1" %></li>
</ul>
</li>
</ul> </ul>
</div> </div>

View File

@@ -9,8 +9,8 @@
<title>SmartSales : Restaurant</title> <title>SmartSales : Restaurant</title>
<%= csrf_meta_tags %> <%= csrf_meta_tags %>
<%= stylesheet_link_tag 'orgiami', media: 'all', 'data-turbolinks-track': 'reload' %> <%= stylesheet_link_tag 'origami', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'orgiami', 'data-turbolinks-track': 'reload' %> <%= javascript_include_tag 'origami', 'data-turbolinks-track': 'reload' %>
</head> </head>
<body> <body>

View File

@@ -21,23 +21,23 @@
<!--- Panel 0 - Table Orders --> <!--- Panel 0 - Table Orders -->
<div class="tab-pane active" id="tables" role="tabpanel"> <div class="tab-pane active" id="tables" role="tabpanel">
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;"> <div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
<% <%
@booking_orders.each do |bko| @booking_orders.each do |bko|
# Assigned Id for new Order? Sale? # Assigned Id for new Order? Sale?
unique_id="" unique_id=""
# For CSS- Class for Order? Sale? # For CSS- Class for Order? Sale?
sale_status="" sale_status=""
if bko.order_status == 'new' if bko.order_status == 'new'
unique_id=bko.booking_id unique_id=bko.booking_id
else else
unique_id=bko.sale_id unique_id=bko.sale_id
sale_status="sold" sale_status="sold"
end end
%> %>
<div class="card orders <%= sale_status %>"> <div class="card orders <%= sale_status %>">
<div class="card-block"> <div class="card-block">
<p class="hidden orders-id"><%= unique_id %></p> <p class="hidden orders-id"><%= unique_id %></p>
<h4 class="card-title orders-table"><%= bko.table_name %></h4> <h4 class="card-title orders-table"><%= bko.table_name %></h4>
<p class="card-text"> <p class="card-text">
Receipt No : Receipt No :
<span class="orders-receipt-no"> <span class="orders-receipt-no">
@@ -48,12 +48,12 @@
Order Status : Order Status :
<span class="orders-order-status"> <span class="orders-order-status">
<%= bko.order_status %> <%= bko.order_status %>
</span> </span>
</small> </small>
</p> </p>
</div> </div>
</div> </div>
<% <%
end end
%> %>
</div> </div>
@@ -62,23 +62,23 @@
<!--- Panel 1 - Room Orders --> <!--- Panel 1 - Room Orders -->
<div class="tab-pane active" id="rooms" role="tabpanel"> <div class="tab-pane active" id="rooms" role="tabpanel">
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;"> <div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
<% <%
@booking_rooms.each do |rmo| @booking_rooms.each do |rmo|
# Assigned Id for new Order? Sale? # Assigned Id for new Order? Sale?
unique_id="" unique_id=""
# For CSS- Class for Order? Sale? # For CSS- Class for Order? Sale?
sale_status="" sale_status=""
if rmo.order_status == 'new' if rmo.order_status == 'new'
unique_id=rmo.booking_id unique_id=rmo.booking_id
else else
unique_id=rmo.sale_id unique_id=rmo.sale_id
sale_status="sold" sale_status="sold"
end end
%> %>
<div class="card orders <%= sale_status %>"> <div class="card orders <%= sale_status %>">
<div class="card-block"> <div class="card-block">
<p class="hidden orders-id"><%= unique_id %></p> <p class="hidden orders-id"><%= unique_id %></p>
<h4 class="card-title orders-table"><%= rmo.room_name %></h4> <h4 class="card-title orders-table"><%= rmo.room_name %></h4>
<p class="card-text"> <p class="card-text">
Receipt No : Receipt No :
<span class="orders-receipt-no"> <span class="orders-receipt-no">
@@ -89,12 +89,12 @@
Order Status : Order Status :
<span class="orders-order-status"> <span class="orders-order-status">
<%= rmo.order_status %> <%= rmo.order_status %>
</span> </span>
</small> </small>
</p> </p>
</div> </div>
</div> </div>
<% <%
end end
%> %>
</div> </div>
@@ -103,23 +103,23 @@
<!--- Panel 2 - Orders --> <!--- Panel 2 - Orders -->
<div class="tab-pane active" id="orders" role="tabpanel"> <div class="tab-pane active" id="orders" role="tabpanel">
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;"> <div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
<% <%
@orders.each do |odr| @orders.each do |odr|
# Assigned Id for new Order? Sale? # Assigned Id for new Order? Sale?
unique_id="" unique_id=""
# For CSS- Class for Order? Sale? # For CSS- Class for Order? Sale?
sale_status="" sale_status=""
if odr.order_status == 'new' if odr.order_status == 'new'
unique_id=odr.booking_id unique_id=odr.booking_id
else else
unique_id=odr.sale_id unique_id=odr.sale_id
sale_status="sold" sale_status="sold"
end end
%> %>
<div class="card orders <%= sale_status %>"> <div class="card orders <%= sale_status %>">
<div class="card-block"> <div class="card-block">
<p class="hidden orders-id"><%= unique_id %></p> <p class="hidden orders-id"><%= unique_id %></p>
<h4 class="card-title orders-table"><%= odr.table_name %></h4> <h4 class="card-title orders-table"><%= odr.table_name %></h4>
<p class="card-text"> <p class="card-text">
Receipt No : Receipt No :
<span class="orders-receipt-no"> <span class="orders-receipt-no">
@@ -130,16 +130,16 @@
Order Status : Order Status :
<span class="orders-order-status"> <span class="orders-order-status">
<%= odr.order_status %> <%= odr.order_status %>
</span> </span>
</small> </small>
</p> </p>
</div> </div>
</div> </div>
<% <%
end end
%> %>
</div> </div>
</div> </div>
</div> </div>
<!-- tabs - End --> <!-- tabs - End -->
@@ -157,10 +157,10 @@
<div class="col-lg-6 col-md-6 col-sm-6"> <div class="col-lg-6 col-md-6 col-sm-6">
<p>Receipt No: <span id="receipt_no"></span></p> <p>Receipt No: <span id="receipt_no"></span></p>
<p>Cashier: <span id="cashier"></span></p> <p>Cashier: <span id="cashier"></span></p>
</div> </div>
<div class="col-lg-6 col-md-6 col-sm-6 text-right"> <div class="col-lg-6 col-md-6 col-sm-6 text-right">
<p>Date: <span id="receipt_date"></span></p> <p>Date: <span id="receipt_date"></span></p>
</div> </div>
</div> </div>
<div class="card-text"> <div class="card-text">
<table class="table table-striped" id="order-items-table"> <table class="table table-striped" id="order-items-table">
@@ -205,7 +205,7 @@
</table> </table>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<!-- Column Three --> <!-- Column Three -->
@@ -215,13 +215,13 @@
<button type="button" class="btn btn-primary btn-lg btn-block" disabled>Edit</button> <button type="button" class="btn btn-primary btn-lg btn-block" disabled>Edit</button>
<button type="button" class="btn btn-primary btn-lg btn-block" disabled>Move</button> <button type="button" class="btn btn-primary btn-lg btn-block" disabled>Move</button>
<button type="button" class="btn btn-primary btn-lg btn-block" disabled>Customer</button> <button type="button" class="btn btn-primary btn-lg btn-block" disabled id="customer">Customer</button>
<button type="button" id="request_bills" class="btn btn-primary btn-lg btn-block">Req.Bill</button> <button type="button" id="request_bills" class="btn btn-primary btn-lg btn-block">Req.Bill</button>
<!-- Cashier Buttons --> <!-- Cashier Buttons -->
<button type="button" id="discount" class="btn btn-primary btn-lg btn-block">Discount</button> <button type="button" id="discount" class="btn btn-primary btn-lg btn-block">Discount</button>
<button type="button" class="btn btn-primary btn-lg btn-block" disabled>Tax</button> <!-- <button type="button" class="btn btn-primary btn-lg btn-block" disabled>Tax</button> -->
<button type="button" id="pay" class="btn btn-primary btn-lg btn-block" >Pay</button> <button type="button" id="pay-bill" class="btn btn-primary btn-lg btn-block" >Pay</button>
<button type="button" class="btn btn-primary btn-lg btn-block" disabled>Re.Print</button> <button type="button" class="btn btn-primary btn-lg btn-block" disabled>Re.Print</button>
</div> </div>
</div> </div>

View File

@@ -1,15 +1,15 @@
<div class="row"> <div class="row">
<div class="col-lg-5 col-md-5 col-sm-3"> <div class="col-lg-5 col-md-5 col-sm-3">
<div class="card"> <div class="card">
<% @payment_method_setting.each do |payment_method|%> <% @payment_method_setting.each do |payment_method|%>
<div class="col-md-5"> <div class="col-md-5">
<div class="col-md-12 long purple " id="<%= payment_method.payment_method%>" data-url="<%=payment_method.gateway_url%>" data-sale-id="<%= @sale_id%>"><%= payment_method.payment_method %></div> <div class="col-md-12 long purple " id="<%= payment_method.payment_method%>" data-url="<%=payment_method.gateway_url%>" data-sale-id="<%= @sale_id%>"><%= payment_method.payment_method %></div>
</div> </div>
<% end %> <% end %>
</div> </div>
</div> </div>
<div class="col-lg-7 col-md-7 col-sm-7"> <div class="col-lg-7 col-md-7 col-sm-7">
<div class="rebate-form" hidden="true"> <div class="rebate-form" hidden="true">
<div class="row"> <div class="row">
@@ -18,14 +18,14 @@
<input type="text" name="valid_amount" id="valid_amount" class="form-control col-lg-7 col-md-7 col-sm-7" readonly="" value=""> <input type="text" name="valid_amount" id="valid_amount" class="form-control col-lg-7 col-md-7 col-sm-7" readonly="" value="">
</div> </div>
<hr> <hr>
</div> </div>
<div class="row"> <div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12"> <div class="form-group col-lg-12 col-md-12 col-sm-12">
<label class="col-lg-4 col-md-4 col-sm-4">Used Amount</label> <label class="col-lg-4 col-md-4 col-sm-4">Used Amount</label>
<div id="used_amount" class="form-control col-lg-7 col-md-7 col-sm-7">0.0</div> <div id="used_amount" class="form-control col-lg-7 col-md-7 col-sm-7">0.0</div>
</div> </div>
<hr> <hr>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
@@ -86,16 +86,16 @@
</div> </div>
</div> </div>
<div class="col-md-5"> <div class="col-md-5">
<div class="col-md-12 cashier_number long purple" id="redeem" data-member-value = "">PAY</div> <div class="col-md-12 cashier_number long purple" id="redeem" data-value="<%=@sale_id %>" data-member-value="<%= @membership_id %>">PAY</div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
$(document).on('click', '.cashier_number', function(event){ $(document).on('click', '.cashier_number', function(event){
@@ -121,7 +121,7 @@ $(document).on('click', '.cashier_number', function(event){
var input_value = $(this).attr("data-value"); var input_value = $(this).attr("data-value");
amount = parseInt(input_value) + parseInt(original_value); amount = parseInt(input_value) + parseInt(original_value);
$('#used_amount').html(amount); $('#used_amount').html(amount);
break; break;
case 'clr': case 'clr':
$('#used_amount').html("0.0"); $('#used_amount').html("0.0");
@@ -133,7 +133,6 @@ $(document).on('click', '.cashier_number', function(event){
// return false; // return false;
// } // }
}); });
$("#REDIMREBATE").click(function(){ $("#REDIMREBATE").click(function(){
$('.rebate-form').removeAttr("hidden"); $('.rebate-form').removeAttr("hidden");
gateway_url = $(this).attr("data-url"); gateway_url = $(this).attr("data-url");
@@ -175,4 +174,4 @@ $("#redeem").click(function(){
}) })
} }
}); });
</script> </script>

View File

@@ -78,7 +78,7 @@
<hr> <hr>
<div class="row"> <div class="row">
<div class="col-md-8">CASH</div> <div class="col-md-8">CASH</div>
<div class="col-md-4" id="cash" >0.0</div> <div class="col-md-4" id="cash" ><%= @cash %></div>
</div> </div>
<hr> <hr>
<div class="row" id="credit_payment"> <div class="row" id="credit_payment">
@@ -165,42 +165,43 @@
<script> <script>
$(document).on('click', '.cashier_number', function(event){ $(document).on('click', '.cashier_number', function(event){
event.stopPropagation(); if(event.handled !== true) {
event.preventDefault(); var original_value;
if(event.handled !== true) { original_value = $('#cash').text();
var original_value;
original_value = $('#cash').text();
var input_type = $(this).attr("data-type"); var input_type = $(this).attr("data-type");
switch (input_type) {
case 'num':
var input_value = $(this).attr("data-value");
if (original_value == "0.0"){
$('#cash').text(input_value);
update_balance();
}else{
$('#cash').append(input_value);
update_balance();
}
break;
case 'add': switch (input_type) {
var input_value = $(this).attr("data-value"); case 'num':
amount = parseInt(input_value) + parseInt(original_value); var input_value = $(this).attr("data-value");
$('#cash').text(amount); if (original_value == "0.0"){
update_balance(); $('#cash').text(input_value);
break; update_balance();
}else{
case 'clr': $('#cash').append(input_value);
$('#cash').text("0.0"); update_balance();
update_balance();
break;
}
event.handled = true;
} else {
return false;
} }
break;
case 'add':
var input_value = $(this).attr("data-value");
amount = parseInt(input_value) + parseInt(original_value);
$('#cash').text(amount);
update_balance();
break;
case 'del' :
var cash=$('#cash').text();
$('#cash').text(cash.substr(0,cash.length-1));
update_balance();
break;
case 'clr':
$('#cash').text("0.0");
update_balance();
break;
}
event.handled = true;
} else {
return false;
}
}); });
$( document ).ready(function() { $( document ).ready(function() {
@@ -221,19 +222,18 @@ $( document ).ready(function() {
if($('#balance').text() > 0){ if($('#balance').text() > 0){
alert(" Insufficient Amount!") alert(" Insufficient Amount!")
}else{ }else{
// payment // payment
var cash = $('#cash').text(); var cash = $('#cash').text();
var credit = $('#credit').text(); var credit = $('#credit').text();
var card = $('#card').text(); var card = $('#card').text();
var sale_id = $('#sale_id').text(); var sale_id = $('#sale_id').text();
$.ajax({type: "POST", $.ajax({type: "POST",
url: "<%= origami_payment_process_path %>", url: "<%= origami_payment_process_path %>",
data: "cash="+ cash + "&sale_id=" + sale_id, data: "cash="+ cash + "&sale_id=" + sale_id,
success:function(result){ success:function(result){
alert("THANK YOU") alert("THANK YOU")
} }
}); });
} }
}); });

View File

@@ -11,10 +11,10 @@ Rails.application.config.assets.version = '1.0'
# Rails.application.config.assets.precompile += %w( search.js ) # Rails.application.config.assets.precompile += %w( search.js )
# --- Waiter/ Cashier - Orgiami ---- # --- Waiter/ Cashier - Orgiami ----
Rails.application.config.assets.precompile += %w( orgiami.css ) Rails.application.config.assets.precompile += %w( origami.css )
Rails.application.config.assets.precompile += %w( orgiami.js ) Rails.application.config.assets.precompile += %w( origami.js )
# -- Order Queue Station ----- # -- Order Queue Station -----
Rails.application.config.assets.precompile += %w( OQS.css ) Rails.application.config.assets.precompile += %w( OQS.css )
Rails.application.config.assets.precompile += %w( OQS.js ) Rails.application.config.assets.precompile += %w( OQS.js )
Rails.application.config.assets.precompile += %w( settings.css ) Rails.application.config.assets.precompile += %w( settings.css )

View File

@@ -13,6 +13,7 @@ class CreateOrderItems < ActiveRecord::Migration[5.1]
t.string :options t.string :options
t.json :set_menu_items #this parameter is require to route the items correctly t.json :set_menu_items #this parameter is require to route the items correctly
t.boolean :taxable, :null => false, :default => true t.boolean :taxable, :null => false, :default => true
t.string :completed_by
t.timestamps t.timestamps
end end
end end

View File

@@ -7,7 +7,7 @@ class CreatePaymentMethodSettings < ActiveRecord::Migration[5.1]
t.string :gateway_url t.string :gateway_url
t.string :auth_token t.string :auth_token
t.string :merchant_account_id t.string :merchant_account_id
t.string :additional_parameters
t.timestamps t.timestamps
end end
end end

View File

@@ -1,8 +1,8 @@
class CreateSaleOrders < ActiveRecord::Migration[5.1] class CreateSaleOrders < ActiveRecord::Migration[5.1]
def change def change
create_table :sale_orders, :id => false do |t| create_table :sale_orders, :id => false do |t|
t.primary_key :sale_order_id #custom primary key - to ensure consistence for cloud syncing
t.string :sale_order_id, :limit => 16, :primary_key => true
t.string :sale_id, foreign_key: true,:limit => 16 t.string :sale_id, foreign_key: true,:limit => 16
t.string :order_id, foreign_key: true, :limit => 16 t.string :order_id, foreign_key: true, :limit => 16

View File

@@ -1,5 +0,0 @@
class AddCompanyAddressEmail < ActiveRecord::Migration[5.1]
def change
add_column :order_items, :completed_by, :string
end
end

View File

@@ -1,5 +0,0 @@
class Additionparametertopaymentsettings < ActiveRecord::Migration[5.1]
def change
add_column :payment_method_settings, :additional_parameters, :string
end
end

View File

@@ -142,6 +142,7 @@ beverage = Account.create({title: "Beverage", account_type: "1"})
order_station1=PrintSetting.create({name: "OrderItemPdf", unique_code: "OrderItemPdf", printer_name: "EPSON-TM-T82-S-A"}) order_station1=PrintSetting.create({name: "OrderItemPdf", unique_code: "OrderItemPdf", printer_name: "EPSON-TM-T82-S-A"})
order_station2=PrintSetting.create({name: "Order Summary", unique_code: "OrderSummaryPdf", printer_name: "EPSON-TM-T82-S-A"}) order_station2=PrintSetting.create({name: "Order Summary", unique_code: "OrderSummaryPdf", printer_name: "EPSON-TM-T82-S-A"})
request_bill_printer=PrintSetting.create({name: "Receipt Bill", unique_code: "ReceiptBillPdf", printer_name: "EPSON-TM-T82-S-A"})
# shop = Shop.create( # shop = Shop.create(
# {name: "Beauty In The Pot", address: "address", township: "Yangon", city: "Yangon", state: "Yangon", # {name: "Beauty In The Pot", address: "address", township: "Yangon", city: "Yangon", state: "Yangon",