Processing of Digital Invoices Content

Download as pdf or txt
Download as pdf or txt
You are on page 1of 18

PUBLIC

2017-06-08

Processing of Digital Invoices


Content

1 Processing of Digital Invoices. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3


1.1 Customizing for Digital Invoices. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.2 Signing Electronic Invoices. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Digital Signature Creation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.3 Approval and Cancellation of Digital Invoices. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.4 Printing Digital Invoices. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.5 IDoc Mapping for Digital Invoices. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10
IDoc Mapping for Invoice Approval and Cancellation Requests. . . . . . . . . . . . . . . . . . . . . . . . . . . . .11
IDoc Mapping for Customer Invoices. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14

Processing of Digital Invoices


2 PUBLIC Content
1 Processing of Digital Invoices

Use

In Mexico, the law requires companies to issue electronic invoices and to use XML-based files as a medium for
invoice exchange. This exchange, referred to as Comprobantes Fiscales Digitales por Internet (CFDI), involves a
customer, a vendor, and a local authorized certification provider (Proveedor Autorizado de Certificación, PAC).

Note
As of 2014, companies must use CFDI and the old CFD schema is not supported anymore. For information
about how to migrate to the CFDI schema, see the SAP Note 1933263.

Companies issuing electronic invoices must request the PAC to certify each document. The PAC then assigns a
unique identification number (UUID) for each document on behalf of the tax authority (Servicio de Administración
Tributaria, SAT).

This function enables companies in Mexico to meet legal requirements when they create electronic invoices and
electronic debit or credit memos directly in Financial Accounting (FI). According to the Anexo 20 law in Mexico, all
companies that issue electronic invoices must protect the integrity of these documents by applying a digital
signature.

You can use Mexico-specific functions to sign electronic invoices digitally, for example, credit memos that you
send to your business partners.

Integration

You use digital invoices with for Mexico. In the environment, the system calls the invoice and tax amounts from
the leading ledger to collect data for the digital signature function.

You use the digital signature functions as part of the regular posting process in the Accounts Receivable
component in Financial Accounting. For more information, see .

You use a middleware product that is able to process inbound and outbound IDocs. You use the middleware for
the following purposes:

● To create XML files and send these files to your certified service provider (PAC) and to receive XML files from
this service provider
● To create electronic invoices that you send to your business partners

To print a customer invoice, you require third-party software that generates a graphical image that represents the
Quick Response Code (QR code) as specified in Anexo 20 (page 109). The graphical image is base64 encoded.
How the QR code is interpreted is dependent on your certified service provider (PAC).

Processing of Digital Invoices


Processing of Digital Invoices PUBLIC 3
Prerequisites

● You have completed the settings described in Customizing for Digital Invoices [page 4]. These settings
enable the system to send and receive electronic invoice data.
● You or the operator of your middleware has implemented coding to generate XML files from the electronic
invoice data (IDoc) to create approval requests, cancellation requests, or customer invoices.

Features

In Mexico, some business practices require companies to create accounting documents, for example, customer
invoices, debit memos, and credit memos directly in Financial Accounting. When you create an invoice to send to
your customers, you can protect the integrity of the document using Public Key Cryptography Standards, which
use a private key and a public key. When you save invoices in the system, the system uses standard security
functions with the legally required encryption methods and your private key to sign the documents digitally. You
distribute the corresponding public key to the business partners to whom you want to send digital invoices. Your
business partners use the public key to verify the contents of the documents that you send.

For more information about the digital signature process, see Signing Electronic Invoices [page 5].

To meet legal requirements for creating or cancelling a digital document, you must request approval from the
Mexican authorities. For more information, see Approval and Cancellation of Digital Invoices [page 8].

To comply with legal requirements in Mexico for creating digital invoices, you must map some IDoc types
provided for invoice approval and cancellation requests and for customer invoices. For more information, see IDoc
Mapping for Digital Invoices [page 10].

1.1 Customizing for Digital Invoices

Context

To set up your system to sign invoices digitally, you make the settings described below.

Procedure

1. Make all the settings described in Customizing for . These settings are required to trigger creation of the
digital signature.
2. To determine which invoices you want to sign digitally, make the following settings in Customizing for Cross-
Application Functions under General Application Functions Cross-Application Document Numbering
Mexico Automatic Document Numbering Assign Document Classes to Document Types :

Processing of Digital Invoices


