Skip to content

Commit

Permalink
fix: credit note
Browse files Browse the repository at this point in the history
  • Loading branch information
ljain112 committed Nov 19, 2024
1 parent 1269713 commit 487b4ec
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 1 deletion.
77 changes: 77 additions & 0 deletions india_compliance/gst_india/utils/ve_credit_note.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import frappe
from erpnext.accounts.doctype.chart_of_accounts_importer.chart_of_accounts_importer import (
generate_data_from_excel,
get_file,
)
from frappe.utils.data import (
add_days,
add_months,
add_to_date,
cint,
date_diff,
flt,
get_date_str,
getdate,
nowdate,
)


CREDIT_NOTE_ACCOUNT = "Credit Note By Company - VE"


def import_invoices():
file_name = "/private/files/Ledger_Report_19Nov2024_638676311193017942.xlsx"
file_doc, extension = get_file(file_name)

data = generate_data_from_excel(file_doc, extension, as_dict=True)

for row in data:
row = frappe._dict(row)
print(row)
print(row.credit, "row.credit")
if row.particulars != "PROCESSING CREDIT NOTE":
continue

if frappe.db.get_value("Journal Entry", {"bill_no": row.document_no}):
continue


date =getdate(row.document_date)

jv = frappe.new_doc("Journal Entry")
jv.posting_date = date
jv.voucher_type = "Credit Note"
jv.bill_no = row.document_no
jv.bill_date = date
jv.user_remark = row.particulars

jv.append(
"accounts",
{
"account":"Debtors - VE",
"party_type": "Customer",
"party": row.account_code,
"credit": row.credit,
"debit": 0,
"credit_in_account_currency": row.credit,
"debit_in_account_currency": 0,
},
)

jv.append(
"accounts",
{
"account": CREDIT_NOTE_ACCOUNT,
"debit_in_account_currency": row.credit,
"credit_in_account_currency": 0,
"debit": row.credit,
"credit": 0,
},
)

jv.set_missing_values()

print(jv.as_dict())

jv.insert()
jv.save()
2 changes: 1 addition & 1 deletion india_compliance/gst_india/utils/ve_sales_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


def import_invoices():
file_name = "/private/files/Data_20129252_O_20241105023010_7325_E_05Nov2024_638663943037325347.xlsx"
file_name = "/private/files/Data_20129252_CO1_20241119094156_5236_E_19Nov2024_638676297076402496.xlsx"
file_doc, extension = get_file(file_name)

data = generate_data_from_excel(file_doc, extension, as_dict=True)
Expand Down

0 comments on commit 487b4ec

Please sign in to comment.