Update invoice generator to current API
This commit is contained in:
parent
ab14604e39
commit
e72db6cf38
@ -69,10 +69,12 @@ class Position:
|
||||
|
||||
|
||||
class NewInvoiceParams:
|
||||
def __init__(self, client, positions):
|
||||
def __init__(self, client, positions, number=None,
|
||||
issue_date=datetime.date.today()):
|
||||
self.client = client
|
||||
self.positions = positions
|
||||
self.issue_date = datetime.date.today()
|
||||
self.number = number
|
||||
self.issue_date = issue_date
|
||||
|
||||
def __get_issue_date(self):
|
||||
return strftime("%Y-%m-%d", self.issue_date.timetuple())
|
||||
@ -87,6 +89,7 @@ class NewInvoiceParams:
|
||||
)
|
||||
|
||||
def get_request_data(self):
|
||||
series = self.number.split('/')[0][-1]
|
||||
return {
|
||||
"Zaplacono": self.__get_total_price(),
|
||||
"ZaplaconoNaDokumencie": self.__get_total_price(),
|
||||
@ -98,6 +101,7 @@ class NewInvoiceParams:
|
||||
"RodzajPodpisuOdbiorcy": "BPO",
|
||||
"WidocznyNumerGios": False,
|
||||
"Numer": None,
|
||||
"NazwaSeriiNumeracji": series,
|
||||
"Pozycje": [position.get_dict() for position in self.positions],
|
||||
"Kontrahent": self.client.get_dict(),
|
||||
}
|
||||
@ -126,6 +130,8 @@ class iFirmaAPI():
|
||||
response_code = real_response_content.get("Kod", -1)
|
||||
|
||||
if response_code != 0:
|
||||
print(response_code)
|
||||
print(real_response_content)
|
||||
raise PythonIfirmaExceptionFactory.throw_exception_by_code(response_code)
|
||||
|
||||
return response_dict
|
||||
@ -137,6 +143,8 @@ class iFirmaAPI():
|
||||
)
|
||||
|
||||
def __create_invoice_and_return_id(self, invoice, url):
|
||||
from pprint import pprint
|
||||
pprint(invoice.get_request_data())
|
||||
request_content = json.dumps(invoice.get_request_data(), separators=(',', ':'))
|
||||
request_hash_text = "{}{}{}{}".format(
|
||||
url,
|
||||
@ -202,4 +210,4 @@ class iFirmaAPI():
|
||||
file_obj = six.BytesIO()
|
||||
file_obj.write(content)
|
||||
file_obj.seek(0)
|
||||
return file_obj
|
||||
return file_obj
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user