From 9ecc881bd1904120489d5f38ec99c118005de651 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 20 Dec 2024 13:50:21 +0000 Subject: [PATCH] deploy: 02f832d1c46895d094a78d40f516d58764b37472 --- 404.html | 2 +- assets/js/f538922c.0a2098c2.js | 1 + assets/js/f538922c.54dbb831.js | 1 - .../js/{runtime~main.49e36b6a.js => runtime~main.98915f15.js} | 2 +- docs/category/user-management.html | 2 +- docs/courses/basic-end-to-end-flow-with-rossum.html | 2 +- .../basic-end-to-end-flow-with-rossum/basic-data-matching.html | 2 +- .../basic-data-validation.html | 2 +- .../data-export-via-webhooks.html | 2 +- .../basic-end-to-end-flow-with-rossum/document-ingestion.html | 2 +- .../document-pre-processing.html | 2 +- docs/docusaurus/best-practices-for-content.html | 2 +- docs/docusaurus/create-a-blog-post.html | 2 +- docs/docusaurus/create-a-document.html | 2 +- docs/docusaurus/create-a-page.html | 2 +- docs/docusaurus/markdown-features.html | 2 +- docs/learn/ai-learning.html | 2 +- docs/learn/business-rules-validation.html | 2 +- .../business-rules-validation/configuration-examples.html | 2 +- docs/learn/business-rules-validation/expression-engine.html | 2 +- docs/learn/copy-paste-values.html | 2 +- docs/learn/copy-paste-values/configuration-examples.html | 2 +- docs/learn/coupa.html | 2 +- docs/learn/coupa/export-configuration.html | 2 +- docs/learn/coupa/import-configuration.html | 2 +- docs/learn/coupa/integration-setup.html | 2 +- docs/learn/coupa/oauth-scopes.html | 2 +- docs/learn/coupa/postman-collection.html | 2 +- docs/learn/coupa/workflow-example.html | 2 +- docs/learn/deprecated.html | 2 +- docs/learn/duplicates-detection.html | 2 +- docs/learn/duplicates-detection/configuration-examples.html | 2 +- docs/learn/emails.html | 2 +- docs/learn/emails/auto-rejections.html | 2 +- docs/learn/emails/email-body-converter.html | 2 +- docs/learn/export-pipeline.html | 2 +- docs/learn/export-pipeline/custom-format-templating-purge.html | 2 +- docs/learn/export-pipeline/custom-format-templating.html | 2 +- docs/learn/export-pipeline/data-value-extractor.html | 2 +- docs/learn/export-pipeline/export-evaluator.html | 2 +- docs/learn/export-pipeline/rest-api-export.html | 2 +- docs/learn/find-replace-values.html | 2 +- docs/learn/find-replace-values/configuration-examples.html | 2 +- docs/learn/integration-patterns.html | 2 +- docs/learn/json-templating.html | 2 +- docs/learn/line-items-grouping.html | 2 +- .../learn/line-items-grouping/alternative-python-solution.html | 2 +- docs/learn/line-items-grouping/configuration-examples.html | 2 +- docs/learn/master-data-hub.html | 2 +- docs/learn/master-data-hub/configuration-examples.html | 2 +- docs/learn/master-data-hub/dataset-management.html | 2 +- docs/learn/master-data-hub/dataset-matching-configuration.html | 2 +- docs/learn/master-data-hub/full-dataset-replace.html | 2 +- docs/learn/master-data-hub/using-api.html | 2 +- docs/learn/netsuite.html | 2 +- docs/learn/netsuite/considerations.html | 2 +- docs/learn/netsuite/export-configuration.html | 2 +- docs/learn/netsuite/import-configuration.html | 2 +- docs/learn/netsuite/integration-configuration.html | 2 +- docs/learn/netsuite/postman.html | 2 +- docs/learn/rossum-formulas.html | 2 +- docs/learn/rossum-formulas/custom-code-handbook.html | 2 +- docs/learn/rossum-formulas/formula-fields.html | 3 ++- docs/learn/rossum-formulas/serverless-functions.html | 2 +- docs/learn/sandboxes.html | 2 +- docs/learn/sandboxes/deployment-patterns.html | 2 +- docs/learn/sftp-s3-import-export.html | 2 +- docs/learn/sftp-s3-import-export/configuration-examples.html | 2 +- docs/learn/structured-formats-import.html | 2 +- .../structured-formats-import/configuration-examples.html | 2 +- .../italy-sistema-di-interscambio.html | 2 +- docs/learn/user-management/service-account.html | 2 +- docs/learn/user-management/sso.html | 2 +- docs/learn/workday.html | 2 +- docs/learn/workday/export-configuration.html | 2 +- docs/learn/workday/import-configuration.html | 2 +- docs/watch.html | 2 +- index.html | 2 +- search.html | 2 +- 79 files changed, 79 insertions(+), 78 deletions(-) create mode 100644 assets/js/f538922c.0a2098c2.js delete mode 100644 assets/js/f538922c.54dbb831.js rename assets/js/{runtime~main.49e36b6a.js => runtime~main.98915f15.js} (99%) diff --git a/404.html b/404.html index 15de3d59..689e1178 100644 --- a/404.html +++ b/404.html @@ -10,7 +10,7 @@ - + diff --git a/assets/js/f538922c.0a2098c2.js b/assets/js/f538922c.0a2098c2.js new file mode 100644 index 00000000..79d1df1a --- /dev/null +++ b/assets/js/f538922c.0a2098c2.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunkuniversity=self.webpackChunkuniversity||[]).push([[9269],{2971:(e,i,a)=>{a.r(i),a.d(i,{assets:()=>o,contentTitle:()=>d,default:()=>u,frontMatter:()=>s,metadata:()=>t,toc:()=>r});const t=JSON.parse('{"id":"learn/rossum-formulas/formula-fields","title":"Rossum Formulas: Formula fields","description":"Intro","source":"@site/docs/learn/rossum-formulas/formula-fields.md","sourceDirName":"learn/rossum-formulas","slug":"/learn/rossum-formulas/formula-fields","permalink":"/docs/learn/rossum-formulas/formula-fields","draft":false,"unlisted":false,"editUrl":"https://github.com/rossumai/university/tree/master/docs/learn/rossum-formulas/formula-fields.md","tags":[],"version":"current","sidebarPosition":1,"frontMatter":{"sidebar_position":1,"sidebar_label":"Formula fields","title":"Rossum Formulas: Formula fields","toc_max_heading_level":4},"sidebar":"learnSidebar","previous":{"title":"Rossum Formulas","permalink":"/docs/learn/rossum-formulas/"},"next":{"title":"Serverless functions","permalink":"/docs/learn/rossum-formulas/serverless-functions"}}');var n=a(4848),l=a(8453);const s={sidebar_position:1,sidebar_label:"Formula fields",title:"Rossum Formulas: Formula fields",toc_max_heading_level:4},d="Formula fields",o={},r=[{value:"Intro",id:"intro",level:2},{value:"Basic information",id:"basic-information",level:2},{value:"Best practices",id:"best-practices",level:2},{value:"Field naming and management",id:"field-naming-and-management",level:3},{value:"Wide variety of functions",id:"wide-variety-of-functions",level:3},{value:"Access document object information in formula field",id:"access-document-object-information-in-formula-field",level:3},{value:"When to Use Formula Fields vs. Serverless Functions",id:"when-to-use-formula-fields-vs-serverless-functions",level:3},{value:"Examples of common formula fields",id:"examples-of-common-formula-fields",level:2},{value:"Access other table and its first row values",id:"access-other-table-and-its-first-row-values",level:3},{value:"Copy fields conditionally",id:"copy-fields-conditionally",level:3},{value:"Get all enum options",id:"get-all-enum-options",level:3},{value:"Find first non-empty line item value",id:"find-first-non-empty-line-item-value",level:3},{value:"Generate NetSuite external IDs",id:"generate-netsuite-external-ids",level:3},{value:"Get line item index",id:"get-line-item-index",level:3},{value:"Normalize field value",id:"normalize-field-value",level:3},{value:"Sum line item values",id:"sum-line-item-values",level:3},{value:"Validations",id:"validations",level:3},{value:"Get year/month from a date field",id:"get-yearmonth-from-a-date-field",level:3},{value:"Date validation",id:"date-validation",level:3},{value:"HTML formatting",id:"html-formatting",level:3},{value:"VAT Rates table fallbacks",id:"vat-rates-table-fallbacks",level:3},{value:"tax_detail_rate_calculated",id:"tax_detail_rate_calculated",level:4},{value:"tax_detail_base_calculated",id:"tax_detail_base_calculated",level:4},{value:"tax_detail_tax_calculated",id:"tax_detail_tax_calculated",level:4},{value:"tax_detail_total_calculated",id:"tax_detail_total_calculated",level:4},{value:"Check existence of a field in the schema",id:"check-existence-of-a-field-in-the-schema",level:3},{value:"Remove whitespaces",id:"remove-whitespaces",level:3}];function c(e){const i={a:"a",admonition:"admonition",code:"code",em:"em",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,l.R)(),...e.components};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(i.header,{children:(0,n.jsx)(i.h1,{id:"formula-fields",children:"Formula fields"})}),"\n",(0,n.jsx)(i.h2,{id:"intro",children:"Intro"}),"\n",(0,n.jsx)(i.p,{children:"Formula fields in Rossum enable you to easily transform your data directly within the app. Whether you need to normalize data, perform calculations, or handle text operations, formula fields provide the flexibility to set values based on your custom logic."}),"\n",(0,n.jsx)(i.p,{children:"For most tasks, Rossum\u2019s Copilot handles everything seamlessly without needing code, and we recommend using it for the best results. However, if you want to dive deeper into custom logic, formula fields support Python-based coding with simple examples to get you started."}),"\n",(0,n.jsx)(i.admonition,{type:"info",children:(0,n.jsxs)(i.p,{children:["This powerful feature is available on the Business plan and above. Existing customers interested in using formula fields can reach out to our support team at ",(0,n.jsx)(i.a,{href:"mailto:support@rossum.ai",children:"support@rossum.ai"})," for assistance."]})}),"\n",(0,n.jsx)(i.h2,{id:"basic-information",children:"Basic information"}),"\n",(0,n.jsxs)(i.ul,{children:["\n",(0,n.jsxs)(i.li,{children:["Formula Fields can run any Python code including its ",(0,n.jsx)(i.a,{href:"https://docs.python.org/3/library/index.html",children:"Standard Library modules"}),"."]}),"\n",(0,n.jsx)(i.li,{children:"Additionally, the runtime is enriched with Rossum-specific functions and variables"}),"\n",(0,n.jsx)(i.li,{children:"They are executed in an AWS lambda"}),"\n",(0,n.jsx)(i.li,{children:"Formula Fields are automatically executed before and after each extension."}),"\n",(0,n.jsx)(i.li,{children:"Extensions cannot overwrite Formula Fields value (create a separate \u201cdata\u201d field instead)."}),"\n"]}),"\n",(0,n.jsx)(i.h2,{id:"best-practices",children:"Best practices"}),"\n",(0,n.jsx)(i.h3,{id:"field-naming-and-management",children:"Field naming and management"}),"\n",(0,n.jsxs)(i.p,{children:["When you need to create a normalized version of a field like ",(0,n.jsx)(i.code,{children:"document_id"}),", it's recommended to create a new field, such as ",(0,n.jsx)(i.code,{children:"document_id_normalized"}),". Use the formula field to apply the normalization logic. This approach allows you to preserve the original value while keeping the normalized result in a separate field, making it easier to manage both."]}),"\n",(0,n.jsx)(i.p,{children:"For better organization, it's also a good practice to group these related fields together, ensuring they are logically aligned and easy to find."}),"\n",(0,n.jsx)(i.h3,{id:"wide-variety-of-functions",children:"Wide variety of functions"}),"\n",(0,n.jsx)(i.p,{children:"As mentioned earlier, formula fields allow you to work with Python, enabling operations similar to those in serverless functions. However, formula fields are much simpler to maintain and manage, offering a streamlined approach for straightforward tasks."}),"\n",(0,n.jsx)(i.h3,{id:"access-document-object-information-in-formula-field",children:"Access document object information in formula field"}),"\n",(0,n.jsx)(i.p,{children:"Unfortunately right now there is no better way than create a simple serverless function to store desired information to custom field and continue with that one in formula field."}),"\n",(0,n.jsx)(i.h3,{id:"when-to-use-formula-fields-vs-serverless-functions",children:"When to Use Formula Fields vs. Serverless Functions"}),"\n",(0,n.jsx)(i.p,{children:"Formula fields are ideal for simple tasks such as data normalization or creating new fields based on existing ones. For more complex operations, serverless functions may be more appropriate. Situations where you should prefer serverless functions include:"}),"\n",(0,n.jsxs)(i.ul,{children:["\n",(0,n.jsxs)(i.li,{children:["There is a limit of ",(0,n.jsx)(i.strong,{children:"2000"})," characters per formula fields which declares the highest complexity of the formula fields."]}),"\n",(0,n.jsx)(i.li,{children:"You cannot access the document object from within the formula function."}),"\n",(0,n.jsx)(i.li,{children:"Formula Fields cannot and should not make HTTP requests (to Rossum API or elsewhere)."}),"\n",(0,n.jsx)(i.li,{children:"Formula Fields are executed only within the scope the specific field; for many rows (200+), the execution time may be too long."}),"\n",(0,n.jsx)(i.li,{children:"You need to set annotation status (e.g., \u201crejected\u201d, \u201cpostponed\u201d, etc.), you have to use Serverless functions."}),"\n",(0,n.jsx)(i.li,{children:"You want to edit multiple fields at the same time"}),"\n",(0,n.jsx)(i.li,{children:"Manipulate enums"}),"\n"]}),"\n",(0,n.jsx)(i.p,{children:"An additional advantage of formula fields is that they are stored at the schema level, so when you copy a queue, all associated formula fields are copied automatically. In contrast, serverless functions must be configured manually and re-linked to new queues after being copied."}),"\n",(0,n.jsx)(i.h2,{id:"examples-of-common-formula-fields",children:"Examples of common formula fields"}),"\n",(0,n.jsx)(i.h3,{id:"access-other-table-and-its-first-row-values",children:"Access other table and its first row values"}),"\n",(0,n.jsx)(i.pre,{children:(0,n.jsx)(i.code,{className:"language-py",children:"field.table_name[0].column_name\n"})}),"\n",(0,n.jsx)(i.h3,{id:"copy-fields-conditionally",children:"Copy fields conditionally"}),"\n",(0,n.jsxs)(i.p,{children:["Copy ",(0,n.jsx)(i.code,{children:"order_id"})," into another field but prioritize ",(0,n.jsx)(i.code,{children:"order_id_manual"})," datapoint if it exists:"]}),"\n",(0,n.jsxs)(i.p,{children:["New formula field ",(0,n.jsx)(i.code,{children:"order_id_normalized"}),":"]}),"\n",(0,n.jsx)(i.pre,{children:(0,n.jsx)(i.code,{className:"language-py",children:"field.order_id_manual if not is_empty(field.order_id_manual) else field.order_id\n"})}),"\n",(0,n.jsxs)(i.admonition,{type:"danger",children:[(0,n.jsxs)(i.p,{children:["Note that copying numbers like this does not copy the original format (specifically trailing zeros). So copying number ",(0,n.jsx)(i.code,{children:"123.40"})," will result in ",(0,n.jsx)(i.code,{children:"123.4"})," (notice the missing zero). In most of the cases, this is not an issue, however. To get the original format (as a string), you must use the following code:"]}),(0,n.jsx)(i.pre,{children:(0,n.jsx)(i.code,{className:"language-py",children:'field.amount.attr.value # "123.40"\n'})})]}),"\n",(0,n.jsx)(i.h3,{id:"get-all-enum-options",children:"Get all enum options"}),"\n",(0,n.jsxs)(i.p,{children:["You can access all enum options via special ",(0,n.jsx)(i.code,{children:"attr"})," attribute. The following code would return the number of enum options (regardless of what option is selected):"]}),"\n",(0,n.jsx)(i.pre,{children:(0,n.jsx)(i.code,{className:"language-py",children:"len(field.language.attr.options)\n"})}),"\n",(0,n.jsx)(i.h3,{id:"find-first-non-empty-line-item-value",children:"Find first non-empty line item value"}),"\n",(0,n.jsx)(i.pre,{children:(0,n.jsx)(i.code,{className:"language-py",children:'next((item for item in field.item_code.all_values if item), "")\n'})}),"\n",(0,n.jsx)(i.h3,{id:"generate-netsuite-external-ids",children:"Generate NetSuite external IDs"}),"\n",(0,n.jsxs)(i.p,{children:["Create external ID needed by NetSuite for ",(0,n.jsx)(i.em,{children:"VendorBill"})," and ",(0,n.jsx)(i.em,{children:"VendorCredit"})," records:"]}),"\n",(0,n.jsx)(i.pre,{children:(0,n.jsx)(i.code,{className:"language-py",children:'# Create an external ID by combining document ID and entity (vendor) match. This is to make sure\n# that different vendors with identical document numbering are not matched to the same NetSuite\n# record (same NetSuite external ID).\nexternal_id = f"{field.document_id}__{field.order_match__entity_internalId}"\n\n# Construct the final result by concatenating (and normalizing) Rossum prefix, document type, and external ID:\nsubstitute(r"[^a-zA-Z\\d\\-_]", "", f"__rossum__{field.document_type}__{external_id}".lower())\n'})}),"\n",(0,n.jsxs)(i.p,{children:["This is typically necessary when ",(0,n.jsx)(i.a,{href:"../netsuite/export-configuration#vendor-bills-invoices",children:"exporting records into NetSuite"}),"."]}),"\n",(0,n.jsx)(i.h3,{id:"get-line-item-index",children:"Get line item index"}),"\n",(0,n.jsx)(i.p,{children:"Returns line item number (indexed from 0):"}),"\n",(0,n.jsx)(i.pre,{children:(0,n.jsx)(i.code,{className:"language-py",children:"field._index\n"})}),"\n",(0,n.jsx)(i.h3,{id:"normalize-field-value",children:"Normalize field value"}),"\n",(0,n.jsx)(i.p,{children:'Remove non-alphanumeric characters (except "-" and "_"):'}),"\n",(0,n.jsx)(i.pre,{children:(0,n.jsx)(i.code,{className:"language-py",children:'substitute(r"[^a-zA-Z\\d\\-_]", "", field.order_id)\n'})}),"\n",(0,n.jsx)(i.h3,{id:"sum-line-item-values",children:"Sum line item values"}),"\n",(0,n.jsxs)(i.p,{children:["Sum the values of ",(0,n.jsx)(i.code,{children:"item_amount_total"}),". Use ",(0,n.jsx)(i.code,{children:"0"})," if the field is empty."]}),"\n",(0,n.jsx)(i.pre,{children:(0,n.jsx)(i.code,{className:"language-py",children:"sum(default_to(field.item_amount_total.all_values, 0))\n"})}),"\n",(0,n.jsx)(i.h3,{id:"validations",children:"Validations"}),"\n",(0,n.jsx)(i.admonition,{type:"warning",children:(0,n.jsxs)(i.p,{children:["Consider using a ",(0,n.jsx)(i.a,{href:"/docs/learn/rossum-formulas/serverless-functions",children:"Serverless function"})," as a better place to perform such validations. Internally, we consider this technique deprecated, albeit still valid. Formula fields should not affect behavior of other fields indirectly as it makes the overall solution less readable and predictable."]})}),"\n",(0,n.jsxs)(i.p,{children:["To validate line items, create ",(0,n.jsx)(i.code,{children:"item_validator"})," formula field with the following code:"]}),"\n",(0,n.jsx)(i.pre,{children:(0,n.jsx)(i.code,{className:"language-py",children:'import math\n\nitem_total_base_calculated = field.item_quantity * field.item_amount_base\n\nif not math.isclose(item_total_base_calculated, field.item_total_base, rel_tol=0.004):\n item_total_base_diff = abs(item_total_base_calculated - field.item_total_base)\n message = (f"The totals do not match. Expected total: {field.item_total_base}, "\n f"Calculated total: {item_total_base_calculated}, "\n f"Difference: {item_total_base_diff}")\n\n show_error(message, field.item_quantity)\n show_error(message, field.item_amount_base)\n show_error(message, field.item_total_base)\n'})}),"\n",(0,n.jsx)(i.h3,{id:"get-yearmonth-from-a-date-field",children:"Get year/month from a date field"}),"\n",(0,n.jsx)(i.p,{children:"Returns year/month integer of a date field:"}),"\n",(0,n.jsx)(i.pre,{children:(0,n.jsx)(i.code,{className:"language-py",children:"field.date_issue.year\nfield.date_issue.month\n"})}),"\n",(0,n.jsx)(i.h3,{id:"date-validation",children:"Date validation"}),"\n",(0,n.jsxs)(i.p,{children:["This function, ",(0,n.jsx)(i.code,{children:"check_invoice_date"}),", checks if the invoice date (passed as ",(0,n.jsx)(i.code,{children:"document_date"}),") is more than 90 days old compared to the current date. It calculates the difference in days between the two dates and, if the document is older than 90 days, triggers a warning message. This message notifies the user of the outdated date and blocks further automation until the issue is resolved."]}),"\n",(0,n.jsx)(i.pre,{children:(0,n.jsx)(i.code,{className:"language-py",children:'# import fo the datetime module is not necessary as it is already imported by default\nimport datetime\ndef check_invoice_date(document_date):\n # Get the current date\n current_date = datetime.datetime.now().date()\n\n # Calculate the difference in days between the current date and the document date\n days_difference = (current_date - document_date).days\n\n # Check if the document date is older than 90 days\n if days_difference > 90:\n # Raise a warning and set an automation blocker\n warning_message = f"Warning: Invoice date is older than 90 days ({days_difference} days). Please confirm the date."\n automation_blocker(warning_message, field.date_issue)\n show_warning(warning_message)\n\ncheck_invoice_date(field.date_issue)\n'})}),"\n",(0,n.jsx)(i.h3,{id:"html-formatting",children:"HTML formatting"}),"\n",(0,n.jsx)(i.p,{children:"Basic HTML formatting is available inside show_warning() and similar functions.\nYou can even paste links (e.g, to the ERP system)."}),"\n",(0,n.jsx)(i.p,{children:"Example:"}),"\n",(0,n.jsx)(i.pre,{children:(0,n.jsx)(i.code,{className:"language-python",children:'show_warning("""\n\n""")\n'})}),"\n",(0,n.jsx)(i.p,{children:"Will render as:"}),"\n",(0,n.jsx)(i.p,{children:(0,n.jsx)(i.img,{alt:"Warning example",src:a(9089).A+"",width:"899",height:"221"})}),"\n",(0,n.jsx)(i.h3,{id:"vat-rates-table-fallbacks",children:"VAT Rates table fallbacks"}),"\n",(0,n.jsx)(i.p,{children:'It is often necessary to calculate missing values from the captured VAT information. For example, if we know "VAT Base" and "VAT Amount", we can calulate the missing "VAT Rate". The following section shows all the necessary combinations to calculate the missing values.'}),"\n",(0,n.jsx)(i.p,{children:"All the following examples are rounding the values to two decimal places."}),"\n",(0,n.jsx)(i.h4,{id:"tax_detail_rate_calculated",children:(0,n.jsx)(i.code,{children:"tax_detail_rate_calculated"})}),"\n",(0,n.jsx)(i.pre,{children:(0,n.jsx)(i.code,{className:"language-py",children:"if is_set(field.tax_detail_rate):\n round(field.tax_detail_rate, 2)\nelif is_set(field.tax_detail_base) and is_set(field.tax_detail_tax) and field.tax_detail_base != 0:\n round((field.tax_detail_tax / field.tax_detail_base) * 100, 2)\nelse:\n 0\n"})}),"\n",(0,n.jsx)(i.h4,{id:"tax_detail_base_calculated",children:(0,n.jsx)(i.code,{children:"tax_detail_base_calculated"})}),"\n",(0,n.jsx)(i.pre,{children:(0,n.jsx)(i.code,{className:"language-py",children:"if is_set(field.tax_detail_base):\n round(field.tax_detail_base, 2)\nelif is_set(field.tax_detail_tax) and is_set(field.tax_detail_rate) and field.tax_detail_rate != 0:\n round(field.tax_detail_tax * 100 / field.tax_detail_rate, 2)\n"})}),"\n",(0,n.jsx)(i.h4,{id:"tax_detail_tax_calculated",children:(0,n.jsx)(i.code,{children:"tax_detail_tax_calculated"})}),"\n",(0,n.jsx)(i.pre,{children:(0,n.jsx)(i.code,{className:"language-py",children:"if is_set(field.tax_detail_tax):\n round(field.tax_detail_tax, 2)\nelif is_set(field.tax_detail_base) and is_set(field.tax_detail_rate):\n round(field.tax_detail_base * field.tax_detail_rate / 100, 2)\n"})}),"\n",(0,n.jsx)(i.h4,{id:"tax_detail_total_calculated",children:(0,n.jsx)(i.code,{children:"tax_detail_total_calculated"})}),"\n",(0,n.jsx)(i.pre,{children:(0,n.jsx)(i.code,{className:"language-py",children:"if is_set(field.tax_detail_total):\n round(field.tax_detail_total, 2)\nelif is_set(field.tax_detail_base) and is_set(field.tax_detail_tax):\n round(field.tax_detail_base + field.tax_detail_tax, 2)\nelif is_set(field.tax_detail_base) and is_set(field.tax_detail_rate):\n round(field.tax_detail_base * (1 + field.tax_detail_rate / 100), 2)\nelif is_set(field.tax_detail_rate) and is_set(field.tax_detail_tax) and field.tax_detail_rate != 0:\n round(field.tax_detail_tax / (field.tax_detail_rate / 100) + field.tax_detail_tax, 2)\n"})}),"\n",(0,n.jsx)(i.h3,{id:"check-existence-of-a-field-in-the-schema",children:"Check existence of a field in the schema"}),"\n",(0,n.jsx)(i.p,{children:"Formula fields expect that all fields are present in the schema. If a field is missing, an error will be raised. For example:"}),"\n",(0,n.jsx)(i.pre,{children:(0,n.jsx)(i.code,{className:"language-txt",children:"AttributeError: Field 'doesntexist' is not defined\n\nTraceback (most recent call last):\n at line 7, in :\n if is_set(field.doesntexist):\n"})}),"\n",(0,n.jsx)(i.p,{children:"If you'd like to check the field existence, use one of the following formulas (all of them should work):"}),"\n",(0,n.jsx)(i.pre,{children:(0,n.jsx)(i.code,{className:"language-py",children:"if 'doesntexist' in vars(field) and is_set(value := field.doesntexist):\n show_info(value)\n"})}),"\n",(0,n.jsx)(i.p,{children:"Or:"}),"\n",(0,n.jsx)(i.pre,{children:(0,n.jsx)(i.code,{className:"language-py",children:"if hasattr(field, 'doesntexist') and is_set(value := field.doesntexist):\n show_info(value)\n"})}),"\n",(0,n.jsx)(i.p,{children:"Or:"}),"\n",(0,n.jsx)(i.pre,{children:(0,n.jsx)(i.code,{className:"language-py",children:"if is_set(value := getattr(field, 'doesntexist', None)):\n show_info(value)\n"})}),"\n",(0,n.jsx)(i.p,{children:"Or:"}),"\n",(0,n.jsx)(i.pre,{children:(0,n.jsx)(i.code,{className:"language-py",children:"try:\n if is_set(value := field.doesntexist):\n show_info(value)\nexcept AttributeError:\n pass\n"})}),"\n",(0,n.jsx)(i.h3,{id:"remove-whitespaces",children:"Remove whitespaces"}),"\n",(0,n.jsx)(i.pre,{children:(0,n.jsx)(i.code,{className:"language-py",children:"''.join(field.iban.split())\n"})})]})}function u(e={}){const{wrapper:i}={...(0,l.R)(),...e.components};return i?(0,n.jsx)(i,{...e,children:(0,n.jsx)(c,{...e})}):c(e)}},9089:(e,i,a)=>{a.d(i,{A:()=>t});const t=a.p+"assets/images/warning_message-f412da8cad68104721c552d96f06de8b.png"},8453:(e,i,a)=>{a.d(i,{R:()=>s,x:()=>d});var t=a(6540);const n={},l=t.createContext(n);function s(e){const i=t.useContext(l);return t.useMemo((function(){return"function"==typeof e?e(i):{...i,...e}}),[i,e])}function d(e){let i;return i=e.disableParentContext?"function"==typeof e.components?e.components(n):e.components||n:s(e.components),t.createElement(l.Provider,{value:i},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/f538922c.54dbb831.js b/assets/js/f538922c.54dbb831.js deleted file mode 100644 index 1ec274ee..00000000 --- a/assets/js/f538922c.54dbb831.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunkuniversity=self.webpackChunkuniversity||[]).push([[9269],{2971:(e,a,i)=>{i.r(a),i.d(a,{assets:()=>o,contentTitle:()=>d,default:()=>u,frontMatter:()=>s,metadata:()=>t,toc:()=>r});const t=JSON.parse('{"id":"learn/rossum-formulas/formula-fields","title":"Rossum Formulas: Formula fields","description":"Intro","source":"@site/docs/learn/rossum-formulas/formula-fields.md","sourceDirName":"learn/rossum-formulas","slug":"/learn/rossum-formulas/formula-fields","permalink":"/docs/learn/rossum-formulas/formula-fields","draft":false,"unlisted":false,"editUrl":"https://github.com/rossumai/university/tree/master/docs/learn/rossum-formulas/formula-fields.md","tags":[],"version":"current","sidebarPosition":1,"frontMatter":{"sidebar_position":1,"sidebar_label":"Formula fields","title":"Rossum Formulas: Formula fields","toc_max_heading_level":4},"sidebar":"learnSidebar","previous":{"title":"Rossum Formulas","permalink":"/docs/learn/rossum-formulas/"},"next":{"title":"Serverless functions","permalink":"/docs/learn/rossum-formulas/serverless-functions"}}');var n=i(4848),l=i(8453);const s={sidebar_position:1,sidebar_label:"Formula fields",title:"Rossum Formulas: Formula fields",toc_max_heading_level:4},d="Formula fields",o={},r=[{value:"Intro",id:"intro",level:2},{value:"Basic information",id:"basic-information",level:2},{value:"Best practices",id:"best-practices",level:2},{value:"Field naming and management",id:"field-naming-and-management",level:3},{value:"Wide variety of functions",id:"wide-variety-of-functions",level:3},{value:"Access document object information in formula field",id:"access-document-object-information-in-formula-field",level:3},{value:"When to Use Formula Fields vs. Serverless Functions",id:"when-to-use-formula-fields-vs-serverless-functions",level:3},{value:"Examples of common formula fields",id:"examples-of-common-formula-fields",level:2},{value:"Access other table and its first row values",id:"access-other-table-and-its-first-row-values",level:3},{value:"Copy fields conditionally",id:"copy-fields-conditionally",level:3},{value:"Get all enum options",id:"get-all-enum-options",level:3},{value:"Find first non-empty line item value",id:"find-first-non-empty-line-item-value",level:3},{value:"Generate NetSuite external IDs",id:"generate-netsuite-external-ids",level:3},{value:"Get line item index",id:"get-line-item-index",level:3},{value:"Normalize field value",id:"normalize-field-value",level:3},{value:"Sum line item values",id:"sum-line-item-values",level:3},{value:"Validations",id:"validations",level:3},{value:"Get year/month from a date field",id:"get-yearmonth-from-a-date-field",level:3},{value:"Date validation",id:"date-validation",level:3},{value:"HTML formatting",id:"html-formatting",level:3},{value:"VAT Rates table fallbacks",id:"vat-rates-table-fallbacks",level:3},{value:"tax_detail_rate_calculated",id:"tax_detail_rate_calculated",level:4},{value:"tax_detail_base_calculated",id:"tax_detail_base_calculated",level:4},{value:"tax_detail_tax_calculated",id:"tax_detail_tax_calculated",level:4},{value:"tax_detail_total_calculated",id:"tax_detail_total_calculated",level:4},{value:"Check existence of a field in the schema",id:"check-existence-of-a-field-in-the-schema",level:3},{value:"Remove whitespaces",id:"remove-whitespaces",level:3}];function c(e){const a={a:"a",admonition:"admonition",code:"code",em:"em",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,l.R)(),...e.components};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(a.header,{children:(0,n.jsx)(a.h1,{id:"formula-fields",children:"Formula fields"})}),"\n",(0,n.jsx)(a.h2,{id:"intro",children:"Intro"}),"\n",(0,n.jsx)(a.p,{children:"Formula fields in Rossum enable you to easily transform your data directly within the app. Whether you need to normalize data, perform calculations, or handle text operations, formula fields provide the flexibility to set values based on your custom logic."}),"\n",(0,n.jsx)(a.p,{children:"For most tasks, Rossum\u2019s Copilot handles everything seamlessly without needing code, and we recommend using it for the best results. However, if you want to dive deeper into custom logic, formula fields support Python-based coding with simple examples to get you started."}),"\n",(0,n.jsx)(a.admonition,{type:"info",children:(0,n.jsxs)(a.p,{children:["This powerful feature is available on the Business plan and above. Existing customers interested in using formula fields can reach out to our support team at ",(0,n.jsx)(a.a,{href:"mailto:support@rossum.ai",children:"support@rossum.ai"})," for assistance."]})}),"\n",(0,n.jsx)(a.h2,{id:"basic-information",children:"Basic information"}),"\n",(0,n.jsxs)(a.ul,{children:["\n",(0,n.jsxs)(a.li,{children:["Formula Fields can run any Python code including its ",(0,n.jsx)(a.a,{href:"https://docs.python.org/3/library/index.html",children:"Standard Library modules"}),"."]}),"\n",(0,n.jsx)(a.li,{children:"Additionally, the runtime is enriched with Rossum-specific functions and variables"}),"\n",(0,n.jsx)(a.li,{children:"They are executed in an AWS lambda"}),"\n",(0,n.jsx)(a.li,{children:"Formula Fields are automatically executed before and after each extension."}),"\n",(0,n.jsx)(a.li,{children:"Extensions cannot overwrite Formula Fields value (create a separate \u201cdata\u201d field instead)."}),"\n"]}),"\n",(0,n.jsx)(a.h2,{id:"best-practices",children:"Best practices"}),"\n",(0,n.jsx)(a.h3,{id:"field-naming-and-management",children:"Field naming and management"}),"\n",(0,n.jsxs)(a.p,{children:["When you need to create a normalized version of a field like ",(0,n.jsx)(a.code,{children:"document_id"}),", it's recommended to create a new field, such as ",(0,n.jsx)(a.code,{children:"document_id_normalized"}),". Use the formula field to apply the normalization logic. This approach allows you to preserve the original value while keeping the normalized result in a separate field, making it easier to manage both."]}),"\n",(0,n.jsx)(a.p,{children:"For better organization, it's also a good practice to group these related fields together, ensuring they are logically aligned and easy to find."}),"\n",(0,n.jsx)(a.h3,{id:"wide-variety-of-functions",children:"Wide variety of functions"}),"\n",(0,n.jsx)(a.p,{children:"As mentioned earlier, formula fields allow you to work with Python, enabling operations similar to those in serverless functions. However, formula fields are much simpler to maintain and manage, offering a streamlined approach for straightforward tasks."}),"\n",(0,n.jsx)(a.h3,{id:"access-document-object-information-in-formula-field",children:"Access document object information in formula field"}),"\n",(0,n.jsx)(a.p,{children:"Unfortunately right now there is no better way than create a simple serverless function to store desired information to custom field and continue with that one in formula field."}),"\n",(0,n.jsx)(a.h3,{id:"when-to-use-formula-fields-vs-serverless-functions",children:"When to Use Formula Fields vs. Serverless Functions"}),"\n",(0,n.jsx)(a.p,{children:"Formula fields are ideal for simple tasks such as data normalization or creating new fields based on existing ones. For more complex operations, serverless functions may be more appropriate. Situations where you should prefer serverless functions include:"}),"\n",(0,n.jsxs)(a.ul,{children:["\n",(0,n.jsxs)(a.li,{children:["There is a limit of ",(0,n.jsx)(a.strong,{children:"2000"})," characters per formula fields which declares the highest complexity of the formula fields."]}),"\n",(0,n.jsx)(a.li,{children:"You cannot access the document object from within the formula function."}),"\n",(0,n.jsx)(a.li,{children:"Formula Fields cannot and should not make HTTP requests (to Rossum API or elsewhere)."}),"\n",(0,n.jsx)(a.li,{children:"Formula Fields are executed only within the scope the specific field; for many rows (200+), the execution time may be too long."}),"\n",(0,n.jsx)(a.li,{children:"You need to set annotation status (e.g., \u201crejected\u201d, \u201cpostponed\u201d, etc.), you have to use Serverless functions."}),"\n",(0,n.jsx)(a.li,{children:"You want to edit multiple fields at the same time"}),"\n",(0,n.jsx)(a.li,{children:"Manipulate enums"}),"\n"]}),"\n",(0,n.jsx)(a.p,{children:"An additional advantage of formula fields is that they are stored at the schema level, so when you copy a queue, all associated formula fields are copied automatically. In contrast, serverless functions must be configured manually and re-linked to new queues after being copied."}),"\n",(0,n.jsx)(a.h2,{id:"examples-of-common-formula-fields",children:"Examples of common formula fields"}),"\n",(0,n.jsx)(a.h3,{id:"access-other-table-and-its-first-row-values",children:"Access other table and its first row values"}),"\n",(0,n.jsx)(a.pre,{children:(0,n.jsx)(a.code,{className:"language-py",children:"field.table_name[0].column_name\n"})}),"\n",(0,n.jsx)(a.h3,{id:"copy-fields-conditionally",children:"Copy fields conditionally"}),"\n",(0,n.jsxs)(a.p,{children:["Copy ",(0,n.jsx)(a.code,{children:"order_id"})," into another field but prioritize ",(0,n.jsx)(a.code,{children:"order_id_manual"})," datapoint if it exists:"]}),"\n",(0,n.jsxs)(a.p,{children:["New formula field ",(0,n.jsx)(a.code,{children:"order_id_normalized"}),":"]}),"\n",(0,n.jsx)(a.pre,{children:(0,n.jsx)(a.code,{className:"language-py",children:"field.order_id_manual if not is_empty(field.order_id_manual) else field.order_id\n"})}),"\n",(0,n.jsx)(a.h3,{id:"get-all-enum-options",children:"Get all enum options"}),"\n",(0,n.jsxs)(a.p,{children:["You can access all enum options via special ",(0,n.jsx)(a.code,{children:"attr"})," attribute. The following code would return the number of enum options (regardless of what option is selected):"]}),"\n",(0,n.jsx)(a.pre,{children:(0,n.jsx)(a.code,{className:"language-py",children:"len(field.language.attr.options)\n"})}),"\n",(0,n.jsx)(a.h3,{id:"find-first-non-empty-line-item-value",children:"Find first non-empty line item value"}),"\n",(0,n.jsx)(a.pre,{children:(0,n.jsx)(a.code,{className:"language-py",children:'next((item for item in field.item_code.all_values if item), "")\n'})}),"\n",(0,n.jsx)(a.h3,{id:"generate-netsuite-external-ids",children:"Generate NetSuite external IDs"}),"\n",(0,n.jsxs)(a.p,{children:["Create external ID needed by NetSuite for ",(0,n.jsx)(a.em,{children:"VendorBill"})," and ",(0,n.jsx)(a.em,{children:"VendorCredit"})," records:"]}),"\n",(0,n.jsx)(a.pre,{children:(0,n.jsx)(a.code,{className:"language-py",children:'# Create an external ID by combining document ID and entity (vendor) match. This is to make sure\n# that different vendors with identical document numbering are not matched to the same NetSuite\n# record (same NetSuite external ID).\nexternal_id = f"{field.document_id}__{field.order_match__entity_internalId}"\n\n# Construct the final result by concatenating (and normalizing) Rossum prefix, document type, and external ID:\nsubstitute(r"[^a-zA-Z\\d\\-_]", "", f"__rossum__{field.document_type}__{external_id}".lower())\n'})}),"\n",(0,n.jsxs)(a.p,{children:["This is typically necessary when ",(0,n.jsx)(a.a,{href:"../netsuite/export-configuration#vendor-bills-invoices",children:"exporting records into NetSuite"}),"."]}),"\n",(0,n.jsx)(a.h3,{id:"get-line-item-index",children:"Get line item index"}),"\n",(0,n.jsx)(a.p,{children:"Returns line item number (indexed from 0):"}),"\n",(0,n.jsx)(a.pre,{children:(0,n.jsx)(a.code,{className:"language-py",children:"field._index\n"})}),"\n",(0,n.jsx)(a.h3,{id:"normalize-field-value",children:"Normalize field value"}),"\n",(0,n.jsx)(a.p,{children:'Remove non-alphanumeric characters (except "-" and "_"):'}),"\n",(0,n.jsx)(a.pre,{children:(0,n.jsx)(a.code,{className:"language-py",children:'substitute(r"[^a-zA-Z\\d\\-_]", "", field.order_id)\n'})}),"\n",(0,n.jsx)(a.h3,{id:"sum-line-item-values",children:"Sum line item values"}),"\n",(0,n.jsxs)(a.p,{children:["Sum the values of ",(0,n.jsx)(a.code,{children:"item_amount_total"}),". Use ",(0,n.jsx)(a.code,{children:"0"})," if the field is empty."]}),"\n",(0,n.jsx)(a.pre,{children:(0,n.jsx)(a.code,{className:"language-py",children:"sum(default_to(field.item_amount_total.all_values, 0))\n"})}),"\n",(0,n.jsx)(a.h3,{id:"validations",children:"Validations"}),"\n",(0,n.jsx)(a.admonition,{type:"warning",children:(0,n.jsxs)(a.p,{children:["Consider using a ",(0,n.jsx)(a.a,{href:"/docs/learn/rossum-formulas/serverless-functions",children:"Serverless function"})," as a better place to perform such validations. Internally, we consider this technique deprecated, albeit still valid. Formula fields should not affect behavior of other fields indirectly as it makes the overall solution less readable and predictable."]})}),"\n",(0,n.jsxs)(a.p,{children:["To validate line items, create ",(0,n.jsx)(a.code,{children:"item_validator"})," formula field with the following code:"]}),"\n",(0,n.jsx)(a.pre,{children:(0,n.jsx)(a.code,{className:"language-py",children:'import math\n\nitem_total_base_calculated = field.item_quantity * field.item_amount_base\n\nif not math.isclose(item_total_base_calculated, field.item_total_base, rel_tol=0.004):\n item_total_base_diff = abs(item_total_base_calculated - field.item_total_base)\n message = (f"The totals do not match. Expected total: {field.item_total_base}, "\n f"Calculated total: {item_total_base_calculated}, "\n f"Difference: {item_total_base_diff}")\n\n show_error(message, field.item_quantity)\n show_error(message, field.item_amount_base)\n show_error(message, field.item_total_base)\n'})}),"\n",(0,n.jsx)(a.h3,{id:"get-yearmonth-from-a-date-field",children:"Get year/month from a date field"}),"\n",(0,n.jsx)(a.p,{children:"Returns year/month integer of a date field:"}),"\n",(0,n.jsx)(a.pre,{children:(0,n.jsx)(a.code,{className:"language-py",children:"field.date_issue.year\nfield.date_issue.month\n"})}),"\n",(0,n.jsx)(a.h3,{id:"date-validation",children:"Date validation"}),"\n",(0,n.jsxs)(a.p,{children:["This function, ",(0,n.jsx)(a.code,{children:"check_invoice_date"}),", checks if the invoice date (passed as ",(0,n.jsx)(a.code,{children:"document_date"}),") is more than 90 days old compared to the current date. It calculates the difference in days between the two dates and, if the document is older than 90 days, triggers a warning message. This message notifies the user of the outdated date and blocks further automation until the issue is resolved."]}),"\n",(0,n.jsx)(a.pre,{children:(0,n.jsx)(a.code,{className:"language-py",children:'# import fo the datetime module is not necessary as it is already imported by default\nimport datetime\ndef check_invoice_date(document_date):\n # Get the current date\n current_date = datetime.datetime.now().date()\n\n # Calculate the difference in days between the current date and the document date\n days_difference = (current_date - document_date).days\n\n # Check if the document date is older than 90 days\n if days_difference > 90:\n # Raise a warning and set an automation blocker\n warning_message = f"Warning: Invoice date is older than 90 days ({days_difference} days). Please confirm the date."\n automation_blocker(warning_message, field.date_issue)\n show_warning(warning_message)\n\ncheck_invoice_date(field.date_issue)\n'})}),"\n",(0,n.jsx)(a.h3,{id:"html-formatting",children:"HTML formatting"}),"\n",(0,n.jsx)(a.p,{children:"Basic HTML formatting is available inside show_warning() and similar functions.\nYou can even paste links (e.g, to the ERP system)."}),"\n",(0,n.jsx)(a.p,{children:"Example:"}),"\n",(0,n.jsx)(a.pre,{children:(0,n.jsx)(a.code,{className:"language-python",children:'show_warning("""\n\n""")\n'})}),"\n",(0,n.jsx)(a.p,{children:"Will render as:"}),"\n",(0,n.jsx)(a.p,{children:(0,n.jsx)(a.img,{alt:"Warning example",src:i(9089).A+"",width:"899",height:"221"})}),"\n",(0,n.jsx)(a.h3,{id:"vat-rates-table-fallbacks",children:"VAT Rates table fallbacks"}),"\n",(0,n.jsx)(a.p,{children:'It is often necessary to calculate missing values from the captured VAT information. For example, if we know "VAT Base" and "VAT Amount", we can calulate the missing "VAT Rate". The following section shows all the necessary combinations to calculate the missing values.'}),"\n",(0,n.jsx)(a.p,{children:"All the following examples are rounding the values to two decimal places."}),"\n",(0,n.jsx)(a.h4,{id:"tax_detail_rate_calculated",children:(0,n.jsx)(a.code,{children:"tax_detail_rate_calculated"})}),"\n",(0,n.jsx)(a.pre,{children:(0,n.jsx)(a.code,{className:"language-py",children:"if is_set(field.tax_detail_rate):\n round(field.tax_detail_rate, 2)\nelif is_set(field.tax_detail_base) and is_set(field.tax_detail_tax) and field.tax_detail_base != 0:\n round((field.tax_detail_tax / field.tax_detail_base) * 100, 2)\nelse:\n 0\n"})}),"\n",(0,n.jsx)(a.h4,{id:"tax_detail_base_calculated",children:(0,n.jsx)(a.code,{children:"tax_detail_base_calculated"})}),"\n",(0,n.jsx)(a.pre,{children:(0,n.jsx)(a.code,{className:"language-py",children:"if is_set(field.tax_detail_base):\n round(field.tax_detail_base, 2)\nelif is_set(field.tax_detail_tax) and is_set(field.tax_detail_rate) and field.tax_detail_rate != 0:\n round(field.tax_detail_tax * 100 / field.tax_detail_rate, 2)\n"})}),"\n",(0,n.jsx)(a.h4,{id:"tax_detail_tax_calculated",children:(0,n.jsx)(a.code,{children:"tax_detail_tax_calculated"})}),"\n",(0,n.jsx)(a.pre,{children:(0,n.jsx)(a.code,{className:"language-py",children:"if is_set(field.tax_detail_tax):\n round(field.tax_detail_tax, 2)\nelif is_set(field.tax_detail_base) and is_set(field.tax_detail_rate):\n round(field.tax_detail_base * field.tax_detail_rate / 100, 2)\n"})}),"\n",(0,n.jsx)(a.h4,{id:"tax_detail_total_calculated",children:(0,n.jsx)(a.code,{children:"tax_detail_total_calculated"})}),"\n",(0,n.jsx)(a.pre,{children:(0,n.jsx)(a.code,{className:"language-py",children:"if is_set(field.tax_detail_total):\n round(field.tax_detail_total, 2)\nelif is_set(field.tax_detail_base) and is_set(field.tax_detail_tax):\n round(field.tax_detail_base + field.tax_detail_tax, 2)\nelif is_set(field.tax_detail_base) and is_set(field.tax_detail_rate):\n round(field.tax_detail_base * (1 + field.tax_detail_rate / 100), 2)\nelif is_set(field.tax_detail_rate) and is_set(field.tax_detail_tax) and field.tax_detail_rate != 0:\n round(field.tax_detail_tax / (field.tax_detail_rate / 100) + field.tax_detail_tax, 2)\n"})}),"\n",(0,n.jsx)(a.h3,{id:"check-existence-of-a-field-in-the-schema",children:"Check existence of a field in the schema"}),"\n",(0,n.jsx)(a.p,{children:"Formula fields expect that all fields are present in the schema. If a field is missing, an error will be raised. For example:"}),"\n",(0,n.jsx)(a.pre,{children:(0,n.jsx)(a.code,{className:"language-txt",children:"AttributeError: Field 'doesntexist' is not defined\n\nTraceback (most recent call last):\n at line 7, in :\n if is_set(field.doesntexist):\n"})}),"\n",(0,n.jsx)(a.p,{children:"If you'd like to check the field existence, use one of the following formulas (all of them should work):"}),"\n",(0,n.jsx)(a.pre,{children:(0,n.jsx)(a.code,{className:"language-py",children:"if 'doesntexist' in vars(field) and is_set(value := field.doesntexist):\n show_info(value)\n"})}),"\n",(0,n.jsx)(a.p,{children:"Or:"}),"\n",(0,n.jsx)(a.pre,{children:(0,n.jsx)(a.code,{className:"language-py",children:"if hasattr(field, 'doesntexist') and is_set(value := field.doesntexist):\n show_info(value)\n"})}),"\n",(0,n.jsx)(a.p,{children:"Or:"}),"\n",(0,n.jsx)(a.pre,{children:(0,n.jsx)(a.code,{className:"language-py",children:"if is_set(value := getattr(field, 'doesntexist', None)):\n show_info(value)\n"})}),"\n",(0,n.jsx)(a.p,{children:"Or:"}),"\n",(0,n.jsx)(a.pre,{children:(0,n.jsx)(a.code,{className:"language-py",children:"try:\n if is_set(value := field.doesntexist):\n show_info(value)\nexcept AttributeError:\n pass\n"})}),"\n",(0,n.jsx)(a.h3,{id:"remove-whitespaces",children:"Remove whitespaces"}),"\n",(0,n.jsx)(a.pre,{children:(0,n.jsx)(a.code,{className:"language-py",children:"''.join(field.iban.split())\n"})})]})}function u(e={}){const{wrapper:a}={...(0,l.R)(),...e.components};return a?(0,n.jsx)(a,{...e,children:(0,n.jsx)(c,{...e})}):c(e)}},9089:(e,a,i)=>{i.d(a,{A:()=>t});const t=i.p+"assets/images/warning_message-f412da8cad68104721c552d96f06de8b.png"},8453:(e,a,i)=>{i.d(a,{R:()=>s,x:()=>d});var t=i(6540);const n={},l=t.createContext(n);function s(e){const a=t.useContext(l);return t.useMemo((function(){return"function"==typeof e?e(a):{...a,...e}}),[a,e])}function d(e){let a;return a=e.disableParentContext?"function"==typeof e.components?e.components(n):e.components||n:s(e.components),t.createElement(l.Provider,{value:a},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/runtime~main.49e36b6a.js b/assets/js/runtime~main.98915f15.js similarity index 99% rename from assets/js/runtime~main.49e36b6a.js rename to assets/js/runtime~main.98915f15.js index 84981e43..60770f04 100644 --- a/assets/js/runtime~main.49e36b6a.js +++ b/assets/js/runtime~main.98915f15.js @@ -1 +1 @@ -(()=>{"use strict";var e,a,c,f,d,b={},t={};function r(e){var a=t[e];if(void 0!==a)return a.exports;var c=t[e]={exports:{}};return b[e].call(c.exports,c,c.exports,r),c.exports}r.m=b,e=[],r.O=(a,c,f,d)=>{if(!c){var b=1/0;for(i=0;i=d)&&Object.keys(r.O).every((e=>r.O[e](c[o])))?c.splice(o--,1):(t=!1,d0&&e[i-1][2]>d;i--)e[i]=e[i-1];e[i]=[c,f,d]},r.n=e=>{var a=e&&e.__esModule?()=>e.default:()=>e;return r.d(a,{a:a}),a},c=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,r.t=function(e,f){if(1&f&&(e=this(e)),8&f)return e;if("object"==typeof e&&e){if(4&f&&e.__esModule)return e;if(16&f&&"function"==typeof e.then)return e}var d=Object.create(null);r.r(d);var b={};a=a||[null,c({}),c([]),c(c)];for(var t=2&f&&e;"object"==typeof t&&!~a.indexOf(t);t=c(t))Object.getOwnPropertyNames(t).forEach((a=>b[a]=()=>e[a]));return b.default=()=>e,r.d(d,b),d},r.d=(e,a)=>{for(var c in a)r.o(a,c)&&!r.o(e,c)&&Object.defineProperty(e,c,{enumerable:!0,get:a[c]})},r.f={},r.e=e=>Promise.all(Object.keys(r.f).reduce(((a,c)=>(r.f[c](e,a),a)),[])),r.u=e=>"assets/js/"+({8:"87870a77",30:"a0d0303f",58:"36113f10",124:"45d8669e",167:"9194d0c0",197:"7bc57c03",226:"d9579b4e",307:"7e227553",827:"65dda65a",849:"0058b4c6",868:"d0076172",957:"c141421f",989:"e9a6d939",1145:"eff8eb88",1235:"a7456010",1246:"98083335",1331:"5355a5f6",1729:"49cbce88",1843:"d75e79d1",2138:"1a4e3797",2189:"21539068",2343:"ecb29807",2558:"2a18cecd",2634:"c4f5d8e4",2779:"8c33af2f",3031:"4de008a4",3139:"0b976963",3224:"7165fbd0",3331:"46fdca80",3403:"2424c742",3456:"53f9498a",3467:"ce8af1f0",3808:"1bd21fa2",3835:"a35fff70",4008:"34bb27a8",4220:"704ec7af",4292:"159da944",4459:"a2f35568",4497:"736016fe",4588:"0164bf5c",4649:"c4ad0d80",4710:"f492dbce",4743:"8544f9b4",4759:"974bf4e7",4920:"05749220",5316:"d922b24b",5451:"83c5e61e",5550:"c7c920e6",5608:"72524c0f",5677:"838d8184",5742:"aba21aa0",5760:"9830673e",5838:"80247147",6061:"1f391b9e",6212:"9003d50b",6221:"05252284",6961:"78fd8131",6969:"14eb3368",7084:"62511cfc",7098:"a7bd4aaa",7339:"683a4745",7451:"093eb245",7480:"05868134",7743:"06c5bd31",7852:"eb35b875",8145:"3c53f774",8157:"a491ca58",8300:"ce87d750",8348:"7f3a5c57",8401:"17896441",8488:"83c47fc7",8561:"a908b4a1",8754:"a9d430b8",8831:"0b1a2cf7",9048:"a94703ab",9050:"0bbf8641",9185:"ea1c9209",9201:"270f5770",9240:"cd2a2605",9269:"f538922c",9524:"e0e11fd7",9632:"539bded7",9647:"5e95c892",9722:"7d578c10",9833:"3ee17669"}[e]||e)+"."+{8:"7502009d",30:"a9f6b7c9",58:"9e48a0b7",124:"1e57fee9",167:"3c700af4",197:"c2068a17",226:"0fbccdb2",307:"fc2c3822",416:"bae3bcc2",827:"2bb5a1c6",849:"06982b68",868:"a63330a2",957:"629a07de",989:"4c0a3184",1145:"8ef66421",1235:"4feb9a40",1246:"e43e8944",1331:"532d7567",1729:"99e8abd1",1843:"c795d64d",2138:"88ea2824",2189:"0387cf76",2237:"515130f8",2343:"86255a73",2558:"71b69121",2634:"419f9356",2779:"1701ed3d",3031:"b5d5e900",3139:"4c155ff4",3224:"31702077",3331:"63193aac",3403:"410cc952",3456:"56391fb3",3467:"33d6f954",3808:"947e834b",3835:"0ea7bda2",4008:"8c9d0c7c",4220:"7eaec880",4292:"1b58df12",4459:"69f771ae",4497:"c49f3512",4588:"901f13e0",4649:"5eaa58f2",4710:"d9edc8ee",4743:"5987bf7d",4759:"104e0a63",4920:"88a0479a",5316:"74d4e05c",5451:"395acef0",5550:"f3a6bc2d",5608:"281c01fa",5677:"efaa131d",5742:"049fb24a",5760:"af7f0fea",5838:"fc7adfd2",6061:"4c605d2d",6212:"77d0a3e2",6221:"f196f8b5",6961:"c8488ea9",6969:"38a40449",7084:"488dce9a",7098:"c0bba837",7339:"c2d91b31",7451:"ac0b36a4",7480:"6829094d",7743:"369c75f3",7852:"06a7d6e1",8145:"f30a24c5",8157:"1dfe2894",8158:"c3cec630",8300:"0e6c4789",8348:"61663f77",8401:"0da2d1a0",8488:"9345189c",8561:"040e6daf",8608:"012e14b4",8754:"b540f6f9",8831:"e666e9f0",8913:"c66354f7",9048:"fe6fafff",9050:"a08e5ca4",9185:"e6ff02c7",9201:"770add1c",9240:"26242442",9269:"54dbb831",9524:"7bd53693",9632:"4c2d785d",9647:"61ddbc70",9722:"6aa576da",9833:"3bbbe17d"}[e]+".js",r.miniCssF=e=>{},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=(e,a)=>Object.prototype.hasOwnProperty.call(e,a),f={},d="university:",r.l=(e,a,c,b)=>{if(f[e])f[e].push(a);else{var t,o;if(void 0!==c)for(var n=document.getElementsByTagName("script"),i=0;i{t.onerror=t.onload=null,clearTimeout(s);var d=f[e];if(delete f[e],t.parentNode&&t.parentNode.removeChild(t),d&&d.forEach((e=>e(c))),a)return a(c)},s=setTimeout(l.bind(null,void 0,{type:"timeout",target:t}),12e4);t.onerror=l.bind(null,t.onerror),t.onload=l.bind(null,t.onload),o&&document.head.appendChild(t)}},r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.p="/",r.gca=function(e){return e={17896441:"8401",21539068:"2189",80247147:"5838",98083335:"1246","87870a77":"8",a0d0303f:"30","36113f10":"58","45d8669e":"124","9194d0c0":"167","7bc57c03":"197",d9579b4e:"226","7e227553":"307","65dda65a":"827","0058b4c6":"849",d0076172:"868",c141421f:"957",e9a6d939:"989",eff8eb88:"1145",a7456010:"1235","5355a5f6":"1331","49cbce88":"1729",d75e79d1:"1843","1a4e3797":"2138",ecb29807:"2343","2a18cecd":"2558",c4f5d8e4:"2634","8c33af2f":"2779","4de008a4":"3031","0b976963":"3139","7165fbd0":"3224","46fdca80":"3331","2424c742":"3403","53f9498a":"3456",ce8af1f0:"3467","1bd21fa2":"3808",a35fff70:"3835","34bb27a8":"4008","704ec7af":"4220","159da944":"4292",a2f35568:"4459","736016fe":"4497","0164bf5c":"4588",c4ad0d80:"4649",f492dbce:"4710","8544f9b4":"4743","974bf4e7":"4759","05749220":"4920",d922b24b:"5316","83c5e61e":"5451",c7c920e6:"5550","72524c0f":"5608","838d8184":"5677",aba21aa0:"5742","9830673e":"5760","1f391b9e":"6061","9003d50b":"6212","05252284":"6221","78fd8131":"6961","14eb3368":"6969","62511cfc":"7084",a7bd4aaa:"7098","683a4745":"7339","093eb245":"7451","05868134":"7480","06c5bd31":"7743",eb35b875:"7852","3c53f774":"8145",a491ca58:"8157",ce87d750:"8300","7f3a5c57":"8348","83c47fc7":"8488",a908b4a1:"8561",a9d430b8:"8754","0b1a2cf7":"8831",a94703ab:"9048","0bbf8641":"9050",ea1c9209:"9185","270f5770":"9201",cd2a2605:"9240",f538922c:"9269",e0e11fd7:"9524","539bded7":"9632","5e95c892":"9647","7d578c10":"9722","3ee17669":"9833"}[e]||e,r.p+r.u(e)},(()=>{var e={5354:0,1869:0};r.f.j=(a,c)=>{var f=r.o(e,a)?e[a]:void 0;if(0!==f)if(f)c.push(f[2]);else if(/^(1869|5354)$/.test(a))e[a]=0;else{var d=new Promise(((c,d)=>f=e[a]=[c,d]));c.push(f[2]=d);var b=r.p+r.u(a),t=new Error;r.l(b,(c=>{if(r.o(e,a)&&(0!==(f=e[a])&&(e[a]=void 0),f)){var d=c&&("load"===c.type?"missing":c.type),b=c&&c.target&&c.target.src;t.message="Loading chunk "+a+" failed.\n("+d+": "+b+")",t.name="ChunkLoadError",t.type=d,t.request=b,f[1](t)}}),"chunk-"+a,a)}},r.O.j=a=>0===e[a];var a=(a,c)=>{var f,d,b=c[0],t=c[1],o=c[2],n=0;if(b.some((a=>0!==e[a]))){for(f in t)r.o(t,f)&&(r.m[f]=t[f]);if(o)var i=o(r)}for(a&&a(c);n{"use strict";var e,a,c,f,d,b={},t={};function r(e){var a=t[e];if(void 0!==a)return a.exports;var c=t[e]={exports:{}};return b[e].call(c.exports,c,c.exports,r),c.exports}r.m=b,e=[],r.O=(a,c,f,d)=>{if(!c){var b=1/0;for(i=0;i=d)&&Object.keys(r.O).every((e=>r.O[e](c[o])))?c.splice(o--,1):(t=!1,d0&&e[i-1][2]>d;i--)e[i]=e[i-1];e[i]=[c,f,d]},r.n=e=>{var a=e&&e.__esModule?()=>e.default:()=>e;return r.d(a,{a:a}),a},c=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,r.t=function(e,f){if(1&f&&(e=this(e)),8&f)return e;if("object"==typeof e&&e){if(4&f&&e.__esModule)return e;if(16&f&&"function"==typeof e.then)return e}var d=Object.create(null);r.r(d);var b={};a=a||[null,c({}),c([]),c(c)];for(var t=2&f&&e;"object"==typeof t&&!~a.indexOf(t);t=c(t))Object.getOwnPropertyNames(t).forEach((a=>b[a]=()=>e[a]));return b.default=()=>e,r.d(d,b),d},r.d=(e,a)=>{for(var c in a)r.o(a,c)&&!r.o(e,c)&&Object.defineProperty(e,c,{enumerable:!0,get:a[c]})},r.f={},r.e=e=>Promise.all(Object.keys(r.f).reduce(((a,c)=>(r.f[c](e,a),a)),[])),r.u=e=>"assets/js/"+({8:"87870a77",30:"a0d0303f",58:"36113f10",124:"45d8669e",167:"9194d0c0",197:"7bc57c03",226:"d9579b4e",307:"7e227553",827:"65dda65a",849:"0058b4c6",868:"d0076172",957:"c141421f",989:"e9a6d939",1145:"eff8eb88",1235:"a7456010",1246:"98083335",1331:"5355a5f6",1729:"49cbce88",1843:"d75e79d1",2138:"1a4e3797",2189:"21539068",2343:"ecb29807",2558:"2a18cecd",2634:"c4f5d8e4",2779:"8c33af2f",3031:"4de008a4",3139:"0b976963",3224:"7165fbd0",3331:"46fdca80",3403:"2424c742",3456:"53f9498a",3467:"ce8af1f0",3808:"1bd21fa2",3835:"a35fff70",4008:"34bb27a8",4220:"704ec7af",4292:"159da944",4459:"a2f35568",4497:"736016fe",4588:"0164bf5c",4649:"c4ad0d80",4710:"f492dbce",4743:"8544f9b4",4759:"974bf4e7",4920:"05749220",5316:"d922b24b",5451:"83c5e61e",5550:"c7c920e6",5608:"72524c0f",5677:"838d8184",5742:"aba21aa0",5760:"9830673e",5838:"80247147",6061:"1f391b9e",6212:"9003d50b",6221:"05252284",6961:"78fd8131",6969:"14eb3368",7084:"62511cfc",7098:"a7bd4aaa",7339:"683a4745",7451:"093eb245",7480:"05868134",7743:"06c5bd31",7852:"eb35b875",8145:"3c53f774",8157:"a491ca58",8300:"ce87d750",8348:"7f3a5c57",8401:"17896441",8488:"83c47fc7",8561:"a908b4a1",8754:"a9d430b8",8831:"0b1a2cf7",9048:"a94703ab",9050:"0bbf8641",9185:"ea1c9209",9201:"270f5770",9240:"cd2a2605",9269:"f538922c",9524:"e0e11fd7",9632:"539bded7",9647:"5e95c892",9722:"7d578c10",9833:"3ee17669"}[e]||e)+"."+{8:"7502009d",30:"a9f6b7c9",58:"9e48a0b7",124:"1e57fee9",167:"3c700af4",197:"c2068a17",226:"0fbccdb2",307:"fc2c3822",416:"bae3bcc2",827:"2bb5a1c6",849:"06982b68",868:"a63330a2",957:"629a07de",989:"4c0a3184",1145:"8ef66421",1235:"4feb9a40",1246:"e43e8944",1331:"532d7567",1729:"99e8abd1",1843:"c795d64d",2138:"88ea2824",2189:"0387cf76",2237:"515130f8",2343:"86255a73",2558:"71b69121",2634:"419f9356",2779:"1701ed3d",3031:"b5d5e900",3139:"4c155ff4",3224:"31702077",3331:"63193aac",3403:"410cc952",3456:"56391fb3",3467:"33d6f954",3808:"947e834b",3835:"0ea7bda2",4008:"8c9d0c7c",4220:"7eaec880",4292:"1b58df12",4459:"69f771ae",4497:"c49f3512",4588:"901f13e0",4649:"5eaa58f2",4710:"d9edc8ee",4743:"5987bf7d",4759:"104e0a63",4920:"88a0479a",5316:"74d4e05c",5451:"395acef0",5550:"f3a6bc2d",5608:"281c01fa",5677:"efaa131d",5742:"049fb24a",5760:"af7f0fea",5838:"fc7adfd2",6061:"4c605d2d",6212:"77d0a3e2",6221:"f196f8b5",6961:"c8488ea9",6969:"38a40449",7084:"488dce9a",7098:"c0bba837",7339:"c2d91b31",7451:"ac0b36a4",7480:"6829094d",7743:"369c75f3",7852:"06a7d6e1",8145:"f30a24c5",8157:"1dfe2894",8158:"c3cec630",8300:"0e6c4789",8348:"61663f77",8401:"0da2d1a0",8488:"9345189c",8561:"040e6daf",8608:"012e14b4",8754:"b540f6f9",8831:"e666e9f0",8913:"c66354f7",9048:"fe6fafff",9050:"a08e5ca4",9185:"e6ff02c7",9201:"770add1c",9240:"26242442",9269:"0a2098c2",9524:"7bd53693",9632:"4c2d785d",9647:"61ddbc70",9722:"6aa576da",9833:"3bbbe17d"}[e]+".js",r.miniCssF=e=>{},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=(e,a)=>Object.prototype.hasOwnProperty.call(e,a),f={},d="university:",r.l=(e,a,c,b)=>{if(f[e])f[e].push(a);else{var t,o;if(void 0!==c)for(var n=document.getElementsByTagName("script"),i=0;i{t.onerror=t.onload=null,clearTimeout(s);var d=f[e];if(delete f[e],t.parentNode&&t.parentNode.removeChild(t),d&&d.forEach((e=>e(c))),a)return a(c)},s=setTimeout(l.bind(null,void 0,{type:"timeout",target:t}),12e4);t.onerror=l.bind(null,t.onerror),t.onload=l.bind(null,t.onload),o&&document.head.appendChild(t)}},r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.p="/",r.gca=function(e){return e={17896441:"8401",21539068:"2189",80247147:"5838",98083335:"1246","87870a77":"8",a0d0303f:"30","36113f10":"58","45d8669e":"124","9194d0c0":"167","7bc57c03":"197",d9579b4e:"226","7e227553":"307","65dda65a":"827","0058b4c6":"849",d0076172:"868",c141421f:"957",e9a6d939:"989",eff8eb88:"1145",a7456010:"1235","5355a5f6":"1331","49cbce88":"1729",d75e79d1:"1843","1a4e3797":"2138",ecb29807:"2343","2a18cecd":"2558",c4f5d8e4:"2634","8c33af2f":"2779","4de008a4":"3031","0b976963":"3139","7165fbd0":"3224","46fdca80":"3331","2424c742":"3403","53f9498a":"3456",ce8af1f0:"3467","1bd21fa2":"3808",a35fff70:"3835","34bb27a8":"4008","704ec7af":"4220","159da944":"4292",a2f35568:"4459","736016fe":"4497","0164bf5c":"4588",c4ad0d80:"4649",f492dbce:"4710","8544f9b4":"4743","974bf4e7":"4759","05749220":"4920",d922b24b:"5316","83c5e61e":"5451",c7c920e6:"5550","72524c0f":"5608","838d8184":"5677",aba21aa0:"5742","9830673e":"5760","1f391b9e":"6061","9003d50b":"6212","05252284":"6221","78fd8131":"6961","14eb3368":"6969","62511cfc":"7084",a7bd4aaa:"7098","683a4745":"7339","093eb245":"7451","05868134":"7480","06c5bd31":"7743",eb35b875:"7852","3c53f774":"8145",a491ca58:"8157",ce87d750:"8300","7f3a5c57":"8348","83c47fc7":"8488",a908b4a1:"8561",a9d430b8:"8754","0b1a2cf7":"8831",a94703ab:"9048","0bbf8641":"9050",ea1c9209:"9185","270f5770":"9201",cd2a2605:"9240",f538922c:"9269",e0e11fd7:"9524","539bded7":"9632","5e95c892":"9647","7d578c10":"9722","3ee17669":"9833"}[e]||e,r.p+r.u(e)},(()=>{var e={5354:0,1869:0};r.f.j=(a,c)=>{var f=r.o(e,a)?e[a]:void 0;if(0!==f)if(f)c.push(f[2]);else if(/^(1869|5354)$/.test(a))e[a]=0;else{var d=new Promise(((c,d)=>f=e[a]=[c,d]));c.push(f[2]=d);var b=r.p+r.u(a),t=new Error;r.l(b,(c=>{if(r.o(e,a)&&(0!==(f=e[a])&&(e[a]=void 0),f)){var d=c&&("load"===c.type?"missing":c.type),b=c&&c.target&&c.target.src;t.message="Loading chunk "+a+" failed.\n("+d+": "+b+")",t.name="ChunkLoadError",t.type=d,t.request=b,f[1](t)}}),"chunk-"+a,a)}},r.O.j=a=>0===e[a];var a=(a,c)=>{var f,d,b=c[0],t=c[1],o=c[2],n=0;if(b.some((a=>0!==e[a]))){for(f in t)r.o(t,f)&&(r.m[f]=t[f]);if(o)var i=o(r)}for(a&&a(c);n