Skip to content

Commit

Permalink
Removal of commented code
Browse files Browse the repository at this point in the history
  • Loading branch information
maniamartial committed Jun 1, 2024
1 parent d122de5 commit 5331b13
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2024-02-24 10:39:35.240704",
"modified": "2024-06-01 18:24:33.127310",
"modified_by": "Administrator",
"module": "Burundi Compliance",
"name": "eBMS API Methods",
Expand Down
13 changes: 0 additions & 13 deletions burundi_compliance/burundi_compliance/overrides/sales_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,6 @@ def on_submit(doc, method=None):
doc.reload()


# if doc.doctype == "Sales Invoice":
# on_submit_update_stock(doc)

# def on_submit_update_stock(doc, method=None):
# if allow_obr_to_track_stock_movement==1:
# if doc.update_stock==1 or doc.is_return==1:
# # Check if the flag is set before queuing stock movements
# if not doc.get("__stock_movement_queued"):
# frappe.publish_realtime('update_stock 1', {"message": "Updating stock"}, user=frappe.session.user)
# get_items(doc)
# # Set the flag to indicate that stock movement has been queued
# doc.set("__stock_movement_queued", True)

def submit_invoice_request(doc):
if allow_obr_to_track_sales==1:
sales_invoice_data_processor = InvoiceDataProcessor(doc)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ def send_data(doc):
'''If the item is set to be tracked, then enqueue the stock movement'''
if allow_obr_to_track_stock_movement == 1 and item_doc.custom_allow_obr_to_track_stock_movement == 1:
try:

enqueue_stock_movement(data, doc)
frappe.msgprint(f"The transaction for {data.get('item_code')} queued successfully", alert=True)
except Exception as e:
Expand Down
12 changes: 2 additions & 10 deletions burundi_compliance/burundi_compliance/utils/background_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def enqueue_retry_posting_sales_invoice(invoice_data, doc_name):

@frappe.whitelist(allow_guest=True)
def retry_stock_movement(data, doc):

from ..api_classes.add_stock_movement import TrackStockMovement
retries = 0
doc=frappe.get_doc(doc.doctype, doc.name)
Expand All @@ -90,20 +90,11 @@ def retry_stock_movement(data, doc):
time.sleep(retry_delay_seconds)
continue
frappe.log_error(f"Max retries reached. Unable to send invoice data to OBR.")

# '''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)



######################################################################################################
###########Enqueue the background job to Cancel sales invoice#####################################
######################################################################################################
Expand Down Expand Up @@ -212,6 +203,7 @@ def retry_sending_invoice(invoice_identifier):

@frappe.whitelist(allow_guest=True)
def retry_stock_movement_after_failure(doc_type, doc_name):

doc = frappe.get_doc(doc_type, doc_name)

frappe.msgprint(f"Retrying sending stock movement data to OBR for {doc.name}", alert=True)
Expand Down
9 changes: 4 additions & 5 deletions burundi_compliance/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,15 +186,14 @@
##################################################################################################################
##############################Remember to change the cron job to the correct time#################################
##################################################################################################################
from burundi_compliance.burundi_compliance.utils.event_frequency_schedular import get_event_frequency
invoice_frequency, stock_movement_frequency = get_event_frequency()
# from burundi_compliance.burundi_compliance.utils.event_frequency_schedular import get_event_frequency
# invoice_frequency, stock_movement_frequency = get_event_frequency()

scheduler_events = {

"cron":{
f"{invoice_frequency}":["burundi_compliance.burundi_compliance.utils.schedular.check_and_send_pending_sales_invoices"],
f"{stock_movement_frequency}":["burundi_compliance.burundi_compliance.utils.schedular.check_and_send_pending_stock_ledger_entry"],

"0 * * * *":["burundi_compliance.burundi_compliance.utils.schedular.check_and_send_pending_sales_invoices"],
"2 * * * *":["burundi_compliance.burundi_compliance.utils.schedular.check_and_send_pending_stock_ledger_entry"],
},

}
Expand Down

0 comments on commit 5331b13

Please sign in to comment.