Private
Public Access
1
0

passing tests

This commit is contained in:
2024-11-19 15:49:44 +01:00
parent 615a3fc689
commit 7a3fa8fe30
6 changed files with 82 additions and 28 deletions

View File

@@ -77,7 +77,6 @@ def get_contacts(rower):
if res.status_code != 200: # pragma: no cover
return None
data = res.json()['Data']['Items']
if len(data) >= 1:
@@ -141,7 +140,7 @@ def create_invoice(rower, amount, braintreeid, dosend=True, contact_id=None, nam
token = idoklad_token()
if token is None:
return None
return 0
dologging('idoklad.log','Creating idoklad invoice for '+str(rower.user.email)+'\n')
@@ -177,26 +176,29 @@ def create_invoice(rower, amount, braintreeid, dosend=True, contact_id=None, nam
id = res.json()['Data']['Id']
if dosend:
url = invoice_url+'/'+str(id)+'/Send'
print(url)
data = {
'AttachmentIds': [id],
'DocumentId': braintreeid,
'AttachmentIds': [],
'DocumentId': id,
'EmailBody': 'Dear customer, we are sending you the invoice for your subscription. Please do not hesitate to contact us if you have any questions. Best regards, Rowsandall Team',
'EmailSubject': 'Rowsandall Subscription Invoice',
'Method': 1,
'ReportLanguage': 3,
'SendToSelf': True,
'SendToSelf': True,
'SendToPartner': True,
'SendToAccountant': False,
}
print(data)
print(email_url)
headers = {
'Authorization': 'Bearer {access_token}'.format(access_token=token.access_token),
'Content-Type': 'application/json',
'Accept': 'application/json',
}
res = requests.post(email_url, json=data, headers=headers)
dologging('idoklad.log','Invoice Sent - status code '+str(res.status_code)+'\n')
if res.status_code not in [200, 201]:
dologging('idoklad.log','Invoice Sent - reason '+str(res.reason)+'\n')
dologging('idoklad.log','Invoice Sent - reason '+str(res.text)+'\n')
return id