4 PUBLIC Processing of Digital Invoices
○ Specify which accounting document types are relevant for the digital signature process by assigning a
document class to the corresponding accounting document type.
○ For each of the accounting document types that you want to sign digitally, on the Details screen, select
Generate Official Document Number with Date Control in the Official Doc. Number (Official Document
Number) field.
3. To enable the system to sign invoices digitally, activate the application IDMXDI in Customizing for Financial
Accounting under Financial Accounting Global Settings Business Transaction Events .
4. To enable the system to digitally sign invoices for use in Mexico, perform the activities in Customizing for
Cross-Application Components under General Application Components Digital Signature Country-
Specific Settings Mexico Digital Signature Settings .

Note
The section above includes general settings for Mexico, as well as specific settings depending on whether
you want to digitally sign billing documents in Sales and Distribution (SD) or invoices in Financial
Accounting (FI).

5. To send intermediate documents (IDocs) to an external system to generate an XML file, you must set up your
system to send IDocs.

For more information about setting up a system to send IDocs, see IDoc Interface/Electronic Data
Interchange. For more information about approval requests, approval responses, cancellation requests,
cancellation responses, and creation of digital invoices, see IDoc Mapping for Digital Invoices [page 10].
6. To ensure that iDocs are filled in accordance with CFDI catalog values published by SAT, make the settings in
Customizing for Cross-Application Components under General Application Components Digital Signature
Country-Specific Settings Mexico Digital Signature Settings General Settings Settings for iDoc Filling
with CFDI Catalog Data .

1.2 Signing Electronic Invoices

Use

You can use this process to meet legal requirements in Mexico by applying a digital signature to electronic
invoices that you send to your business partners as part of the billing process. For example, in Mexico, if your
customer pays within a specified period of time and is entitled to a discount, you must register the discount by
creating a credit memo in Financial Accounting (FI) and sending it to your customer.

The system signs the data in electronic invoices digitally using the algorithms and encryption standards stipulated
by Mexican law.

You use the encrypted data to generate an IDoc, which is sent to your middleware.

On the basis of the IDoc, the middleware generates an XML file for creating an approval request, a cancellation
request, or an invoice request. The middleware receives responses, which are sent to the SAP system as part of
the legal approval process.

Processing of Digital Invoices


Processing of Digital Invoices PUBLIC 5
Prerequisites

You have made the settings described in Customizing for Digital Invoices [page 4].

Process

1. You create an invoice in the system.


2. When the data in the invoice is complete, you save the invoice.
3. The system determines whether the invoice requires a digital signature, for example, by checking your
Customizing settings for automatic document numbering and whether the company code is specific to
Mexico.
4. The system uses standard security functions to sign the electronic document digitally. For more information,
see Digital Signature Creation [page 6].
This point in time signals the final digital seal on the invoice and the storage of the data required for the digital
signature process as follows:
○ In text fields in the invoice
○ In an IDoc, which is sent to your middleware to create an approval request.
For more information about the data that the system stores in text fields, see Customizing for Cross-
Application Components under General Application Components Digital Signature Country-Specific
Settings Mexico Digital Signature Settings Settings for Documents in Financial Accounting
Determine Text IDs to Store Invoice Data .

Note
When you save an invoice, the system creates an IDoc and sends the IDoc to the target system (for
more information, see Customizing for Digital Invoices [page 4]).

5. You use a middleware product to generate the XML file that you send to your business partners.
In line with the latest requirements stipulated by the Mexican authorities, you add any extra information, for
example, official codes or special tax payer data, to the XML file and then send it to your business partners.
For more information about generating the required XML file, see SAP Note 1943607 .

Note
The system that you use to generate the XML file can be a third-party system.

1.2.1 Digital Signature Creation

Use

This function enables you to encrypt the data in invoices as part of the digital signature process.

Processing of Digital Invoices


6 PUBLIC Processing of Digital Invoices
Features

The system uses a combination of data stored in the invoice and data that it derives from the contents of the
invoice to compile a character string known as the original input message. The system forms the character string
in a specific order, which the Mexican authorities define.

The character string comprises the following data:

Table 1:

Category Description

Document data Official document numbering information, document type,


and payment information

Company code data Your company’s tax number and name

Company address data Your company’s full address

Address data for sales organization The address of your sales organization, if that differs from
your company’s address.

Tax Regime data The type of tax regime your company belongs to

Customer identification data The tax number and name of your customer

Customer’s address The full address of your customer

