forked from resilient-tech/india-compliance
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
78 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters