diff --git a/rigpl_erpnext/rigpl_erpnext/doctype/carrier_tracking/fedex_functions.py b/rigpl_erpnext/rigpl_erpnext/doctype/carrier_tracking/fedex_functions.py index 0158836b..35bc7e0c 100644 --- a/rigpl_erpnext/rigpl_erpnext/doctype/carrier_tracking/fedex_functions.py +++ b/rigpl_erpnext/rigpl_erpnext/doctype/carrier_tracking/fedex_functions.py @@ -196,6 +196,8 @@ def get_tracking_from_fedex(track_doc): scans = [] if scan_events: for event in scan_events: + if event.get('EventType') == 'DL': + track_doc.delivery_date_time = event.get('Timestamp').replace(tzinfo=None) row_dict = {"time": event.get('Timestamp').replace(tzinfo=None)} city = event.get('Address').get('City', None) state = event.get('Address').get('StateOrProvinceCode', None) diff --git a/rigpl_erpnext/rigpl_erpnext/scheduled_tasks/shipment_data_update.py b/rigpl_erpnext/rigpl_erpnext/scheduled_tasks/shipment_data_update.py index f282f020..31302385 100644 --- a/rigpl_erpnext/rigpl_erpnext/scheduled_tasks/shipment_data_update.py +++ b/rigpl_erpnext/rigpl_erpnext/scheduled_tasks/shipment_data_update.py @@ -11,6 +11,18 @@ from ..doctype.carrier_tracking.fedex_functions import get_tracking_from_fedex +def update_delivery_date_time(): + ctrack_dict = frappe.db.sql("""SELECT ct.name FROM `tabCarrier Tracking` ct WHERE ct.status = 'Delivered' + AND ct.docstatus !=2 AND ct.status_code = 'DL' AND ct.delivery_date_time IS NULL + ORDER BY ct.creation ASC""", as_dict=1) + sno=1 + for ct in ctrack_dict: + ct_doc = frappe.get_doc('Carrier Tracking', ct.name) + print(str(sno) + ". " + ct.name + " is being Updated") + sno +=1 + get_tracking_from_fedex(ct_doc) + frappe.db.commit() + def update_costing_bypass(): bypass_ct = frappe.db.sql("""SELECT ct.name FROM `tabCarrier Tracking` ct WHERE ct.docstatus<2 AND ct.document = 'Sales Invoice' ORDER BY ct.creation DESC""")