add req and fix for shift
This commit is contained in:
@@ -10,9 +10,10 @@ class Origami::VoidController < BaseOrigamiController
|
|||||||
sale.save
|
sale.save
|
||||||
|
|
||||||
# update count for shift sale
|
# update count for shift sale
|
||||||
shift = ShiftSale.current_open_shift(sale.cashier_id)
|
if(sale.sale_status == "completed")
|
||||||
shift.total_void = shift.total_void + 1
|
shift = ShiftSale.current_open_shift(sale.cashier_id)
|
||||||
shift.save
|
shift.calculate(sale, "void")
|
||||||
|
end
|
||||||
|
|
||||||
bookings = sale.bookings
|
bookings = sale.bookings
|
||||||
bookings.each do |booking|
|
bookings.each do |booking|
|
||||||
|
|||||||
@@ -604,7 +604,7 @@ end
|
|||||||
def get_commerical_tax
|
def get_commerical_tax
|
||||||
tax = 0.0
|
tax = 0.0
|
||||||
self.sale_taxes.each do |taxobj|
|
self.sale_taxes.each do |taxobj|
|
||||||
if taxobj.tax_name == "Commerical Tax"
|
if taxobj.tax_name == "Commercial Tax"
|
||||||
tax += taxobj.tax_payable_amount
|
tax += taxobj.tax_payable_amount
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -52,11 +52,34 @@ class ShiftSale < ApplicationRecord
|
|||||||
self.cash_sales = self.cash_sales.to_f + cash.to_f
|
self.cash_sales = self.cash_sales.to_f + cash.to_f
|
||||||
self.credit_sales = self.credit_sales.to_i + credit.to_f
|
self.credit_sales = self.credit_sales.to_i + credit.to_f
|
||||||
self.other_sales = self.other_sales.to_i + other_sales.to_f
|
self.other_sales = self.other_sales.to_i + other_sales.to_f
|
||||||
self.nett_sales = saleobj.total_amount.to_f #self.grand_total.to_i - self.commercial_taxes
|
self.nett_sales = self.nett_sales + saleobj.total_amount.to_f #self.grand_total.to_i - self.commercial_taxes
|
||||||
self.commercial_taxes = self.commercial_taxes.to_i + tax.to_f
|
self.commercial_taxes = self.commercial_taxes.to_i + tax.to_f
|
||||||
|
self.total_rounding = self.total_rounding + saleobj.rounding_adjustment
|
||||||
self.total_receipt = self.total_receipt + 1
|
self.total_receipt = self.total_receipt + 1
|
||||||
self.save
|
self.save
|
||||||
|
end
|
||||||
|
|
||||||
|
# Calculate by type and update
|
||||||
|
def calculate(sale, type)
|
||||||
|
saleobj = Sale.find_by_sale_id(sale)
|
||||||
|
cash = saleobj.get_cash_amount
|
||||||
|
credit = saleobj.get_credit_amount
|
||||||
|
other_sales = saleobj.get_other_amount
|
||||||
|
tax = saleobj.get_commerical_tax
|
||||||
|
if type == "void"
|
||||||
|
self.total_revenue = self.total_revenue.to_f - saleobj.total_amount.to_f
|
||||||
|
self.total_discounts = self.total_discounts - saleobj.total_discount
|
||||||
|
self.total_taxes = self.total_taxes - saleobj.total_tax
|
||||||
|
self.grand_total = self.grand_total - saleobj.grand_total
|
||||||
|
self.cash_sales = self.cash_sales.to_f - cash.to_f
|
||||||
|
self.credit_sales = self.credit_sales.to_i - credit.to_f
|
||||||
|
self.other_sales = self.other_sales.to_i - other_sales.to_f
|
||||||
|
self.nett_sales = self.nett_sales - saleobj.total_amount.to_f #self.grand_total.to_i - self.commercial_taxes
|
||||||
|
self.commercial_taxes = self.commercial_taxes.to_i - tax.to_f
|
||||||
|
self.total_rounding = self.total_rounding - saleobj.rounding_adjustment
|
||||||
|
self.total_void = self.total_void + saleobj.grand_total
|
||||||
|
self.save
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_closing_balance(shift)
|
def get_closing_balance(shift)
|
||||||
|
|||||||
@@ -68,6 +68,22 @@ class CloseCashierPdf < Prawn::Document
|
|||||||
bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
|
bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
|
||||||
text "#{ shift_sale.cashier_terminal.name}" , :size => self.item_font_size,:align => :left
|
text "#{ shift_sale.cashier_terminal.name}" , :size => self.item_font_size,:align => :left
|
||||||
end
|
end
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
|
||||||
|
text "Opening Date : ", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
|
||||||
|
text "#{ shift_sale.shift_started_at.utc.getlocal.strftime('%d-%m-%Y %I:%M %p') }" , :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
|
||||||
|
text "Closing Date : ", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
|
||||||
|
text "#{ shift_sale.shift_closed_at.utc.getlocal.strftime('%d-%m-%Y %I:%M %p') }" , :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
|
||||||
y_position = cursor
|
y_position = cursor
|
||||||
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
|
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
|
||||||
@@ -88,6 +104,12 @@ class CloseCashierPdf < Prawn::Document
|
|||||||
|
|
||||||
move_down 10
|
move_down 10
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.page_width - 10, :height => 20) do
|
||||||
|
text "Shift Sale Summary", :size => self.header_font_size, :align => :center
|
||||||
|
end
|
||||||
|
move_down 10
|
||||||
|
|
||||||
y_position = cursor
|
y_position = cursor
|
||||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
text "Received Amount :", :size => self.item_font_size, :align => :right
|
text "Received Amount :", :size => self.item_font_size, :align => :right
|
||||||
@@ -168,6 +190,22 @@ class CloseCashierPdf < Prawn::Document
|
|||||||
text "#{shift_sale.grand_total}", :size => self.item_font_size, :align => :right
|
text "#{shift_sale.grand_total}", :size => self.item_font_size, :align => :right
|
||||||
end
|
end
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
text "Total Receipts :", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "#{shift_sale.total_receipt}", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
text "Total Void:", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "(#{shift_sale.total_void})", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
|
||||||
move_down 5
|
move_down 5
|
||||||
stroke_horizontal_rule
|
stroke_horizontal_rule
|
||||||
move_down 5
|
move_down 5
|
||||||
|
|||||||
@@ -191,7 +191,7 @@
|
|||||||
<button id="remove-all" class="btn btn-warning btn-block action-btn">Remove All</button>
|
<button id="remove-all" class="btn btn-warning btn-block action-btn">Remove All</button>
|
||||||
<button id="pay-discount" class="btn btn-danger btn-block action-btn">Enter</button>
|
<button id="pay-discount" class="btn btn-danger btn-block action-btn">Enter</button>
|
||||||
<hr />
|
<hr />
|
||||||
<button id="member-discount" class="btn green btn-block action-btn">Member Discount</button>
|
<button id="member-discount" class="btn btn-success btn-block action-btn">Member Discount</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -222,6 +222,22 @@ $('#pay').on('click',function() {
|
|||||||
$('#back').on('click',function(){
|
$('#back').on('click',function(){
|
||||||
window.location.href = '/origami/';
|
window.location.href = '/origami/';
|
||||||
})
|
})
|
||||||
|
|
||||||
|
$('#void').on('click',function () {
|
||||||
|
var sure = confirm("Are you sure want to Void");
|
||||||
|
if (sure == true) {
|
||||||
|
var sale_id = $('#sale_id').val();
|
||||||
|
var ajax_url = "/origami/sale/" + sale_id + '/void';
|
||||||
|
$.ajax({
|
||||||
|
type: 'POST',
|
||||||
|
url: ajax_url,
|
||||||
|
success: function () {
|
||||||
|
window.location.href = '/origami/';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
$('#re-print').click(function() {
|
$('#re-print').click(function() {
|
||||||
var sale_id = $('#sale_id').val();
|
var sale_id = $('#sale_id').val();
|
||||||
window.location.href = '/origami/'+ sale_id + "/reprint"
|
window.location.href = '/origami/'+ sale_id + "/reprint"
|
||||||
|
|||||||
@@ -21,8 +21,9 @@ class CreateShiftSales < ActiveRecord::Migration[5.1]
|
|||||||
t.integer :dining_count, :default => 0
|
t.integer :dining_count, :default => 0
|
||||||
t.integer :takeaway_count, :default => 0
|
t.integer :takeaway_count, :default => 0
|
||||||
t.integer :member_count, :default => 0
|
t.integer :member_count, :default => 0
|
||||||
|
t.integer :total_rounding, :default => 0
|
||||||
t.integer :total_receipt, :default => 0
|
t.integer :total_receipt, :default => 0
|
||||||
t.integer :total_void, :default => 0
|
t.decimal :total_void, :default => 0
|
||||||
t.timestamps
|
t.timestamps
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ customer2 = Customer.create({name:"TAKEAWAY", email: "cus2@customer.com", contac
|
|||||||
# room = Room.create({name:"Table 2", zone: zone2, status:"available", seater: 4 , order_by:1, created_by:"SYSTEM DEFAULT"})
|
# room = Room.create({name:"Table 2", zone: zone2, status:"available", seater: 4 , order_by:1, created_by:"SYSTEM DEFAULT"})
|
||||||
|
|
||||||
#Tax Profile
|
#Tax Profile
|
||||||
tax_profiles = TaxProfile.create({id:1, name: "Commerical Tax", rate:5.0, order_by:1, created_by:"SYSTEM DEFAULT"})
|
tax_profiles = TaxProfile.create({id:1, name: "Commercial Tax", rate:5.0, order_by:1, created_by:"SYSTEM DEFAULT"})
|
||||||
|
|
||||||
#Account for Menu Item Type (eg: Food, Beverage)
|
#Account for Menu Item Type (eg: Food, Beverage)
|
||||||
# food = Account.create({title: "Food", account_type: "0"})
|
# food = Account.create({title: "Food", account_type: "0"})
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
namespace :clear do
|
namespace :clear do
|
||||||
# desc "Clear Data"
|
desc "Clear Data"
|
||||||
# task :data => :environment do
|
task :data => :environment do
|
||||||
# BookingOrder.delete_all
|
BookingOrder.delete_all
|
||||||
# Booking.delete_all
|
Booking.delete_all
|
||||||
# OrderItem.delete_all
|
OrderItem.delete_all
|
||||||
# AssignedOrderItem.delete_all
|
AssignedOrderItem.delete_all
|
||||||
# Order.delete_all
|
Order.delete_all
|
||||||
# SaleOrder.delete_all
|
SaleOrder.delete_all
|
||||||
# SaleItem.delete_all
|
SaleItem.delete_all
|
||||||
# Sale.delete_all
|
Sale.delete_all
|
||||||
# SaleAudit.delete_all
|
SaleAudit.delete_all
|
||||||
# SalePayment.delete_all
|
SalePayment.delete_all
|
||||||
# ShiftSale.delete_all
|
ShiftSale.delete_all
|
||||||
# PaymentJournal.delete_all
|
PaymentJournal.delete_all
|
||||||
# DiningFacility.update_all(status:'available')
|
DiningFacility.update_all(status:'available')
|
||||||
# puts "Clear Data Done."
|
puts "Clear Data Done."
|
||||||
# end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user