brotherton-erpnext/erpnext/templates/pages/order.js
Faris Ansari 38ac7f7350 Enhancements to Supplier Portal (#19221)
* fix: Add Purchase Order to portal

* fix: Create Customer or Supplier on first login

Based on default role set in Portal Settings, a Customer or Supplier
will be created when the user logs in for the first time.

* fix: Styling for transaction_row

* fix: Styling for RFQ page

* fix: Add Purchase Invoice route

- Make Purchase Invoice from PO

* fix: minor

- Admissions for Student role
- Remove print statement
2019-10-09 11:41:33 +05:30

43 lines
1.7 KiB
JavaScript

// Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
// For license information, please see license.txt
frappe.ready(function(){
var loyalty_points_input = document.getElementById("loyalty-point-to-redeem");
var loyalty_points_status = document.getElementById("loyalty-points-status");
if (loyalty_points_input) {
loyalty_points_input.onblur = apply_loyalty_points;
}
function apply_loyalty_points() {
var loyalty_points = parseInt(loyalty_points_input.value);
if (loyalty_points) {
frappe.call({
method: "erpnext.accounts.doctype.loyalty_program.loyalty_program.get_redeemption_factor",
args: {
"customer": doc_info.customer
},
callback: function(r) {
if (r) {
var message = ""
let loyalty_amount = flt(r.message*loyalty_points);
if (doc_info.grand_total && doc_info.grand_total < loyalty_amount) {
let redeemable_amount = parseInt(doc_info.grand_total/r.message);
message = "You can only redeem max " + redeemable_amount + " points in this order.";
frappe.msgprint(__(message));
} else {
message = loyalty_points + " Loyalty Points of amount "+ loyalty_amount + " is applied."
frappe.msgprint(__(message));
var remaining_amount = flt(doc_info.grand_total) - flt(loyalty_amount);
var payment_button = document.getElementById("pay-for-order");
payment_button.innerHTML = __("Pay Remaining");
payment_button.href = "/api/method/erpnext.accounts.doctype.payment_request.payment_request.make_payment_request?dn="+doc_info.doctype_name+"&dt="+doc_info.doctype+"&loyalty_points="+loyalty_points+"&submit_doc=1&order_type=Shopping Cart";
}
loyalty_points_status.innerHTML = message;
}
}
});
}
}
})