add print at receipt no report

This commit is contained in:
NyanLinHtut
2019-10-02 09:24:30 +06:30
parent 94a1f5b2b5
commit a61c4a1932
7 changed files with 148 additions and 14 deletions

View File

@@ -93,6 +93,12 @@ For Show Sale Items Summary at CloseCashierPrint
1) settings/print_settings 1) settings/print_settings
a) Check => Shift Sale Items a) Check => Shift Sale Items
For Show/Hide AddOrder Button in QuickService
1) settings/lookups => {type:quickservice_add_order, name: QuickServiceAddOrder, value:1 OR 0}
For Show Print Button in ReceiptNo Report
1) settings/lookups => {type:reprint_receipt, name: Reprint Receipt in Report, value:1}
For Bank Integration setting For Bank Integration setting
1) rake db:migrate for card_sale_trans, card_settle_trans 1) rake db:migrate for card_sale_trans, card_settle_trans
2) settings/lookups => { type:bank_integration, name: Bank Integration, value:1 } 2) settings/lookups => { type:bank_integration, name: Bank Integration, value:1 }

View File

@@ -30,7 +30,7 @@ class Origami::QuickServiceController < ApplicationController
end end
#checked quick_service only #checked quick_service only
@quick_service_only = false @quick_service_only = false
lookup_dine_in = Lookup.collection_of('quickservice_add_order') lookup_dine_in = Lookup.collection_of('quickservice_add_order')
puts 'lookup_dine_in!!!!' puts 'lookup_dine_in!!!!'
puts lookup_dine_in puts lookup_dine_in

View File

