Skip to content

Commit

Permalink
changes on ipro report
Browse files Browse the repository at this point in the history
  • Loading branch information
maniamartial committed Apr 8, 2024
1 parent 6151e1a commit 7d8f6ad
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 45 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# Copyright (c) 2024, Navari Limited and contributors
# For license information, please see license.txt

# import frappe


import frappe
from frappe import _
from pypika import Case
Expand Down Expand Up @@ -33,8 +30,8 @@ def get_columns():
},

{
"fieldname": "base_income_tax",
"label": _("Base Income Tax"),
"fieldname": "base_imposable",
"label": _("Base imposable"),
"fieldtype": "Currency",
"width": 150
},
Expand Down Expand Up @@ -102,14 +99,14 @@ def get_p10_report_data(filters):
conditions.append(salary_slip.company == filters.get("company"))
if filters.get("employee"):
conditions.append(salary_slip.employee == filters.get("employee"))
if filters.get("from_date") and filters.get("to_date"):
conditions.append(
salary_slip.posting_date.between(filters.get("from_date"), filters.get("to_date"))
)
if filters.get("from_date"):
conditions.append(salary_slip.start_date >= filters.get("from_date"))
if filters.get("to_date"):
conditions.append(salary_slip.end_date <= filters.get("to_date"))

salary_components = [
'Salaire de base', 'Indemnité de logement', 'Indemnité de déplacement',
'Leave Allowance', 'Heures supplementaire', 'Commissions', 'Impot a payer','Base IRE 0%','Base IRE 0%','Base IRE 30%' 'IRE 0%', 'IRE 20%','IRE 30%']
'Leave Allowance', 'Heures supplementaire', 'Commissions','Base imposable', 'Impot a payer','Base IRE 0%','Base IRE 20%','Base IRE 30%', 'IRE 0%', 'IRE 20%','IRE 30%']

query = frappe.qb.from_(salary_slip) \
.inner_join(employee) \
Expand All @@ -130,7 +127,6 @@ def get_p10_report_data(filters):

data = query.run(as_dict=True)


employee_data = {}
for row in data:
employee_pin = row["custom_tax_id"]
Expand All @@ -155,4 +151,3 @@ def get_p10_report_data(filters):
report_data.append(row)

return report_data

14 changes: 7 additions & 7 deletions burundi_compliance/burundi_compliance/utils/background_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,13 @@ def retry_stock_movement(data, doc):
continue
frappe.log_error(f"Max retries reached. Unable to send invoice data to OBR.")

'''send email to sales manager if max retries reached'''
try:
subject = f'Maximum retries reached. Unable to send invoice to OBR. '
message="I hope this message finds you well. We regret to inform you that we have encountered difficulties in sending the stock data to OBR (Office Burundais des Recettes).To address this matter promptly, we kindly request that you reach out to OBR directly to confirm the issue and ensure a smooth resolution",
send_max_retries_email(get_user_email(frappe.get_doc(doc.voucher_type, doc.voucher_no)), subject, message, as_markdown=False)
except Exception as e:
frappe.msgprint(f"Error sending emails: {str(e)}")
# '''send email to stock manager if max retries reached'''
# try:
# subject = f'Maximum retries reached. Unable to send invoice to OBR. '
# message="I hope this message finds you well. We regret to inform you that we have encountered difficulties in sending the stock data to OBR (Office Burundais des Recettes).To address this matter promptly, we kindly request that you reach out to OBR directly to confirm the issue and ensure a smooth resolution",
# send_max_retries_email(get_user_email(frappe.get_doc(doc.voucher_type, doc.voucher_no)), subject, message, as_markdown=False)
# except Exception as e:
# frappe.msgprint(f"Error sending emails: {str(e)}")

def enqueue_stock_movement(data, doc):
frappe.enqueue('burundi_compliance.burundi_compliance.utils.background_jobs.retry_stock_movement', data=data, doc=doc, queue='long', is_async=True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def bulk_stock_submission():
stock_docs = frappe.form_dict.get("stock_details")
stock_docs_list = ast.literal_eval(stock_docs)
doctype=frappe.form_dict.get("doctype")
frappe.publish_realtime("stock_update", "Updating stock for selected invoices", user=frappe.session.user)
for stock_doc in stock_docs_list:
try:
doc=frappe.get_doc(doctype, stock_doc)
Expand Down
25 changes: 12 additions & 13 deletions burundi_compliance/burundi_compliance/utils/get_stock_items.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,15 @@


def get_items(doc):
items_data = single_stock_data(doc)
# frappe.throw(str(items_data))
# for item in items_data:
# try:

# #get the stock ledger entry for the item
# stock_ledger_entry = frappe.get_all("Stock Ledger Entry", filters={"item_code": item.get("item_code"), "voucher_no": doc.name}, fields=["*"])
# for stock_ledger in stock_ledger_entry:
# stock_ledger_doc = frappe.get_doc("Stock Ledger Entry", stock_ledger.name)
# send_data(stock_ledger_doc)
# except Exception as e:
# frappe.msgprint(f"Error sending item {item}: {str(e)}")
# raise StockMovementError(f"Error sending item {item}: {str(e)}")
items_data = single_stock_data(doc)

for item in items_data:
try:
#get the stock ledger entry for the item
stock_ledger_entry = frappe.get_all("Stock Ledger Entry", filters={"item_code": item.get("item_code"), "voucher_no": doc.name}, fields=["*"])
for stock_ledger in stock_ledger_entry:
stock_ledger_doc = frappe.get_doc("Stock Ledger Entry", stock_ledger.name)
send_data(stock_ledger_doc)
except Exception as e:
frappe.msgprint(f"Error sending item {item}: {str(e)}")
raise StockMovementError(f"Error sending item {item}: {str(e)}")
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"hidden": 0,
"is_query_report": 0,
"label": "Payroll Reports",
"link_count": 5,
"link_count": 4,
"link_type": "DocType",
"onboard": 0,
"type": "Card Break"
Expand Down Expand Up @@ -74,23 +74,13 @@
{
"hidden": 0,
"is_query_report": 1,
"label": "Burundi P10 Tax Report",
"label": "IPRO1 Report",
"link_count": 0,
"link_to": "Burundi P10 Tax Report",
"link_type": "Report",
"onboard": 0,
"type": "Link"
},
{
"hidden": 0,
"is_query_report": 1,
"label": "Burundi P9A Tax Deduction Card Report",
"link_count": 0,
"link_to": "Burundi P9A Tax Deduction Card Report",
"link_type": "Report",
"onboard": 0,
"type": "Link"
},
{
"hidden": 0,
"is_query_report": 1,
Expand All @@ -102,7 +92,7 @@
"type": "Link"
}
],
"modified": "2024-03-22 05:43:32.458914",
"modified": "2024-04-07 09:45:31.514215",
"modified_by": "Administrator",
"module": "Burundi Compliance",
"name": "Burundi Compliance",
Expand Down

0 comments on commit 7d8f6ad

Please sign in to comment.