Skip to content

Commit d78277f

Browse files
committed
Updated Reimbursements
1 parent 59f7061 commit d78277f

6 files changed

Lines changed: 51 additions & 15 deletions

File tree

functions/Actions/CampsEvents.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def callback2(request_id, response, exception):
5252
print(f'[ERROR] In batch3: {exception}')
5353
else:
5454
# Keep track of first non excluded day
55-
first_non_exluded_day = True
55+
# first_non_exluded_day = True
5656

5757
# Loop through the instances (sorted by start date)
5858
for instance in sorted(response['items'], key=lambda item: item["start"]["dateTime"]):
@@ -61,11 +61,11 @@ def callback2(request_id, response, exception):
6161
# Delete the excluded instances
6262
instance["status"] = "cancelled"
6363
updated = True
64-
elif first_non_exluded_day:
65-
# Update the start date of the first instance
66-
instance["start"]["dateTime"] = camp_info["start_day1"]
67-
first_non_exluded_day = False
68-
updated = True
64+
# elif first_non_exluded_day:
65+
# # Update the start date of the first instance
66+
# instance["start"]["dateTime"] = camp_info["start_day1"]
67+
# first_non_exluded_day = False
68+
# updated = True
6969

7070
# Find the replacement day, if any
7171
replacement = next((c for c in camp_info.get("replacements") if c["date"] == instance["start"]["dateTime"][:10]), None)

functions/Actions/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from .EventsToText import generate_confirmation_text, get_teacher_dict
22
from .CampsForm import get_camps_form
33
from .UpdatePaymentsSheet import update_payment_sheet
4-
# from .CampsEvents import update_and_create_camps_per_week
4+
from .CampsEvents import update_and_create_camps_per_week
55
from .CampsEvents import update_and_create_camps
66
# from .ClassesEvents import update_and_create_classes_per_week
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from Helpers import firebase_functions_custom, https_fn_custom
2+
from Salesforce import getSF
3+
from Actions import update_and_create_camps_per_week
4+
from Google.Connector import GoogleConnector
5+
from firebase_functions import https_fn, options
6+
7+
@https_fn_custom(timeout_sec=540)
8+
@firebase_functions_custom(auth_level=2)
9+
def events_a_update_camps(data):
10+
"""HTTPS Cloud Function to update calendar events for camps."""
11+
# Initialize the Salesforce client
12+
sf = getSF()
13+
14+
# Initialize the Google client
15+
google = GoogleConnector()
16+
17+
# Update Calendar Events
18+
message, success = update_and_create_camps_per_week(google, sf, data["week_codes"])
19+
20+
# # Create Picture Folders
21+
# create_camp_pictures(google, sf, data["week_codes"])
22+
23+
return {"data": {"response": message, "status": 200}}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
from .Events_U_UpdateClass import events_u_update_class
22
from .Events_U_UpdateCamp import events_u_update_camp
33
from .getSchedule import getSchedule
4+
from .Events_A_UpdateCamps import events_a_update_camps
Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,32 @@
1+
from datetime import datetime
2+
13
from Helpers import firebase_functions_custom, https_fn_custom, safe_create
24
from Salesforce import getSF
35

6+
47
@https_fn_custom()
58
@firebase_functions_custom(auth_level=3)
69
def reimbursements_a_approve(data):
710
# Initialize DB and SF
811
sf = getSF()
912

1013
# Get all payments from SF
11-
details = data.get("details")
12-
details["RecordTypeId"] = "012P5000001tcX7IAI"
13-
details["Beneficiary__c"] = details["Employee__c"]
14-
details["Name"] = "Remboursement " + details["Name"]
14+
details = data.get("details", {})
1515

1616
# Create the payment
17-
payment = safe_create(sf.sf.Payment__c, details)
17+
payment = safe_create(sf.sf.Payment__c, {
18+
"RecordTypeId": "012P5000001tcX7IAI",
19+
"Beneficiary__c": details.get("Employee__r", {}).get("Id", ""),
20+
"Name": "Remboursement " + details.get("Name", ""),
21+
"Amount__c": details.get("Amount__c", 0),
22+
"Month__c": datetime.now().month,
23+
"Year__c": datetime.now().year
24+
})
25+
26+
# Update the reimbursement status to "Accepted"
27+
sf.sf.Reimbursement__c.update(details.get("Id", ""), {
28+
"Status__c": "Accepted"
29+
})
1830

1931
# Return the payment ID
20-
return {"data": {"response": {"Id": payment.get("id")}, "status": 200}}
32+
return {"data": {"response": {"Id": payment.get("id")}, "status": 200}}

functions/FunctionsCurriculum/Reimbursements/Reimbursements_A_Get.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
def reimbursements_a_get(data):
77
return getter(f"""
88
SELECT
9-
Id, CreatedDate, Date__c, Amount__c, Justification__c, Attachment__c, Status__c,
10-
Status_Justification__c, Summary__c, Employee__r.Full_Name__c
9+
Id, Name, CreatedDate, Date__c, Amount__c, Justification__c, Attachment__c, Status__c,
10+
Status_Justification__c, Summary__c, Employee__r.Full_Name__c, Employee__r.Id
1111
FROM Reimbursement__c
1212
WHERE RecordType.Name = 'UserRequested'
1313
AND Deleted__c = False

0 commit comments

Comments
 (0)