Sales or goods data Details of the goods or services that you sell

Customs data Details of the customs document that the authorities issue for
foreign trade

Property account data Relates only to lease agreements; for example, if a customer
rents a room in your building, your building has a property ac­
count number.

Supplement ( Complemento ) for goods or services in invoice Additional data about the individual items in an invoice that
some companies are required by law to provide

Tax data The tax type, rate, and amount

Supplement ( Complemento ) for whole invoice Additional data at the header level of an invoice that some
companies are required by law to provide

Addendum ( Addenda ) Additional data that customers can choose to include in their
invoices

Note
According to Mexican law, some of the texts that the system derives must be in Spanish.

Processing of Digital Invoices


Processing of Digital Invoices PUBLIC 7
To crunch the data in a character string to the required number of characters for the subsequent processing
steps, the system applies the SHA1 hash algorithm to the original input message. The result is a character string
that comprises 32 characters. To place a unique fingerprint on the data, the system encrypts the hashed message
by applying your private key to the hashed message. The resulting message digest is 172 characters long.

Since the system generates a character string for the original input message whenever you save an invoice, each
time you save an invoice, the system generates a different original input message and therefore a different digital
signature.

1.3 Approval and Cancellation of Digital Invoices

Use

This function enables you to meet business requirements in Mexico for requesting approval to create a digital
invoice or for cancelling an approved digital invoice.

Features

You use the Monitor Approval Requests report (transaction code CFDI_MONITOR) to monitor the process status
of a digital invoice and to trigger the generation or the cancellation of the digital invoice if this has been approved
by the SAT (Servicio de Administracíon Tributaria).

You use the Cancellation Request report (transaction code CFDI_CANC) to trigger the generation of a cancellation
request.

1.4 Printing Digital Invoices

Use

This function enables you to meet business requirements in Mexico by printing digital invoices.

Although you send digitally signed invoices to your business partners electronically, some companies require you
to send a hard copy of the digital document.

Processing of Digital Invoices


8 PUBLIC Processing of Digital Invoices
Features

You use the standard correspondence functions in Financial Accounting (FI) to print digital invoices. In line with
legal and local business requirements in Mexico, you can enhance the standard correspondence functions to
ensure that the printout contains the following data:

● Original input message


● Signed message digest
To ensure that the system can print all characters in the message digest, the system applies base 64
encoding.
● Standard text This document is a printout of a fiscal invoice in Spanish ( Este documento es una impression
del comprobante fiscal )
● QR code
To ensure that the system can print the QR code, the system must use third-party software to interpret the
base64-encoded value returned by your certified service provider. Note the following:
○ The QR code in the QR code field of the response to the request for approval provided by your certified
service provider must be mapped to the text ID QR in the document header text in the relevant IDoc. For
more information, see IDoc Mapping for Invoice Approval Requests [page 12].
○ The content is saved in the table CFDI_CHAIN_MX with the GUID according to the row in the table
CFDI_RESP_MX (GUID of the QR code (invoice approval)).
○ The QR code contains the following data:
○ Issuer identification tax number
○ Receiver identification tax number
○ Total amount
○ Unique identifier assigned to the invoice by the tax authorities
Up to 95 characters can be used as specified in the following table:

Table 2:

Prefix Data Total No. of


Characters
(Prefix +
Data)

?re= Issuer Identification Tax Number (12-13 characters) 16-17

&rr= Receiver Identification Tax Number (12-13 characters) 16-17

&tt= Total amount (17 characters: 10 characters for the integer part + . + 6 characters 21
for the decimal part)

&id= Unique identifier assigned to the invoice by the tax authorities (36 characters) 40

Example
?re=XAXX010101000&rr=XAXX010101000&tt=1234567890.123456&id=ad662d33-6934-459c-a128-
BDf0393f0f44

○ The QR code must be printed in a box with sides no lower than 2.75 cm.

Processing of Digital Invoices


Processing of Digital Invoices PUBLIC 9
Example

Figure 1: Sample QR Code

Activities

To print a digital invoice, follow the standard procedure for printing correspondence. For more information, see .

1.5 IDoc Mapping for Digital Invoices

The function for creating digital invoices to meet legal requirements in Mexico provides IDoc basic types for the
following:

● Invoice approval and cancellation requests and the responses to these requests
For more information, see IDoc Mapping for Invoice Approval and Cancellation Requests [page 11]
● Customer invoices
For more information, see IDoc Mapping for Customer Invoices [page 14]

