Skip to content

Commit

Permalink
Merge 81d2d15 into 4b37168
Browse files Browse the repository at this point in the history
  • Loading branch information
xzzy committed Aug 24, 2020
2 parents 4b37168 + 81d2d15 commit 1a18eb5
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 9 deletions.
72 changes: 71 additions & 1 deletion ledger/payments/static/payments/js/payment.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,6 @@ $(function(){
var external = false;
var amount = $('#other_amount').val();


amount = amount.replace(/,/g, "");
console.log('cleaned');
// Hide div if not hidden
Expand Down Expand Up @@ -336,6 +335,16 @@ $(function(){
payload['district'] = $('#districts').val();
}
payload['receipt'] = $('#receipt_number').val();

$('#record_manual_payment').prop('disabled', true);
$('#recordPaymentLoader').show();
$('#other_amount').prop('disabled', true);
$('#other_payment').prop('disabled', true);
$('#other_source').prop('disabled', true);
$('#regions').prop('disabled', true);
$('#districts').prop('disabled', true);
$('#receipt_number').prop('disabled', true);

// POST
$.ajax ({
beforeSend: function(xhrObj){
Expand All @@ -348,10 +357,27 @@ $(function(){
dataType: "json",
headers: {'X-CSRFToken': getCookie('csrftoken')},
success: function(resp){
$('#other_payment').prop('disabled', false);
$('#other_source').prop('disabled', false);
$('#other_amount').prop('disabled', false);
$('#regions').prop('disabled', false);
$('#districts').prop('disabled', false);
$('#receipt_number').prop('disabled', false);

$('#record_manual_payment').prop('disabled', false);
$('#recordPaymentLoader').hide();
success(resp,invoice,$('#other_source').val());
sendCallback();
},
error: function(resp){
$('#other_payment').prop('disabled', false);
$('#other_source').prop('disabled', false);
$('#other_amount').prop('disabled', false);
$('#regions').prop('disabled', false);
$('#receipt_number').prop('disabled', false);

$('#record_manual_payment').prop('disabled', false);
$('#recordPaymentLoader').hide();
error(resp);
},
complete: function(resp){
Expand Down Expand Up @@ -653,7 +679,14 @@ $(function(){
return amount;
},
cardRefund: function(amount){
console.log("CARD REFUND")
amount = amount.replace(/,/g, "");
$('#record_refund').prop( "disabled", true );
$('#cancel_refund').prop( "disabled", true );
$('#refundAmount').prop( "disabled", true );
$('#refund_option').prop( "disabled", true );
$('#refund_details_text').prop( "disabled", true );
$('#refundLoader').show();
payload = {
"amount": amount,
"details": $("#refund_details > textarea[name='refund_details']").val()
Expand All @@ -672,8 +705,20 @@ $(function(){
success: function(resp){
rf.refund_modal.foundation('close');
rf.refund_form.reset();
$('#record_refund').prop( "disabled", false );
$('#cancel_refund').prop( "disabled", false );
$('#refundAmount').prop( "disabled", false );
$('#refund_option').prop( "disabled", false );
$('#refund_details_text').prop( "disabled", false );
$('#refundLoader').hide();
},
error: function(resp){
$('#record_refund').prop( "disabled", false );
$('#cancel_refund').prop( "disabled", false );
$('#refundAmount').prop( "disabled", false );
$('#refund_option').prop( "disabled", false );
$('#refund_details_text').prop( "disabled", false );
$('#refundLoader').hide();
var str = resp.responseText.replace(/[\[\]"]/g,'');
str = str.replace(/[\{\}"]/g,'');
rf.displayError(str);
Expand All @@ -684,6 +729,15 @@ $(function(){
});
},
manualRefund: function(){
$('#record_manual_payment').prop('disabled', true);

$('#record_refund').prop( "disabled", true );
$('#cancel_refund').prop( "disabled", true );
$('#refundAmount').prop( "disabled", true );
$('#refund_option').prop( "disabled", true );
$('#refund_details_text').prop( "disabled", true );
$('#refundLoader').show();

// Get payload
payload = {
"invoice": invoice,
Expand All @@ -704,10 +758,26 @@ $(function(){
dataType: "json",
headers: {'X-CSRFToken': getCookie('csrftoken')},
success: function(resp){
$('#record_manual_payment').prop('disabled', false);
$('#record_refund').prop( "disabled", false );
$('#cancel_refund').prop( "disabled", false );
$('#refundAmount').prop( "disabled", false );
$('#refund_option').prop( "disabled", false );
$('#refund_details_text').prop( "disabled", false );
$('#refundLoader').hide();

rf.refund_form.reset();
$(rf.refund_modal).foundation('close');
},
error: function(resp){
$('#record_manual_payment').prop('disabled', false);
$('#record_refund').prop( "disabled", false );
$('#cancel_refund').prop( "disabled", false );
$('#refundAmount').prop( "disabled", false );
$('#refund_option').prop( "disabled", false );
$('#refund_details_text').prop( "disabled", false );
$('#refundLoader').hide();

var str = resp.responseText.replace(/[\[\]"]/g,'');
str = str.replace(/[\{\}"]/g,'');
rf.displayError(str);
Expand Down
24 changes: 16 additions & 8 deletions ledger/payments/templates/dpaw_payments/invoice/payment.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Payments - Department of Parks and Wildlife</title>
<title>Payments - Department of Biodiversity, Conservation and Attractions</title>
<meta name="description" content="" />
<meta name="viewport" content="width=device-width, initial-scale=1" />

Expand Down Expand Up @@ -255,7 +255,15 @@ <h3> Record Payment</h3>
</fieldset>
<div class="row align-right">
<div class="columns medium-3">
<input id="" type="submit" class="pay_btn float-right button" value="Record Payment" />
<div class='col-lg-12'>
<div style='float: right; margin-left: 10px;'>
<div id="recordPaymentLoader" style="display:none; text-align:right; ">
<p class="text-right"><i class="fa fa-spin fa-spinner fa-2x"></i></p>
</div>
</div>

<input id="record_manual_payment" type="submit" class="pay_btn float-right button" value="Record Payment" />

</div>
</div>
<!-- Pay Button -->
Expand Down Expand Up @@ -319,7 +327,7 @@ <h3 class="text-center">Refund</h3>
<label>Details: </label>
</div>
<div class="medium-6 columns" id="refund_details">
<textarea name="refund_details" rows="4" style="width:100%;"></textarea>
<textarea id='refund_details_text' name="refund_details" rows="4" style="width:100%;"></textarea>
</div>
</div>
</div>
Expand All @@ -329,7 +337,7 @@ <h3 class="text-center">Refund</h3>
<div class="row align-right">
<div class="columns medium-3 button-group float-right align-right">
<input id="cancel_refund" type="button" class="pay_btn secondary button" style="margin-right:10px;" value="Cancel"/>
<input id="" type="submit" class="pay_btn button" value="Record Refund"/>
<input id="record_refund" type="submit" class="pay_btn button" value="Record Refund"/>
</div>
</div>
</div>
Expand Down Expand Up @@ -534,10 +542,10 @@ <h3>Linked BPAY Payments</h3>
</div>
<script type="text/javascript" src="//static.dpaw.wa.gov.au/static/libs/datatables/1.10.13/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="//static.dpaw.wa.gov.au/static/libs/datatables/1.10.13/js/dataTables.foundation.min.js"></script>
<script type="text/javascript" src="{% static 'payments/js/jquery.glob.js'%}"></script>
<script type="text/javascript" src="{% static 'payments/js/jQuery.glob.en-AU.js'%}"></script>
<script type="text/javascript" src="{% static 'payments/js/moneyInput.js'%}"></script>
<script type="text/javascript" src="{% static 'payments/js/payment.js'%}"></script>
<script type="text/javascript" src="{% static 'payments/js/jquery.glob.js'%}?ver={% now "Ymd" %}"></script>
<script type="text/javascript" src="{% static 'payments/js/jQuery.glob.en-AU.js'%}?ver={% now "Ymd" %}"></script>
<script type="text/javascript" src="{% static 'payments/js/moneyInput.js'%}?ver={% now "Ymd" %}"></script>
<script type="text/javascript" src="{% static 'payments/js/payment.js'%}?ver={% now "Ymd" %}"></script>
</body>

</html>

0 comments on commit 1a18eb5

Please sign in to comment.