In this article you will learn how to upload digital receipts to the RetailForce cloud using the FiscalClient (when used without fiscalisation) and get a link to download for your client.
This functionality is available from version 1.2 of the client and provides a corresponding offline capability for the digital receipt.
In order to use this function, the Digital Receipt (full product) licence must be activated in the configuration for the respective client..
Use by means of FiscalClient/FiscalService
When using FiscalClient, the following 2 methods are available for transferring digital receipts:
Method using file name
/// <summary>
/// Uploads digital receipt with digital receipt metadata.
/// </summary>
/// <param name="uniqueClientId">The client id of the client where the digital receipt should be uploaded.</param>
/// <param name="filename">The name of the file to be uploaded. The file must exist and must be readable.</param>
/// <param name="receiptMetaData">The metadata of the file.</param>
/// <returns>A unique url to download the file for the customer.</returns>
/// <exception cref="ArgumentNullException">Thrown if parameter <paramref name="uniqueClientId"/> is set to <see cref="Guid.Empty"/>.</exception>
/// <exception cref="ArgumentNullException">Thrown if parameter <paramref name="filename"/> is null or <see cref="string.Empty"/>.</exception>
/// <exception cref="FileNotFoundException">Thrown if given filename is not found.</exception>
/// <exception cref="UnauthorizedAccessException"><paramref name="filename" /> specified a directory.-or- The caller does not have the required permission. </exception>
/// <exception cref="IOException">An I/O error occurred while opening the file. </exception>
public string UploadDigitalReceipt(Guid uniqueClientId, string filename, ReceiptMetaData receiptMetaData)
This function allows you to upload the digital receipt using a file on the hard disk (file name).
Parameters
- uniqueClientId: the unique Id of the fiscal client.
- filename: the file name (incl. path) of the PDF file to be uploaded.
- receiptMetaData: the metadata for the digital receipt.
Return value: URL for display.
Streaming method
/// <summary>
/// Uploads digital receipt with digital receipt metadata.
/// </summary>
/// <param name="uniqueClientId">The client id of the client where the digital receipt should be uploaded.</param>
/// <param name="file">The stream of the file to be uploaded.</param>
/// <param name="receiptMetaData">The metadata of the file.</param>
/// <returns>A unique url to download the file for the customer.</returns>
/// <exception cref="ArgumentNullException">Thrown if parameter <paramref name="uniqueClientId"/> is set to <see cref="Guid.Empty"/>.</exception>
/// <exception cref="ArgumentNullException">Thrown if parameter <paramref name="file"/> is set to null.</exception>
public string UploadDigitalReceipt(Guid uniqueClientId, Stream file, ReceiptMetaData receiptMetaData)
This function allows you to upload the digital receipt by transferring a filestream (or streams).
Parameters
- uniqueClientId: the unique Id of the fiscal client.
- file: the stream with the content of the PDF file (stream must be at the beginning)
- receiptMetaData: the metadata for the digital receipt
Return value: URL for display.
Usage via nuget implementation
When using the direct implementation of the Fiskaclient (TrustedFiscalModule) with nuget, only one method with FileStream is available:
/// <summary>
/// Uploads digital receipt (if proper license exists).
/// </summary>
/// <param name="receiptMetaData">The metadata for the receipt.</param>
/// <param name="file">The pdf file as stream.</param>
/// <returns>An url to request the file in the cloud.</returns>
/// <remarks>If <paramref name="receiptMetaData"/> is set to null, only bookDate is set to Now, other values are not set.</remarks>
/// <exception cref="ArgumentNullException">Thrown if parameter <paramref name="file"/> is set to null.</exception>
public string UploadDigitalReceipt(Stream file, ReceiptMetaData receiptMetaData)
With this function you can upload the digital receipt by transferring a filestream (or streams).
Parameters
- file: the stream with the content of the PDF file (stream must be at the beginning)
- receiptMetaData: the metadata for the digital receipt
Return value: URL for display.
ReceiptMetaData
The ReceiptMetaData object contains the metadata for the digital receipt, this includes the following data:
- DocumentType: the document type (invoice, receipt, deposit, etc.)
- DocumentGuid: the DocumentGuid of the receipt (not to be confused with the DocumentGuid of the fiscalisation system)
- BookDate: the document date
- Amount: the gross amount of the voucher
- Partner: for a sales document the customer, for other documents the corresponding partner (supplier, customer, ...)
The object description can be found in the Document Object Model documentation. (In the downloads section of the releases).
Comments
0 comments
Please sign in to leave a comment.