Skip to content

Commit d06ef7a

Browse files
committed
Added Ignore and Invoicing Options to payments
1 parent d78277f commit d06ef7a

4 files changed

Lines changed: 14 additions & 5 deletions

File tree

functions/FunctionsCurriculum/Attestations/Attestations_A_Create.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ def attestations_a_create(data):
5656
# Create the timesheets, send the emails and add the document to Firestore
5757
for teacher_email in teacher_dict:
5858
teacher = teacher_dict.get(teacher_email)
59-
generate_timesheet(google, sf, teacher, year, month)
59+
if teacher.get("Contract_Type__c") != "Ignore":
60+
generate_timesheet(google, sf, teacher, year, month)
6061

6162
# Send the confirmation email to the admin
6263
send_attestation_admin(return_string, year, month)

functions/Google/Document.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
ATTESTATION_TEMPLATE_ID = os.getenv('ATTESTATION_TEMPLATE_ID')
55
PRESTATION_TEMPLATE_ID = os.getenv('PRESTATION_TEMPLATE_ID')
6+
INVOICING_TEMPLATE_ID = os.getenv('INVOICING_TEMPLATE_ID')
7+
68
CONVENTION_TEMPLATE_ID = os.getenv('CONVENTION_TEMPLATE_ID')
79
DOCUMENTS_BY_BOT_ID = os.getenv('DOCUMENTS_BY_BOT_ID')
810
PAYMENTS_TEMPLATE_ID = os.getenv('PAYMENTS_TEMPLATE_ID')
@@ -58,8 +60,13 @@ def __init__(self, google, teacher, year, month):
5860
self.year = year
5961
self.month = month
6062

61-
file_id = PRESTATION_TEMPLATE_ID if teacher.get('contract') else ATTESTATION_TEMPLATE_ID
62-
name = f"{year}-{month} {'Prestations' if teacher.get('contract') else 'Attestation'} {teacher.get('name')}"
63+
if teacher.get("Contract_Type__c") == "Volunteering":
64+
file_id = ATTESTATION_TEMPLATE_ID
65+
elif teacher.get("Contract_Type__c") == "Article 17" or teacher.get("Contract_Type__c") == "Student Contract":
66+
file_id = PRESTATION_TEMPLATE_ID
67+
elif teacher.get("Contract_Type__c") == "Invoicing":
68+
file_id = INVOICING_TEMPLATE_ID
69+
name = f"{year}-{month} Prestations {teacher.get('name')}"
6370
log_details = teacher.get('name')
6471
self.log_details = log_details
6572
self.document_id = self._Document__copy_document(file_id, name, log_details)
@@ -76,7 +83,7 @@ def fill(self):
7683
{'replaceAllText': {'containsText': {'text': '{ADDRESS}'}, 'replaceText': self.teacher.get('address')}},
7784
{'replaceAllText': {'containsText': {'text': '{TOTAL_HOURS}'}, 'replaceText': f"{self.teacher.get('hours')}h{self.teacher.get('minutes')}"}},
7885
{'replaceAllText': {'containsText': {'text': '{TOTAL_AMOUNT}'}, 'replaceText': str(self.teacher.get('total_amount'))}},
79-
{'replaceAllText': {'containsText': {'text': '{DESCRIPTIONS_FR}'}, 'replaceText': '\n'.join(list(map(lambda x: x.get('nice_name'), self.teacher.get('events'))))}},
86+
{'replaceAllText': {'containsText': {'text': '{DESCRIPTIONS_FR}'}, 'replaceText': '\n'.join(list(map(lambda x: x.get('nice_name')[4:], self.teacher.get('events'))))}},
8087
{'replaceAllText': {'containsText': {'text': '{TOTAL_HOURS_SECOND_HOURS}'}, 'replaceText': str(round(self.teacher.get('total_amount') / self.teacher.get('contract'))) if self.teacher.get('contract') > 0 else "0"}},
8188
{'replaceAllText': {'containsText': {'text': '{TOTAL_HOURS_SECOND_MIN}'}, 'replaceText': str(round(((self.teacher.get('total_amount') / self.teacher.get('contract')) % 1) * 60)) if self.teacher.get('contract') > 0 else "0"}},
8289
{'replaceAllText': {'containsText': {'text': '{SALARY}'}, 'replaceText': str(self.teacher.get('contract'))}}

functions/Google/Events.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def __process_google_events(self, events):
7272
title.pop(0)
7373
title = '-'.join(title)
7474
amount = round(self.__calculate_amount(code, minutes), 2)
75-
nice_name = f" [{code}] {title} ({start}, {minutes}min, {amount}€)"
75+
nice_name = f" [{code}] {start} - {title.split('[')[0]}({minutes}min, {amount}€)"
7676
processed_events.append({
7777
'teachers': teachers,
7878
'held': held,

functions/config.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Attestation Document Template IDs
22
ATTESTATION_TEMPLATE_ID=1DiT2wj3ZpaZzzX1ACT1igQdqhyfebl_7lbKQw1Ubego
33
PRESTATION_TEMPLATE_ID=1guzoO5hwGgqpphVp-i9dGAAiM8wojnzpe4Qlk9-yZY4
4+
INVOICING_TEMPLATE_ID=15sw-eqmtZQ7y5xK5b3au1qGvARkSjaAa1wOQNRO_wi4
45

56
# Contract Document Template IDs
67
CONVENTION_TEMPLATE_ID=108r2FThPRfhT_MlrZApP1I8V-Oqf7gADnfg5BCSFUcY

0 commit comments

Comments
 (0)