payment
This commit is contained in:
@@ -1,8 +1,17 @@
|
||||
class Origami::MpuController < BaseOrigamiController
|
||||
|
||||
def index
|
||||
@sale_id = params[:sale_id]
|
||||
end
|
||||
|
||||
|
||||
def create
|
||||
cash = params[:amount]
|
||||
sale_id = params[:sale_id]
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
sale_payment = SalePayment.new
|
||||
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "mpu")
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -17,11 +17,16 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
def show
|
||||
sale_id = params[:sale_id]
|
||||
if Sale.exists?(sale_id)
|
||||
@cash = 0.0
|
||||
@other = 0.0
|
||||
@sale_data = Sale.find_by_sale_id(sale_id)
|
||||
@sale_data.sale_payments.each do |spay|
|
||||
if spay.payment_method == "cash"
|
||||
@cash = spay.payment_amount
|
||||
end
|
||||
if spay.payment_method == "mpu"
|
||||
@other = spay.payment_amount
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -134,7 +134,7 @@ class SalePayment < ApplicationRecord
|
||||
self.payment_method = method
|
||||
self.payment_amount = self.received_amount
|
||||
self.payment_reference = self.card_payment_reference
|
||||
self.outstanding_amount = self.sale.grand_total- self.received_amount
|
||||
self.outstanding_amount = self.sale.grand_total.to_f - self.received_amount.to_f
|
||||
self.payment_status = "paid"
|
||||
payment_method = self.save!
|
||||
|
||||
|
||||
5
app/views/origami/mpu/create.json.jbuilder
Normal file
5
app/views/origami/mpu/create.json.jbuilder
Normal file
@@ -0,0 +1,5 @@
|
||||
if(@status)
|
||||
json.status @status
|
||||
else
|
||||
json.status false
|
||||
end
|
||||
@@ -1 +1,25 @@
|
||||
Hello MPU
|
||||
<h2> MPU </h2>
|
||||
|
||||
|
||||
Amount :
|
||||
|
||||
<input type="text" name="amount" id="amount" value=""/>
|
||||
|
||||
<button type="submit" id="mpu_pay" > PAY </button>
|
||||
|
||||
<script>
|
||||
$('#mpu_pay').on('click',function(){
|
||||
var amount = $('#amount').val();
|
||||
var sale_id = "<%= @sale_id %>";
|
||||
alert(amount);
|
||||
$.ajax({type: "POST",
|
||||
url: "<%= origami_create_mpu_payment_path %>",
|
||||
data: "amount="+ amount + "&sale_id="+ sale_id,
|
||||
success:function(result){
|
||||
if(result){
|
||||
window.location.href = '/origami/sale/'+ sale_id + "/payment";
|
||||
}
|
||||
}
|
||||
});
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
$('.others-payment').on('click',function(){
|
||||
var input_type = $(this).attr("data-type");
|
||||
var sale_id = $(this).attr("data-sale-id");
|
||||
alert(input_type)
|
||||
window.location.href = '/origami/sale/'+ sale_id + "/payment/others_payment/" + input_type;
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -93,12 +93,12 @@
|
||||
<hr>
|
||||
<div class="row" id="credit_payment">
|
||||
<div class="col-md-8">Credit</div>
|
||||
<div class="col-md-4">0.0</div>
|
||||
<div class="col-md-4" id="credit">0.0</div>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="row" id="card_payment">
|
||||
<div class="col-md-8">Others Payment</div>
|
||||
<div class="col-md-4">0.0</div>
|
||||
<div class="col-md-4" id="others"><%= @other %></div>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="row">
|
||||
@@ -159,6 +159,9 @@
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
update_balance();
|
||||
})
|
||||
$(document).on('click', '.cashier_number', function(event){
|
||||
if(event.handled !== true) {
|
||||
var original_value;
|
||||
@@ -237,9 +240,9 @@ $( document ).ready(function() {
|
||||
function update_balance(){
|
||||
var cash = $('#cash').text();
|
||||
var credit = $('#credit').text();
|
||||
var card = $('#card').text();
|
||||
var card = $('#others').text();
|
||||
var amount_due = $('#amount_due').text();
|
||||
var total = cash + credit + card
|
||||
var total = parseFloat(cash) + parseFloat(credit) + parseFloat(card)
|
||||
var result = amount_due - total
|
||||
$('#balance').text(result);
|
||||
}
|
||||
|
||||
@@ -87,6 +87,7 @@ Rails.application.routes.draw do
|
||||
get 'sale/:sale_id/payment/others_payment' => "others_payments#index"
|
||||
# get 'sale/:sale_id/payment/others_payment/:payment_method' => "redeem_payments#index"
|
||||
get 'sale/:sale_id/payment/others_payment/MPU' => "mpu#index"
|
||||
post 'create_mpu_payment' => "mpu#create"
|
||||
get 'sale/:sale_id/payment/others_payment/REDIMREBATE' => "redeem_payments#index"
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user