mirror of
https://github.com/Eledio/superfaktura-client.git
synced 2025-11-01 00:18:25 +01:00
examples: simplify add_invoice
This commit is contained in:
@@ -21,7 +21,8 @@ Dependencies:
|
|||||||
- superfaktura.utils.data_types.Date
|
- superfaktura.utils.data_types.Date
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from examples.tools import save_file_as_pdf
|
from pathlib import Path
|
||||||
|
|
||||||
from superfaktura.bank_account import BankAccount
|
from superfaktura.bank_account import BankAccount
|
||||||
from superfaktura.client_contacts import ClientContactModel
|
from superfaktura.client_contacts import ClientContactModel
|
||||||
from superfaktura.enumerations.currency import Currencies
|
from superfaktura.enumerations.currency import Currencies
|
||||||
@@ -72,7 +73,8 @@ def main():
|
|||||||
)
|
)
|
||||||
_pdf = invoice.get_pdf(invoice=resp, language=Language.English)
|
_pdf = invoice.get_pdf(invoice=resp, language=Language.English)
|
||||||
|
|
||||||
save_file_as_pdf(_pdf, "invoice.pdf")
|
p = Path("invoice.pdf")
|
||||||
|
p.write_bytes(_pdf)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
"""
|
|
||||||
This module contains tools for working with these examples.
|
|
||||||
"""
|
|
||||||
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
|
|
||||||
def save_file_as_pdf(input_data: bytes, output_path: str = "output.pdf") -> None:
|
|
||||||
"""
|
|
||||||
Save the input data as a PDF file.
|
|
||||||
:param input_data:
|
|
||||||
:param output_path:
|
|
||||||
:return:
|
|
||||||
"""
|
|
||||||
p = Path(output_path)
|
|
||||||
p.write_bytes(input_data)
|
|
||||||
Reference in New Issue
Block a user