Private
Public Access
1
0

sending invoices

This commit is contained in:
2024-12-26 12:49:29 +01:00
parent c0e1df04d8
commit b58dacb863
6 changed files with 58 additions and 1 deletions

View File

@@ -14,6 +14,13 @@ contacts_url = 'https://api.idoklad.cz/v3/Contacts'
invoice_url = 'https://api.idoklad.cz/v3/IssuedInvoices'
email_url = 'https://api.idoklad.cz/v3/Mails/IssuedInvoice/Send'
from rowers.tasks import handle_send_email_noinvoice
from rowers.utils import myqueue
import django_rq
queuehigh = django_rq.get_queue('high')
from rowers.models import iDokladToken
#idoklad_countries = json.loads(open('rowers/idoklad_countries.json').read())["Data"]["Items"]
@@ -86,6 +93,7 @@ def get_contacts(rower):
return None # pragma
def create_contact(rower):
print("idoklad create contact", rower)
token = idoklad_token()
if token is None:
return None
@@ -118,6 +126,14 @@ def create_contact(rower):
res = requests.post(contacts_url, json=data, headers=headers)
if res.status_code not in [200, 201]:
dologging('idoklad.log','Contact Created - reason '+str(res.reason)+'\n')
_ = myqueue.enqueue(
queuehigh, handle_send_email_noinvoice,
rower.user.email,
rower.user.first_name,
rower.user.last_name,
'idoklad Contact creation failed for '+str(rower.user.email)+'\n'+str(res.text)
)
return 0
id = res.json()['Data']['Id']
@@ -199,6 +215,14 @@ def create_invoice(rower, amount, braintreeid, dosend=True, contact_id=None, nam
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.text)+'\n')
_ = myqueue.enqueue(
queuehigh, handle_send_email_noinvoice,
rower.user.email,
rower.user.first_name,
rower.user.last_name,
'idoklad Invoice sending failed for '+str(rower.user.email)+'\n'+str(res.text)
)
return id