Merge branch 'august_spring' of bitbucket.org:code2lab/sxrestaurant into august_spring
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
class Origami::InJutiesController < BaseOrigamiController
|
||||
before_action :set_in_juty, only: [:show, :edit, :update, :destroy]
|
||||
before_action :set_in_juty, only: [:show, :edit, :update,:edit_in_juty, :update_for_in_juty , :destroy ,:destroy_in_juty]
|
||||
|
||||
# GET /in_juties
|
||||
# GET /in_juties.json
|
||||
@@ -7,6 +7,9 @@ class Origami::InJutiesController < BaseOrigamiController
|
||||
@in_juties = InJuty.all
|
||||
end
|
||||
|
||||
def index_in_juty
|
||||
@juties_in= InJuty.where("dinning_id=?",params[:table_id])
|
||||
end
|
||||
# GET /in_juties/1
|
||||
# GET /in_juties/1.json
|
||||
def show
|
||||
@@ -21,6 +24,14 @@ class Origami::InJutiesController < BaseOrigamiController
|
||||
def edit
|
||||
end
|
||||
|
||||
def edit_in_juty
|
||||
@table = DiningFacility.find(params[:table_id])
|
||||
end
|
||||
|
||||
def assign_in_juty
|
||||
@in_juty = InJuty.new
|
||||
@table = DiningFacility.find(params[:table_id])
|
||||
end
|
||||
# POST /in_juties
|
||||
# POST /in_juties.json
|
||||
def create
|
||||
@@ -37,6 +48,15 @@ class Origami::InJutiesController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
|
||||
def create_for_in_juty
|
||||
|
||||
@in_juty.dinning_id = params[:dining_id]
|
||||
@in_juty.commissioner_ids = params[:commissioner_ids]
|
||||
@in_juty.in_time = params[:in_time]
|
||||
@in_juty.out_time = params[:out_time]
|
||||
@in_juty.save
|
||||
end
|
||||
|
||||
# PATCH/PUT /in_juties/1
|
||||
# PATCH/PUT /in_juties/1.json
|
||||
def update
|
||||
@@ -51,6 +71,15 @@ class Origami::InJutiesController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def update_for_in_juty
|
||||
@in_juty.dinning_id = params[:dining_id]
|
||||
@in_juty.commissioner_ids = params[:commissioner_ids]
|
||||
@in_juty.in_time = params[:in_time]
|
||||
@in_juty.out_time = params[:out_time]
|
||||
@in_juty.update
|
||||
end
|
||||
|
||||
# DELETE /in_juties/1
|
||||
# DELETE /in_juties/1.json
|
||||
def destroy
|
||||
@@ -61,6 +90,14 @@ class Origami::InJutiesController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
|
||||
def destroy_in_juty
|
||||
@in_juty.destroy
|
||||
respond_to do |format|
|
||||
format.html { redirect_to origami_in_juties_path, notice: 'In juty was successfully destroyed.' }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_in_juty
|
||||
|
||||
@@ -120,6 +120,10 @@ class Promotion < ApplicationRecord
|
||||
def self.give_promotion_second_product(orderitem_count, foc_min_qty, promo_product, orderitem, sale_id)
|
||||
puts "..... orderitem_count: " + orderitem_count.to_s + " / foc_min_qty: " + foc_min_qty.to_s + " /promo_product: " + promo_product + " orderitem: " + orderitem.to_s
|
||||
promotion_qty = orderitem_count.to_i / foc_min_qty.to_i # get foc item qty
|
||||
foc_qty = find_second_item_qty(sale_id, promo_product)
|
||||
if (foc_qty < promotion_qty)
|
||||
promotion_qty = foc_qty
|
||||
end
|
||||
item = OrderItem.find_by_item_code(promo_product)
|
||||
update_existing_item(promotion_qty, item, sale_id, "promotion", item.price)
|
||||
end
|
||||
@@ -135,13 +139,15 @@ class Promotion < ApplicationRecord
|
||||
sale_item.qty = foc_qty * (-1)
|
||||
|
||||
sale_item.unit_price = item_price * (-1)
|
||||
sale_item.taxable_price = item_price
|
||||
sale_item.taxable_price = item_price * (-1)
|
||||
sale_item.price = foc_qty * item_price * (-1)
|
||||
|
||||
sale_item.is_taxable = item.taxable
|
||||
sale_item.is_taxable = false
|
||||
sale_item.sale_id = sale_id
|
||||
|
||||
sale_item.save
|
||||
sale = Sale.find(sale_id).
|
||||
sale.compute_by_sale_items(sale.id, sale.sale_items, sale.total_discount)
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -183,6 +183,7 @@ class Sale < ApplicationRecord
|
||||
sale_item.sale_id = self.id
|
||||
sale_item.price = diningprice
|
||||
sale_item.save
|
||||
self.compute
|
||||
end
|
||||
|
||||
def update_item (item)
|
||||
@@ -214,10 +215,11 @@ class Sale < ApplicationRecord
|
||||
|
||||
sales_items.each do |item|
|
||||
#compute each item and added to total
|
||||
puts "item.sales_item_id ddd"
|
||||
puts item.sale_item_id
|
||||
subtotal_price = subtotal_price + item.price
|
||||
total_taxable = total_taxable + (item.taxable_price * item.qty)
|
||||
end
|
||||
|
||||
apply_tax (total_taxable)
|
||||
self.total_amount = subtotal_price
|
||||
self.total_discount = total_discount
|
||||
|
||||
@@ -333,6 +333,7 @@
|
||||
<button type="button" id="discount" class="btn btn-primary btn-block">Discount</button>
|
||||
<button type="button" id="other-charges" class="btn btn-primary btn-block">Charges</button>
|
||||
<button type="button" id="commissions" class="btn btn-primary btn-block">Commissions</button>
|
||||
<button type="button" id="in_juties" class="btn btn-primary btn-block">In Juties</button>
|
||||
<button type="button" class="btn btn-primary btn-block" id='move' disabled="">Move</button>
|
||||
<button type="button" id="request_bills" class="btn btn-primary btn-block" disabled> Req.Bill</button>
|
||||
<button type="button" id="first_bill" class="btn btn-primary btn-block">First Bill</button>
|
||||
@@ -579,6 +580,11 @@
|
||||
window.location.href = '/origami/table/' + dining_id + "/sale/" + sale_id + "/load_commissioners";
|
||||
});
|
||||
|
||||
$('#in_juties').on('click', function () {
|
||||
var dining_id = "<%= @dining.id %>"
|
||||
window.location.href = '/origami/assign_in_juty/'+ dining_id;
|
||||
});
|
||||
|
||||
$('#void').on('click', function () {
|
||||
var sure = confirm("Are you sure want to Void");
|
||||
if (sure == true) {
|
||||
|
||||
58
app/views/origami/in_juties/_assign_in_juty.html.erb
Normal file
58
app/views/origami/in_juties/_assign_in_juty.html.erb
Normal file
@@ -0,0 +1,58 @@
|
||||
<div class="col-md-3">
|
||||
<%= simple_form_for([:origami,@in_juty]) do |f| %>
|
||||
<%= f.error_notification %>
|
||||
|
||||
<div class="form-inputs">
|
||||
<%= f.label :dinning_id %>
|
||||
<br/>
|
||||
<%= @table.name %>
|
||||
<br/>
|
||||
|
||||
<%= f.label :commissioner_ids %>
|
||||
<%= f.collection_select :commissioner_ids, Commissioner.all, :id, :name, {prompt: 'Select Commissioner'}, {class: 'form-control'} %><br/>
|
||||
<label>In time</label>
|
||||
<%= f.text_field :in_time, :value=>DateTime.now.strftime("%Y-%m-%d / %I:%M %p"),:class=>"form-control datepicker"%><br/>
|
||||
<label>Out time</label>
|
||||
<%= f.text_field :out_time, :value=>DateTime.now.strftime("%Y-%m-%d / %I:%M %p"),:class=>"form-control datepicker"%>
|
||||
</div><br>
|
||||
<div class="form-actions">
|
||||
<div class='row'>
|
||||
<div class="col-md-2">
|
||||
<%= link_to 'Back', origami_path(@table.id), class: 'btn btn-success' %>
|
||||
</div>
|
||||
<div class="col-md-10">
|
||||
<button type="button" class="btn btn-primary btn-block" id='in_juty'>Create In Juty</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
$(function() {
|
||||
$('.datepicker').datepicker({
|
||||
format : 'dd-mm-yyyy',
|
||||
autoclose: true
|
||||
});
|
||||
$('.datepicker').attr('ReadOnly','true');
|
||||
$('.datepicker').css('cursor','pointer');
|
||||
});
|
||||
|
||||
$('#in_juty').on('click', function () {
|
||||
var ajax_url = "/origami/assign_in_juty";
|
||||
var commissioner_ids = $('#in_juty_commissioner_ids').val();
|
||||
var in_time = $('#in_juty_in_time').val();
|
||||
var out_time = $('#in_juty_out_time').val();
|
||||
var dining_id = '<%= @table.id %>'
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: ajax_url,
|
||||
data: 'dining_id=' + dining_id + "&commissioner_ids=" + commissioner_ids +'&in_time=' + in_time + "&out_time=" + out_time,
|
||||
success: function (result) {
|
||||
window.location.href = '/origami/table/' + dining_id;
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
</script>
|
||||
59
app/views/origami/in_juties/_edit_form.html.erb
Normal file
59
app/views/origami/in_juties/_edit_form.html.erb
Normal file
@@ -0,0 +1,59 @@
|
||||
<div class="col-md-3">
|
||||
<%= simple_form_for([:origami,@in_juty]) do |f| %>
|
||||
<%= f.error_notification %>
|
||||
|
||||
<div class="form-inputs">
|
||||
<%= f.label :dinning_id %>
|
||||
<br/>
|
||||
<%= @table.name %>
|
||||
<br/>
|
||||
|
||||
<%= f.label :commissioner_ids %>
|
||||
<%= f.collection_select :commissioner_ids, Commissioner.all, :id, :name, {prompt: 'Select Commissioner'}, {class: 'form-control'} ,:value => @in_juty.commissioner.name %><br/>
|
||||
<label>In time</label>
|
||||
<%= f.text_field :in_time, :value=>DateTime.now.strftime("%Y-%m-%d / %I:%M %p"),:class=>"form-control datepicker" ,:value => @in_juty.in_time %><br/>
|
||||
<label>Out time</label>
|
||||
<%= f.text_field :out_time, :value=>DateTime.now.strftime("%Y-%m-%d / %I:%M %p"),:class=>"form-control datepicker" ,:value => @in_juty.out_time %>
|
||||
</div><br>
|
||||
<div class="form-actions">
|
||||
<div class='row'>
|
||||
<div class="col-md-2">
|
||||
<%= link_to 'Back', origami_index_in_juty_path, class: 'btn btn-success' %>
|
||||
</div>
|
||||
<div class="col-md-10">
|
||||
<button type="button" class="btn btn-primary btn-block" id='in_juty'>Update In Juty</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
$(function() {
|
||||
$('.datepicker').datepicker({
|
||||
format : 'dd-mm-yyyy',
|
||||
autoclose: true
|
||||
});
|
||||
$('.datepicker').attr('ReadOnly','true');
|
||||
$('.datepicker').css('cursor','pointer');
|
||||
});
|
||||
|
||||
$('#in_juty').on('click', function () {
|
||||
var id = '<%= @in_juty.id %>'
|
||||
var ajax_url = "/origami/edit_in_juty/" + id;
|
||||
var commissioner_ids = $('#in_juty_commissioner_ids').val();
|
||||
var in_time = $('#in_juty_in_time').val();
|
||||
var out_time = $('#in_juty_out_time').val();
|
||||
var dining_id = '<%= @table.id %>'
|
||||
$.ajax({
|
||||
type: "PUT",
|
||||
url: ajax_url,
|
||||
data: 'dining_id=' + dining_id + "&commissioner_ids=" + commissioner_ids +'&in_time=' + in_time + "&out_time=" + out_time,
|
||||
success: function (result) {
|
||||
window.location.href = '/origami/assign_in_juty';
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
</script>
|
||||
3
app/views/origami/in_juties/assign_in_juty.html.erb
Normal file
3
app/views/origami/in_juties/assign_in_juty.html.erb
Normal file
@@ -0,0 +1,3 @@
|
||||
<div class="span12">
|
||||
<%= render 'assign_in_juty', in_juty: @in_juty %>
|
||||
</div>
|
||||
10
app/views/origami/in_juties/edit_in_juty.html.erb
Normal file
10
app/views/origami/in_juties/edit_in_juty.html.erb
Normal file
@@ -0,0 +1,10 @@
|
||||
<div class="span12">
|
||||
<div class="page-header">
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="<%= origami_root_path %>">Home</a></li>
|
||||
<li><a href="<%= origami_in_juties_path %>">In Juties</a></li>
|
||||
<li>Edit</li>
|
||||
</ul>
|
||||
</div>
|
||||
<%= render 'form', in_juty: @in_juty %>
|
||||
</div>
|
||||
37
app/views/origami/in_juties/index_in_juty.html.erb
Normal file
37
app/views/origami/in_juties/index_in_juty.html.erb
Normal file
@@ -0,0 +1,37 @@
|
||||
<div class="page-header">
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="<%= origami_root_path %>">Home</a></li>
|
||||
<li>In Juties</li>
|
||||
<span style="float: right">
|
||||
<%= link_to t('.new', :default => t("helpers.links.new")), origami_assign_in_juty_path, :class => 'btn btn-primary btn-sm', :flag => 'new' %>
|
||||
</span>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
<div class="card">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Dining Facility Name</th>
|
||||
<th>Commissioner Ids</th>
|
||||
<th>In time</th>
|
||||
<th>Out time</th>
|
||||
<th colspan="2"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<% @juties_in.each do |in_juty| %>
|
||||
<tr>
|
||||
<td><%= in_juty.dining_facility.name rescue '-' %></td>
|
||||
<td><%= in_juty.commissioner.name rescue '-' %></td>
|
||||
<td><%= in_juty.in_time.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") rescue '-' %></td>
|
||||
<td><%= in_juty.out_time.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") rescue '-' %></td>
|
||||
<td><%= link_to 'Edit', origami_edit_in_juty_path(in_juty) %></td>
|
||||
<td><%= link_to 'Destroy', origami_destroy_in_juty_path(in_juty), method: :delete, data: {confirm: 'Are you sure?'} %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@@ -90,6 +90,15 @@ Rails.application.routes.draw do
|
||||
# commissions
|
||||
get '/table/:table_id/sale/:sale_id/load_commissioners' => 'commissions#load_commissioners', as: 'load_commissioners'
|
||||
post 'select_sale_item' => 'commissions#select_sale_item'
|
||||
# in_juties
|
||||
get '/table/:table_id/assign_in_juty' => 'in_juties#assign_in_juty', as: 'assign_in_juty'
|
||||
post 'assign_in_juty' => 'in_juties#create_for_in_juty', as: 'create_for_in_juty'
|
||||
get 'assign_in_juty/:table_id' => 'in_juties#index_in_juty', as: 'index_in_juty'
|
||||
get '/in_juty/:in_juty_id/edit' => 'in_juties#edit_in_juty' ,as: 'edit_in_juty'
|
||||
put '/edit_in_juty/:in_juty_id' => 'in_juties#update_for_in_juty', as: 'update_for_in_juty'
|
||||
delete '/destroy_in_juty/:in_juty_id' => 'in_juties#destroy_in_juty', as: 'destroy_in_juty'
|
||||
|
||||
|
||||
|
||||
get 'table/:dining_id/movetable' => "movetable#move_dining"
|
||||
get 'table/:dining_id/moveroom' => "moveroom#move_dining"
|
||||
|
||||
Reference in New Issue
Block a user