DocBits- IDP for Infor ERP
HomeAppStatusAPI
🇩🇪 Deutsch
🇩🇪 Deutsch
  • Grundlagen und Überblick
    • DocBits
      • Hauptmerkmale von DocBits
    • Architektur
      • DocBits Infor On-Premise-Kunde
      • Zertifizierungen
    • Infor Infrastruktur
    • Release-Notizen
  • Endnutzer und Partner Bereich
    • Endbenutzer Abschnitt
      • Dashboard
        • Dashboard-Tools
        • Dokumentenzusammenführung
        • Dokumentenstatus
        • Dokumente filtern
        • Übersicht der hochgeladenen Dokumente
        • Aufgabenzähler
        • Validierte extrahierte Felder
        • Dokument-Flow
        • Best Practice
        • Tastenkombinationen
      • Aufgaben
      • Advance Shipment Dashboard
      • Dashboard für Bestellungen
      • Dashboard für Rechnungen
      • Shipment Order Dashboard
      • Benutzerkonfigurationsoptionen
      • AI-Tabelle
        • AI-Tabellen-Tags
      • Validierungsbildschirm
        • Unscharfe Daten
        • QR-Codes
        • Tastenkombinationen
      • Zweck und Verwendung
      • Bestellabgleich
        • Automatischer Bestelldatenabgleich
        • Lieferanten-Artikelnummern-Zuordnung
        • Tastenkombinationen
      • Buchhaltung für Kostenrechnungen und indirekte Verkäufe
      • Wie man Dokumente importiert
        • FTP
        • Manueller Import
        • Webhook
        • E-Mail
          • IMAP
          • OAuth Office365
      • Technischer Support in DocBits
        • Ticket erstellen
        • Hilfe-Symbole
      • Kurs
        • Einführung
        • Dashboard
        • Validierte Dokumente
        • AI-Tabelle
        • Master-Bestellabgleich mit DocBits
      • Unser Dokumenten-Prioritätssystem
      • Lieferantenportal
        • Lieferantenregistrierung
        • Lieferantenstatus
      • Ressourcen und Support
        • Benutzersupport
    • Partnerbereich
      • Rechnungsautomatisierungstests mit DocBits
  • Administration und Einrichtung
    • Einstellungen
      • Globale Einstellungen
        • Firmeninformationen
        • Gruppen, Benutzer und Berechtigungen
          • Benutzer
            • Benutzerdetails bearbeiten
            • Admin-Privilegien
          • Unterorganisationen
            • Wie man eine Unterorganisation erstellt
          • Gruppen und Berechtigungen
            • Zweck und Verwendung
            • Gruppen hinzufügen/bearbeiten
            • Berechtigungen aktivieren
            • Zugangskontrolle
            • Fehlerbehebung
        • Best Practices
        • Integration
          • API-Schlüssel
          • API-Aufrufe und Beispiele
          • API-Schlüsselverwaltung
          • Konfiguration von Single Sign-On (SSO)
          • Konfiguration des Identitätsdienstanbieters
          • Best Practices
          • Fehlerbehebung bei häufigen Problemen
        • Dokumenttypen
          • Layout Manager
            • Navigieren im Layout-Manager
          • Document Sub Types
          • Table Columns
          • Fields
            • Hinzufügen und Bearbeiten von Feldern
          • Model Training
          • Regex
          • Script
          • EDI
          • Weitere Einstellungen
            • Zweck und Verwendung
            • Best Practices
            • Fehlerbehebung
            • Erkennung von doppelten Dokumenten
            • Genehmigungsstempel
            • Lieferantenartikelnummernkarte - Administrationsdokumentation
            • Einstellungen zur Toleranz von Bestellungen / Zusätzliche Toleranz für Bestellungen
            • Bestellung deaktivieren Status
            • Auftragstabelle im Layout-Builder
            • Automatische Prüfung auf PO-Aktualisierungen
            • Berechnung des PO-Einzelpreises
            • Export nicht übereinstimmender PO-Zeilen
          • e-docs
            • e-SLOG 1.6 und 2.0
        • Email Notification
        • Custom Filters
        • Integration
          • API Calls and Examples
        • Dashboard
      • Dokumentenverarbeitung
        • Dokumentenablauf
        • Import
        • Regelmanager
        • Ocr Settings
        • Klassifizierung und Extraktion
          • Tabellenextraktion für Kostenelemente
          • Automatische Erfassung des Steuercodes
        • Master Data Lookup
        • List Of Values
        • Export
        • Module
          • Anmerkungsmodus
          • Approval Before Export
          • Doc Scan
          • Doc Script
          • IDM ACL Updater
          • Swiss QR Code
        • Entscheidungsbäume
      • Log Einstellungen
        • Aufgabenverwaltung
        • Daten Synchronization
      • API Lizenzen
      • Lieferanten Einstellungen
        • Generelle Lieferanten Einstellungen
        • Email Vorlagen editieren
        • Export Konfiguration für Lieferanten Portal M3
      • Cache Management
    • 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
      • Testing
        • PO Matching
        • Auto Accounting
          • LN
          • M3
      • Lieferantenportal
      • WatchDog Installation
      • SSO Configuration
  • Infor Integration und Konfiguration
    • Importing Master Data
      • Field Mappings
      • LN
        • Auto Accounting
        • Suppliers and Purchase Orders
        • Tax Codes
      • M3
        • Auto Accounting
        • Suppliers and Purchase Orders
        • Tabellenextraktion für Kostenelemente
    • Exporting in DocBits
      • Export Module
    • Exporting to INFOR
      • Creating a BOD Mapping File
      • Erstellen einer IDM-Mapping-Datei
      • Creating an ION API Endpoint
      • Creating an ION API File
      • Export to M3 Mapping (API)
      • Exporting to IDM
      • M3
        • M3 Configuration
      • LN
        • Exportieren von Steuercodes nach LN
        • LN Configuration
  • erweiterte funktionen und werkzeuge
    • Scripting in 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
      • Funktionen
      • Generating Extended Invoice Numbers Script for Docbits
      • Generating Extended Invoice Numbers Script for Docbits
    • Postman for DocBits
    • Importieren von Lieferanten- und Bestelldaten in DocBits aus CSV-Dateien
