diff --git a/app/assets/javascripts/cable.js b/app/assets/javascripts/cable.js
index 739aa5f0..ce5ac871 100644
--- a/app/assets/javascripts/cable.js
+++ b/app/assets/javascripts/cable.js
@@ -5,9 +5,10 @@
//= require_self
//= require_tree ./channels
-(function() {
- this.App || (this.App = {});
+// Temp Disable
+// (function() {
+// this.App || (this.App = {});
- App.cable = ActionCable.createConsumer();
+// App.cable = ActionCable.createConsumer();
-}).call(this);
+// }).call(this);
diff --git a/app/assets/javascripts/origami.js b/app/assets/javascripts/origami.js
index 14f9fbe9..4af97d29 100644
--- a/app/assets/javascripts/origami.js
+++ b/app/assets/javascripts/origami.js
@@ -28,7 +28,7 @@ $(document).ready(function(){
$("#order-Tax").text('');
$("#order-grand-total").text('');
- var zone_name=$(this).find(".orders-table").text();
+ var zone_name=$(this).find(".orders-table").text();
var receipt_no=$(this).find(".orders-receipt-no").text();
var unique_id = $(this).find(".orders-id").text();
var order_status=$(this).find(".orders-order-status").text().trim();
@@ -37,15 +37,12 @@ $(document).ready(function(){
control_button(order_status);
//for customer button
- if(unique_id.charAt(0) == 'S'){
$("#customer").removeAttr('disabled');
- }else{
- $("#customer").attr('disabled','disabled');
- }
+
var customer_id=$(this).find(".customer-id").text();
show_customer_details(customer_id);
-
+
var cashier="";
var receipt_date="";
@@ -63,13 +60,7 @@ $(document).ready(function(){
type: "POST",
url: "/origami/" + unique_id,
data: { 'booking_id' : unique_id },
- success:function(result){
-// =======
-// type: "GET",
-// url: "origami/" + unique_id,
-// data: { 'id' : unique_id },
-// success:function(result){
-// >>>>>>> 5ee3ae257a59269b651dcc5c0232b95d7f41fb77
+ success:function(result){
for (i = 0; i < result.length; i++) {
var data = JSON.stringify(result[i]);
var parse_data = JSON.parse(data);
@@ -86,7 +77,7 @@ $(document).ready(function(){
//Receipt Charges
sub_total += (parse_data.qty*parse_data.price);
-
+
discount_amount = parse_data.discount_amount == null? '0.0' : parse_data.discount_amount;
tax_amount = parse_data.tax_amount;
grand_total_amount = parse_data.grand_total_amount;
@@ -184,27 +175,45 @@ $(document).ready(function(){
});
$('#customer').click(function() {
- var sale_id=$(".selected-item").find(".orders-id").text();
+ var sale = $(".selected-item").find(".orders-id").text();
+ if (sale.substring(0, 3)=="SAL") {
+ var sale_id = sale
+ }else{
+ var sale_id = $(".selected-item").find(".order-cid").text();
+ }
window.location.href = '/origami/'+ sale_id + "/add_customer"
return false;
});
- function show_customer_details(customer_id){
- $('.customer_detail').removeClass('hide');
- //Start Ajax
- $.ajax({
- type: "GET",
- url: "origami/"+customer_id+"/get_customer/",
- data: {},
- dataType: "json",
- success: function(data) {
- $("#customer_name").text(data.name);
- $("#customer_name").text(data.name);
- }
- });
- //End Ajax
-}
+ function show_customer_details(customer_id){
+
+ $('.customer_detail').removeClass('hide');
+ //Start Ajax
+ $.ajax({
+ type: "GET",
+ url: "origami/"+customer_id+"/get_customer/",
+ data: {},
+ dataType: "json",
+ success: function(data) {
+ $("#customer_name").text(data["customer"].name);
+ $.each(data["response_data"]["data"], function (i) {
+ if(data["response_data"]["data"][i]["accountable_type"] == "RebateAccount"){
+ var balance = data["response_data"]["data"][i]["balance"];
+ console.log(balance);
+ if (balance) {
+ $("#customer_amount").text(balance);
+ }else{
+ $("#customer_amount").text('00');
+ }
+
+
+ }
+ });
+ }
+ });
+ //End Ajax
+ }
/* For Receipt - Calculate discount or tax */
$('.cashier_number').on('click', function(event){
diff --git a/app/assets/javascripts/settings/orders.coffee b/app/assets/javascripts/settings/orders.coffee
new file mode 100644
index 00000000..24f83d18
--- /dev/null
+++ b/app/assets/javascripts/settings/orders.coffee
@@ -0,0 +1,3 @@
+# 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/
diff --git a/app/assets/stylesheets/origami.scss b/app/assets/stylesheets/origami.scss
index 9e886d87..5e361f7e 100644
--- a/app/assets/stylesheets/origami.scss
+++ b/app/assets/stylesheets/origami.scss
@@ -21,8 +21,9 @@
}
.cashier_number{
- height:60px;
- line-height:60px;
+ width: 33%;
+ height:70px;
+ line-height:70px;
text-align:center;
background:#54A5AF;
// float:left;
@@ -34,8 +35,8 @@
.pay{
width: 98%;
- height:210px;
- line-height:210px;
+ height:211px;
+ line-height:211px;
text-align:center;
font-size:20px;
color:white;
@@ -46,7 +47,7 @@
}
.long{
- width:100%;
+ width:49%;
}
.sold {
@@ -121,4 +122,4 @@ select.form-control {
tr.discount-item-row:hover {
background-color: #e3e3e3 !important;
-}
\ No newline at end of file
+}
diff --git a/app/assets/stylesheets/settings/orders.scss b/app/assets/stylesheets/settings/orders.scss
new file mode 100644
index 00000000..436ceee1
--- /dev/null
+++ b/app/assets/stylesheets/settings/orders.scss
@@ -0,0 +1,3 @@
+// Place all the styles related to the settings/orders controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
diff --git a/app/controllers/api/orders_controller.rb b/app/controllers/api/orders_controller.rb
index df9b1542..8bd348e2 100644
--- a/app/controllers/api/orders_controller.rb
+++ b/app/controllers/api/orders_controller.rb
@@ -38,9 +38,8 @@ class Api::OrdersController < Api::ApiController
#Create Table Booking or Room Booking
- if !params["booking_id"].nil? && params[:booking_id].to_i > 0
- #@order.new_booking = false
- @order.new_booking = true
+ if !params["booking_id"].nil?
+ @order.new_booking = false
@order.booking_id = params[:booking_id]
end
diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb
index f6159cb7..01acd441 100644
--- a/app/controllers/crm/customers_controller.rb
+++ b/app/controllers/crm/customers_controller.rb
@@ -14,9 +14,9 @@ class Crm::CustomersController < BaseCrmController
end
#@crm_customers = Customer.all
@crm_customer = Customer.new
- @crm_customer.valid?
-
-
+ if @crm_customer.valid?
+ @crm_customer.errors.messages
+ end
# @membership = Customer.get_member_group
# if @membership["status"] == true
# @member_group = @membership["data"]
@@ -30,6 +30,15 @@ class Crm::CustomersController < BaseCrmController
# GET /crm/customers/1
# GET /crm/customers/1.json
def show
+ @orders = Order.where("customer_id=?", params[:id])
+
+ if @orders
+ @order_items = []
+ @orders.each do |bo|
+ @order_items = @order_items + bo.order_items
+ end
+
+ end
end
# GET /crm/customers/new
@@ -45,66 +54,64 @@ class Crm::CustomersController < BaseCrmController
# POST /crm/customers
# POST /crm/customers.json
- def create
+ def create
@crm_customers = Customer.new(customer_params)
-
+
respond_to do |format|
if @crm_customers.save
name = customer_params[:name]
phone = customer_params[:contact_no]
email = customer_params[:email]
date_of_birth = customer_params[:date_of_birth]
- membership_id = params[:membership_id]
+ member_group_id = params[:member_group_id]
membership = MembershipSetting.find_by_membership_type("paypar_url")
memberaction = MembershipAction.find_by_membership_type("create_membership_customer")
- app_token = membership.auth_token.to_s
+ merchant_uid = memberaction.merchant_account_id.to_s
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
response = HTTParty.post(url, :body => { name: name,phone: phone,email: email,
date_of_birth: date_of_birth,
- membership_id: membership_id}.to_json,
+ member_group_id: member_group_id,merchant_uid:merchant_uid}.to_json,
:headers => {
'Content-Type' => 'application/json',
'Accept' => 'application/json'
}
)
- if response["status"] == true
+ if response["status"] == true
+
customer = Customer.find(@crm_customers.customer_id)
status = customer.update_attributes(membership_id: response["customer_datas"]["id"])
- if params[:sale_id].nil?
-
- format.html { redirect_to '/origami/'+params[:sale_id]+'/add_customer', notice: 'Customer was successfully created.' }
- else
- format.html { redirect_to crm_customers_path, notice: 'Customer was successfully created.' }
- end
+ if params[:sale_id]
+ format.html { redirect_to '/origami/'+params[:sale_id]+'/add_customer', notice: 'Customer was successfully created.' }
+ else
+ format.html { redirect_to crm_customers_path, notice: 'Customer was successfully created'}
+ end
# format.json { render :index, status: :created, location: @crm_customers }
else
@crm_customers.destroy
- if params[:sale_id].nil?
+ if params[:sale_id]
format.html { redirect_to '/origami/'+params[:sale_id]+'/add_customer'}
else
format.html { redirect_to crm_customers_path, notice: response["message"] }
end
end
- # format.json { render :index, status: :created, location: @crm_customers }
else
-
- if params[:sale_id].nil?
-
+
+ if params[:sale_id]
format.html { redirect_to '/origami/'+params[:sale_id]+'/add_customer'}
else
-
format.html { redirect_to crm_customers_path}
format.json { render json: @crm_customers.errors, status: :unprocessable_entity }
end
end
- end
+
end
+end
# PATCH/PUT /crm/customers/1
# PATCH/PUT /crm/customers/1.json
@@ -118,15 +125,16 @@ class Crm::CustomersController < BaseCrmController
email = customer_params[:email]
date_of_birth = customer_params[:date_of_birth]
id = customer_params[:membership_id]
+ member_group_id = params[:member_group_id]
membership = MembershipSetting.find_by_membership_type("paypar_url")
memberaction = MembershipAction.find_by_membership_type("update_membership_customer")
- app_token = membership.auth_token.to_s
+ merchant_uid = memberaction.merchant_account_id.to_s
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
response = HTTParty.post(url, :body => { name: name,phone: phone,email: email,
date_of_birth: date_of_birth,
- id: id}.to_json,
+ id: id,member_group_id:member_group_id,merchant_uid:merchant_uid}.to_json,
:headers => {
'Content-Type' => 'application/json',
'Accept' => 'application/json'
@@ -155,22 +163,6 @@ class Crm::CustomersController < BaseCrmController
end
end
- # DELETE /crm/customers/1
- # DELETE /crm/customers/1.json
- def get_sale_id
- @sale_id = params[:sale_id]
- @crm_customers = Customer.all
- @crm_customer = Customer.new
- @membership = Customer.get_member_group
- if @membership["status"] == true
- @member_group = @membership["data"]
- end
- respond_to do |format|
- format.html { render action: "index"}
- format.json { render json: @crm_customers }
- end
- end
-
private
# Use callbacks to share common setup or constraints between actions.
def set_crm_customer
diff --git a/app/controllers/origami/customers_controller.rb b/app/controllers/origami/customers_controller.rb
index 7917b03f..a1a067fe 100644
--- a/app/controllers/origami/customers_controller.rb
+++ b/app/controllers/origami/customers_controller.rb
@@ -18,15 +18,20 @@ class Origami::CustomersController < BaseOrigamiController
filter = params[:filter]
if filter.nil?
- @crm_customers = Customer.order("name").page(params[:page])
+ @crm_customers = Customer.order("name").page params[:page]
else
- @crm_customers = Customer.where("name LIKE ?", "%#{filter}%").order("name").page(params[:page])
+ @crm_customers = Customer.where("name LIKE ?", "%#{filter}%").order("name").page params[:page]
end
+ # @crm_customers = Kaminari.paginate_array(@crm_customers).page(params[:page]).per(2)
@crm_customer = Customer.new
- @membership = Customer.get_member_group
- if @membership["status"] == true
- @member_group = @membership["data"]
- end
+ # @membership = Customer.get_member_group
+ # if @membership["status"] == true
+ # @member_group = @membership["data"]
+ # end
+ puts "Errrrrrrrrrrrrrrrrr"
+ puts @crm_customer.new_record?
+
+
respond_to do |format|
# format.html { render :template => "crm/customers/index" }
format.html { render action: "index"}
diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb
index 669c8a7f..de526f81 100644
--- a/app/controllers/origami/home_controller.rb
+++ b/app/controllers/origami/home_controller.rb
@@ -12,6 +12,7 @@ class Origami::HomeController < BaseOrigamiController
@selected_item_type="Order"
end
end
+ puts params[:booking_id]
@completed_orders = Order.get_completed_order()
@booking_orders = Order.get_booking_order_table()
@@ -48,20 +49,47 @@ class Origami::HomeController < BaseOrigamiController
def update_sale_by_customer
- sale = Sale.find(params[:sale_id])
- status = sale.update_attributes(customer_id: params[:customer_id])
-
- if status == true
+ id = params[:sale_id][0,3]
+ if(id == "SAL")
+ sale = Sale.find(params[:sale_id])
+ else
+ sale = Order.find(params[:sale_id])
+ end
+
+ status = sale.update_attributes(customer_id: params[:customer_id])
+
+ if status == true
render json: JSON.generate({:status => true})
- else
+ else
render json: JSON.generate({:status => false, :error_message => "Record not found"})
- end
+ end
end
def get_customer
- @customer = Customer.find(params[:customer_id])
- render :json => @customer.to_json
+ @customer = Customer.find(params[:customer_id])
+
+ membership = MembershipSetting.find_by_membership_type("paypar_url")
+
+ memberaction = MembershipAction.find_by_membership_type("get_all_member_account")
+ merchant_uid = memberaction.merchant_account_id.to_s
+ url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
+
+ response = HTTParty.get(url, :body => { membership_id: @customer.membership_id,merchant_uid:merchant_uid}.to_json,
+ :headers => {
+ 'Content-Type' => 'application/json',
+ 'Accept' => 'application/json'
+ }
+ )
+
+ respond_to do |format|
+ format.js do
+ render :json => {
+ :response_data => response.as_json,
+ :customer => @customer}
+ end
+ end
end
+
end
diff --git a/app/controllers/origami/redeem_payments_controller.rb b/app/controllers/origami/redeem_payments_controller.rb
index 0821a2d8..5fd386e8 100644
--- a/app/controllers/origami/redeem_payments_controller.rb
+++ b/app/controllers/origami/redeem_payments_controller.rb
@@ -16,7 +16,8 @@ class Origami::RedeemPaymentsController < BaseOrigamiController
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
- membership_data = SalePayment.get_paypar_account(url,membership_setting.auth_token,@membership_id,@campaign_type_id)
+ merchant_uid= member_actions.merchant_account_id
+ membership_data = SalePayment.get_paypar_account(url,membership_setting.auth_token,@membership_id,@campaign_type_id,merchant_uid)
if membership_data["status"]==true
@membership_rebate_balance=membership_data["balance"]
@out = true, @membership_rebate_balance,@membership_id
diff --git a/app/controllers/origami/request_bills_controller.rb b/app/controllers/origami/request_bills_controller.rb
index 4e884aaf..58ba0b11 100644
--- a/app/controllers/origami/request_bills_controller.rb
+++ b/app/controllers/origami/request_bills_controller.rb
@@ -30,7 +30,7 @@ class Origami::RequestBillsController < BaseOrigamiController
printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, food_total, beverage_total)
- redirect_to origami_path(sale_order.sale_id)
+ redirect_to origami_path(@sale_data.sale_id)
end
end
diff --git a/app/controllers/settings/orders_controller.rb b/app/controllers/settings/orders_controller.rb
new file mode 100644
index 00000000..b5bbdc1c
--- /dev/null
+++ b/app/controllers/settings/orders_controller.rb
@@ -0,0 +1,32 @@
+class Settings::OrdersController < ApplicationController
+ def index
+
+ filter = params[:filter]
+ if filter.nil?
+ orders = Order.order("order_id desc").limit(1000)
+ else
+ order = Order.where("order_id LIKE ?", "%#{filter}%").order("order_id desc").limit(1000).page(params[:page])
+ if order.count > 0
+ orders = order
+ else
+ orders = Order.order("order_id desc").limit(1000)
+ flash[:notice] = "There is no data."
+ end
+ end
+ @orders = Kaminari.paginate_array(orders).page(params[:page]).per(50)
+ respond_to do |format|
+ format.html # index.html.erb
+ format.json { render json: @orders }
+ end
+ end
+ def show
+
+ @order = Order.find(params[:id])
+
+ respond_to do |format|
+ format.html # show.html.erb
+ format.json { render json: @order }
+ end
+ end
+
+end
diff --git a/app/controllers/settings/sales_controller.rb b/app/controllers/settings/sales_controller.rb
new file mode 100644
index 00000000..6bb58244
--- /dev/null
+++ b/app/controllers/settings/sales_controller.rb
@@ -0,0 +1,42 @@
+class Settings::SalesController < ApplicationController
+ def index
+
+ search_date = params[:date]
+ receipt_no = params[:receipt_no]
+ today = Date.today
+
+ if receipt_no.nil? && search_date.nil?
+ @sales = Sale.where("NOT sale_status = 'void'" ).order("sale_id desc").limit(500)
+ else
+ if !search_date.blank? && receipt_no.blank?
+ sale = Sale.where("DATE_FORMAT(receipt_date,'%Y-%b-%d') = ?", search_date).order("sale_id desc").limit(500).page(params[:page])
+ elsif !search_date.blank? && !receipt_no.blank?
+ sale = Sale.where("receipt_no LIKE ? or DATE_FORMAT(receipt_date,'%Y-%b-%d') = ?", "%#{receipt_no}%", search_date).order("sale_id desc").limit(500).page(params[:page])
+ else
+ sale = Sale.where("receipt_no LIKE ?", receipt_no).order("sale_id desc").limit(500).page(params[:page])
+ end
+ if sale.count > 0
+ @sales = sale
+ else
+ @sales = Sale.where("NOT sale_status = 'void'").order("sale_id desc").limit(500)
+ end
+ end
+ @sales = Kaminari.paginate_array(@sales).page(params[:page]).per(50)
+ respond_to do |format|
+ format.html # index.html.erb
+ format.json { render json: @sales }
+ end
+ end
+
+ def show
+
+ @sale = Sale.find(params[:id])
+ # @sale_receivables = SaleReceivable.where('sale_id = ?', @sale.id)
+ respond_to do |format|
+ format.html # show.html.erb
+ format.json { render json: @sale }
+ end
+ end
+
+
+end
\ No newline at end of file
diff --git a/app/helpers/settings/orders_helper.rb b/app/helpers/settings/orders_helper.rb
new file mode 100644
index 00000000..f5825365
--- /dev/null
+++ b/app/helpers/settings/orders_helper.rb
@@ -0,0 +1,2 @@
+module Settings::OrdersHelper
+end
diff --git a/app/models/customer.rb b/app/models/customer.rb
index 4f013678..b5e101cb 100644
--- a/app/models/customer.rb
+++ b/app/models/customer.rb
@@ -14,9 +14,9 @@ class Customer < ApplicationRecord
def self.get_member_group
- membership = MembershipSetting.find_by_membership_type("paypar_url")
+ membership = MembershipSetting.find_by_membership_type("paypar_url")
memberaction = MembershipAction.find_by_membership_type("get_all_member_group")
- app_token = membership.auth_token.to_s
+ app_token = membership.auth_token.to_s
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
response = HTTParty.get(url,
diff --git a/app/models/dining_facility.rb b/app/models/dining_facility.rb
index 9a4f7a75..a3f8948f 100644
--- a/app/models/dining_facility.rb
+++ b/app/models/dining_facility.rb
@@ -9,10 +9,11 @@ class DiningFacility < ApplicationRecord
scope :active, -> {where(is_active: true)}
def get_current_booking
- booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='occupied' and checkin_at between '#{DateTime.now.utc - 5.hours}' and '#{DateTime.now.utc}' and checkout_at is null").limit(1)
+ puts "enter booking"
+ booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='assign' and checkin_at between '#{DateTime.now.utc - 5.hours}' and '#{DateTime.now.utc}' and checkout_at is null").limit(1)
if booking.count > 0 then
- return booking[0]
+ return booking[0].booking_id
else
return nil
end
diff --git a/app/models/dining_queue.rb b/app/models/dining_queue.rb
index dfcc5b43..ea6a1381 100644
--- a/app/models/dining_queue.rb
+++ b/app/models/dining_queue.rb
@@ -1,3 +1,2 @@
class DiningQueue < ApplicationRecord
-
end
diff --git a/app/models/lookup.rb b/app/models/lookup.rb
index e1b141df..5434cedd 100644
--- a/app/models/lookup.rb
+++ b/app/models/lookup.rb
@@ -17,6 +17,10 @@ class Lookup < ApplicationRecord
"Gateway Communication Type" => "gateway_communication_type"}
end
+ # def self.get_by_type( lookup_type)
+ # Lookup.select("value, name").where("lookup_type = ?", lookup_type ).order("name asc").map { |r| [r.name, r.value] }
+ # end
+
def self.collection_of(type)
Lookup.select("name, value").where("lookup_type" => type ).map { |l| [l.name, l.value] }
diff --git a/app/models/order.rb b/app/models/order.rb
index a165b7b4..5a4d6e2d 100644
--- a/app/models/order.rb
+++ b/app/models/order.rb
@@ -25,14 +25,15 @@ class Order < ApplicationRecord
booking = nil
if self.new_booking
+ puts "a"
booking = Booking.create({:dining_facility_id => self.table_id,:type => "TableBooking",
:checkin_at => Time.now.utc, :checkin_by => self.employee_name,
:booking_status => "assign" })
+ table = DiningFacility.find(self.table_id)
+ table.status = "occupied"
+ table.save
else
- if (self.booking_id.to_i > 0 )
- booking = Booking.find(self.booking_id)
- end
-
+ booking = Booking.find(self.booking_id)
end
booking.save!
@@ -222,28 +223,29 @@ class Order < ApplicationRecord
#Origami: Cashier : to view booking order Table
def self.get_booking_order_table
- booking_orders = Booking.select("sales.receipt_no,orders.status as order_status,orders.customer_id as customer_id,
+ booking_orders = Booking.select("sales.receipt_no,orders.status as order_status,
+ orders.order_id as order_id,sales.customer_id as sale_customer_id,orders.customer_id as order_customer_id,
bookings.booking_id,sales.sale_id as sale_id,dining_facilities.name as table_name")
.joins("left join booking_orders on booking_orders.booking_id = bookings.booking_id")
.joins("left join dining_facilities on dining_facilities.id = bookings.dining_facility_id")
- .joins("left join orders on orders.order_id = booking_orders.order_id")
+ .joins("left join orders on orders.order_id = booking_orders.order_id")
.joins("left join sales on sales.sale_id = bookings.sale_id")
.where("booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::TABLE_TYPE,true)
- .group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status")
+ .group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status,orders.order_id")
end
#Origami: Cashier : to view booking order Table
def self.get_completed_order
- completed_orders = Booking.select("sales.receipt_no,orders.status as order_status,
- bookings.booking_id,sales.sale_id as sale_id,dining_facilities.name as table_name")
+ completed_orders = Booking.select("sales.receipt_no,orders.status as order_status,orders.order_id,
+ bookings.booking_id,sales.sale_id as sale_id,dining_facilities.name as table_name,sales.customer_id as sale_customer_id,orders.customer_id as order_customer_id")
.joins("left join booking_orders on booking_orders.booking_id = bookings.booking_id")
.joins("left join dining_facilities on dining_facilities.id = bookings.dining_facility_id")
- .joins("left join orders on orders.order_id = booking_orders.order_id")
+ .joins("left join orders on orders.order_id = booking_orders.order_id")
.joins("left join sales on sales.sale_id = bookings.sale_id")
.where("sales.sale_status='completed'")
+<<<<<<< HEAD
.group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status")
-
end
#Origami: Cashier : to view booking order Table
@@ -252,24 +254,25 @@ class Order < ApplicationRecord
bookings.booking_id,sales.sale_id as sale_id,dining_facilities.name as table_name")
.joins("left join booking_orders on booking_orders.booking_id = bookings.booking_id")
.joins("left join dining_facilities on dining_facilities.id = bookings.dining_facility_id")
- .joins("left join orders on orders.order_id = booking_orders.order_id")
+ .joins("left join orders on orders.order_id = booking_orders.order_id")
.joins("left join sales on sales.sale_id = bookings.sale_id")
- .where("booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::TABLE_TYPE,true)
- .group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status")
-
+ .where("sales.sale_status<>'completed' and booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::TABLE_TYPE,true)
+ .group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status,orders.customer_id,sales.customer_id,orders.order_id")
end
#Origami: Cashier : to view order type Room
def self.get_booking_order_rooms
- booking_rooms = Booking.select("sales.receipt_no,orders.status as order_status,bookings.booking_id,orders.customer_id as customer_id,
+ booking_rooms = Booking.select("sales.receipt_no,orders.status as order_status,
+ orders.order_id as order_id,sales.customer_id as sale_customer_id,orders.customer_id as order_customer_id,
+ bookings.booking_id,orders.customer_id as customer_id,
sales.sale_id as sale_id,dining_facilities.name as room_name")
.joins("left join booking_orders on booking_orders.booking_id = bookings.booking_id")
.joins("left join dining_facilities on dining_facilities.id = bookings.dining_facility_id")
.joins("left join orders on orders.order_id = booking_orders.order_id")
.joins("left join sale_orders on sale_orders.order_id = orders.order_id")
.joins("left join sales on sales.sale_id = sale_orders.sale_id")
- .where("booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::ROOM_TYPE,true)
- .group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name")
+ .where("sales.sale_status<>'completed' and sales.sale_status<>'complete' and booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::ROOM_TYPE,true)
+ .group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.customer_id")
end
#Origami: Cashier : to view order type Room
@@ -290,15 +293,16 @@ class Order < ApplicationRecord
from = Time.now.beginning_of_day.utc
to = Time.now.end_of_day.utc
orders = Order.select("orders.order_id as order_id,sales.receipt_no,orders.status as order_status,
- orders.customer_id as customer_id,bookings.booking_id,sales.sale_id as sale_id,dining_facilities.name as table_name")
+ orders.order_id as order_id,sales.customer_id as sale_customer_id,orders.customer_id as order_customer_id
+ ,bookings.booking_id,sales.sale_id as sale_id,dining_facilities.name as table_name")
.joins("left join booking_orders on booking_orders.order_id = orders.order_id
left join bookings on bookings.booking_id = booking_orders.order_id
left join dining_facilities on dining_facilities.id = bookings.dining_facility_id
left join order_items on order_items.order_id = orders.order_id
left join sale_orders on sale_orders.order_id = orders.order_id
left join sales on sales.sale_id = sale_orders.sale_id")
- .where("sales.sale_status<>'complete' and dining_facilities.is_active=? and orders.date between ? and ?",true,from,to)
- .group("orders.order_id,order_items.order_items_id,dining_facilities.name,sales.receipt_no,bookings.booking_id,sales.sale_id")
+ .where("sales.sale_status<>'completed' and dining_facilities.is_active=? and orders.date between ? and ?",true,from,to)
+ .group("orders.order_id,order_items.order_items_id,dining_facilities.name,sales.receipt_no,bookings.booking_id,sales.sale_id,orders.customer_id")
end
diff --git a/app/models/sale_item.rb b/app/models/sale_item.rb
index 0aed9a23..ef852bbd 100644
--- a/app/models/sale_item.rb
+++ b/app/models/sale_item.rb
@@ -1,6 +1,6 @@
class SaleItem < ApplicationRecord
self.primary_key = "sale_item_id"
-
+
#primary key - need to be unique generated for multiple shops
before_create :generate_custom_id
@@ -12,17 +12,17 @@ class SaleItem < ApplicationRecord
def self.get_order_items_details(sale_id)
- order_details = SaleItem.select("sales.total_tax as tax_amount, sales.grand_total as grand_total_amount , sales.total_discount as discount_amount,DATE_FORMAT(sales.receipt_date,'%Y-%m-%d %h:%m') as receipt_date,
+ order_details = SaleItem.select("sales.total_tax as tax_amount, sales.grand_total as grand_total_amount , sales.total_discount as discount_amount,sales.receipt_date as receipt_date,
sales.cashier_name,sales.receipt_no,sale_items.product_name as item_name,sale_items.qty,sale_items.price,sale_items.unit_price as total_price")
.joins("left join sales on sales.sale_id = sale_items.sale_id")
.where("sale_items.sale_id=?",sale_id)
# sale_orders = SaleOrder.where("sale_id=?",sale_id)
# if sale_orders
- # sale_orders.each do |sale_order|
+ # sale_orders.each do |sale_order|
# order_details = SaleItem.select("sales.total_discount as discount_amount,DATE_FORMAT(sales.receipt_date,'%Y-%m-%d %h:%m') as receipt_date,sales.cashier_name,sales.receipt_no,sale_items.product_name as item_name,sale_items.qty,sale_items.price,sale_items.unit_price as total_price")
# .joins("left join sales on sales.id = sale_items.sale_id")
- # .where("sale_items.sale_id=?",sale_order.sale_id)
+ # .where("sale_items.sale_id=?",sale_order.sale_id)
# return order_details
# end
# else
@@ -35,27 +35,30 @@ class SaleItem < ApplicationRecord
beverage_prices=0
sale_items.each do |si|
- food_price = self.get_food_price(si.sale_item_id)
- beverage_price = self.get_beverage_price(si.sale_item_id)
-puts food_price
- # food_prices = food_prices + food_price.price
- # beverage_prices = beverage_prices + beverage_price.price
+ food_price, beverage_price = self.get_price(si.sale_item_id)
+
+ food_prices = food_prices + food_price
+ beverage_prices = beverage_prices + beverage_price
end
return food_prices, beverage_prices
end
- def self.get_food_price(sale_item_id)
- food_price=SaleItem.select("sale_items.price")
+ def self.get_price(sale_item_id)
+ food_price=0
+ beverage_price=0
+
+ item=SaleItem.select("sale_items.price , menu_items.account_id")
.joins("left join menu_items on menu_items.item_code = sale_items.product_code")
- .where("sale_items.sale_item_id=? and menu_items.account_id=0", sale_item_id)
+ .where("sale_items.sale_item_id=?", sale_item_id.to_s)
+ if item[0].account_id == 1
+ food_price = item[0].price
+ else
+ beverage_price = item[0].price
+ end
+
+ return food_price, beverage_price
end
- def self.get_beverage_price(sale_item_id)
- beverage_price=SaleItem.select("sale_items.price")
- .joins("left join menu_items on menu_items.item_code = sale_items.product_code")
- .where("sale_items.sale_item_id=? and menu_items.account_id=1", sale_item_id)
- end
-
private
def generate_custom_id
self.sale_item_id = SeedGenerator.generate_id(self.class.name, "SLI")
diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb
index 6609a28e..b8c527af 100644
--- a/app/models/sale_payment.rb
+++ b/app/models/sale_payment.rb
@@ -60,15 +60,15 @@ class SalePayment < ApplicationRecord
#record an payment in sale-audit
remark = "No outstanding Amount - Grand Total [#{invoice.grand_total}] | Due [#{amount_due}] | Paid [#{invoice.amount_received}]"
sale_audit = SaleAudit.record_payment(invoice.id, remark,action_by)
-
+
return false, "No outstanding Amount"
end
end
- def self.get_paypar_account(url,token,membership_id,campaign_type_id)
+ def self.get_paypar_account(url,token,membership_id,campaign_type_id,merchant_uid)
response = HTTParty.get(url,
- :body => { app_token: token,membership_id:membership_id,campaign_type_id:campaign_type_id}.to_json,
+ :body => { app_token: token,membership_id:membership_id,campaign_type_id:campaign_type_id,merchant_uid:merchant_uid}.to_json,
:headers => {
'Content-Type' => 'application/json',
'Accept' => 'application/json'
@@ -82,9 +82,10 @@ class SalePayment < ApplicationRecord
membership_actions_data = MembershipAction.find_by_membership_type("redeem");
if !membership_actions_data.nil?
url = paypar_url.to_s + membership_actions_data.gateway_url.to_s
- campaign_type_id = membership_actions_data.additional_parameter["campaign_type_id"]
+ merchant_uid = membership_actions_data.merchant_account_id
+ campaign_type_id = membership_actions_data.additional_parameter["campaign_type_id"]
response = HTTParty.post(url,
- :body => { generic_customer_id:membership_id,total_amount:received_amount,receipet_no:sale_id,campaign_type_id:campaign_type_id,account_no:""}.to_json,
+ :body => { generic_customer_id:membership_id,redeem_amount:received_amount,receipet_no:sale_id,campaign_type_id:campaign_type_id,account_no:"",merchant_uid:merchant_uid}.to_json,
:headers => {
'Content-Type' => 'application/json',
'Accept' => 'application/json'
@@ -211,18 +212,29 @@ class SalePayment < ApplicationRecord
sObj.sale_payments.each do |spay|
all_received_amount += spay.payment_amount.to_f
end
-
if (self.sale.grand_total <= all_received_amount)
self.sale.payment_status = "paid"
self.sale.sale_status = "completed"
self.sale.save!
+ table_update_status(sObj)
rebat()
end
end
+ def table_update_status(sale_obj)
+ booking = Booking.find_by_sale_id(sale_obj.id)
+ if booking
+ table = DiningFacility.find(booking.dining_facility_id)
+ if table
+ table.status = "available"
+ table.save
+ end
+ end
+ end
+
def rebat
-
+
end
private
diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb
index f91aebe1..dbaea572 100644
--- a/app/pdf/receipt_bill_pdf.rb
+++ b/app/pdf/receipt_bill_pdf.rb
@@ -1,16 +1,16 @@
class ReceiptBillPdf < Prawn::Document
- attr_accessor :receipt_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
+ 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, sale_items, sale_data, customer_name, food_total, beverage_total)
- self.page_width = 300
+ self.page_width = 250
self.page_height = 1450
self.margin = 10
- self.price_width = 50
- self.qty_width = 30
- self.total_width = 50
- self.item_width = self.page_width - (self.price_width + self.qty_width + self.total_width)
+ self.price_width = 40
+ self.qty_width = 20
+ self.total_width = 40
+ self.item_width = self.page_width - ((self.price_width + self.qty_width + self.total_width)+(self.margin*4))
self.item_height = 15
self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width)
- self.receipt_width=100
+ self.label_width=80
# @item_width = self.page_width.to_i / 2
# @qty_width = @item_width.to_i / 3
@@ -22,8 +22,8 @@ class ReceiptBillPdf < Prawn::Document
# font "public/fonts/#{font_name}".to_s + ".ttf".to_s
# font "public/fonts/Zawgyi-One.ttf"
# font "public/fonts/padauk.ttf"
- self.header_font_size = 12
- self.item_font_size = 10
+ self.header_font_size = 11
+ self.item_font_size = 9
header( printer_settings.printer_name, printer_settings.name)
@@ -31,66 +31,64 @@ class ReceiptBillPdf < Prawn::Document
cashier_info(sale_data, customer_name)
line_items(sale_items, food_total, beverage_total)
- all_total(sale_data)
-
-
+ all_total(sale_data)
+ footer
end
def header (printer_name, name)
- text "#{printer_name}", :size => self.header_font_size,:align => :center
- move_down 5
- text "#{name}", :size => self.header_font_size,:align => :center
- # move_down self.item_height
- move_down 5
+ text "#{printer_name}", :left_margin => -10, :size => self.header_font_size,:align => :center
+ move_down 5
+ text "#{name}", :size => self.header_font_size,:align => :center
+ # move_down self.item_height
+ move_down 5
- stroke_horizontal_rule
+ stroke_horizontal_rule
end
def cashier_info(sale_data, customer_name)
move_down 7
# move_down 2
y_position = cursor
- bounding_box([0,y_position], :width =>self.receipt_width, :height => self.item_height) do
+ bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
text "Receipt No:", :size => self.item_font_size,:align => :left
end
- bounding_box([self.receipt_width, y_position], :width =>self.receipt_width) do
+ bounding_box([self.label_width, y_position], :width =>self.item_width) do
text "#{sale_data.receipt_no}" , :size => self.item_font_size, :align => :left
end
move_down 5
y_position = cursor
- bounding_box([0,y_position], :width =>self.receipt_width, :height => self.item_height) do
+ bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
text "Customer:", :size => self.item_font_size,:align => :left
end
- bounding_box([self.receipt_width,y_position], :width =>self.receipt_width) do
+ bounding_box([self.label_width,y_position], :width =>self.item_width) do
text "#{customer_name}" , :size => self.item_font_size,:align => :left
end
move_down 5
y_position = cursor
- bounding_box([0,y_position], :width =>self.receipt_width, :height => self.item_height) do
- text "Date:", :size => self.item_font_size,:align => :left
+ bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
+ text "Date:", :size => self.item_font_size,:align => :left
end
- bounding_box([self.receipt_width,y_position], :width =>self.receipt_width) do
- text "#{sale_data.receipt_date.strftime('%Y %m %d %h:%m')}" , :size => self.item_font_size,:align => :left
+ bounding_box([self.label_width,y_position], :width => self.item_width) do
+ text "#{sale_data.receipt_date.strftime('%Y-%m-%d %I:%M %p')}" , :size => self.item_font_size,:align => :left
end
- # stroke_horizontal_rule
+
+ move_down 5
+ stroke_horizontal_rule
move_down 5
end
def line_items(sale_items, food_total, beverage_total)
y_position = cursor
- stroke_horizontal_rule
- move_down 5
-
pad_top(15) {
# @item_width.to_i + @half_qty.to_i
- text_box "Items", :at =>[0,y_position], :width => self.item_width - 20, :height =>self.item_height, :size => self.item_font_size
- text_box "Price", :at =>[self.item_width-20,y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right
- text_box "Qty", :at =>[self.item_width+self.price_width,y_position], :width => self.qty_width, :height =>self.item_height, :size => self.item_font_size, :align => :right
- text_box "Total", :at =>[self.item_width+self.price_width+self.qty_width,y_position], :width => self.total_width, :height =>self.item_height, :size => self.item_font_size, :align => :right
+ text_box "Items", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :size => self.item_font_size, :overflow => :shrink_to_fix
+ text_box "Price", :at =>[self.item_width,y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
+ text_box "Qty", :at =>[(self.item_width+self.price_width),y_position], :width => self.qty_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
+ text_box "Total", :at =>[(self.item_width+self.price_width+2),y_position], :width => self.total_width+2, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
}
@@ -99,88 +97,88 @@ class ReceiptBillPdf < Prawn::Document
add_line_item_row(sale_items, food_total, beverage_total)
-
end
def add_line_item_row(sale_items, food_total, beverage_total)
- item_name_width = self.item_width-20
+ item_name_width = (self.item_width+self.price_width)
y_position = cursor
move_down 5
sub_total = 0.0
- sale_items.each do |item|
+ sale_items.each do |item|
+ sub_total += (item.qty*item.unit_price)
+ qty = item.qty
+ total_price = item.qty*item.unit_price
+ price = item.unit_price
+ product_name = item.product_name
+
- sub_total += item.qty*item.unit_price
- qty = item.qty
- total_price = item.qty*item.unit_price
- price = item.unit_price
- product_name = item.product_name
-
+ y_position = cursor
- y_position = cursor
+ pad_top(15) {
+ # @item_width.to_i + @half_qty.to_i
+ text_box "#{product_name}", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :overflow => :shrink_to_fix, :size => self.item_font_size, :overflow => :shrink_to_fix
+ text_box "#{price}", :at =>[self.item_width,y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
+ text_box "#{qty.to_i}", :at =>[item_name_width,y_position], :width => self.qty_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
+ text_box "#{total_price}", :at =>[(item_name_width+2),y_position], :width =>self.total_width+2, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
- pad_top(15) {
- # @item_width.to_i + @half_qty.to_i
- text_box "#{product_name}", :at =>[0,y_position], :width => item_name_width, :height =>self.item_height, :overflow => :shrink_to_fix, :size => self.item_font_size
- text_box "#{price}", :at =>[item_name_width,y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right
- text_box "#{qty.to_i}", :at =>[item_name_width+self.price_width,y_position], :width => self.qty_width, :height =>self.item_height, :size => self.item_font_size, :align => :right
- text_box "#{total_price}", :at =>[item_name_width+self.price_width+self.qty_width,y_position], :width =>self.total_width, :height =>self.item_height, :size => self.item_font_size, :align => :right
-
- }
- move_down 3
- end
+ }
+ move_down 3
+ end
stroke_horizontal_rule
move_down 5
y_position = cursor
- bounding_box([0,y_position], :width =>(item_name_width+self.price_width+self.qty_width), :height => self.item_height) do
+ bounding_box([0,y_position], :width =>item_name_width, :height => self.item_height) do
text "Sub Total", :size => self.item_font_size,:align => :left
end
- bounding_box([(item_name_width+self.price_width+self.qty_width),y_position], :width =>self.total_width) do
- text "#{sub_total}" , :size => self.item_font_size,:align => :right
+ bounding_box([item_name_width,y_position], :width =>self.total_width) do
+ text "#{ sub_total }" , :size => self.item_font_size,:align => :right
end
# Food and Beverage
- food_beverage_total = food_total.to_s + '/' + beverage_total.to_s
+ food_beverage_total = food_total.to_s + "/" + beverage_total.to_s
+
move_down 5
+
y_position = cursor
- bounding_box([0,y_position], :width =>(item_name_width+self.price_width+self.qty_width), :height => self.item_height) do
+ bounding_box([0,y_position], :width =>(item_name_width), :height => self.item_height) do
text "Food/Beverage Total", :size => self.item_font_size,:align => :left
end
- bounding_box([(item_name_width+self.price_width+self.qty_width),y_position], :width =>self.total_width) do
+ bounding_box([item_name_width,y_position], :width =>self.total_width) do
text "#{ food_beverage_total }" , :size => self.item_font_size,:align => :right
end
end
def all_total(sale_data)
- item_name_width = self.item_width-20
+ item_name_width = self.item_width
move_down 5
y_position = cursor
- bounding_box([0,y_position], :width =>(item_name_width+self.price_width+self.qty_width), :height => self.item_height) do
+ bounding_box([0,y_position], :width =>(item_name_width+self.price_width), :height => self.item_height) do
text "Discount", :size => self.item_font_size,:align => :left
end
- bounding_box([(item_name_width+self.price_width+self.qty_width),y_position], :width =>self.total_width) do
+ bounding_box([(item_name_width+self.price_width),y_position], :width =>self.total_width) do
text "( " +"#{sale_data.total_discount}" +" )" , :size => self.item_font_size,:align => :right
end
move_down 5
y_position = cursor
- bounding_box([0,y_position], :width =>(item_name_width+self.price_width+self.qty_width), :height => self.item_height) do
+ bounding_box([0,y_position], :width =>(item_name_width+self.price_width), :height => self.item_height) do
text "Total Tax", :size => self.item_font_size,:align => :left
end
- bounding_box([(item_name_width+self.price_width+self.qty_width),y_position], :width =>self.total_width) do
+ bounding_box([(item_name_width+self.price_width),y_position], :width =>self.total_width) do
text "( " +"#{sale_data.total_tax}" +" )" , :size => self.item_font_size,:align => :right
end
move_down 5
y_position = cursor
move_down 5
- bounding_box([0,y_position], :width =>(item_name_width+self.price_width+self.qty_width), :height => self.item_height) do
+ bounding_box([0,y_position], :width =>(item_name_width+self.price_width), :height => self.item_height) do
text "Grand Total", :size => self.item_font_size,:align => :left
end
- bounding_box([(item_name_width+self.price_width+self.qty_width),y_position], :width =>self.total_width) do
+ bounding_box([(item_name_width+self.price_width),y_position], :width =>self.total_width) do
text "#{sale_data.grand_total}" , :size => self.item_font_size,:align => :right
end
move_down 5
@@ -188,4 +186,14 @@ class ReceiptBillPdf < Prawn::Document
end
+ def footer
+ move_down 5
+ stroke_horizontal_rule
+ move_down 5
+
+ text "*** Thank You ***", :left_margin => -10, :size => self.header_font_size,:align => :center
+
+ move_down 5
+ end
+
end
diff --git a/app/views/crm/customers/_error_messages.html.erb b/app/views/crm/customers/_error_messages.html.erb
new file mode 100644
index 00000000..bbff284b
--- /dev/null
+++ b/app/views/crm/customers/_error_messages.html.erb
@@ -0,0 +1,9 @@
+
+
+ Select Member Group
+ <% @member_group.each do |member| %>
+ ">
+ <%= member["name"] %>
+ <%end %>
+
+
diff --git a/app/views/crm/customers/index.html.erb b/app/views/crm/customers/index.html.erb
index e4f6d07d..9f62b55b 100644
--- a/app/views/crm/customers/index.html.erb
+++ b/app/views/crm/customers/index.html.erb
@@ -51,7 +51,7 @@
<%= crm_customer.contact_no %>
<%= crm_customer.email %>
- <%= link_to 'Destroy', crm_customer_path(crm_customer), method: :delete, data: { confirm: 'Are you sure?' } %>
+ <%= link_to 'Show', crm_customer_path(crm_customer) %>
@@ -71,7 +71,6 @@
<%= simple_form_for @crm_customer,:url => crm_customers_path, :method => :post do |f| %>
-
<%= f.error_notification %>
<%= f.hidden_field :id, :class => "form-control col-md-6 " %>
@@ -94,17 +93,20 @@
Date Of Birth
- <%= f.text_field :date_of_birth,:class=>"form-control date_of_birth datepicker"%>
+ <%= f.text_field :date_of_birth,:class => "form-control datepicker date_of_birth "%>
+
+
+ Select Member Group
+ <% Lookup.where("lookup_type = ?", "member_group_type" ).each do |member| %>
+
+ <%= member.name %>
+ <%end %>
+
+
+
-
+
+
+
-<%= link_to 'Edit', edit_crm_customer_path(@crm_customer) %> |
-<%= link_to 'Back', crm_customers_path %>
diff --git a/app/views/kaminari/_first_page.html.erb b/app/views/kaminari/_first_page.html.erb
new file mode 100644
index 00000000..2682d341
--- /dev/null
+++ b/app/views/kaminari/_first_page.html.erb
@@ -0,0 +1,11 @@
+<%# Link to the "First" page
+ - available local variables
+ url: url to the first page
+ current_page: a page object for the currently displayed page
+ total_pages: total number of pages
+ per_page: number of items to fetch per page
+ remote: data-remote
+-%>
+
+ <%= link_to_unless current_page.first?, t('views.pagination.first').html_safe, url, :remote => remote %>
+
diff --git a/app/views/kaminari/_gap.html.erb b/app/views/kaminari/_gap.html.erb
new file mode 100644
index 00000000..bbb0f983
--- /dev/null
+++ b/app/views/kaminari/_gap.html.erb
@@ -0,0 +1,8 @@
+<%# Non-link tag that stands for skipped pages...
+ - available local variables
+ current_page: a page object for the currently displayed page
+ total_pages: total number of pages
+ per_page: number of items to fetch per page
+ remote: data-remote
+-%>
+<%= t('views.pagination.truncate').html_safe %>
diff --git a/app/views/kaminari/_last_page.html.erb b/app/views/kaminari/_last_page.html.erb
new file mode 100644
index 00000000..53d61307
--- /dev/null
+++ b/app/views/kaminari/_last_page.html.erb
@@ -0,0 +1,11 @@
+<%# Link to the "Last" page
+ - available local variables
+ url: url to the last page
+ current_page: a page object for the currently displayed page
+ total_pages: total number of pages
+ per_page: number of items to fetch per page
+ remote: data-remote
+-%>
+
+ <%= link_to_unless current_page.last?, t('views.pagination.last').html_safe, url, :remote => remote %>
+
diff --git a/app/views/kaminari/_next_page.html.erb b/app/views/kaminari/_next_page.html.erb
new file mode 100644
index 00000000..4fc20712
--- /dev/null
+++ b/app/views/kaminari/_next_page.html.erb
@@ -0,0 +1,11 @@
+<%# Link to the "Next" page
+ - available local variables
+ url: url to the next page
+ current_page: a page object for the currently displayed page
+ total_pages: total number of pages
+ per_page: number of items to fetch per page
+ remote: data-remote
+-%>
+
+ <%= link_to_unless current_page.last?, t('views.pagination.next').html_safe, url, :rel => 'next', :remote => remote %>
+
diff --git a/app/views/kaminari/_page.html.erb b/app/views/kaminari/_page.html.erb
new file mode 100644
index 00000000..582af7bc
--- /dev/null
+++ b/app/views/kaminari/_page.html.erb
@@ -0,0 +1,12 @@
+<%# Link showing page number
+ - available local variables
+ page: a page object for "this" page
+ url: url to this page
+ current_page: a page object for the currently displayed page
+ total_pages: total number of pages
+ per_page: number of items to fetch per page
+ remote: data-remote
+-%>
+
+ <%= link_to_unless page.current?, page, url, {:remote => remote, :rel => page.next? ? 'next' : page.prev? ? 'prev' : nil} %>
+
diff --git a/app/views/kaminari/_paginator.html.erb b/app/views/kaminari/_paginator.html.erb
new file mode 100644
index 00000000..4fb445fd
--- /dev/null
+++ b/app/views/kaminari/_paginator.html.erb
@@ -0,0 +1,23 @@
+<%# The container tag
+ - available local variables
+ current_page: a page object for the currently displayed page
+ total_pages: total number of pages
+ per_page: number of items to fetch per page
+ remote: data-remote
+ paginator: the paginator that renders the pagination tags inside
+-%>
+<%= paginator.render do -%>
+
+<% end -%>
diff --git a/app/views/kaminari/_prev_page.html.erb b/app/views/kaminari/_prev_page.html.erb
new file mode 100644
index 00000000..9c4aff49
--- /dev/null
+++ b/app/views/kaminari/_prev_page.html.erb
@@ -0,0 +1,11 @@
+<%# Link to the "Previous" page
+ - available local variables
+ url: url to the previous page
+ current_page: a page object for the currently displayed page
+ total_pages: total number of pages
+ per_page: number of items to fetch per page
+ remote: data-remote
+-%>
+
+ <%= link_to_unless current_page.first?, t('views.pagination.previous').html_safe, url, :rel => 'prev', :remote => remote %>
+
diff --git a/app/views/origami/customers/index.html.erb b/app/views/origami/customers/index.html.erb
new file mode 100644
index 00000000..070d6d26
--- /dev/null
+++ b/app/views/origami/customers/index.html.erb
@@ -0,0 +1,233 @@
+
+
+
+
+
+
+
+
+
+
+
+ <%= paginate @crm_customers %>
+
+
+
+
+
+
+ <%= simple_form_for @crm_customer,:url => crm_customers_path, :method => :post do |f| %>
+
+
+
+ <%= f.error_notification %>
+ <%= f.hidden_field :id, :class => "form-control col-md-6 " %>
+
+
+ <%= f.input :name, :class => "form-control col-md-6 name" %>
+
+
+
+ <%= f.input :company, :class => "form-control col-md-6 company" %>
+
+
+ <%= f.input :contact_no, :class => "form-control col-md-6 contact_no" %>
+
+
+
+
+
+ <%= f.input :email, :class => "form-control col-md-6 email" %>
+
+
+
+ Date Of Birth
+ <%= f.text_field :date_of_birth,:class=>"form-control date_of_birth datepicker"%>
+
+
+
+
+ Select Member Group
+ <% Lookup.where("lookup_type = ?", "member_group_type" ).each do |member| %>
+
+ <%= member.name %>
+ <%end %>
+
+
+
+
+
+
+
+
+
+ <%= f.button :submit, "Submit",:class => 'btn btn-primary ', :id => 'submit_customer' %>
+ <%= f.button :submit, "Update",:class => 'btn btn-primary ', :disabled =>'', :id => 'update_customer' %>
+
+ <%end%>
+
+
+
+
+
+
+
+
+
+
diff --git a/app/views/origami/discounts/index.html.erb b/app/views/origami/discounts/index.html.erb
index 65b376d8..4f6b7c9a 100644
--- a/app/views/origami/discounts/index.html.erb
+++ b/app/views/origami/discounts/index.html.erb
@@ -4,7 +4,7 @@
-
@@ -13,10 +13,10 @@
<%=@sale_data.sale_id %>
Receipt No: <%=@sale_data.receipt_no rescue ' '%>
-
+
Date: <%=@sale_data.receipt_date.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%>
-
+
-
+
@@ -88,7 +88,7 @@
-
+
@@ -125,12 +125,12 @@
10%
@@ -138,12 +138,12 @@
20%
@@ -151,12 +151,12 @@
30%
-
+
-
+
diff --git a/app/views/origami/home/index.html.erb b/app/views/origami/home/index.html.erb
index 394d494b..0332fa12 100644
--- a/app/views/origami/home/index.html.erb
+++ b/app/views/origami/home/index.html.erb
@@ -23,37 +23,44 @@
- <%
- @completed_orders.each do |cpo|
+ <%
+ @completed_orders.each do |cpo|
# ToDo no need check new
# Assigned Id for new Order? Sale?
- unique_id=""
+ unique_id = ""
+ customer_id = ""
+
# For CSS- Class for Order? Sale?
sale_status=""
- if cpo.order_status == 'new'
+ if cpo.order_status == 'new'
unique_id=cpo.booking_id
- # check selected item and assign
- if @selected_item != nil
+
+ customer_id=cpo.order_customer_id
+ # check selected item and assign
+ if @selected_item != nil
if cpo.order_id == @selected_item.order_id
sale_status = sale_status + " selected-item"
end
end
- else
+ else
unique_id=cpo.sale_id
+ customer_id=cpo.sale_customer_id
sale_status="paid"
- # check selected item and assign
+ # check selected item and assign
if @selected_item != nil
if unique_id == @selected_item.sale_id
sale_status = sale_status + " selected-item"
end
end
- end
+ end
%>
-
<%= unique_id %>
-
<%= bko.customer_id %>
-
<%= cpo.table_name %>
+
+
<%= unique_id %>
+
<%= customer_id %>
+
<%= cpo.order_id %>
+
<%= cpo.table_name %>
Receipt No :
@@ -64,12 +71,12 @@
Order Status :
<%= cpo.order_status %>
-
+
-
-
-
- <%
+
+
+
+ <%
end
%>
@@ -78,34 +85,39 @@
- <%
- @booking_orders.each do |bko|
+ <%
+ @booking_orders.each do |bko|
# Assigned Id for new Order? Sale?
unique_id=""
+ customer_id=""
# For CSS- Class for Order? Sale?
sale_status=""
- if bko.order_status == 'new'
+ if bko.order_status == 'new'
unique_id=bko.booking_id
- # check selected item and assign
- if @selected_item != nil
+ customer_id=bko.order_customer_id
+ # check selected item and assign
+ if @selected_item != nil
if bko.order_id == @selected_item.order_id
sale_status = sale_status + " selected-item"
end
end
- else
+ else
unique_id=bko.sale_id
+ customer_id=bko.sale_customer_id
sale_status="sold"
- # check selected item and assign
+ # check selected item and assign
if @selected_item != nil
if unique_id == @selected_item.sale_id
sale_status = sale_status + " selected-item"
end
end
- end
+ end
%>
<%= unique_id %>
+
<%= customer_id %>
+
<%= bko.order_id %>
<%= bko.table_name %>
Receipt No :
@@ -135,34 +147,37 @@
@booking_rooms.each do |rmo|
# Assigned Id for new Order? Sale?
unique_id=""
+ customer_id=""
# For CSS- Class for Order? Sale?
sale_status=""
- if rmo.order_status == 'new'
+ if rmo.order_status == 'new'
unique_id=rmo.booking_id
- # check selected item and assign
- if @selected_item != nil
+ customer_id=rmo.order_customer_id
+ # check selected item and assign
+ if @selected_item != nil
if rmo.order_id == @selected_item.order_id
sale_status = sale_status + " selected-item"
- end
- end
- else
+ end
+ end
+ else
unique_id=rmo.sale_id
+ customer_id=rmo.sale_customer_id
sale_status="sold"
- # check selected item and assign
+ # check selected item and assign
if @selected_item != nil
if unique_id == @selected_item.sale_id
sale_status = sale_status + " selected-item"
end
end
- end
+ end
%>
<%= unique_id %>
-
<%= rmo.customer_id %>
-
<%= rmo.room_name %>
-
+
<%= customer_id %>
+
<%= rmo.order_id %>
+
<%= rmo.room_name %>
Receipt No :
@@ -186,40 +201,42 @@
-
- <%
- @orders.each do |odr|
+
+ <%
+ @orders.each do |odr|
# Assigned Id for new Order? Sale?
unique_id=""
+ customer_id=""
# 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
- # check selected item and assign
- if @selected_item != nil
+ customer_id = odr.order_customer_id
+ if @selected_item != nil
if odr.order_id == @selected_item.order_id
sale_status = sale_status + " selected-item"
end
end
- else
+ else
unique_id=odr.sale_id
- sale_status="sold"
- # check selected item and assign
- if @selected_item != nil
+ customer_id = odr.sale_customer_id
+ sale_status="sold"
+ # check selected item and assign
+ if @selected_item != nil
if unique_id == @selected_item.sale_id
sale_status = sale_status + " selected-item"
end
end
- end
+ end
%>
-
<%= unique_id %>
-
<%= odr.customer_id %>
-
<%= odr.table_name %>
-
-
+
<%= unique_id %>
+
<%= customer_id %>
+
<%= odr.order_id %>
+
<%= odr.table_name %>
Receipt No :
<%= odr.receipt_no %>
@@ -256,19 +273,19 @@
Receipt No: <%=@selected_item.receipt_no rescue ' '%>
-
+
Date: <%=@selected_item.receipt_date.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%>
-
+
+
@@ -280,7 +297,7 @@
- <%
+ <%
# For Sale Items
sub_total = 0
if @selected_item_type == "Sale"
@@ -288,16 +305,16 @@
sub_total += sale_item.qty*sale_item.unit_price
%>
- <%= sale_item.product_name %>
+ <%= sale_item.product_name %>
<%= sale_item.qty %>
<%= sale_item.qty*sale_item.price %>
- <%
+ <%
end
end
%>
- <%
+ <%
# For Order Items
sub_total = 0
if @selected_item_type == "Order"
@@ -305,11 +322,11 @@
sub_total += order_item.qty*order_item.unit_price
%>
- <%= order_item.item_name %>
+ <%= order_item.item_name %>
<%= order_item.qty %>
<%= order_item.qty*order_item.price %>
- <%
+ <%
end
end
%>
@@ -354,7 +371,8 @@
Add Order
Edit
Move
- Customer
+ Customer
+ Req.Bill
Req.Bill
Discount
diff --git a/app/views/origami/mpu/index.html.erb b/app/views/origami/mpu/index.html.erb
index f082dc1a..7b483a75 100644
--- a/app/views/origami/mpu/index.html.erb
+++ b/app/views/origami/mpu/index.html.erb
@@ -13,7 +13,7 @@ Amount :
var sale_id = "<%= @sale_id %>";
$.ajax({type: "POST",
- url: "<%= origami_create_mpu_payment_path %>",
+ url: "<%= origami_payment_mpu_path %>",
data: "amount="+ amount + "&sale_id="+ sale_id,
success:function(result){
if(result){
diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb
index 198b9518..f9ae06b7 100644
--- a/app/views/origami/payments/show.html.erb
+++ b/app/views/origami/payments/show.html.erb
@@ -6,8 +6,8 @@
- Receipt No : <%=@sale_data.receipt_no rescue ' '%>
- Receipt Date : <%=@sale_data.receipt_date.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%>
+ Receipt No : <%=@sale_data.receipt_no rescue ' '%>
+ Receipt Date : <%=@sale_data.receipt_date.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%>
Table No <% if @sale_data%>- <%=@sale_data.receipt_no%><% end %>
@@ -130,7 +130,7 @@
00
@@ -195,6 +195,10 @@ $(document).on('click', '.cashier_number', function(event){
$('#cash').text("0.0");
update_balance();
break;
+ case 'nett':
+ $('#cash').text($('#amount_due').text());
+ update_balance();
+ break;
}
event.handled = true;
} else {
@@ -216,7 +220,6 @@ $( document ).ready(function() {
});
$('#pay').click(function() {
-
if($('#balance').text() > 0){
alert(" Insufficient Amount!")
}else{
@@ -226,10 +229,15 @@ $( document ).ready(function() {
var card = $('#card').text();
var sale_id = $('#sale_id').text();
$.ajax({type: "POST",
- url: "<%= origami_payment_process_path %>",
+ url: "<%= origami_payment_cash_path %>",
data: "cash="+ cash + "&sale_id=" + sale_id,
success:function(result){
- alert("Thank you")
+ if($('#balance').text() < 0){
+ alert("Changed amount " + $('#balance').text() * (-1) )
+ }else{
+ alert("Thank you")
+ }
+
window.location.href = '/origami';
}
});
diff --git a/app/views/origami/redeem_payments/index.html.erb b/app/views/origami/redeem_payments/index.html.erb
index 72c09d4d..0ffa08e8 100644
--- a/app/views/origami/redeem_payments/index.html.erb
+++ b/app/views/origami/redeem_payments/index.html.erb
@@ -1,7 +1,7 @@