from Builders.pdf import generate_invoice
from Builders.pdf.generator import generate_facturx
from Builders.xml.generate_xml import generate_xml, write_xml_from_string
from Samples.data import data_pdf
from Validators.schematron import xml_check_schematron
from Validators.xml_check_xsd import xml_check_xsd

DESTINATION_FOLDER = 'eFacturePy'

#Création du xml
print("---Création du XML---")
xml_string = generate_xml(data_pdf)
folder = write_xml_from_string(xml_string=xml_string, destination_folder=DESTINATION_FOLDER, file_name='my_first_xml')

#Validation du xml (xsd)
print("---Validation(xsd) du XML---")
check_res = xml_check_xsd(xml_string)

#Validation du xml (schematron)
print("---Validation(sch) du XML---")
report = xml_check_schematron(xml_path = folder)

#Création du pdf
print("---Création du PDF---")
generate_invoice(file_name='my_first_invoice.pdf',destination_folder=DESTINATION_FOLDER , data=data_pdf, title='mon_titre')

#Création de la factur-x
print("---Création de la factur-x---")
generate_facturx(file_name='my_first_invoice.pdf',destination_folder=DESTINATION_FOLDER, xml=xml_string)

