Merge pull request #667 from pateljannat/batch-ic
fix: misc batch issues
This commit is contained in:
@@ -48,7 +48,7 @@ def get_context(context):
|
||||
else:
|
||||
upcoming_batches.append(batch)
|
||||
|
||||
context.past_batches = sorted(past_batches, key=lambda d: d.start_date)
|
||||
context.past_batches = sorted(past_batches, key=lambda d: d.start_date, reverse=True)
|
||||
context.upcoming_batches = sorted(upcoming_batches, key=lambda d: d.start_date)
|
||||
context.private_batches = sorted(private_batches, key=lambda d: d.start_date)
|
||||
|
||||
@@ -83,5 +83,6 @@ def get_context(context):
|
||||
batchinfo.seats_left = batchinfo.seat_count - batchinfo.student_count
|
||||
|
||||
my_batches_info.append(batchinfo)
|
||||
my_batches_info = sorted(my_batches_info, key=lambda d: d.start_date, reverse=True)
|
||||
|
||||
context.my_batches = my_batches_info
|
||||
|
||||
@@ -114,6 +114,7 @@ const setup_billing = () => {
|
||||
|
||||
const generate_payment_link = (e) => {
|
||||
let new_address = this.billing.get_values();
|
||||
validate_address(new_address);
|
||||
let doctype = $(e.currentTarget).attr("data-doctype");
|
||||
let docname = decodeURIComponent($(e.currentTarget).attr("data-name"));
|
||||
|
||||
@@ -182,8 +183,10 @@ const change_currency = () => {
|
||||
if (current_price != data.message) {
|
||||
update_price(data.message);
|
||||
}
|
||||
if (!data.message.includes("INR")) {
|
||||
$("#gst-message").addClass("hide");
|
||||
if (data.message.includes("INR")) {
|
||||
$("#gst-message").removeClass("hide").addClass("show");
|
||||
} else {
|
||||
$("#gst-message").removeClass("show").addClass("hide");
|
||||
}
|
||||
},
|
||||
});
|
||||
@@ -196,3 +199,48 @@ const update_price = (price) => {
|
||||
indicator: "yellow",
|
||||
});
|
||||
};
|
||||
|
||||
const validate_address = (billing_address) => {
|
||||
if (billing_address.country == "India" && !billing_address.state)
|
||||
frappe.throw(__("State is mandatory."));
|
||||
|
||||
const states = [
|
||||
"Andhra Pradesh",
|
||||
"Arunachal Pradesh",
|
||||
"Assam",
|
||||
"Bihar",
|
||||
"Chhattisgarh",
|
||||
"Goa",
|
||||
"Gujarat",
|
||||
"Haryana",
|
||||
"Himachal Pradesh",
|
||||
"Jharkhand",
|
||||
"Karnataka",
|
||||
"Kerala",
|
||||
"Madhya Pradesh",
|
||||
"Maharashtra",
|
||||
"Manipur",
|
||||
"Meghalaya",
|
||||
"Mizoram",
|
||||
"Nagaland",
|
||||
"Odisha",
|
||||
"Punjab",
|
||||
"Rajasthan",
|
||||
"Sikkim",
|
||||
"Tamil Nadu",
|
||||
"Telangana",
|
||||
"Tripura",
|
||||
"Uttar Pradesh",
|
||||
"Uttarakhand",
|
||||
"West Bengal",
|
||||
];
|
||||
if (
|
||||
billing_address.country == "India" &&
|
||||
!states.includes(billing_address.state)
|
||||
)
|
||||
frappe.throw(
|
||||
__(
|
||||
"Please enter a valid state with correct spelling and the first letter capitalized."
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
@@ -15,6 +15,13 @@ def get_context(context):
|
||||
validate_access(doctype, docname, module)
|
||||
get_billing_details(context)
|
||||
|
||||
context.original_currency = context.currency
|
||||
context.original_amount = (
|
||||
apply_gst(context.amount, None)[0]
|
||||
if context.original_currency == "INR"
|
||||
else context.amount
|
||||
)
|
||||
|
||||
context.exception_country = frappe.get_all(
|
||||
"Payment Country", filters={"parent": "LMS Settings"}, pluck="country"
|
||||
)
|
||||
@@ -27,9 +34,6 @@ def get_context(context):
|
||||
if context.currency == "INR":
|
||||
context.amount, context.gst_applied = apply_gst(context.amount, None)
|
||||
|
||||
context.original_amount = context.amount
|
||||
context.original_currency = context.currency
|
||||
|
||||
|
||||
def validate_access(doctype, docname, module):
|
||||
if frappe.session.user == "Guest":
|
||||
|
||||
Reference in New Issue
Block a user