Merge branch 'master' of bitbucket.org:code2lab/sxrestaurant

This commit is contained in:
superuser
2017-06-15 15:06:54 +06:30
9 changed files with 58 additions and 36 deletions

1
.gitignore vendored
View File

@@ -9,6 +9,7 @@
# Ignore all logfiles and tempfiles.
.DS_Store
*.rdb
*.rbc
*.sassc
.sass-cache

View File

@@ -12,14 +12,14 @@ class Api::BillController < Api::ApiController
if booking
if booking.sale_id.nil?
@sale = Sale.new
@status, @sale_id = @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)
else
@status = true
end
end
elsif (params[:order_id])
@sale = Sale.new
@status, @sale_id = @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)
end
end

View File

@@ -45,7 +45,11 @@ class Api::OrdersController < Api::ApiController
@order.new_booking = false
@order.booking_id = params[:booking_id]
end
end
else
@order.new_booking = false
@order.booking_id = params[:booking_id]
puts "booking sale is null"
end
end
@status, @booking = @order.generate

View File

@@ -32,7 +32,7 @@ class Order < ApplicationRecord
table = DiningFacility.find(self.table_id)
table.status = "occupied"
table.save
else
else
booking = Booking.find(self.booking_id)
end
@@ -231,7 +231,7 @@ class Order < ApplicationRecord
.joins("left join orders on orders.order_id = booking_orders.order_id")
.joins("left join sales on sales.sale_id = bookings.sale_id")
.where("(orders.status = 'new' or orders.status = 'billed') and (dining_facilities.type=? and dining_facilities.is_active=?)",DiningFacility::TABLE_TYPE,true)
.group("bookings.booking_id,orders.status,sales.receipt_no,sales.sale_status,orders.order_id,sales.customer_id,sales.sale_id,dining_facilities.name")
.group("bookings.booking_id")
# For PG
# booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::TABLE_TYPE,true
# sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status,orders.order_id
@@ -246,7 +246,7 @@ class Order < ApplicationRecord
.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'")
.group("sales.sale_id,orders.status,orders.order_id,bookings.booking_id,dining_facilities.name")
.group("sales.sale_id")
# For PG
#bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status,orders.order_id
end
@@ -262,7 +262,7 @@ class Order < ApplicationRecord
.joins("left join orders on orders.order_id = booking_orders.order_id")
.joins("left join sales on sales.sale_id = bookings.sale_id")
.where("(orders.status = 'new' or orders.status = 'billed') and (dining_facilities.type=? and dining_facilities.is_active=?)",DiningFacility::ROOM_TYPE,true)
.group("bookings.booking_id,sales.receipt_no,orders.status,orders.order_id,sales.customer_id,sales.sale_status,orders.customer_id,sales.sale_id,dining_facilities.name")
.group("bookings.booking_id")
# For PG
# booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::ROOM_TYPE,true
# sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.customer_id,orders.order_id

View File

