mirror of
https://github.com/frappe/erpnext.git
synced 2026-09-20 03:47:11 +00:00
feat(Non Profit): 80G Certificates and Donations (#24657)
* feat: 80G Certificates * feat: add non-profit custom fields for India * feat: 80G Certificate print format for memberships * feat: Donation doctype and API endpoint to capture donations via razorpay * chore: Rename Membership Settings to Non Profit Settings * chore: clean up Non Profit Settings - Rename fields, better labels - patch for renaming * feat: Webhook secret generation for Razorpay donations in Non-Profit Settings * feat: Payment Entry for donations - added Donor as Party Type - setting for automating payment entries for donations created via web form * fix: linter and sider issues * fix: translation syntax * feat: PAN Details custom field for Indian donors * feat: 80G certificates for Donations with Print Format * fix: sider * feat: validations for donor and donation - create donor for website user from donations - validate donor email * feat: extract member name from subscription notes * test: Donation * test: Tax Exemption 80G Certificate * chore: styling fixes * fix: tests * fix: sider * feat: extract PAN number from additional subscription notes * feat: Add creation user field in Non Profit Settings fix: Payment Entry not generating for memberships and donations * feat: update desk page * fix: tests
This commit is contained in:
@@ -92,14 +92,16 @@ frappe.ui.form.on('Payment Entry', {
|
||||
});
|
||||
|
||||
frm.set_query("reference_doctype", "references", function() {
|
||||
if (frm.doc.party_type=="Customer") {
|
||||
if (frm.doc.party_type == "Customer") {
|
||||
var doctypes = ["Sales Order", "Sales Invoice", "Journal Entry", "Dunning"];
|
||||
} else if (frm.doc.party_type=="Supplier") {
|
||||
} else if (frm.doc.party_type == "Supplier") {
|
||||
var doctypes = ["Purchase Order", "Purchase Invoice", "Journal Entry"];
|
||||
} else if (frm.doc.party_type=="Employee") {
|
||||
} else if (frm.doc.party_type == "Employee") {
|
||||
var doctypes = ["Expense Claim", "Journal Entry"];
|
||||
} else if (frm.doc.party_type=="Student") {
|
||||
} else if (frm.doc.party_type == "Student") {
|
||||
var doctypes = ["Fees"];
|
||||
} else if (frm.doc.party_type == "Donor") {
|
||||
var doctypes = ["Donation"];
|
||||
} else {
|
||||
var doctypes = ["Journal Entry"];
|
||||
}
|
||||
@@ -128,7 +130,7 @@ frappe.ui.form.on('Payment Entry', {
|
||||
const child = locals[cdt][cdn];
|
||||
const filters = {"docstatus": 1, "company": doc.company};
|
||||
const party_type_doctypes = ['Sales Invoice', 'Sales Order', 'Purchase Invoice',
|
||||
'Purchase Order', 'Expense Claim', 'Fees', 'Dunning'];
|
||||
'Purchase Order', 'Expense Claim', 'Fees', 'Dunning', 'Donation'];
|
||||
|
||||
if (in_list(party_type_doctypes, child.reference_doctype)) {
|
||||
filters[doc.party_type.toLowerCase()] = doc.party;
|
||||
@@ -281,7 +283,7 @@ frappe.ui.form.on('Payment Entry', {
|
||||
let party_types = Object.keys(frappe.boot.party_account_types);
|
||||
if(frm.doc.party_type && !party_types.includes(frm.doc.party_type)){
|
||||
frm.set_value("party_type", "");
|
||||
frappe.throw(__("Party can only be one of "+ party_types.join(", ")));
|
||||
frappe.throw(__("Party can only be one of {0}", [party_types.join(", ")]));
|
||||
}
|
||||
|
||||
frm.set_query("party", function() {
|
||||
@@ -705,7 +707,8 @@ frappe.ui.form.on('Payment Entry', {
|
||||
(frm.doc.payment_type=="Receive" && frm.doc.party_type=="Customer") ||
|
||||
(frm.doc.payment_type=="Pay" && frm.doc.party_type=="Supplier") ||
|
||||
(frm.doc.payment_type=="Pay" && frm.doc.party_type=="Employee") ||
|
||||
(frm.doc.payment_type=="Receive" && frm.doc.party_type=="Student")
|
||||
(frm.doc.payment_type=="Receive" && frm.doc.party_type=="Student") ||
|
||||
(frm.doc.payment_type=="Receive" && frm.doc.party_type=="Donor")
|
||||
) {
|
||||
if(total_positive_outstanding > total_negative_outstanding)
|
||||
if (!frm.doc.paid_amount)
|
||||
@@ -748,7 +751,8 @@ frappe.ui.form.on('Payment Entry', {
|
||||
(frm.doc.payment_type=="Receive" && frm.doc.party_type=="Customer") ||
|
||||
(frm.doc.payment_type=="Pay" && frm.doc.party_type=="Supplier") ||
|
||||
(frm.doc.payment_type=="Pay" && frm.doc.party_type=="Employee") ||
|
||||
(frm.doc.payment_type=="Receive" && frm.doc.party_type=="Student")
|
||||
(frm.doc.payment_type=="Receive" && frm.doc.party_type=="Student") ||
|
||||
(frm.doc.payment_type=="Receive" && frm.doc.party_type=="Donor")
|
||||
) {
|
||||
if(total_positive_outstanding_including_order > paid_amount) {
|
||||
var remaining_outstanding = total_positive_outstanding_including_order - paid_amount;
|
||||
@@ -905,6 +909,12 @@ frappe.ui.form.on('Payment Entry', {
|
||||
frappe.msgprint(__("Row #{0}: Reference Document Type must be one of Expense Claim or Journal Entry", [row.idx]));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (frm.doc.party_type == "Donor" && row.reference_doctype != "Donation") {
|
||||
frappe.model.set_value(row.doctype, row.name, "reference_doctype", null);
|
||||
frappe.msgprint(__("Row #{0}: Reference Document Type must be Donation", [row.idx]));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (row) {
|
||||
|
||||
@@ -72,6 +72,7 @@ class PaymentEntry(AccountsController):
|
||||
self.update_outstanding_amounts()
|
||||
self.update_advance_paid()
|
||||
self.update_expense_claim()
|
||||
self.update_donation()
|
||||
self.update_payment_schedule()
|
||||
self.set_status()
|
||||
|
||||
@@ -82,6 +83,7 @@ class PaymentEntry(AccountsController):
|
||||
self.update_outstanding_amounts()
|
||||
self.update_advance_paid()
|
||||
self.update_expense_claim()
|
||||
self.update_donation(cancel=1)
|
||||
self.delink_advance_entry_references()
|
||||
self.update_payment_schedule(cancel=1)
|
||||
self.set_payment_req_status()
|
||||
@@ -245,6 +247,8 @@ class PaymentEntry(AccountsController):
|
||||
valid_reference_doctypes = ("Expense Claim", "Journal Entry", "Employee Advance")
|
||||
elif self.party_type == "Shareholder":
|
||||
valid_reference_doctypes = ("Journal Entry")
|
||||
elif self.party_type == "Donor":
|
||||
valid_reference_doctypes = ("Donation")
|
||||
|
||||
for d in self.get("references"):
|
||||
if not d.allocated_amount:
|
||||
@@ -618,6 +622,13 @@ class PaymentEntry(AccountsController):
|
||||
doc = frappe.get_doc("Expense Claim", d.reference_name)
|
||||
update_reimbursed_amount(doc, self.name)
|
||||
|
||||
def update_donation(self, cancel=0):
|
||||
if self.payment_type == "Receive" and self.party_type == "Donor" and self.party:
|
||||
for d in self.get("references"):
|
||||
if d.reference_doctype=="Donation" and d.reference_name:
|
||||
is_paid = 0 if cancel else 1
|
||||
frappe.db.set_value("Donation", d.reference_name, "paid", is_paid)
|
||||
|
||||
def on_recurring(self, reference_doc, auto_repeat_doc):
|
||||
self.reference_no = reference_doc.name
|
||||
self.reference_date = nowdate()
|
||||
@@ -917,6 +928,9 @@ def get_reference_details(reference_doctype, reference_name, party_account_curre
|
||||
total_amount = ref_doc.get("grand_total")
|
||||
exchange_rate = 1
|
||||
outstanding_amount = ref_doc.get("outstanding_amount")
|
||||
elif reference_doctype == "Donation":
|
||||
total_amount = ref_doc.get("amount")
|
||||
exchange_rate = 1
|
||||
elif reference_doctype == "Dunning":
|
||||
total_amount = ref_doc.get("dunning_amount")
|
||||
exchange_rate = 1
|
||||
@@ -1166,8 +1180,10 @@ def set_party_type(dt):
|
||||
party_type = "Supplier"
|
||||
elif dt in ("Expense Claim", "Employee Advance"):
|
||||
party_type = "Employee"
|
||||
elif dt in ("Fees"):
|
||||
elif dt == "Fees":
|
||||
party_type = "Student"
|
||||
elif dt == "Donation":
|
||||
party_type = "Donor"
|
||||
return party_type
|
||||
|
||||
def set_party_account(dt, dn, doc, party_type):
|
||||
@@ -1193,7 +1209,7 @@ def set_party_account_currency(dt, party_account, doc):
|
||||
return party_account_currency
|
||||
|
||||
def set_payment_type(dt, doc):
|
||||
if (dt == "Sales Order" or (dt in ("Sales Invoice", "Fees", "Dunning") and doc.outstanding_amount > 0)) \
|
||||
if (dt in ("Sales Order", "Donation") or (dt in ("Sales Invoice", "Fees", "Dunning") and doc.outstanding_amount > 0)) \
|
||||
or (dt=="Purchase Invoice" and doc.outstanding_amount < 0):
|
||||
payment_type = "Receive"
|
||||
else:
|
||||
@@ -1226,6 +1242,9 @@ def set_grand_total_and_outstanding_amount(party_amount, dt, party_account_curre
|
||||
elif dt == "Dunning":
|
||||
grand_total = doc.grand_total
|
||||
outstanding_amount = doc.grand_total
|
||||
elif dt == "Donation":
|
||||
grand_total = doc.amount
|
||||
outstanding_amount = doc.amount
|
||||
else:
|
||||
if party_account_currency == doc.company_currency:
|
||||
grand_total = flt(doc.get("base_rounded_total") or doc.base_grand_total)
|
||||
|
||||
Reference in New Issue
Block a user