Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
This document provides a detailed guide on the "Calculating Total Charges" script within the Docbits platform. The script is designed to automatically calculate the total amount charged on an invoice by summing up various individual charges. This automation enhances accuracy and efficiency in document processing.
The aim of this script is to streamline the calculation process for total charges on invoices. By automatically adding up specified charges, such as base charges, taxes, and additional fees, the script ensures that the total charges reflected on each invoice are accurate and comprehensive.
This document outlines the "Formatting Export Certificate Reference Numbers" script, aimed at standardizing reference numbers across export certificates in Docbits. Proper formatting ensures that reference numbers comply with external systems or regulatory requirements.
The script's primary goal is to format reference numbers on export certificates, ensuring they meet a predefined length requirement by padding them with leading zeros. This consistency aids in maintaining a standardized format for all export documents processed through Docbits.
The script identifies the reference_number
field in an export certificate, checks its length, and if necessary, pads the number with leading zeros to ensure it meets the minimum length requirement.
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.
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.
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.
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
.
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.
The script effectively ensures data integrity by:
Removing data rows that do not contribute to the invoice’s financial total due to lacking quantities or amounts.
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.
This guide focuses on automating the creation of extended invoice numbers in Docbits, a crucial feature for improving invoice management and tracking. The "Generating Extended Invoice Numbers" script concatenates various document identifiers, such as invoice ID and purchase order number, to create a comprehensive and unique identifier for each invoice.
The primary goal of this script is to automate the generation of extended invoice numbers, facilitating easier tracking and management of invoices by combining multiple identifiers into a single, unique number.
This document details the "Generating Extended Invoice Numbers" script, which automates the creation of extended invoice numbers in Docbits. Extended invoice numbers combine multiple document identifiers, such as the invoice ID and the purchase order number, into a single, comprehensive identifier. This script enhances document traceability and simplifies record-keeping.
The purpose of this script is to streamline the process of generating extended invoice numbers by automatically concatenating the invoice ID and purchase order number, thereby providing a unified and unique identifier for each invoice document.
The script checks for the presence of invoice ID and purchase order number fields within the document, concatenates their values if both are present (separated by a hyphen), and updates or creates a new field to store the combined value.
Functional Documentation
This module contains functions for manipulating document data and performing various operations related to document fields.
Description: Sets the value of a field in the document data.
Parameters:
document_data
(dict): The document data containing field information.
field_name
(str): The name of the field to set.
value
: The value to set for the field.
Example:
set_field_value(document_data, "name", "John Doe")
Description: Sets the value of a date field in the document data.
Parameters:
document_data
(dict): The document data containing field information.
field_name
(str): The name of the date field to set.
value
: The date value to set in ISO format (e.g., "2020-12-31").
Example:
set_date_value(document_data, "date_of_birth", "1990-05-15")
Description: Sets a custom attribute of a field in the document data.
Parameters:
attribute_name
(str): The name of the attribute to set.
value
: The value to set for the attribute.
Example:
set_field_attribute(document_data, "address", "is_verified", True)
Description: Updates the status of a document with the specified ID.
Parameters:
doc_id
(str): The ID of the document to update.
user
: The user performing the update (either user ID or UserAuthentication object).
org_id
: The ID of the organization to which the document belongs.
status
(str): The new status of the document.
message
: Optional message associated with the status update.
doc_classification_class
: Optional document classification class.
Example:
update_document_status_with_doc_id("123456", user, org_id, "approved", "Document approved")
Description: Checks if a supplier is valid based on the provided criteria.
Parameters:
user
(UserAuthentication): The authenticated user.
filter_data_json
: Filter criteria for validating the supplier.
sub_org_id
: Optional sub-organization ID for filtering.
Example:
is_supplier_valid(user, {"name": "Supplier Inc."})
Description: Marks a field as invalid in the document data.
Parameters:
document_data
(dict): The document data containing field information.
field_name
(str): The name of the field to mark as invalid.
message
(str): The validation message for the field.
code
(optional): Error code for the validation (default is None).
Example:
set_field_as_invalid(document_data, "email", "Invalid email format", "EMAIL_FORMAT_INVALID")
\
Witamy w przewodniku po skryptach Docbits! Tutaj dowiesz się, jak używać skryptów do automatyzacji i ulepszania przetwarzania dokumentów w Docbits. Skrypty umożliwiają niestandardową manipulację polami, transformację danych i implementację logiki w różnych typach dokumentów.
Skrypty w Docbits są pisane w języku Python. Wchodzą w interakcję z polami dokumentów i metadanymi, aby wykonywać szeroki zakres operacji, od prostego formatowania danych po złożoną logikę.
Kluczowe funkcje
get_field_value(fields_dict, field_name, default=None)
: Pobiera wartość określonego pola.
set_field_value(fields_dict, field_name, value)
: Ustawia wartość określonego pola.
create_new_field(field_name, value)
: Tworzy nowe pole o określonej nazwie i wartości.
format_decimal_to_locale(value, locale)
: Formatuje wartość dziesiętną zgodnie z określoną lokalizacją.
Poniżej znajduje się kilka przykładów demonstrujących typowe zadania skryptowe.
Przykład 1: Mapowanie walut dla faktur
Standaryzacja symboli walut lub tekstu do kodów walut ISO.