Note
The IDoc types introduced below are part of the Comprobantes Fiscales Digitales por Internet (CFDI) solution.
These IDoc types do not support the inclusion of withholding tax data. If you want to add withholding tax data,
you can only do so for billing documents created in Sales and Distribution, by implementing the Business Add-
In (BAdI) method Get Withholding Tax Data of the Line Item (GET_LINE_ITEM_WHT) of the BAdI: SD Data
Determination (IDMX_DI_SDDATA_DET). To access this BAdI, in Customizing for Cross-Application
Components, choose General Application Components Digital Signature Country-Specific Settings
Mexico Digital Signature Settings Business Add-Ins (BAdIs) Digital Invoice Mexico: Data Determination
BAdI: SD Data Determination .

Processing of Digital Invoices


10 PUBLIC Processing of Digital Invoices
1.5.1 IDoc Mapping for Invoice Approval and Cancellation
Requests

Use

The following basic types exist for the invoice approval and approval of invoice cancellation processes:

● Send invoice approval requests and invoice cancellation requests from SAP ERP (IDoc basic type
MXCFDIREQ001).
This basic type contains the data (that is, the original input message) that is required to generate the digital
signature and the data that is required for invoice approval requests (for example, the UUID and timestamp).
● Receive responses in SAP ERP from the authorities (PAC/SAT) (IDoc basic type MXCFDIRESP001)
This basic type contains the data sent by the authorities (for example, the UUID or digital stamp issued by the
government system).

Process

Figure 2: Flow for Invoice Approval and Cancellation Requests and Responses to These Requests

Processing of Digital Invoices


Processing of Digital Invoices PUBLIC 11
Message types are assigned to each IDoc basic type to indicate the contents of the IDoc.

The IDoc basic type MXCFDIREQ001 is assigned the following message types:

● MX_CFDI_APPREQ: Invoice approval requests


● MX_CFDI_CANAPPREQ: Invoice cancellation requests

The IDoc basic type MXCFDIRESP001 is assigned the following message types:

● MX_CFDI_APPROV: Responses to invoice approval requests


● MX_CFDI_CANAPP: Responses to invoice cancellation requests

For more information, see IDoc Mapping for Invoice Approval Requests [page 12] and IDoc Mapping for Invoice
Cancellation Requests [page 13].

1.5.1.1 IDoc Mapping for Invoice Approval Requests

Use

During document posting, the digital signature is generated and the invoice approval request is triggered.

Process

The IDoc that contains the data that is required for generating the digital signature and for requesting approval is
created (IDoc basic type MXCFDIREQ001). Message type MX_CFDI_APPREQ is assigned to the IDoc to indicate
that it contains the invoice approval request. The IDoc is sent to the middleware and is converted into an XML
format. The middleware communicates with the PAC system to obtain the approval from the government system.

A response is sent (in XML format) from the PAC to the middleware. The middleware maps the XML response to
the response IDoc basic type (MXCFDIRESP001). Message type MX_CFDI_APPROV is assigned to this IDoc to
indicate that it contains the response to the invoice approval request.

Processing of Digital Invoices


12 PUBLIC Processing of Digital Invoices
Figure 3: Flow for Invoice Approval Requests

1.5.1.2 IDoc Mapping for Invoice Cancellation Requests

Use

Before you can cancel an invoice that has already been approved, you have to request approval for the
cancellation from the government system.

Process

You trigger the invoice cancellation request using the report CFDI_CANC_REQ_MX (transaction code CFCICANC),
and the IDoc (MXCFDIREQ001) is created to send out the request. The message type MX_CFDI_CANAPPREQ is
assigned to the IDoc to indicate that the IDoc contains the invoice cancellation request.

The response to the invoice cancellation request is sent to SAP ERP via IDoc MXCFDIRESP001 with the message
type MX_CFDI_CANAPP.

Note that you cannot cancel an invoice document in SAP ERP until the response to the invoice cancellation
request has been received.

Processing of Digital Invoices


Processing of Digital Invoices PUBLIC 13
Figure 4: Flow for Invoice Cancellation Requests

1.5.2 IDoc Mapping for Customer Invoices

Use

The IDoc type MXCFDIINV001 contains the information needed to generate the final digital invoice, that is, the
official XML file that is sent to the customer.

The segments used for this IDoc type are the same as used for the IDoc type for the approval request
MXCFDIREQ001, with the following exceptions:

