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

@@ -143,7 +143,7 @@ $(document).ready(function(){
});
// Payment for Bill
$('#pay').click(function() {
$('#pay-bill').click(function() {
var sale_id=$(".selected-item").find(".orders-id").text();
if(sale_id!=""){
window.location.href = '/origami/sale/'+ sale_id + "/payment"
@@ -160,10 +160,9 @@ $(document).ready(function(){
window.location.href = '/crm/customers/'+ sale_id + "/assign_sale_id"
return false;
});
});
/* For Receipt - Calculate discount or tax */
$(document).on('click', '.cashier_number', function(event){
/* For Receipt - Calculate discount or tax */
$('.cashier_number').on('click', function(event){
if(event.handled !== true) {
var original_value=0;
original_value = $('#discount-amount').val();
@@ -206,6 +205,8 @@ $(document).on('click', '.cashier_number', function(event){
} else {
return false;
}
});
});
/* 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
if (params[:booking_id])
@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])
@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

View File

@@ -63,8 +63,6 @@ class Crm::CustomersController < ApplicationController
)
if response["status"] == true
puts "hhhhhhhhhhhhhhhhhh"
puts params[:sale_id]
customer = Customer.find(@crm_customers.customer_id)
status = customer.update_attributes(membership_id: response["customer_datas"]["id"])
if params[:sale_id] != 0
@@ -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)
end
end

View File

@@ -10,7 +10,7 @@ class Origami::PaymentsController < BaseOrigamiController
if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id)
sale_payment = SalePayment.new
sale_payment.process_payment(saleObj, @user, cash)
sale_payment.process_payment(saleObj, @user, cash, "cash")
end
end
@@ -18,6 +18,11 @@ class Origami::PaymentsController < BaseOrigamiController
sale_id = params[:sale_id]
if Sale.exists?(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

View File

@@ -17,10 +17,12 @@ class Settings::MembershipActionsController < ApplicationController
sale_data = Sale.find_by_sale_id(@sale_id)
if 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
@campaign_type_id =1
if !@membership_id.nil?
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)
if membership_data["status"]==true
@membership_rebate_balance=membership_data["balance"]

View File

@@ -3,7 +3,6 @@ class Sale < ApplicationRecord
#primary key - need to be unique generated for multiple shops
before_create :generate_custom_id
#before_create :generate_receipt_no
belongs_to :cashier, :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}'") }
def generate_invoice_from_booking(booking_id, requested_by)
puts "get invoice from booking"
booking = Booking.find(booking_id)
status = false
Rails.logger.debug "Booking -> " + booking.id.to_s
@@ -33,7 +31,6 @@ class Sale < ApplicationRecord
booking.sale_id = sale_id
end
order = booking.booking_orders.take.order
puts "add sale order"
link_order_sale(order.id)
return status, sale_id
end
@@ -233,7 +230,8 @@ class Sale < ApplicationRecord
saleOrder = SaleOrder.where("sale_id=? and order_id=?", self.id, order_id).take
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
# if (SaleOrder.where("sale_id = #{self.id} and order_id=#{order_id}").nil?)
# SaleOrder.create(:sale_id => self.id, :order_id => order_id)
@@ -261,6 +259,7 @@ class Sale < ApplicationRecord
end
private
def generate_custom_id
self.sale_id = SeedGenerator.generate_id(self.class.name, "SAL")
end

View File

@@ -2,13 +2,22 @@ class SaleOrder < ApplicationRecord
self.primary_key = "sale_order_id"
#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 :order
def create_sale_order(sale, order)
self.sale_id = sale
self.order_id = order
self.save
end
private
def generate_custom_id
self.sale_order_id = SeedGenerator.generate_id(self.class.name, "SOI")
def generate_sale_order_id
self.class.name
saleOrderId = SeedGenerator.generate_id(self.class.name, "SOI")
self.sale_order_id = saleOrderId
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
def process_payment(invoice, action_by, cash_amount,payment_method)
def process_payment(invoice, action_by, cash_amount, payment_method)
self.sale = invoice
self.received_amount = cash_amount
@@ -103,7 +103,7 @@ class SalePayment < ApplicationRecord
payment_status = false
self.payment_method = "cash"
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"
payment_method = self.save!
@@ -200,16 +200,28 @@ class SalePayment < ApplicationRecord
sale_update_payment_status(0)
end
return payment_status
end
def sale_update_payment_status(paid_amount)
puts "sale update"
#update amount_outstanding
self.sale.amount_received = self.sale.amount_received + paid_amount
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_received = self.sale.amount_received.to_f + paid_amount.to_f
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.sale_status = "completed"
self.sale.save!

View File

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

View File

@@ -20,6 +20,7 @@
<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 "Tax Profile", settings_tax_profiles_path, :tabindex =>"-1" %></li>
<li><%= link_to "Print Setting", print_settings_path, :tabindex =>"-1" %></li>
</ul>
</li>
@@ -30,9 +31,14 @@
<li><%= link_to "Sales ", crm_root_path, :tabindex =>"-1" %></li>
</ul>
</li>
<!-- <li class="navbar-nav mr-auto">
Reports
</li> -->
<li class="navbar-nav mr-auto dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">&nbsp;&nbsp;&nbsp;Reports</a>
<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>
</div>

View File

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

View File

@@ -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>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>
<!-- Cashier Buttons -->
<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>
</div>
</div>

View File

@@ -86,7 +86,7 @@
</div>
</div>
<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>
@@ -133,7 +133,6 @@ $(document).on('click', '.cashier_number', function(event){
// return false;
// }
});
$("#REDIMREBATE").click(function(){
$('.rebate-form').removeAttr("hidden");
gateway_url = $(this).attr("data-url");

View File

@@ -78,7 +78,7 @@
<hr>
<div class="row">
<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>
<hr>
<div class="row" id="credit_payment">
@@ -165,8 +165,6 @@
<script>
$(document).on('click', '.cashier_number', function(event){
event.stopPropagation();
event.preventDefault();
if(event.handled !== true) {
var original_value;
original_value = $('#cash').text();
@@ -184,14 +182,17 @@ $(document).on('click', '.cashier_number', function(event){
update_balance();
}
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();
@@ -233,7 +234,6 @@ $( document ).ready(function() {
alert("THANK YOU")
}
});
}
});

View File

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

View File

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

View File

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

View File

@@ -1,8 +1,8 @@
class CreateSaleOrders < ActiveRecord::Migration[5.1]
def change
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 :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_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(
# {name: "Beauty In The Pot", address: "address", township: "Yangon", city: "Yangon", state: "Yangon",