update customer amount

This commit is contained in:
Aung Myo
2017-06-13 10:36:40 +06:30
parent 92f1f80acb
commit c05a64bae7
13 changed files with 105 additions and 130 deletions

View File

@@ -95,6 +95,6 @@ gem 'httparty', '~> 0.15.5'
# gem 'momentjs-rails', '>= 2.9.0' # gem 'momentjs-rails', '>= 2.9.0'
# gem 'bootstrap-datepicker-rails' # gem 'bootstrap-datepicker-rails'
# gem 'momentjs-rails', '>= 2.9.0' # # gem 'momentjs-rails', '>= 2.9.0'
# gem 'bootstrap3-datetimepicker-rails', '~> 4.17.47' # gem 'bootstrap3-datetimepicker-rails'z
gem 'bootstrap-datepicker-rails' gem 'bootstrap-datepicker-rails'

View File

@@ -80,8 +80,8 @@ GEM
httparty (0.15.5) httparty (0.15.5)
multi_xml (>= 0.5.2) multi_xml (>= 0.5.2)
i18n (0.8.4) i18n (0.8.4)
jbuilder (2.6.4) jbuilder (2.7.0)
activesupport (>= 3.0.0) activesupport (>= 4.2.0)
multi_json (>= 1.2) multi_json (>= 1.2)
jquery-rails (4.3.1) jquery-rails (4.3.1)
rails-dom-testing (>= 1, < 3) rails-dom-testing (>= 1, < 3)
@@ -95,20 +95,20 @@ GEM
rb-inotify (~> 0.9, >= 0.9.7) rb-inotify (~> 0.9, >= 0.9.7)
loofah (2.0.3) loofah (2.0.3)
nokogiri (>= 1.5.9) nokogiri (>= 1.5.9)
mail (2.6.5) mail (2.6.6)
mime-types (>= 1.16, < 4) mime-types (>= 1.16, < 4)
method_source (0.8.2) method_source (0.8.2)
mime-types (3.1) mime-types (3.1)
mime-types-data (~> 3.2015) mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521) mime-types-data (3.2016.0521)
mini_portile2 (2.1.0) mini_portile2 (2.2.0)
minitest (5.10.2) minitest (5.10.2)
multi_json (1.12.1) multi_json (1.12.1)
multi_xml (0.6.0) multi_xml (0.6.0)
mysql2 (0.4.6) mysql2 (0.4.6)
nio4r (2.1.0) nio4r (2.1.0)
nokogiri (1.7.2) nokogiri (1.8.0)
mini_portile2 (~> 2.1.0) mini_portile2 (~> 2.2.0)
pdf-core (0.7.0) pdf-core (0.7.0)
prawn (2.2.2) prawn (2.2.2)
pdf-core (~> 0.7.0) pdf-core (~> 0.7.0)
@@ -179,7 +179,7 @@ GEM
activesupport (>= 3.2.1) activesupport (>= 3.2.1)
shoulda-matchers (3.1.1) shoulda-matchers (3.1.1)
activesupport (>= 4.0.0) activesupport (>= 4.0.0)
sidekiq (5.0.0) sidekiq (5.0.2)
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
connection_pool (~> 2.2, >= 2.2.0) connection_pool (~> 2.2, >= 2.2.0)
rack-protection (>= 1.5.0) rack-protection (>= 1.5.0)

View File

@@ -17,11 +17,7 @@
//= require turbolinks //= require turbolinks
//= require cable //= require cable
//= require settings/processing_items //= require settings/processing_items
//= require bootstrap-datepicker/core //= require bootstrap-datepicker
//= require bootstrap-datepicker/locales/bootstrap-datepicker.es
$(document).on("focus", "[data-behaviour~='datepicker']", function(e){
$(this).datepicker({"format": "yyyy-M-dd", "weekStart": 1, "autoclose": true});
$('.dropdown-toggle').dropdown();
});

View File

@@ -6,9 +6,9 @@
//= require_tree ./channels //= require_tree ./channels
// Temp Disable // Temp Disable
// (function() { (function() {
// this.App || (this.App = {}); this.App || (this.App = {});
// App.cable = ActionCable.createConsumer(); App.cable = ActionCable.createConsumer();
// }).call(this); }).call(this);

