tds fixed for PI

This commit is contained in:
Saurabh 2018-05-14 20:19:39 +05:30
parent b9d3385fec
commit f3f438ad18
2 changed files with 15 additions and 20 deletions

View File

@ -732,19 +732,17 @@ class PurchaseInvoice(BuyingController):
def set_tax_withholding(self): def set_tax_withholding(self):
""" """
1. Get TDS Configurations against Supplier or Pull Default One. 1. Get TDS Configurations against Supplier
2. Form Purchase Order, identify partial payments
3. If sum of all invoices grand total is greater than threshold and If TDS not deducted in previos Invoices
then deduct TDS for sum amount else deduct TDS for current Invoice
""" """
if not self.get("__islocal"):
return
tax_withholding_details = get_patry_tax_withholding_details(self) tax_withholding_details = get_patry_tax_withholding_details(self)
for tax_details in tax_withholding_details:
if tax_withholding_details and\ if flt(self.get("rounded_total") or self.grand_total) >= flt(tax_details['threshold']):
flt(self.get("rounded_total") or self.grand_total) >= flt(tax_withholding_details['threshold']): if self.taxes:
self.append('taxes', tax_withholding_details['taxes']) if tax_details['tax']['description'] not in [tax.description for tax in self.taxes]:
self.append('taxes', tax_details['tax'])
else:
self.append('taxes', tax_details['tax'])
@frappe.whitelist() @frappe.whitelist()
def make_debit_note(source_name, target_doc=None): def make_debit_note(source_name, target_doc=None):

View File

@ -478,8 +478,8 @@ def get_party_shipping_address(doctype, name):
def get_patry_tax_withholding_details(ref_doc): def get_patry_tax_withholding_details(ref_doc):
supplier = frappe.get_doc("Supplier", ref_doc.supplier) supplier = frappe.get_doc("Supplier", ref_doc.supplier)
tax_withholding_details = {} tax_withholding_details = []
print(supplier)
for tax in supplier.tax_withholding_config: for tax in supplier.tax_withholding_config:
tax_mapper = get_tax_mapper() tax_mapper = get_tax_mapper()
@ -492,19 +492,16 @@ def get_patry_tax_withholding_details(ref_doc):
prepare_tax_withholding_details(tax_mapper, tax_withholding_details) prepare_tax_withholding_details(tax_mapper, tax_withholding_details)
if not tax_withholding_details:
tax_mapper = get_tax_mapper()
set_tax_withholding_details(tax_mapper, ref_doc, use_default=1)
prepare_tax_withholding_details(tax_mapper, tax_withholding_details)
return tax_withholding_details return tax_withholding_details
def prepare_tax_withholding_details(tax_mapper, tax_withholding_details): def prepare_tax_withholding_details(tax_mapper, tax_withholding_details):
if tax_mapper.get('account_head'): if tax_mapper.get('account_head'):
tax_withholding_details.update({
tax_withholding_details.append({
"threshold": tax_mapper['threshold'], "threshold": tax_mapper['threshold'],
"taxes": tax_mapper "tax": tax_mapper
}) })
del tax_mapper['threshold'] del tax_mapper['threshold']
def set_tax_withholding_details(tax_mapper, ref_doc, tax_withholding_category=None, use_default=0): def set_tax_withholding_details(tax_mapper, ref_doc, tax_withholding_category=None, use_default=0):
@ -534,4 +531,4 @@ def get_tax_mapper():
"description": '', "description": '',
"account_head": '', "account_head": '',
"threshold": 0.0 "threshold": 0.0
} }