OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Voucher Appears on Both Debit and Credit Sides in Sundry Creditors Ledger in Logistic Accounting Software

  • Thread starter Thread starter dev MuhammedSalih
  • Start date Start date
D

dev MuhammedSalih

Guest
I am currently working on existing logistic company's accounting software.the sundry creditors ledger data function returning a single voucher entry twice: once on the debit side and once on the credit side. This behavior seems incorrect as the voucher should only be listed once.its only happening journal Vouchar entry

for eg: - as you can see the 100 rs transaction effects on both dr and cr side its journal Vouchar entry rest of the vouchar types working perfectly

Code:
def get_sundry_creditors_coa_response(coa, start_date, end_date, user):

    invoices = Invoices.objects.filter(date__range=[
                                       start_date, end_date], invoice_type='Purchase', company__users__email=user.email).order_by('date')

    respone = []
    res_obj = {}
    for invoice in invoices:
        cost_entrys = CostEntry.objects.filter(
            invoice__id=invoice.id, is_included=True)

        for cost_entry in cost_entrys:
            res_obj = {
                "account": invoice.client_name.name if invoice.client_name else "",
                "date": invoice.date,
                "currency": invoice.currency_sar,
                "invoice_number": invoice.invoice_number,
                "vat_percent": 0,
                "fcy_amount": 0,
                "vat_amount": 0,
                "amount": 0,
                "dr_amount": 0,
                "cr_amount": 0,
                "net_amount": 0,
                "type": "Invoice",
                "voucher": "",
                "party_account": invoice.party_account.name if invoice.party_account else "",
                "job_no": invoice.job.job_number if invoice.job.job_number else "",
                "narrations": invoice.narration if invoice.narration else "",
                "branch": invoice.branch if invoice.branch else "",
                "language_name": coa.language_name if coa.language_name else ""
            }

            fcy_amount = float(
                cost_entry.fcy_amount if cost_entry.fcy_amount else 0.0)
     
            amount = float(cost_entry.amount if cost_entry.amount else 0.0)
         
            vat_percent = float(
                cost_entry.tax_group_code if cost_entry.tax_group_code else 0.0)
        
            vat_amount = float((vat_percent * amount)/100)
           
            total_amount = float(vat_amount+amount)
          

            res_obj['vat_percent'] = vat_percent
            res_obj['fcy_amount'] = fcy_amount
            res_obj['amount'] = amount
            res_obj['vat_amount'] = vat_amount
            res_obj['dr_amount'] = total_amount
            res_obj['net_amount'] = total_amount

            if not res_obj["dr_amount"] == 0 or not res_obj["cr_amount"] == 0:
                respone.append(res_obj)

    
    coa_account_details = AccountDetails.objects.filter(vouchers__date__range=[
                                                        start_date, end_date], vouchers__company__users__email=user.email)
    account_details = coa_account_details.exclude(
        vouchers__voucher_type="Receipt").exclude(vouchers__voucher_type="CreditNote")
    direct_input_details = account_details.filter(
         ac_name_type='coa')
    
    
    account_details = account_details.union(direct_input_details)    

    for acc in account_details:   
        party_account = None
        if acc.vouchers.party_account:
            if acc.vouchers.party_account_type == 'coa':
                party_account = Coa.objects.filter(
                    id=acc.vouchers.party_account).first()
               
            else :
                party_account = Organization.objects.filter(
                id=acc.vouchers.party_account).first()
            

            
            res_obj = {
                "account": coa.name,
                "date": acc.vouchers.date if acc.vouchers.date else '',
                "currency": acc.currency,
                "invoice_number": "",
                "vat_percent": 0,
                "fcy_amount": 0,
                "vat_amount": 0,
                "amount": 0,
                "dr_amount": 0,
                "cr_amount": 0,
                "net_amount": 0,
                "type": acc.vouchers.voucher_type + " Voucher",
                "voucher": acc.vouchers.voucher_number if acc.vouchers else "",
                "party_account": party_account.name if party_account else '',
                "job_no": acc.vouchers.job.job_number if acc.vouchers and acc.vouchers.job else "",
                "narrations": acc.narration,
                "branch": acc.vouchers.branch if acc.vouchers else "",
                "language_name": coa.language_name if coa.language_name else ""
            }
            
            # print(res_obj)
            # fcy_amount = float(acc.fcy_amount if acc.fcy_amount else 0.0)
            fcy_amount_str = acc.fcy_amount if acc.fcy_amount else "0.0"
    
            # Check if the string contains a decimal point
            if '.' in fcy_amount_str:
                # If the string contains a decimal point, remove the extra decimal point and convert to float
                fcy_amount_str_without_extra_decimal = fcy_amount_str.replace(
                    '.', '', 1)  # Remove the first occurrence of the decimal point
                fcy_amount = float(fcy_amount_str_without_extra_decimal)
            else:
                # If the string does not contain a decimal point, convert to float directly
                fcy_amount = float(fcy_amount_str)
            amount = float(acc.amount_sar if acc.amount_sar else 0.0)
     
            vat_percent = float(
                acc.tax_group_code if acc.tax_group_code else 0.0)
            vat_amount = float((vat_percent * amount)/100)
            total_amount = float(vat_amount+ amount)

            if acc.ac_name == '429' and acc.ac_name_type == 'coa':
                total_amount = amount

            res_obj['vat_percent'] = vat_percent
            res_obj['fcy_amount'] = fcy_amount
            res_obj['amount'] = amount
            res_obj['vat_amount'] = vat_amount
            
                
                    

            if acc.dr_cr == 'Cr':
                if not acc.vouchers.voucher_type == 'DebitNote':
                    res_obj['cr_amount'] = total_amount
                  
            else:
                if not acc.vouchers.voucher_type == 'Payment':
                    res_obj['dr_amount'] = total_amount
                    
                    
           
                    
                    
                
                    
           

            res_obj['net_amount'] = total_amount
            print(res_obj) 
            print(end='\n')

            if not res_obj["dr_amount"] == 0 or not res_obj["cr_amount"] == 0:
                respone.append(res_obj)
                         
                
                
    balance = 0
    results = []
    for res in respone:
        balance = float(balance) + \
            float(float(res['dr_amount']) - float(res['cr_amount']))
        # print(balance)
        res['net_amount'] = balance
        results.append(res)

    return results

