LukeSavefrogs / danea-easyfatt

Danea Easyfatt automation suite
https://lukesavefrogs.github.io/danea-easyfatt/
GNU General Public License v3.0
4 stars 0 forks source link

Errore generazione CSV con un solo documento #89

Closed LukeSavefrogs closed 1 year ago

LukeSavefrogs commented 1 year ago

Se il file .DefXml contiene solo un documento di trasporto, l'intera procedura fallisce con l'errore AttributeError: 'str' object has no attribute 'get':

[01-09-2023 14:32:34] DEBUG    CLI parameters: Namespace(configuration_file='C:\\Users\\lucas\\AppData\\Local\\Temp\\veryeasyfatt-hxz0afad.toml', enable_version_check=False, enable_rich_logging=False, goal='csv-generator')
[01-09-2023 14:32:34] DEBUG    Execution directory: 'D:\Progetti\danea-automation\src\veryeasyfatt'
[01-09-2023 14:32:34] DEBUG    Bundle directory   : 'D:\Progetti\danea-automation\src\veryeasyfatt'
[01-09-2023 14:32:34] DEBUG    Root directory     : 'D:\Progetti\danea-automation'
[01-09-2023 14:32:34] WARNING  Il controllo versione è stato disattivato tramite CLI (--disable-version-check).
[01-09-2023 14:32:34] DEBUG    Configurazione default: {'log_level': 'INFO', 'easyfatt': {'database': {'filename': ''}, 'customers': {'custom_field': 1, 'export_filename': ['Soggetti.xlsx', 'Soggetti.ods']}}, 'files': {'input': {'easyfatt': './Documenti.DefXml', 'addition': ''}, 'output': {'csv': './Documenti.csv', 'kml': ''}}, 'options': {'output': {'csv_template': '@{CustomerName} {CustomerCode}@{eval_IndirizzoSpedizione} {eval_CAPSpedizione} {eval_CittaSpedizione}(20){eval_intervalloSpedizione}^{eval_pesoSpedizione}^'}}, 'features': {'shipping': {'default_interval': '07:00-16:00'}, 'kml_generation': {'google_api_key': '', 'placemark_title': '{customerName} ({customerCode}) {notes}'}}}
[01-09-2023 14:32:34] INFO     Trovato file di configurazione utente
[01-09-2023 14:32:34] DEBUG    Configurazione utente: {'files': {'input': {'easyfatt': './tests/features/csv/Documents.DefXml'}}}
[01-09-2023 14:32:34] ERROR    Nessun file trovato che corrisponda al pattern 'Soggetti.xlsx|Soggetti.ods'
[01-09-2023 14:32:34] WARNING  Gestione automatica degli orari di consegna disabilitata.
[01-09-2023 14:32:34] ERROR    Errore durante la generazione del file CSV.
Traceback (most recent call last):
  File "D:\Progetti\danea-automation\src\veryeasyfatt\app\main.py", line 116, in main
    righe_csv = genera_csv(
  File "D:\Progetti\danea-automation\src\veryeasyfatt\app\process_csv.py", line 51, in genera_csv
    indirizzo_spedizione = document["DeliveryAddress"] if document.get("DeliveryAddress", None) else document["CustomerAddress"]
AttributeError: 'str' object has no attribute 'get'
Premi [INVIO] per terminare il programma...

File Documents.DefXml:

<?xml version="1.0" encoding="UTF-8"?>
<!-- File in formato Easyfatt-XML creato con Danea Easyfatt - www.danea.it/software/easyfatt -->
<!-- Per importare o creare un file in formato Easyfatt-Xml, consultare la documentazione tecnica: www.danea.it/software/easyfatt/xml -->
<EasyfattDocuments AppVersion="2" Creator="Danea Easyfatt Enterprise  2023.54b" CreatorUrl="http://www.danea.it/software/easyfatt" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://www.danea.it/public/easyfatt-xml.xsd">
  <Company>
    <Name>ACME Inc.</Name>
    <Address>Via Anagnina, 0</Address>
    <Postcode>00173</Postcode>
    <City>Roma</City>
    <Province>RM</Province>
    <Country>Italia</Country>
    <FiscalCode>00000000000</FiscalCode>
    <VatCode>00000000000</VatCode>
    <Tel>0000000000</Tel>
    <Email>acme@acme.com</Email>
    <HomePage>https://example.com/</HomePage>
  </Company>
  <Documents>
    <Document>
      <CustomerCode>99999</CustomerCode>
      <CustomerWebLogin></CustomerWebLogin>
      <CustomerName>TEST - Non dovrebbe andare in cache</CustomerName>
      <CustomerAddress>VIA TUSCOLANA, 0</CustomerAddress>
      <CustomerPostcode>00182</CustomerPostcode>
      <CustomerCity>ROMA</CustomerCity>
      <CustomerProvince>RM</CustomerProvince>
      <CustomerCountry>Italia</CustomerCountry>
      <CustomerFiscalCode>PDFDNR38H51B374Q</CustomerFiscalCode>
      <CustomerReference>TEST</CustomerReference>
      <CustomerCellPhone>0123456789</CustomerCellPhone>
      <CustomerEmail>test@gmail.com</CustomerEmail>
      <DeliveryName>TEST's temporary address</DeliveryName>
      <DeliveryAddress>VIA TUSCOLANA, 1000</DeliveryAddress>
      <DeliveryPostcode>00174</DeliveryPostcode>
      <DeliveryCity>ROMA</DeliveryCity>
      <DeliveryProvince>RM</DeliveryProvince>
      <DeliveryCountry>Italia</DeliveryCountry>
      <DocumentType>C</DocumentType>
      <Date>2023-01-30</Date>
      <Number>725</Number>
      <Numbering></Numbering>
      <CostDescription></CostDescription>
      <CostVatCode></CostVatCode>
      <CostAmount></CostAmount>
      <ContribDescription></ContribDescription>
      <ContribPerc></ContribPerc>
      <ContribSubjectToWithholdingTax></ContribSubjectToWithholdingTax>
      <ContribAmount></ContribAmount>
      <ContribVatCode></ContribVatCode>
      <TotalWithoutTax>92.21</TotalWithoutTax>
      <VatAmount>20.29</VatAmount>
      <WithholdingTaxAmount>0</WithholdingTaxAmount>
      <WithholdingTaxAmountB>0</WithholdingTaxAmountB>
      <WithholdingTaxNameB></WithholdingTaxNameB>
      <Total>112.5</Total>
      <PriceList>Dom. OFFERTA</PriceList>
      <PricesIncludeVat>true</PricesIncludeVat>
      <TotalSubjectToWithholdingTax>0</TotalSubjectToWithholdingTax>
      <WithholdingTaxPerc>0</WithholdingTaxPerc>
      <WithholdingTaxPerc2>0</WithholdingTaxPerc2>
      <PaymentName></PaymentName>
      <PaymentBank></PaymentBank>
      <PaymentAdvanceAmount></PaymentAdvanceAmount>
      <Carrier></Carrier>
      <TransportReason></TransportReason>
      <GoodsAppearance></GoodsAppearance>
      <NumOfPieces></NumOfPieces>
      <TransportDateTime></TransportDateTime>
      <ShipmentTerms></ShipmentTerms>
      <TransportedWeight></TransportedWeight>
      <TrackingNumber></TrackingNumber>
      <InternalComment></InternalComment>
      <CustomField1>7:00&gt;&gt;18:00</CustomField1>
      <CustomField2></CustomField2>
      <CustomField3></CustomField3>
      <CustomField4></CustomField4>
      <FootNotes></FootNotes>
      <ExpectedConclusionDate></ExpectedConclusionDate>
      <SalesAgent></SalesAgent>
      <Rows>
        <Row>
          <Code>000029</Code>
          <Description>ACQUA EGERIA LT.1,5X6 PET EFFERVESCENTE NATURALE PLASTICA</Description>
          <Qty>30</Qty>
          <Um>CF</Um>
          <Price>3.75</Price>
          <Discounts></Discounts>
          <VatCode Perc="22" Class="Imponibile" Description="Imponibile 22%">22</VatCode>
          <Total>112.5</Total>
          <Stock>true</Stock>
          <Notes></Notes>
        </Row>
      </Rows>
    </Document>
  </Documents>
</EasyfattDocuments>

Soluzione (?)

Questo problema dovrebbe risolversi usando la funzione read_xml della libreria easyfatt-db-connector