Documentation Index
Fetch the complete documentation index at: https://mintlify.com/TI-Sin-Problemas/erpnext_mexico_compliance/llms.txt
Use this file to discover all available pages before exploring further.
CFDI Stamping Settings is a singleton DocType (one record per ERPNext site). It controls all aspects of CFDI stamping, including API credentials for the TI Sin Problemas web service, auto-stamp behavior on document submission, credit balance warnings, and optional email notifications with CFDI attachments.
Because this is a singleton, only one record exists per ERPNext site. Navigate to it via ERPNext Mexico Compliance → CFDI Stamping Settings.
Fields reference
Web Service
These fields configure the connection to the TI Sin Problemas CFDI stamping web service. Theapi_key and api_secret values can be overridden at the site level via site_config.json (using the keys cfdi_api_key, cfdi_api_secret, and cfdi_test_mode). When set in site_config.json, they cannot be changed from the UI.
API Key for the TI Sin Problemas CFDI web service. Pair this with
api_secret to authenticate all stamping requests. When test_mode is enabled, requests are routed to https://cfdi.tisp-staging.com; when disabled, requests go to https://tisinproblemas.com.API Secret for the TI Sin Problemas CFDI web service. Stored encrypted. Combined with
api_key to form the HTTP Basic authentication token (api_key:api_secret).Enable test (staging) mode. While enabled, all stamping requests are sent to
https://cfdi.tisp-staging.com and do not consume production credits or generate legally valid CFDIs. Disable this field before going live in production.Read-only virtual field — its value is computed at runtime by the
is_premium Python property and is never stored in the database. When both api_key and api_secret are configured and the account has an active subscription, this property returns True and unlocks the Premium Features section. The subscription check result is cached in Redis for 12 hours via the module-level get_is_premium() function.Show an orange alert banner when the available CFDI credit balance falls below
low_credits_threshold. The credit check is performed by calling get_available_credits() against the web service.Numeric threshold for the low-credits alert. The warning fires when remaining credits are strictly less than this value. Only visible when
enable_low_credits_warning is checked.Stamp Behavior
Automatically stamp eligible documents (Sales Invoice, Payment Entry) when they are submitted in ERPNext. When enabled, the
default_csds table becomes mandatory so the system knows which Digital Signing Certificate to use for each company.Maps each company to its active Digital Signing Certificate used for automatic stamping. Each row contains a
company (Link → Company) and a csd (Link → Digital Signing Certificate). This table is only visible and required when stamp_on_submit is enabled.| Column | Type | Required | Description |
|---|---|---|---|
company | Link → Company | ✓ | The ERPNext Company for which this CSD applies |
csd | Link → Digital Signing Certificate | ✓ | The active CSD record to use when stamping documents for this company |
Premium Features
Fields in this section depend on
is_premium evaluating to True. They are visible in the form but have no effect on non-premium accounts.Custom Jinja/HTML PDF templates to use instead of the default layout when generating the CFDI PDF attachment. Each row specifies a
company and document_type (e.g., Sales Invoice, Payment Entry). Duplicate combinations of company + document type are rejected on save. Only visible when is_premium is True.When enabled, an email carrying the stamped CFDI XML and PDF as attachments is sent automatically after each successful stamp operation. Only visible when
is_premium is True.Determines which contact receives the post-stamp email. Only visible when both
This field is mandatory when
send_email_on_stamp and is_premium are set. Valid options:| Value | Behavior |
|---|---|
All Billing Contacts | Sends the email to every contact on the customer record that has the Billing contact type |
Document Contact | Sends the email only to the contact explicitly linked on the Sales Invoice or Payment Entry |
send_email_on_stamp is enabled.Frappe Email Template to use per document type. Each row links a
document_type to an email_template (Link → Email Template). When send_email_on_stamp is enabled and is_premium is True, this table is mandatory. The template is rendered with the full document as context (subject and HTML body).Permissions
| Role | Read | Write | Create | Delete |
|---|---|---|---|---|
| System Manager | ✓ | ✓ | ✓ | ✓ |
Whitelisted methods
The following method is exposed viafrappe.call and can be invoked from the browser or through the Frappe REST API.
get_available_credits()
Returns the number of available stamping credits from the TI Sin Problemas subscription endpoint.
int — the number of available credits reported by the web service.
Internal methods
The following methods exist on theCFDIStampingSettings document but are not exposed as whitelisted endpoints. They are used internally by the stamping and email pipeline.
check_low_credits()
Fetches the current credit balance via get_available_credits() and displays an orange alert if the balance is below low_credits_threshold. No return value; the alert is shown in-app via frappe.msgprint.
can_send_emails(doctype)
Returns True if all conditions for sending a post-stamp email are met for the given document type: the account is premium, send_email_on_stamp is checked, send_email_to is set, and the doctype has a configured entry in email_templates.
| Parameter | Type | Description |
|---|---|---|
doctype | "Payment Entry" | "Sales Invoice" | The document type to check |
bool
get_email_template(doctype, doc)
Renders the configured Frappe Email Template for the given document type using doc as the Jinja context. Raises StopIteration if no template is configured for the doctype.
| Parameter | Type | Description |
|---|---|---|
doctype | "Payment Entry" | "Sales Invoice" | The document type whose template should be rendered |
doc | dict | The document as a dictionary, used as Jinja template context |
dict with keys subject (str) and message (str HTML).
Site config overrides
API credentials and test mode can be locked to values set by the site administrator insite_config.json. When a site-config value is present, the UI field is overwritten on every before_validate hook and a notice is shown to inform users that only the site admin can change it.