this is function for get_sundry_creditors_coa_response

Verified that the voucher is not duplicated in the database. Checked the query to ensure it correctly fetches the ledger entries. Reviewed the logic for generating the ledger report.
<p>I am currently working on existing logistic company's accounting software.the sundry creditors ledger data function returning a single voucher entry twice: once on the debit side and once on the credit side. This behavior seems incorrect as the voucher should only be listed once.its only happening journal Vouchar entry</p>
<p>for eg: -
<a href="https://i.sstatic.net/LhUeTcXd.png" rel="nofollow noreferrer">as you can see the 100 rs transaction effects on both dr and cr side its journal Vouchar entry rest of the vouchar types working perfectly </a></p>
<pre><code>def get_sundry_creditors_coa_response(coa, start_date, end_date, user):

invoices = Invoices.objects.filter(date__range=[
start_date, end_date], invoice_type='Purchase', company__users__email=user.email).order_by('date')

respone = []
res_obj = {}
for invoice in invoices:
cost_entrys = CostEntry.objects.filter(
invoice__id=invoice.id, is_included=True)

for cost_entry in cost_entrys:
res_obj = {
"account": invoice.client_name.name if invoice.client_name else "",
"date": invoice.date,
"currency": invoice.currency_sar,
"invoice_number": invoice.invoice_number,
"vat_percent": 0,
"fcy_amount": 0,
"vat_amount": 0,
"amount": 0,
"dr_amount": 0,
"cr_amount": 0,
"net_amount": 0,
"type": "Invoice",
"voucher": "",
"party_account": invoice.party_account.name if invoice.party_account else "",
"job_no": invoice.job.job_number if invoice.job.job_number else "",
"narrations": invoice.narration if invoice.narration else "",
"branch": invoice.branch if invoice.branch else "",
"language_name": coa.language_name if coa.language_name else ""
}

fcy_amount = float(
cost_entry.fcy_amount if cost_entry.fcy_amount else 0.0)

amount = float(cost_entry.amount if cost_entry.amount else 0.0)

vat_percent = float(
cost_entry.tax_group_code if cost_entry.tax_group_code else 0.0)