View File

@@ -0,0 +1,4 @@
$(document).on("focus", "[data-behaviour~='datepicker']", function(e){
$(this).datepicker({"format": "yyyy-M-dd", "weekStart": 1, "autoclose": true});
$('.dropdown-toggle').dropdown();
});

View File

View File

@@ -2,7 +2,7 @@
@import "bootstrap"; @import "bootstrap";
@import "font-awesome"; @import "font-awesome";
@import "theme"; @import "theme";
@import 'bootstrap-datepicker'; @import "bootstrap-datepicker";
/* Show it is fixed to the top */ /* Show it is fixed to the top */
// body { // body {

View File

@@ -10,13 +10,13 @@ class Crm::CustomersController < BaseCrmController
@crm_customers = Customer.order("customer_id").page(params[:page]) @crm_customers = Customer.order("customer_id").page(params[:page])
#@products = Product.order("name").page(params[:page]).per(5) #@products = Product.order("name").page(params[:page]).per(5)
else 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
end
#@crm_customers = Customer.all #@crm_customers = Customer.all
@crm_customer = Customer.new @crm_customer = Customer.new
if @crm_customer.valid?
@crm_customer.errors.messages
end # puts @crm_customer.valid?
# @membership = Customer.get_member_group # @membership = Customer.get_member_group
# if @membership["status"] == true # if @membership["status"] == true
# @member_group = @membership["data"] # @member_group = @membership["data"]
@@ -59,6 +59,7 @@ class Crm::CustomersController < BaseCrmController
@crm_customers = Customer.new(customer_params) @crm_customers = Customer.new(customer_params)
respond_to do |format| respond_to do |format|
puts @crm_customers.errors.to_json
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]
@@ -105,6 +106,7 @@ class Crm::CustomersController < BaseCrmController
if params[:sale_id] if params[:sale_id]
format.html { redirect_to '/origami/'+params[:sale_id]+'/add_customer'} format.html { redirect_to '/origami/'+params[:sale_id]+'/add_customer'}
else else
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 }
end end

View File

@@ -20,6 +20,31 @@ class Origami::PaymentsController < BaseOrigamiController
@cash = 0.0 @cash = 0.0
@other = 0.0 @other = 0.0
@sale_data = Sale.find_by_sale_id(sale_id) @sale_data = Sale.find_by_sale_id(sale_id)
#get customer amount
@customer = Customer.find(@sale_data.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'
}
)
@balance = 0.00
response["data"].each do |res|
if res["accountable_type"] == "RebateAccount"
@balance = res["balance"]
end
end
#end customer amount
@sale_data.sale_payments.each do |spay| @sale_data.sale_payments.each do |spay|
if spay.payment_method == "cash" if spay.payment_method == "cash"
@cash = spay.payment_amount @cash = spay.payment_amount

View File

@@ -244,21 +244,9 @@ class Order < ApplicationRecord
.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") .joins("left join sales on sales.sale_id = bookings.sale_id")
.where("sales.sale_status='completed'") .where("sales.sale_status='completed'")
<<<<<<< HEAD
.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")
end end
#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,
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 sales on sales.sale_id = bookings.sale_id")
.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 #Origami: Cashier : to view order type Room
def self.get_booking_order_rooms def self.get_booking_order_rooms

View File