● The IDoc type additionally includes the segment E1EDMXCFDISTAMP, which is also used in the IDoc type
MXCFDIRESP001 to receive the approval data.
● The segment E1EDMXDFDICANC is not included. This segment is not needed to create the final electronic
invoice, since it contains only cancellation data.

Process

You can optionally manually select IDocs in the IDoc monitoring tool to trigger sending of electronic invoices to the
customer system. Alternatively, you can configure the middleware to generate electronic invoices on the basis of
the approval request.

In addition to the data from the approval request, the IDoc MXCFDIINV001 contains the digital signature and
optional addenda (if required by the invoice recipient). Addenda are optional nodes that contain business

Processing of Digital Invoices


14 PUBLIC Processing of Digital Invoices
information and that represent extensions to the standard defined by the tax authorities. Since some PACs reject
addenda to avoid validation errors, such addenda must be added after the stamping (digital signature) process.

The addenda texts are sent in both the approval request and final invoice IDocs in the segment E1EDKT1, field TID
= 'ADD', subsegment E1EDKT2, fields TDLINE + TDLINE + TDLINE.

In the invoice approval request, the segment and ID are omitted from the middleware mapping. In the final invoice,
however, the segment and ID are included in the XML file and are mapped to the corresponding element Addenda.

Figure 5: Customer Invoice (XML File)

Processing of Digital Invoices


Processing of Digital Invoices PUBLIC 15
Important Disclaimers and Legal Information

Coding Samples
Any software coding and/or code lines / strings ("Code") included in this documentation are only examples and are not intended to be used in a productive system
environment. The Code is only intended to better explain and visualize the syntax and phrasing rules of certain coding. SAP does not warrant the correctness and
completeness of the Code given herein, and SAP shall not be liable for errors or damages caused by the usage of the Code, unless damages were caused by SAP
intentionally or by SAP's gross negligence.

Accessibility
The information contained in the SAP documentation represents SAP's current view of accessibility criteria as of the date of publication; it is in no way intended to be a
binding guideline on how to ensure accessibility of software products. SAP in particular disclaims any liability in relation to this document. This disclaimer, however, does
not apply in cases of willful misconduct or gross negligence of SAP. Furthermore, this document does not result in any direct or indirect contractual obligations of SAP.

Gender-Neutral Language
As far as possible, SAP documentation is gender neutral. Depending on the context, the reader is addressed directly with "you", or a gender-neutral noun (such as "sales
person" or "working days") is used. If when referring to members of both sexes, however, the third-person singular cannot be avoided or a gender-neutral noun does not
exist, SAP reserves the right to use the masculine form of the noun and pronoun. This is to ensure that the documentation remains comprehensible.

Internet Hyperlinks
The SAP documentation may contain hyperlinks to the Internet. These hyperlinks are intended to serve as a hint about where to find related information. SAP does not
warrant the availability and correctness of this related information or the ability of this information to serve a particular purpose. SAP shall not be liable for any damages
caused by the use of related information unless damages have been caused by SAP's gross negligence or willful misconduct. All links are categorized for transparency
(see: http://help.sap.com/disclaimer).

Processing of Digital Invoices


16 PUBLIC Important Disclaimers and Legal Information
Processing of Digital Invoices
Important Disclaimers and Legal Information PUBLIC 17
go.sap.com/registration/
contact.html

© 2017 SAP SE or an SAP affiliate company. All rights reserved.


No part of this publication may be reproduced or transmitted in any
form or for any purpose without the express permission of SAP SE
or an SAP affiliate company. The information contained herein may
be changed without prior notice.
Some software products marketed by SAP SE and its distributors
contain proprietary software components of other software
vendors. National product specifications may vary.
These materials are provided by SAP SE or an SAP affiliate company
for informational purposes only, without representation or warranty
of any kind, and SAP or its affiliated companies shall not be liable for
errors or omissions with respect to the materials. The only
warranties for SAP or SAP affiliate company products and services
are those that are set forth in the express warranty statements
accompanying such products and services, if any. Nothing herein
should be construed as constituting an additional warranty.
SAP and other SAP products and services mentioned herein as well
as their respective logos are trademarks or registered trademarks
of SAP SE (or an SAP affiliate company) in Germany and other
countries. All other product and service names mentioned are the
trademarks of their respective companies.
Please see http://www.sap.com/corporate-en/legal/copyright/
index.epx for additional trademark information and notices.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy