Syrve POS API SDK

Fiscal Cash Register Custom Functions

Introduction

You can add any operations to the list of fiscal register commands. This may be required, for example, if you need some operations to be carried out before or after the printing of receipts. It can be schematically displayed the following way:

DoCheque

If the plugin needs to take control while printing a payment or refund receipt or during the depositing, withdrawing, and printing X and Z reports, it’s enough to implement the IChequeTaskProcessor interface and register it by invoking the RegisterChequeTaskProcessor() API method:

var chequeTaskProcessor = new ChequeTaskProcessor()
PluginContext.Operations.RegisterChequeTaskProcessor(chequeTaskProcessor);

All IChequeTaskProcessor interface commands can interrupt the main operation: receipt fiscalization, depositing, withdrawing, printing of X and Z reports. For this, you need to throw any type of exception in the command body. For example, we add a condition forbidding virtual receipt printers (FCR) to close orders:

public BeforeDoCheckActionResult BeforeDoCheckAction(ChequeTask chequeTask, ICashRegisterInfo device, CashRegisterChequeExtensions chequeExtensions, IViewManager viewManager)
{
	// Example: allow printing payment and prepayment receipts only on physical devices.
	if (device.IsVirtual)
		throw new Exception("Cash register is virtual. Please close order on real device.");

	PluginContext.Log.InfoFormat("Before printing the receipt: {0} ({1})", device.FriendlyName, device.Id);
	
	...
}

When an order is paid on a virtual FCR, Syrve POS would display an error message and the order remains open:

BeforeDoChequeException

You can find the IChequeTaskProcessor implementation and registration example in SDK SamplePlugin.

Interface IChequeTaskProcessor

Let’s take a closer look at IChequeTaskProcessor commands.

1. BeforeDoCheckAction

BeforeDoCheckAction() - a command executed before the receipt fiscalization. This may be the order closing, refund, guest bill printing, guest bill canceling, and product return. The main purpose of it is to check the operation availability and to add some extra details to a receipt.

How to add extra details to a receipt?

You can do it in two ways:

AddChequeExtensionsSyrveOffice

public BeforeDoCheckActionResult BeforeDoCheckAction(ChequeTask chequeTask, ICashRegisterInfo device, CashRegisterChequeExtensions chequeExtensions, IViewManager viewManager)
{
 var beforeCheque = new List<Data.Print.Document>();
 var documentBefore = new Data.Print.Document();
 documentBefore.Markup.Add(new XElement(Tags.LargeFont, "Welcome"));
 documentBefore.Markup.Add(new XElement(Tags.SmallFont, "tel. 555-123456"));
 beforeCheque.Add(documentBefore);

 var afterCheque = new List<Data.Print.Document>();
 var documentAfter = new Data.Print.Document();
 documentBefore.Markup.Add(new XElement(Tags.SmallFont, "Thank you for shopping"));
 documentBefore.Markup.Add(new XElement(Tags.QRCode, "en.syrve.help"));
 beforeCheque.Add(documentAfter);
	
 return new BeforeDoCheckActionResult
 {
     BeforeCheque = beforeCheque,
     AfterCheque = afterCheque,
     CashierName = "CashierName"
 };
}

Arguments of the BeforeDoCheckAction() function:

2. AfterDoCheckAction

AfterDoCheckAction() — a command executed after the receipt fiscalization operation. The main purpose of it is to perform the final action after the printing of receipts. For example, to queue the operation of export to the external system. The result argument describes an FCR operation result. result.Success = true — operation is successful, otherwise, it is not. If the operation is not successful result.Success = false, the error description will be given in result.Message.

3. BeforeXReport

BeforeXReport() — a command executed before printing an X Report. The following parameters are passed: a fiscal register that performs the operation, IViewManager to display messages or data input, and the authUser user who initiated the printing of the X report.

4. AfterXReport

AfterXReport() — a command executed after printing an X Report. The arguments are similar to the AfterDoCheckAction command.

5. BeforeZReport

BeforeZReport — a command executed before printing a Z Report. Parameters pass the following data: FCR, user, and the IViewManager window manager.

6. AfterPayIn

AfterPayIn — a command executed after depositing money to the cash register. The function receives the following data: FCR, FCR response during the deposit operation, the IViewManager window manager, and the amount of money deposited to the cash register.

7. AfterPayOut

AfterPayOut — a command executed after withdrawing money from the cash register. The function receives the following data: FCR, FCR response during the withdrawal operation, the IViewManager window manager, and the amount of money withdrawn from the cash register.

Additional Interfaces IReadonlyChequeTaskProcessor and IEditableChequeTaskProcessor

Along with the IChequeTaskProcessor interface described above, there are IReadonlyChequeTaskProcessor and IEditableChequeTaskProcessor, extending interfaces which allow completing specific tasks before depositing and withdrawing.

They are registered the same way as the parent interface. The difference between them is only that when using the IReadonlyChequeTaskProcessor interface, the plugin, during the withdrawal, cannot edit the withdrawal amount, whereas the IEditableChequeTaskProcessor — interface can do it through the ref estimatedSum parameter. This is implemented to let the plugin control withdrawal amounts at the end of the day.