@@ -66,25 +66,20 @@
</div> </div>
</div> </div>
<div class="col-lg-4"> <div class="col-lg-4">
<%= simple_form_for @crm_customer,:url => crm_customers_path, :method => :post do |f| %> <%= simple_form_for @crm_customer,:url => crm_customers_path, :method => :post do |f| %>
<span class="patch_method"></span> <span class="patch_method"></span>
<%= f.error_notification %>
<%= f.hidden_field :id, :class => "form-control col-md-6 " %> <%= f.hidden_field :id, :class => "form-control col-md-6 " %>
<div class="form-group"> <div class="form-group">
<%= f.input :name, :class => "form-control col-md-6 name" %> <%= f.input :name, :class => "form-control col-md-6 name" %>
</div> </div>
<div class="form-group"> <div class="form-group">
<%= f.input :company, :class => "form-control col-md-6 company" %> <%= f.input :company, :class => "form-control col-md-6 company" %>
</div> </div>
<div class="form-group"> <div class="form-group">
<%= f.input :contact_no, :class => "form-control col-md-6 contact_no" %> <%= f.input :contact_no, :class => "form-control col-md-6 contact_no" %>
</div> </div>
<div class="form-group"> <div class="form-group">
@@ -92,11 +87,11 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<label>Date Of Birth</label> <%= f.input :date_of_birth,:class=>"form-control date_of_birth"%>
<%= f.text_field :date_of_birth,:class => "form-control datepicker date_of_birth "%>
</div> </div>
<div class="form-group"> <div class="form-group">
<label>Select Member Group</label>
<select class="selectpicker form-control col-md-12" name="member_group_id"> <select class="selectpicker form-control col-md-12" name="member_group_id">
<option>Select Member Group</option> <option>Select Member Group</option>
<% Lookup.where("lookup_type = ?", "member_group_type" ).each do |member| %> <% Lookup.where("lookup_type = ?", "member_group_type" ).each do |member| %>
@@ -115,21 +110,8 @@
</div> </div>
</div> </div>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.2.0/jquery-confirm.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.2.0/jquery-confirm.min.js"></script>
<script type="text/javascript"> <script type="text/javascript">
$(function () {
if (jQuery().datepicker) {
$('.datepicker').datepicker({
format : 'dd-mm-yyyy',
autoclose: true
});
$('.datepicker').attr('ReadOnly','true');
$('.datepicker').css('cursor','pointer');
}
});
$(document).on('click',".checkbox_check",function(){ $(document).on('click',".checkbox_check",function(){
if(this.checked){ if(this.checked){
@@ -137,13 +119,13 @@
var sale_id = $("#sale_id").val() || 0; var sale_id = $("#sale_id").val() || 0;
var customer_id = $(this).val(); var customer_id = $(this).val();
if(sale_id != 0){ // if(sale_id != 0){
// var url = "/"+customer_id; // // var url = "/"+customer_id;
update_sale(customer_id,sale_id); // update_sale(customer_id,sale_id);
}else{ // }else{
var url = "customers/"+customer_id; // var url = "customers/"+customer_id;
} // }
$.ajax({ $.ajax({
type: "GET", type: "GET",
@@ -179,43 +161,43 @@
} }
}) })
function update_sale(customer_id,sale_id) { // function update_sale(customer_id,sale_id) {
$.confirm({ // $.confirm({
title: 'Confirm!', // title: 'Confirm!',
content: 'Are You Sure to assign this customer!', // content: 'Are You Sure to assign this customer!',
buttons: { // buttons: {
cancel: function () { // cancel: function () {
}, // },
confirm: { // confirm: {
text: 'Confirm', // text: 'Confirm',
btnClass: 'btn-green', // btnClass: 'btn-green',
keys: ['enter', 'shift'], // keys: ['enter', 'shift'],
action: function(){ // action: function(){
$.ajax({ // $.ajax({
type: "POST", // type: "POST",
url: "update_sale/" , // url: "update_sale/" ,
data: {customer_id:customer_id,sale_id:sale_id}, // data: {customer_id:customer_id,sale_id:sale_id},
dataType: "json", // dataType: "json",
success: function(data) { // success: function(data) {
if(data.status == true) // if(data.status == true)
{ // {
alert('Customer has assigned'); // alert('Customer has assigned');
window.location.href = '/origami' // window.location.href = '/origami'
}else{ // }else{
alert('Record not found!'); // alert('Record not found!');
location.reload(); // location.reload();
} // }
} // }
}); // });
} // }
} // }
} // }
}); // });
} // }
</script> </script>

View File

@@ -38,6 +38,7 @@
<th>Company</th> <th>Company</th>
<th>Contact no</th> <th>Contact no</th>
<th>Email</th> <th>Email</th>
<th>Date of Birth</th>
</tr> </tr>
</thead> </thead>
@@ -47,11 +48,11 @@
<td> <td>
<input type="radio" style="width:20px;" value="<%= crm_customer.customer_id %>" name="checkbox" class="checkbox_check" ></td> <input type="radio" style="width:20px;" value="<%= crm_customer.customer_id %>" name="checkbox" class="checkbox_check" ></td>
<td><%= crm_customer.name %></td> <td><%= crm_customer.name %></td>
<td><%= crm_customer.company %></td> <td><%= crm_customer.company rescue '-' %></td>
<td><%= crm_customer.contact_no %></td> <td><%= crm_customer.contact_no %></td>
<td><%= crm_customer.email %></td> <td><%= crm_customer.email %></td>
<td> <td>
<%= link_to 'Destroy', crm_customer_path(crm_customer), method: :delete, data: { confirm: 'Are you sure?' } %> <%= crm_customer.date_of_birth rescue '-' %>
</td> </td>
@@ -84,8 +85,6 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<%= f.input :contact_no, :class => "form-control col-md-6 contact_no" %> <%= f.input :contact_no, :class => "form-control col-md-6 contact_no" %>
</div> </div>
<div class="form-group"> <div class="form-group">
@@ -93,11 +92,11 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<label>Date Of Birth</label> <%= f.input :date_of_birth,:class=>"form-control date_of_birth"%>
<%= f.text_field :date_of_birth,:class=>"form-control date_of_birth datepicker"%>
</div> </div>
<div class="form-group"> <div class="form-group">
<label>Select Member Group</label>
<select class="selectpicker form-control col-md-12" name="member_group_id"> <select class="selectpicker form-control col-md-12" name="member_group_id">
<option>Select Member Group</option> <option>Select Member Group</option>
<% Lookup.where("lookup_type = ?", "member_group_type" ).each do |member| %> <% Lookup.where("lookup_type = ?", "member_group_type" ).each do |member| %>
@@ -107,19 +106,9 @@
</select> </select>
</div> </div>
<!-- <div class="form-group">
<%= f.input :membership_type, :class => "form-control col-md-6 membership_type" %>
</div>
<div class="form-group">
<%= f.input :membership_authentication_code, :class => "form-control col-md-6 membership_authentication_code" %>
</div> -->
<div class="form-group"> <div class="form-group">
<%= f.button :submit, "Submit",:class => 'btn btn-primary ', :id => 'submit_customer' %> <%= f.button :submit, "Submit",:class => 'btn btn-primary ', :id => 'submit_customer' %>
<%= f.button :submit, "Update",:class => 'btn btn-primary ', :disabled =>'', :id => 'update_customer' %> <!-- <%= f.button :submit, "Update",:class => 'btn btn-primary ', :disabled =>'', :id => 'update_customer' %> -->
</div> </div>
<%end%> <%end%>
</div> </div>
@@ -128,17 +117,6 @@
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.2.0/jquery-confirm.min.css"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.2.0/jquery-confirm.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.2.0/jquery-confirm.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.2.0/jquery-confirm.min.js"></script>
<script type="text/javascript"> <script type="text/javascript">
$(function () {
if (jQuery().datepicker) {
$('.datepicker').datepicker({
format : 'dd-mm-yyyy',
autoclose: true
});
$('.datepicker').attr('ReadOnly','true');
$('.datepicker').css('cursor','pointer');
}
});
$(document).on('click',".checkbox_check",function(){ $(document).on('click',".checkbox_check",function(){
if(this.checked){ if(this.checked){

View File

@@ -14,8 +14,8 @@
<td><strong>Sale Id</strong> </span><span id="sale_id"><% if @sale_data %><%=@sale_data.sale_id %><% end %></td> <td><strong>Sale Id</strong> </span><span id="sale_id"><% if @sale_data %><%=@sale_data.sale_id %><% end %></td>
</tr> </tr>
<tr> <tr>
<td><strong>Customer :</strong> Default Customer</td> <td><strong>Customer :</strong> <%= @sale_data.customer.name%></td>
<td><strong>Points :</strong> 1234 </td> <td><strong>Points :</strong> <%= @balance %> </td>
</tr> </tr>
</table> </table>
</div> </div>