@@ -1,16 +1,16 @@
class ReceiptBillPdf < Prawn::Document
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, member_info = nil)
self.page_width = 250
self.page_height = 1450
self.margin = 10
self.price_width = 40
self.page_width = 210
self.page_height = 2500
self.margin = 5
self.price_width = 35
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.total_width = 35
self.item_width = self.page_width - ((self.price_width + self.qty_width + self.total_width))
self.item_height = 15
self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width)
self.label_width=80
self.item_description_width = (self.page_width-20) / 2
self.label_width = 100
# @item_width = self.page_width.to_i / 2
# @qty_width = @item_width.to_i / 3
@@ -22,10 +22,10 @@ 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 = 11
self.item_font_size = 9
self.header_font_size = 10
self.item_font_size = 8
header( printer_settings.printer_name, printer_settings.name)
header( "Beauty In the Pot", printer_settings.name)
stroke_horizontal_rule
@@ -92,8 +92,8 @@ class ReceiptBillPdf < Prawn::Document
# @item_width.to_i + @half_qty.to_i
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
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 => :center, :overflow => :shrink_to_fix
text_box "Total", :at =>[(self.item_width+self.price_width),y_position], :width => self.total_width+5, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
}
@@ -121,9 +121,9 @@ class ReceiptBillPdf < Prawn::Document
pad_top(15) {
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
text_box "#{price.to_i}", :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 => :center, :overflow => :shrink_to_fix
text_box "#{total_price.to_i}", :at =>[(item_name_width),y_position], :width =>self.total_width+5, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
}
move_down 3
end
@@ -132,10 +132,10 @@ class ReceiptBillPdf < Prawn::Document
move_down 5
y_position = cursor
bounding_box([0,y_position], :width =>item_name_width, :height => self.item_height) do
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "Sub Total", :size => self.item_font_size,:align => :left
end
bounding_box([item_name_width,y_position], :width =>self.total_width) do
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "#{ sub_total }" , :size => self.item_font_size,:align => :right
end
@@ -145,10 +145,10 @@ class ReceiptBillPdf < Prawn::Document
move_down 5
y_position = cursor
bounding_box([0,y_position], :width =>(item_name_width), :height => self.item_height) do
bounding_box([0,y_position], :width => self.item_description_width, :height => self.item_height) do
text "Food/Beverage Total", :size => self.item_font_size,:align => :left
end
bounding_box([item_name_width,y_position], :width =>self.total_width) do
bounding_box([self.item_description_width,y_position], :width => self.label_width) do
text "#{ food_beverage_total }" , :size => self.item_font_size,:align => :right
end
end
@@ -158,30 +158,30 @@ class ReceiptBillPdf < Prawn::Document
move_down 5
y_position = cursor
bounding_box([0,y_position], :width =>(item_name_width+self.price_width), :height => self.item_height) do
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "Discount", :size => self.item_font_size,:align => :left
end
bounding_box([(item_name_width+self.price_width),y_position], :width =>self.total_width) do
bounding_box([self.item_description_width,y_position], :width =>self.label_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), :height => self.item_height) do
bounding_box([0,y_position], :width =>self.item_description_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),y_position], :width =>self.total_width) do
bounding_box([self.item_description_width,y_position], :width =>self.label_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), :height => self.item_height) do
bounding_box([0,y_position], :width =>self.item_description_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),y_position], :width =>self.total_width) do
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "#{sale_data.grand_total}" , :size => self.item_font_size,:align => :right
end
move_down 5

View File

@@ -121,6 +121,7 @@
<div class="form-group">
<%= 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 :button, "Reset",:class => 'btn btn-danger ', :id => 'reset' %>
</div>
<%end%>
</div>
@@ -230,5 +231,12 @@ $(function() {
});
}
$('#reset').click(function() {
window.location.href = '/crm/customers'
return false;
});
</script>

View File

@@ -2,9 +2,9 @@
<div class="col-lg-12">
<ol class="breadcrumb">
<li><a href="<%= crm_root_path %>">Home</a></li>
<li class="active">
<!-- <li class="active">
<a href="<%= crm_customers_path %>">Customer</a>
</li>
</li> -->
<!-- <a href="<%= new_crm_customer_path%>" class="btn btn-primary pull-right">
<i class="fa fa-plus-circle fa-lg"></i> Add Customer
</a> -->

View File

@@ -287,7 +287,16 @@ $(document).on('click', '.cashier_number', function(event){
update_balance();
break;
case 'nett':
$('#cash').text($('#amount_due').text());
var credit1 = $('#credit').text();
var card1 = $('#others').text();
var paypar1 = $('#ppamount').text();
var visa1 = $('#visacount').text();
var jcb1 = $('#jcbcount').text();
var master1 = $('#mastercount').text();
var othertotal = parseFloat(credit1) + parseFloat(card1) + parseFloat(paypar1) + parseFloat(visa1) + parseFloat(jcb1) + parseFloat(master1);
var total = $('#amount_due').text();
var amt = parseFloat(total) - othertotal;
$('#cash').text(amt);
update_balance();
break;
}

BIN
dump.rdb

Binary file not shown.