diff --git a/app/assets/stylesheets/origami.scss b/app/assets/stylesheets/origami.scss index 3606dadc..8c478a1a 100644 --- a/app/assets/stylesheets/origami.scss +++ b/app/assets/stylesheets/origami.scss @@ -160,6 +160,10 @@ background-color: #FF8C00 } +.blue{ + background-color: blue +} + .left{ margin-left:1px; } diff --git a/app/controllers/origami/room_invoices_controller.rb b/app/controllers/origami/room_invoices_controller.rb new file mode 100644 index 00000000..8d805771 --- /dev/null +++ b/app/controllers/origami/room_invoices_controller.rb @@ -0,0 +1,40 @@ +class Origami::RoomInvoicesController < BaseOrigamiController + def index + @room = DiningFacility.find(params[:room_id]) + puts "room bookig lenght" + @sale_array = Array.new + @room.bookings.each do |booking| + puts booking.sale_id + + if booking.sale_id.nil? + else + sale = Sale.find(booking.sale_id) + + if sale.sale_status != "completed" + @sale_array.push(sale) + end + end + end + end + + def show + @room = DiningFacility.find(params[:room_id]) + @sale_array = Array.new + @room.bookings.each do |booking| + if booking.sale_id.nil? + else + sale = Sale.find(booking.sale_id) + + if sale.sale_status != "completed" + @sale_array.push(sale) + end + end + end + + @sale = Sale.find(params[:invoice_id]) + @date = @sale.created_at + @status_sale = 'sale' + @customer = @sale.customer + end + +end diff --git a/app/controllers/origami/table_invoices_controller.rb b/app/controllers/origami/table_invoices_controller.rb new file mode 100644 index 00000000..32e0ef7f --- /dev/null +++ b/app/controllers/origami/table_invoices_controller.rb @@ -0,0 +1,40 @@ +class Origami::TableInvoicesController < BaseOrigamiController + def index + @table = DiningFacility.find(params[:table_id]) + puts "table bookig lenght" + @sale_array = Array.new + @table.bookings.each do |booking| + puts booking.sale_id + + if booking.sale_id.nil? + else + sale = Sale.find(booking.sale_id) + + if sale.sale_status != "completed" + @sale_array.push(sale) + end + end + end + end + + def show + @table = DiningFacility.find(params[:table_id]) + @sale_array = Array.new + @table.bookings.each do |booking| + if booking.sale_id.nil? + else + sale = Sale.find(booking.sale_id) + + if sale.sale_status != "completed" + @sale_array.push(sale) + end + end + end + + @sale = Sale.find(params[:invoice_id]) + @date = @sale.created_at + @status_sale = 'sale' + @customer = @sale.customer + end + +end diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 950334cb..65fc96b0 100644 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -54,7 +54,7 @@ class SalePayment < ApplicationRecord #record an payment in sale-audit remark = "Payment #{payment_method}- for Invoice #{invoice.receipt_no} Due [#{amount_due}]| pay amount -> #{cash_amount} | Payment Status ->#{payment_status}" sale_audit = SaleAudit.record_payment(invoice.id, remark, action_by) - + return true, self.save else #record an payment in sale-audit @@ -94,10 +94,15 @@ class SalePayment < ApplicationRecord sale_data = Sale.find_by_sale_id(sale_id) if sale_data + others = 0 + sale_data.sale_payments.each do |sale_payment| + others = others + sale_payment.payment_amount + end + redeem_prices = sale_data.grand_total -others # Control for Paypar Cloud begin response = HTTParty.post(url, - :body => { generic_customer_id:membership_id,redeem_amount:received_amount,receipt_no:sale_data.receipt_no,campaign_type_id:campaign_type_id,account_no:"",merchant_uid:merchant_uid,auth_token:auth_token}.to_json, + :body => { generic_customer_id:membership_id,total_amount: redeem_prices,total_sale_transaction_amount: sale_data.grand_total,redeem_amount:received_amount,receipt_no:sale_data.receipt_no,campaign_type_id:campaign_type_id,account_no:"",merchant_uid:merchant_uid,auth_token:auth_token}.to_json, :headers => { 'Content-Type' => 'application/json', 'Accept' => 'application/json' @@ -292,7 +297,7 @@ class SalePayment < ApplicationRecord # Control for Paypar Cloud begin - response = HTTParty.post(url, :body => { generic_customer_id:generic_customer_id ,merchant_uid:merchant_uid,total_amount: total_amount,campaign_type_id: campaign_type_id, + response = HTTParty.post(url, :body => { generic_customer_id:generic_customer_id ,total_sale_transaction_amount: sObj.grand_total,merchant_uid:merchant_uid,total_amount: total_amount,campaign_type_id: campaign_type_id, receipt_no: receipt_no,auth_token:auth_token}.to_json, :headers => { 'Content-Type' => 'application/json', diff --git a/app/views/origami/home/index.html.erb b/app/views/origami/home/index.html.erb index 08f53998..5888bb3e 100644 --- a/app/views/origami/home/index.html.erb +++ b/app/views/origami/home/index.html.erb @@ -38,12 +38,21 @@
Date: <%= @date.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%>
<%= @customer.customer_id %>
-Customer : <%= @customer.name %>
- <%end%> +<%= @customer.customer_id rescue "" %>
+Customer : <%= @customer.name rescue "" %>
+ <%end%>| Receipt No - <%= sale.receipt_no %> | -+ |
Receipt No: + <%= @sale.receipt_no rescue '' %> +
+Date: <%= @sale.created_at.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%>
+| # | +Items | +QTY + | Price + |
|---|---|---|---|
| <%= count %> | +<%= sale_item.product_name %> | +<%= sale_item.qty %> | +<%= sale_item.price %> | +
| <%= count %> | +<%= order_item.item_name %> | +<%= order_item.qty %> | +<%= order_item.qty*order_item.price %> | +
Receipt No: + <%= @sale.receipt_no rescue '' %> +
+Date: <%= @sale.created_at.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%>
+Receipt No: + <%= @sale.receipt_no rescue '' %> +
+Date: <%= @sale.created_at.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%>
+| # | +Items | +QTY + | Price + |
|---|---|---|---|
| <%= count %> | +<%= sale_item.product_name %> | +<%= sale_item.qty %> | +<%= sale_item.price %> | +
| <%= count %> | +<%= order_item.item_name %> | +<%= order_item.qty %> | +<%= order_item.qty*order_item.price %> | +