Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Payment Entry for TDS #6

Open
wants to merge 4 commits into
base: version-14
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 71 additions & 1 deletion razorpay_payment_links_integration/public/js/payment_entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,77 @@ frappe.ui.form.on("Payment Entry", {
frm.set_value('party', sales_order_doc.customer);
frm.set_value('party_name', sales_order_doc.customer_name);
});
}
},
validate:function(frm) {
let total = 0;
frm.doc.references.forEach(i => {
total += i.tds
})
// console.log(total)
if (!frm.doc.deductions || frm.doc.deductions.length == 0){
let new_row = frm.add_child("deductions");
if (frm.doc.company=="Mycorporation Consultants Private Limited"){
new_row.account = 'TDS Receivable - MCPL'
new_row.cost_center = "Main - MCPL"
new_row.amount = isNaN(total) ? 0 : total
frm.refresh_field('deductions')
} else if (frm.doc.company=="Brivan Consultants Private Limited") {
new_row.account = 'TDS Receivable - BCL'
new_row.cost_center = "Main - BCL"
new_row.amount = total
} else{
new_row.account = 'TDS Receivable - KJ'
new_row.cost_center = "Main - KJ "
new_row.amount = total
}}

if (frm.doc.deductions.length > 0){
for (let b = 0;b<frm.doc.deductions.length; b++){

if (frm.doc.deductions[b].account != "TDS Receivable - MCPL" && frm.doc.deductions[b].account != "TDS Receivable - BCL" && frm.doc.deductions[b].account != "TDS Receivable - KJ" ){
let new_row = frm.add_child("deductions");
if (frm.doc.company=="Mycorporation Consultants Private Limited"){
new_row.account = 'TDS Receivable - MCPL'
new_row.cost_center = "Main - MCPL"
new_row.amount = total
frm.refresh_field('deductions')
} else if (frm.doc.company=="Brivan Consultants Private Limited") {
new_row.account = 'TDS Receivable - BCL'
new_row.cost_center = "Main - BCL"
new_row.amount =total
} else{
new_row.account = 'TDS Receivable - KJ'
new_row.cost_center = "Main - KJ "
new_row.amount = total
}}
else if(frm.doc.deductions[b].account == "TDS Receivable - MCPL" || frm.doc.deductions[b].account == "TDS Receivable - BCL" || frm.doc.deductions[b].account == "TDS Receivable - KJ" ){
frm.doc.deductions[b].amount = isNaN(total) ? 0 : total
frm.refresh_field('deductions')
}
}
}}
})

frappe.ui.form.on('Payment Entry Reference', {
references_remove(frm){
let total = 0
frm.doc.references.forEach(i => {
total += i.tds
})
for (let b = 0;b<frm.doc.deductions.length; b++){

if (frm.doc.deductions[b].account != "TDS Receivable - MCPL" ||frm.doc.deductions[b].account != "TDS Receivable - BCL" ||frm.doc.deductions[b].account == "TDS Receivable - KJ"){
return
}
else if(frm.doc.deductions[b].account == "TDS Receivable - MCPL"||frm.doc.deductions[b].account == "TDS Receivable - BCL"||frm.doc.deductions[b].account == "TDS Receivable - KJ"){

frm.doc.deductions[b].amount = 0
frm.doc.deductions[b].amount = total
frm.refresh_field('deductions')
}
}

}


})