Powered by GitBook
On this page
  • Purpose
  • Script Overview

Was this helpful?

Edit on GitHub
Export as PDF
  1. erweiterte funktionen und werkzeuge
  2. Scripting in DocBits

Calculating Total Charges Script for Docbits

The "Calculating Total Charges" script automates the process of summing up various charges and additional amounts within invoice documents. This guide walks you through the script setup, logic, and application to ensure accurate total charge calculations across your documents.

Purpose

This script aims to provide a dynamic way to calculate the total charges on an invoice by adding up different charge types, such as base charges, freight (Fracht), and packaging (Verpackung). It then updates the invoice's total charges field with the calculated sum, ensuring accurate billing information.

Script Overview

The script retrieves values from specified fields, converts them to floats, sums them up, and then updates the total_charges field with the result. If the total_charges field doesn't exist, the script creates this field and sets its value accordingly.

Code Snippet

total_charges = get_field_value(fields_dict, 'total_charges', None)
fracht = get_field_value(fields_dict, 'additional_amount_2', None)
verpackung = get_field_value(fields_dict, 'additional_amount', None)

# Initialize total to 0
total = 0

# Add fracht to total if it exists
if fracht:
    fracht = float(fracht)
    total += fracht

# Add verpackung to total if it exists
if verpackung:
    verpackung = float(verpackung)
    total += verpackung

# Formatting the total to two decimal places
formatted_total = "{0:.2f}".format(total)

# Checking if the total_charges field exists and updating or creating accordingly
if 'total_charges' not in fields_dict:
    new_field = create_new_field('total_charges', formatted_total)
    fields_dict['total_charges'] = new_field
    document_json['fields'].append(new_field)
else:
    set_field_value(fields_dict, 'total_charges', formatted_total)
PreviousScripting in DocBitsNextCalculating Total Charges Script for Docbits

Last updated 1 year ago

Was this helpful?