vat_amount = float((vat_percent * amount)/100)

total_amount = float(vat_amount+amount)


res_obj['vat_percent'] = vat_percent
res_obj['fcy_amount'] = fcy_amount
res_obj['amount'] = amount
res_obj['vat_amount'] = vat_amount
res_obj['dr_amount'] = total_amount
res_obj['net_amount'] = total_amount

if not res_obj["dr_amount"] == 0 or not res_obj["cr_amount"] == 0:
respone.append(res_obj)


coa_account_details = AccountDetails.objects.filter(vouchers__date__range=[
start_date, end_date], vouchers__company__users__email=user.email)
account_details = coa_account_details.exclude(
vouchers__voucher_type="Receipt").exclude(vouchers__voucher_type="CreditNote")
direct_input_details = account_details.filter(
ac_name_type='coa')


account_details = account_details.union(direct_input_details)

for acc in account_details:
party_account = None
if acc.vouchers.party_account:
if acc.vouchers.party_account_type == 'coa':
party_account = Coa.objects.filter(
id=acc.vouchers.party_account).first()

else :
party_account = Organization.objects.filter(
id=acc.vouchers.party_account).first()



res_obj = {
"account": coa.name,
"date": acc.vouchers.date if acc.vouchers.date else '',
"currency": acc.currency,
"invoice_number": "",
"vat_percent": 0,
"fcy_amount": 0,
"vat_amount": 0,
"amount": 0,
"dr_amount": 0,
"cr_amount": 0,
"net_amount": 0,
"type": acc.vouchers.voucher_type + " Voucher",
"voucher": acc.vouchers.voucher_number if acc.vouchers else "",
"party_account": party_account.name if party_account else '',
"job_no": acc.vouchers.job.job_number if acc.vouchers and acc.vouchers.job else "",
"narrations": acc.narration,
"branch": acc.vouchers.branch if acc.vouchers else "",
"language_name": coa.language_name if coa.language_name else ""
}

# print(res_obj)
# fcy_amount = float(acc.fcy_amount if acc.fcy_amount else 0.0)
fcy_amount_str = acc.fcy_amount if acc.fcy_amount else "0.0"

# Check if the string contains a decimal point
if '.' in fcy_amount_str:
# If the string contains a decimal point, remove the extra decimal point and convert to float
fcy_amount_str_without_extra_decimal = fcy_amount_str.replace(
'.', '', 1) # Remove the first occurrence of the decimal point
fcy_amount = float(fcy_amount_str_without_extra_decimal)
else:
# If the string does not contain a decimal point, convert to float directly
fcy_amount = float(fcy_amount_str)
amount = float(acc.amount_sar if acc.amount_sar else 0.0)

vat_percent = float(
acc.tax_group_code if acc.tax_group_code else 0.0)
vat_amount = float((vat_percent * amount)/100)
total_amount = float(vat_amount+ amount)

if acc.ac_name == '429' and acc.ac_name_type == 'coa':
total_amount = amount

res_obj['vat_percent'] = vat_percent
res_obj['fcy_amount'] = fcy_amount
res_obj['amount'] = amount
res_obj['vat_amount'] = vat_amount




if acc.dr_cr == 'Cr':
if not acc.vouchers.voucher_type == 'DebitNote':
res_obj['cr_amount'] = total_amount

else:
if not acc.vouchers.voucher_type == 'Payment':
res_obj['dr_amount'] = total_amount









res_obj['net_amount'] = total_amount
print(res_obj)
print(end='\n')

if not res_obj["dr_amount"] == 0 or not res_obj["cr_amount"] == 0:
respone.append(res_obj)



balance = 0
results = []
for res in respone:
balance = float(balance) + \
float(float(res['dr_amount']) - float(res['cr_amount']))
# print(balance)
res['net_amount'] = balance
results.append(res)

return results

</code></pre>
<p>this is function for get_sundry_creditors_coa_response</p>
<p>Verified that the voucher is not duplicated in the database.
Checked the query to ensure it correctly fetches the ledger entries.
Reviewed the logic for generating the ledger report.</p>
 

Latest posts

U
Replies
0
Views
1
user2774120
U
P
Replies
0
Views
1
Pramod Karandikar
P
Top