DocBits- IDP for Infor ERP
HomeAppStatusAPI
🇫🇷 Français
🇫🇷 Français
  • Vue d'ensemble et principes de base
    • DocBits
      • CaractĂ©ristiques principales de DocBits
    • Architecture
      • DocBits Infor sur le client sur site
      • Certifications
    • Infrastructure Infor
  • Notes de version
  • Section utilisateurs et partenaires
    • Section utilisateur final
      • Tableau de bord
        • Outils du tableau de bord
        • Fusion de Documents
        • Statut du document
        • Filtrage des documents
        • Aperçu des documents tĂ©lĂ©chargĂ©s
        • Compteur de tâches
        • Champs extraits validĂ©s
        • Flux De Documents
        • DĂ©pannage
        • Raccourcis Clavier
      • Tâches
      • Advance Shipment Dashboard
      • Tableau de bord des bons de commande
      • Tableau de bord des factures
      • Shipment Order Dashboard
      • Options de Configuration de l'Utilisateur
      • Tableau AI
        • Étiquettes de tableau AI
      • Écran de validation
        • DonnĂ©es Floues
        • Codes QR
        • Raccourcis Clavier
      • Objectif et Utilisation
      • Appariement des Bons de Commande
        • Correspondance Automatique des DonnĂ©es de Bon de Commande
        • Correspondance des numĂ©ros d'article du fournisseur
        • Raccourcis Clavier
      • ComptabilitĂ© pour les factures de coĂ»ts et les ventes indirectes
      • Comment importer des documents
        • FTP
        • Importation Manuelle
        • Webhook
        • E-mail
          • IMAP
          • OAuth Office365
      • Support technique dans DocBits
        • CrĂ©er un ticket
        • IcĂ´nes d'aide
      • Cours
        • Introduction
        • Tableau de bord
        • Documents validĂ©s
        • Tableau AI
        • Appariement principal des bons de commande avec DocBits
      • Notre Système de PrioritĂ© des Documents
      • Portail Fournisseur
        • Inscription du Fournisseur
        • Statut du Fournisseur
      • Ressources et support
        • Support utilisateur
    • Section Partenaire
      • Automatisation des Tests de Factures avec DocBits
  • Administration et configuration
    • Paramètres
      • Global Settings
        • Informations sur l'entreprise
          • DĂ©finir la couleur de l'application dans les paramètres de l'entreprise
        • Custom Filters
        • Document Expiry
        • Document Types
          • Layout Manager
            • Navigation dans le Gestionnaire de Mise en Page
          • Document Sub Types
          • Table Columns
          • Fields
            • Ajout et Édition de Champs
          • Model Training
          • Regex
          • Script
          • EDI
          • More Settings
            • Objectif et utilisation
            • Meilleures pratiques
            • DĂ©pannage
            • Gestion des documents en double
            • Cachet d'approbation
            • Carte des NumĂ©ros d'Article Fournisseur - Documentation Administrateur
            • Paramètres de tolĂ©rance de commande d'achat / TolĂ©rance de commande d'achat supplĂ©mentaire
            • Statuts de dĂ©sactivation de commande d'achat
            • Table PO dans le Constructeur de Mise en Page
            • VĂ©rification automatique des mises Ă  jour de CA
            • Calculer le prix unitaire de la commande
            • Export des lignes de commande non appariĂ©es
          • e-docs
            • eSLOG 1.6 et 2.0
        • Notification par e-mail
          • Configuration des Notifications
          • Gestion des Notifications
          • Meilleures Pratiques
          • DĂ©pannage
        • Custom Filters
        • Groups, Users and Permissions
          • Utilisateurs
            • Modification des dĂ©tails de l'utilisateur
            • Privilèges d'Administration
          • Sous-Organisations
            • Comment crĂ©er une Sous-Organisation
          • Groupes et Autorisations
            • Objectif et utilisation
            • Ajout/Modification de Groupes
            • Activation des autorisations
            • ContrĂ´le d'Accès
            • DĂ©pannage
        • IntĂ©gration
          • API Calls and Examples
        • Tableau de bord
      • Traitement des documents
        • Documents Expiry
        • Import
        • Gestionnaire de Règles
        • Ocr Settings
        • Classification et extraction
          • Extraction de tableaux pour le calcul des coĂ»ts
          • Extraction automatique du code fiscal
        • Master Data Lookup
        • List Of Values
        • Export
        • Module
          • Mode Annotation
          • Approval Before Export
          • Doc Scan
          • Doc Script
          • Mise Ă  jour de l'ACL IDM
          • Swiss QR Code
        • Arbres de DĂ©cision
      • Log Settings
        • Gestion des tâches
        • Synchronisation des donnĂ©es
      • Licences API
      • Paramètres du Fournisseur
        • Paramètres GĂ©nĂ©raux du Fournisseur
        • Modification des Modèles d'Email
        • Configuration de l'exportation pour le portail des fournisseurs pour M3
      • Gestion du Cache
    • Workflow
      • When
        • Card description
        • Document Operator for Sub-Organizations
        • Document Type Operation
      • And
        • Assigned User Condition
        • Checkbox Field Condition
        • Checkbox
        • Combined Price of Quantity Difference
        • Compare two fields
        • Compare with Purchase Order
        • Confirmed Delivery Date
        • Docfield is
        • Document Field Comparison
        • Document Field
        • Document Status Condition List
        • Document Type Operation one of
        • In Order Confirmation Purchase Order
        • Single Assigned User Condition
        • Single Document Status Condition
        • Supplier on Invoice
        • Text in field
        • Unit Price Combined with Fields
      • Then
      • Workflow Description: Conditional Export Trigger
      • Workflow Documentation
      • Standard Workflow
        • Above Max Amount
        • Cost Invoice - Export
        • Less than Max Amount
        • Purchase Invoice - 2nd Approval Quantity Export
        • Purchase Invoice - 2nd Approval Quantity
        • Purchase Invoice - 2nd Approval Unit Price Export
        • Purchase Invoice - 2nd Approval Unit Price
      • Material Ordering and Processing Workflow
    • Setup
      • Document Types
        • EDI Data Transformation Process
        • Layout Builder
        • Origin Layouts
        • Regex Manager
      • Document Training
        • Training Header Fields
        • Training Line Fields/Table Training
          • Adding New Columns
          • Advanced Settings
          • Defining Tables and Columns
          • Grouping Function
          • Manual Row Selection
          • Mapping Columns
          • Save and Delete Rules
      • SSO Configuration
      • Testing
        • PO Matching
        • Auto Accounting
          • LN
          • M3
      • Portail Fournisseur
      • WatchDog Installation
  • IntĂ©gration et configuration d'Infor
    • Importing Master Data
      • Field Mappings
      • LN
        • Auto Accounting
        • Suppliers and Purchase Orders
        • Tax Codes
      • M3
        • Auto Accounting
        • Suppliers and Purchase Orders
        • Extraction de tableaux pour le calcul des coĂ»ts
    • Exporting in DocBits
      • Export Module
    • Exporting to INFOR
      • Creating a BOD Mapping File
      • CrĂ©ation d'un fichier de mappage IDM
      • Creating an ION API Endpoint
      • Creating an ION API File
      • Export to M3 Mapping (API)
      • Exporting to IDM
      • M3
        • M3 Configuration
      • LN
        • Exporter les codes de taxe vers LN
        • LN Configuration
  • Fonctions et outils avancĂ©s
    • Scripting dans DocBits
      • Calculating Total Charges Script for Docbits
      • Calculating Total Charges Script for Docbits
      • Delete lines with empty quantity and amount
      • Formatting Export Certificate Reference Numbers Script for Docbits
      • Fonctions
      • Generating Extended Invoice Numbers Script for Docbits
      • Generating Extended Invoice Numbers Script for Docbits
    • Postman for DocBits
    • Importation des donnĂ©es de fournisseur et de commande d'achat dans DocBits Ă  partir de fichiers CSV
Powered by GitBook
On this page

Was this helpful?

Edit on GitHub
Export as PDF
  1. Fonctions et outils avancés
  2. Scripting dans DocBits

Delete lines with empty quantity and amount

Part 1: Delete Lines with Empty Quantity and Amount

This section of the script processes an invoice table to remove any lines where both the quantity and the total amount are zero or not provided.

  • Check for INVOICE_TABLE: It starts by checking if the INVOICE_TABLE key exists in the tables_dict dictionary.

  • Iterate Over Rows: For each row in the table, the script initializes flags and variables to determine if the TOTAL_AMOUNT and QUANTITY columns exist and to capture their values.

  • Check Column Names: As it iterates through each column in a row, it looks for columns named TOTAL_AMOUNT and QUANTITY.

    • If TOTAL_AMOUNT is found, it captures the value. If this value is non-zero, it converts it to a float.

    • Similarly for QUANTITY, capturing and converting the value if it is non-zero.

  • Mark Row for Deletion: After checking both columns in a row, if both the total amount and quantity are effectively zero (either by being zero or not existing), the row is marked for deletion by setting row['is_deleted'] to True.

Part 2: Validate Line Total Against Invoice Total

This section calculates the total amount from all lines in an invoice and compares it to the invoice’s reported total to validate their consistency.

  • Initialize Line Total: Starts by setting a variable lines_total to 0.0 to accumulate the total amount from all lines.

  • Sum Line Amounts: Iterates over each row in the INVOICE_TABLE, extracting the TOTAL_AMOUNT from each and adding it to lines_total.

  • Retrieve and Convert Invoice Total: Fetches the total invoice amount using a helper function get_field_value and converts it to a float.

  • Compare Totals: Finally, it checks if the absolute difference between the calculated line total (lines_total) and the reported invoice total (total_amount) exceeds a threshold of 0.05. If so, it marks the invoice total field as invalid using another helper function set_field_as_invalid, citing a mismatch.

##################################################
# Delete lines with empty quantity and amount 
##################################################


if tables_dict.get('INVOICE_TABLE'):
    for row in tables_dict['INVOICE_TABLE']['rows']:
        amount_col_found = False
        quantity_col_found = False
        line_amount = 0.0
        line_quantity = 0.0
        for col in row['columns']:
            if col['name'] == 'TOTAL_AMOUNT':
                amount_col_found = True
                line_amount = col.get('value', 0)
                if line_amount:
                    line_amount = float(line_amount)
            if col['name'] == 'QUANTITY':
                quantity_col_found = True
                line_quantity = col.get('value', 0)
                if line_quantity:
                    line_quantity = float(line_quantity)
            if amount_col_found and quantity_col_found:
                break
        if amount_col_found and quantity_col_found and (not line_amount and not line_quantity or (line_amount + line_quantity) == 0):
            row['is_deleted'] = True
        
##################################################
# End: Delete lines with empty quantity and amount 
##################################################

##################################################
# Validating Line total againg invoice total
##################################################
lines_total = 0.0
# Getting Lines Total
if tables_dict.get('INVOICE_TABLE'):
    for row in tables_dict['INVOICE_TABLE']['rows']:
        line_amount = 0.0
        for col in row['columns']:
            if col['name'] == 'TOTAL_AMOUNT':
                line_amount = col.get('value', 0)
                if line_amount:
                    line_amount = float(line_amount)
                break
        lines_total += line_amount

# Getting Invoice total
total_amount = get_field_value(fields_dict, "net_amount", "0.0")
if total_amount:
    total_amount = float(total_amount)

# Comparing lines total with invoice total    
if abs(total_amount - lines_total) > 0.05:
    set_field_as_invalid(fields_dict, "net_amount", "Invoice total mismatches lines total", "AMOUNTS_MISMATCH")

##################################################
# End: Validating Line total againg invoice total
##################################################






    

Summary

The script effectively ensures data integrity by:

  1. Removing data rows that do not contribute to the invoice’s financial total due to lacking quantities or amounts.

  2. Validating the consistency between the sum of individual line amounts and the overall invoice total, highlighting discrepancies for further action.

This automation helps maintain accurate financial records and can be crucial for systems like ERP that require precise data for accounting and financial reporting.

PreviousCalculating Total Charges Script for DocbitsNextFormatting Export Certificate Reference Numbers Script for Docbits

Last updated 1 year ago

Was this helpful?