@@ -1,4 +1,4 @@
class Reports::ReceiptNoController < BaseReportController class Reports::ReceiptNoController < BaseReportController
authorize_resource :class => false authorize_resource :class => false
def index def index
@payments = [["All Payment",''], ["Cash Payment","cash"], ["Credit Payment","creditnote"], ["FOC Payment","foc"]] @payments = [["All Payment",''], ["Cash Payment","cash"], ["Credit Payment","creditnote"], ["FOC Payment","foc"]]
@@ -13,7 +13,7 @@ authorize_resource :class => false
@shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED) @shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
@shift_sale = ShiftSale.find(params[:shift_name]) @shift_sale = ShiftSale.find(params[:shift_name])
if to.blank? if to.blank?
@shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL ',@shift_sale.shift_started_at) @shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL ',@shift_sale.shift_started_at)
else else
if @shift_sale.shift_closed_at.blank? if @shift_sale.shift_closed_at.blank?
@@ -24,8 +24,13 @@ authorize_resource :class => false
end end
end end
@lookup = Lookup.find_by_lookup_type('reprint_receipt')
if @lookup.nil?
@lookup = Lookup.create_reprint_receipt_lookup
end
payment_type = params[:payment_type] payment_type = params[:payment_type]
@sale_data = Sale.get_shift_sales_by_receipt_no(@shift_sale_range,@shift,from,to,payment_type) @sale_data = Sale.get_shift_sales_by_receipt_no(@shift_sale_range,@shift,from,to,payment_type)
@sale_taxes = Sale.get_separate_tax(@shift_sale_range,@shift,from,to,payment_type) @sale_taxes = Sale.get_separate_tax(@shift_sale_range,@shift,from,to,payment_type)
@tax_profiles = TaxProfile.group('name').order('order_by asc') #.limit(2) @tax_profiles = TaxProfile.group('name').order('order_by asc') #.limit(2)
@@ -64,7 +69,7 @@ authorize_resource :class => false
end end
out = {:status => 'ok', :message => date_arr} out = {:status => 'ok', :message => date_arr}
respond_to do |format| respond_to do |format|
format.json { render json: out } format.json { render json: out }
end end
@@ -126,5 +131,109 @@ authorize_resource :class => false
format.html { redirect_to '/en/reports/receipt_no/', notice: @message} format.html { redirect_to '/en/reports/receipt_no/', notice: @message}
end end
end end
end def reprint
sale_id = params[:sale_id]
member_info = nil
latest_order_no = nil
saleObj = Sale.find(sale_id)
# For Cashier by Zone
bookings = Booking.where("sale_id='#{sale_id}'")
booking = Booking.find_by_sale_id(sale_id)
latest_order = booking.booking_orders.joins(" JOIN orders ON orders.order_id = booking_orders.order_id").where("orders.source = 'quick_service'").order("order_id DESC").limit(1).first()
if !latest_order.nil?
latest_order_no = latest_order.order_id
end
# if bookings.count > 1
# # for Multiple Booking
# table = DiningFacility.find(bookings[0].dining_facility_id)
# else
# table = DiningFacility.find(bookings[0].dining_facility_id)
# end
shift = ShiftSale.current_open_shift(current_user.id)
if !shift.nil?
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
else
if bookings[0].dining_facility_id.to_i > 0
table = DiningFacility.find(bookings[0].dining_facility_id)
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)
else
shift = ShiftSale.find(saleObj.shift_sale_id)
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
end
end
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
unique_code = "ReceiptBillPdf"
if !receipt_bill_a5_pdf.empty?
receipt_bill_a5_pdf.each do |receipt_bilA5|
if receipt_bilA5[0] == 'ReceiptBillA5Pdf'
if receipt_bilA5[1] == '1'
unique_code = "ReceiptBillA5Pdf"
else
unique_code = "ReceiptBillPdf"
end
end
end
end
customer= Customer.find(saleObj.customer_id)
#shop detail
#shop_detail = Shop.first
# get member information
rebate = MembershipSetting.find_by_rebate(1)
if customer.membership_id != nil && rebate
member_info = Customer.get_member_account(customer)
rebate_amount = Customer.get_membership_transactions(customer,saleObj.receipt_no)
current_balance = SaleAudit.paymal_search(sale_id)
end
#for card sale data
card_data = Array.new
card_sale_trans_ref_no = Sale.getCardSaleTrans(sale_id)
if !card_sale_trans_ref_no.nil?
card_sale_trans_ref_no.each do |cash_sale_trans|
card_res_date = cash_sale_trans.res_date.strftime("%Y-%m-%d").to_s
card_res_time = cash_sale_trans.res_time.strftime("%H:%M").to_s
card_no = cash_sale_trans.pan.last(4)
card_no = card_no.rjust(19,"**** **** **** ")
card_data.push({'res_date' => card_res_date, 'res_time' => card_res_time, 'batch_no' => cash_sale_trans.batch_no, 'trace' => cash_sale_trans.trace, 'pan' => card_no, 'app' => cash_sale_trans.app, 'tid' => cash_sale_trans.terminal_id, 'app_code' => cash_sale_trans.app_code, 'ref_no' => cash_sale_trans.ref_no, 'mid' => cash_sale_trans.merchant_id})
end
end
#card_balance amount for Paymal payment
card_balance_amount = SaleAudit.getCardBalanceAmount(sale_id)
# get printer info
print_settings=PrintSetting.find_by_unique_code(unique_code)
# Calculate price_by_accounts
item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
other_amount = SaleItem.calculate_other_charges(saleObj.sale_items)
printer = Printer::ReceiptPrinter.new(print_settings)
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, "Re-print",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil)
result = {
:status => true,
:filepath => filename,
:printer_model => print_settings.brand_name,
:printer_url => print_settings.api_settings
}
# Mobile Print
# render :json => result.to_json
respond_to do |format|
format.html { redirect_to '/en/reports/receipt_no/', notice: "Printing Completed."}
format.json { render json: result }
end
# end
end
end

View File

@@ -1,5 +1,5 @@
class Lookup < ApplicationRecord class Lookup < ApplicationRecord
has_many :accounts has_many :accounts
def available_types def available_types
@@ -18,7 +18,7 @@ class Lookup < ApplicationRecord
end end
# def self.get_by_type( lookup_type) # def self.get_by_type( lookup_type)
# Lookup.select("value, name").where("lookup_type = ?", lookup_type ).order("name asc").map { |r| [r.name, r.value] } # Lookup.select("value, name").where("lookup_type = ?", lookup_type ).order("name asc").map { |r| [r.name, r.value] }
# end # end
def self.get_checkin_time_limit def self.get_checkin_time_limit
@@ -69,6 +69,16 @@ class Lookup < ApplicationRecord
return @lookup return @lookup
end end
def self.create_reprint_receipt_lookup
@lookup = Lookup.new
@lookup.lookup_type = 'reprint_receipt'
@lookup.name = 'Reprint Receipt in Report'
@lookup.value = 0
@lookup.save
return @lookup
end
def self.save_shift_sale_items_settings(val) def self.save_shift_sale_items_settings(val)
@lookup = Lookup.where('lookup_type=?', 'shift_sale_items').last @lookup = Lookup.where('lookup_type=?', 'shift_sale_items').last
if @lookup.nil? if @lookup.nil?

View File

@@ -241,9 +241,9 @@ class Sale < ApplicationRecord
# @sale_data.save # @sale_data.save
# Promotion Activation # Promotion Activation
Promotion.promo_activate(@sale) Promotion.promo_activate(@sale_data)
@status = true @status = true
return @status, @sale return @status, @sale_data
else else
@status = false @status = false
@message = "No Current Open Shift for This Employee" @message = "No Current Open Shift for This Employee"

View File

@@ -56,7 +56,7 @@
<th><%= t("views.right_panel.detail.grand_total") %> +<br/> <th><%= t("views.right_panel.detail.grand_total") %> +<br/>
<%= t("views.right_panel.detail.rnd_adj_sh") %> <%= t("views.right_panel.detail.rnd_adj_sh") %>
</th> </th>
<th><%= "actions" %></th> <th><%= "Action" %></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@@ -168,11 +168,19 @@
<td><%= result.rounding_adjustment.to_f rescue '-' %></td> <td><%= result.rounding_adjustment.to_f rescue '-' %></td>
<td><%= number_with_precision(result.grand_total, precision: precision.to_i ,delimiter: delimiter) %></td> <td><%= number_with_precision(result.grand_total, precision: precision.to_i ,delimiter: delimiter) %></td>
<td> <% if @lookup.value.to_i == 1 %>
<td>
<!-- ############### Need to Check SyncStatus ############# --> <!-- ############### Need to Check SyncStatus ############# -->
<%= link_to "Sync", reports_sync_data_path(:sale_id => result.sale_id), class:"btn btn-info wave-effects" %> <%= link_to "Sync", reports_sync_data_path(:sale_id => result.sale_id), class:"btn btn-info wave-effects" %>
<!-- ###################################################### --> <!-- ###################################################### -->
<%= link_to "Print", reports_receipt_reprint_path(result.sale_id), class:"btn btn-info wave-effects" %>
</td> </td>
<% else %>
<td>
<%= link_to "Sync", reports_sync_data_path(:sale_id => result.sale_id), class:"btn btn-info wave-effects" %>
</td>
<% end %>
</tr> </tr>
<% end %> <% end %>
<tr style="border-top:4px double #666;"> <tr style="border-top:4px double #666;">
@@ -240,7 +248,7 @@
<td><%= t("views.right_panel.detail.grand_total") %> +<br/> <td><%= t("views.right_panel.detail.grand_total") %> +<br/>
<%= t("views.right_panel.detail.rnd_adj_sh") %> <%= t("views.right_panel.detail.rnd_adj_sh") %>
</td> </td>
<td> <td>
</td> </td>
</tr> </tr>
<%end%> <%end%>

View File

@@ -543,6 +543,7 @@ scope "(:locale)", locale: /en|mm/ do
get "order_reservation/get_shift_by_date", to: "order_reservation#show", as: "get_shift_by_order_reservation" get "order_reservation/get_shift_by_date", to: "order_reservation#show", as: "get_shift_by_order_reservation"
get "induty/get_shift_by_date", to: "induty#show", as: "get_shift_by_induty" get "induty/get_shift_by_date", to: "induty#show", as: "get_shift_by_induty"
get "shiftsale_print/:id" , to: "shiftsale#print_close_receipt", as: "get_shift_id" get "shiftsale_print/:id" , to: "shiftsale#print_close_receipt", as: "get_shift_id"
get "receipt_reprint/:sale_id" , to: "receipt_no#reprint", as: "receipt_reprint"
post "print_sale_items", to: "saleitem#print_sale_items", as: "print_sale_items" post "print_sale_items", to: "saleitem#print_sale_items", as: "print_sale_items"
get "sync_data", to:'receipt_no#sync_data', as:'sync_data' get "sync_data", to:'receipt_no#sync_data', as:'sync_data'
end end