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
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
1) rake db:migrate for card_sale_trans, card_settle_trans
2) settings/lookups => { type:bank_integration, name: Bank Integration, value:1 }

View File

@@ -24,6 +24,11 @@ authorize_resource :class => false
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]
@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)
@@ -127,4 +132,108 @@ authorize_resource :class => false
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

@@ -69,6 +69,16 @@ class Lookup < ApplicationRecord
return @lookup
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)
@lookup = Lookup.where('lookup_type=?', 'shift_sale_items').last
if @lookup.nil?

View File

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

View File

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

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 "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 "receipt_reprint/:sale_id" , to: "receipt_no#reprint", as: "receipt_reprint"
post "print_sale_items", to: "saleitem#print_sale_items", as: "print_sale_items"
get "sync_data", to:'receipt_no#sync_data', as:'sync_data'
end