Contents
XML description of a cash document for provision to external systems
Purpose
This standard has been developed to enable uniform provision of purchase details to external stakeholder systems such as CCTV monitoring systems, loyalty systems, etc.
General Description
POS systems by the UCS company transmit information about receipts to external systems through a number of interfaces; for RKeeper v7 the main interface is FarCards.
Tags are always uppercase, attributes are always lowercase. Date and time are formatted according to XML Date/Time
Usage Aspects
Orders/Receipts
An XML document generated by the POS system has to include all the order details available for the POS at the moment of generating an order. If there are several receipts in one order, an XML document transmits precisely the details of a particular receipt, otherwise of an order (in this case, the CheckNum attribute is not filled in).
Interfaces
Interface is a program element interacting with the POS system, receiving XML documents and able to provide the payment, discount and bonus functionality.
The list of interfaces for which an XML is prepared (according to the POS) is located in the INTERFACES tag of the EXTINFO tag. Without any interference, the interface has to control the compliance of its type to those indicated in the type attributes of the nested INTERFACE tag. The external identifier of an interface also has to be specified in the interface attribute of the Payment, Discount and Bonus tags if a corresponding operation has been assisted by that interface. It is the interface actually involved in generating an operation that is specified. This is necessary for an external system to control the presence/absence of other system interference in the receipt that is being processed.
To identify the calling side, the INTERFACE tag has the current=Х attribute that takes a value equal to the internal identifier of the interface for which an XML document is being generated. The external value of the interface identifier is located in the interface attribute of the INTERFACE tag. To identify a receipt from an external system (external supply), the reservation attribute of the EXTINFO tag is used (filled in upon generating an XML in RKeeper 6).
Extension
Below is a minimal list of mandatory and recommended tags. It is possible to extend it. For example, the ticketkind attribute is not specified in the description but is present in the example. Presence of such attributes is not guaranteed and should be ignored by the receiving side.
XML Document Description
CHECK
top level tag
attribute |
type |
Mandatory |
description |
---|---|---|---|
stationcode |
String |
+ |
code of the station that generated the document |
restaurantcode |
String |
+ |
code of the restaurant that generated the document |
cashservername |
String |
+ |
network name of the POS server that generated the document |
generateddatetime |
XMLDateTime |
+ |
generation time |
chmode |
Integer |
- |
receipt mode (see below), types 0–10 starting from version 1.4; types 0–4 were supported before version 1.4 |
locale |
Integer |
- |
Client Windows locale, starting from version 2.4, see {+}https://msdn.microsoft.com/en-us/goglobal/bb896001.aspx+ |
shiftdate |
xmldate |
- |
shift date starting from version 2.6 |
shiftnum |
integer |
- |
shift number starting from version 2.6 |
protocolversion |
String |
+/27 |
starting from version 27: the protocol version supported by the FarCards client that generates XMLs |
clientapp |
String |
+/27 |
starting from version 27: the name of the FarCards client app that generates XMLs (RK6, RK7, Shelter, …) |
clientversion |
String |
+/27 |
starting from version 27: the version of the FarCards client app that generates XMLs (RK6, RK7, Shelter, …) |
Acceptable values of the chmode attribute and their description:
Number |
Constant |
Description |
Comment |
---|---|---|---|
0 |
XMLchmodeNotCheck |
not a receipt (a call not connected to a receipt or a technical call — for example, only to obtain a client's name) |
a short XML in GetCardInfo and in Transaction if called through SimpleTransaction (from the script) |
1 |
XMLchmodeSale |
payment (the POS executes the order payment operation) |
in GetCardInfo before the transaction and in Transaction |
2 |
XMLchmodeSaleRollback |
rollback (the POS is unable to complete all stages of payment correctly but before that the interface confirmed a successful transaction) |
in GetCardInfo before the transaction and in Transaction |
3 |
XMLchmodeReturn |
return (receipt return after successful issuing) |
in GetCardInfo before the transaction and in Transaction |
4 |
XMLchmodeReturnRollback |
return rollback (the POS is unable to complete all stages of return correctly but before that the interface confirmed a successful return transaction) |
in GetCardInfo before the transaction and in Transaction |
5 |
XMLchmodeOrderEditing |
order mode (an incomplete order) |
in GetCardInfo (an order may be incomplete) |
6 |
XMLchmodeOrderBill |
pre-bill printing (an order is not completed but is ready for completion) |
in GetCardInfo when editing the layout and in Transaction (in the mode all reciepts/pre-bills in farcards) |
7 |
XMLchmodeOrderCalc |
calculation mode (an order is not completed but is ready for completion) |
in GetCardInfo |
8 |
XMLchmodePrintCardInfo |
card information printing (may be not from an order): in GetCardInfo |
|
9 |
XMLchmodeInitEntranceCardOrder |
creating an order in the 'entry card' |
short XML in GetCardInfo (before an order, to request information to create an order) |
10 |
XMLchmodePrintAfterTransaction |
after transactions to print slips |
short XML in GetCardInfo |
11 |
XMLchmodeServPrint |
service print (incomplete order) |
(can sometimes have discounts with personal information), starting from version 1.5 |
12 |
XMLchmodeCancelBill |
pre-bill cancellation (incomplete order) |
starting from version 2.4 |
13 |
XMLchmodeBeforeReceipt |
before transactions |
starting from version 28 |
Example of a short XML:
<CHECK chmode="0" stationcode="5" restaurantcode="722500001" cashservername="RLSERV" generateddatetime="2012-04-15T21:32:00" locale="1049" shiftdate="xmldate" shiftnum="int" >
<EXTINFO>
<INTERFACES current="12348">
<INTERFACE type="PDS" id="12348" mode="3" interface="8">
<HOLDERS>
<ITEM cardcode="11301867"/>
</HOLDERS>
</INTERFACE>
</INTERFACES>
</EXTINFO>
</CHECK >
EXTINFO
A tag for describing layout purpose: this tag contains tags determining the layout applicability for different systems. If some system is not identified in the list, it is not guaranteed that the document itself will contain any information for it. It is in that system's tag that specific attributes for the target system are transmitted. It is not allowed to add attributes after this tag (as for some system it is generated externally and is based on string substitutions).
Acceptable tags: VIDEO: for CCTV systems
attribute |
type |
Mandatory |
description |
---|---|---|---|
interface |
Integer |
+ |
number of the external system interface in the POS database |
KDS: for KDS/VDU
attribute |
type |
Mandatory |
description |
---|---|---|---|
interface |
Integer |
+ |
number of the external system interface in the POS database |
PDS: for loyalty systems
attribute |
type |
Mandatory |
description |
---|---|---|---|
id |
Integer |
+ |
internal identifier of the external system interface in the database of the POS processing that identifier |
interface |
Integer |
- |
external system interface code in the database of the POS processing that identifier, used for finding internal payments and discounts by interface attributes |
mode |
Integer |
- |
for protocols < 29: 0 — before a card info request 1) , 1 — before a receipt, 2 — after a receipt. For higher versions information is transmitted in specific operations so this attribute is irrelevant. |
PDS → HOLDERS: in RK7, when calling in Transaction, all undeleted cards of this interface from the receipt are transmitted and when calling GetCardInfo, only one current card is transmitted. In version 35 the new tag ALLCARDS is added where all cards of that interface are transmitted on which there is information in the order being processed (not only in the receipt). In RK7 these are cards specified in discounts and payments for this interface. But the card for which a request is in progress (if this is the first request) is not transmitted; this card is specified in the cardcode attribute of the INTERFACE tag; if it is a GetCardInfo call, the Transaction is not filled in. PDS → ALLCARDS → ITEM and PDS → HOLDERS → ITEM: tag for a list element with a card in the cardcode attribute.
When SberSpasibo is integrated, in PDS → HOLDERS RK7 adds the card code extracted from additional information about the payment if the payment has been made by a Sberbank card and the terminal driver has filled in the «PdsCard=» in ExtTransactionInfo. To turn this option on in RK7, By script must not be indicated in the property Pass All Receipts XML Data of the pdsempty.dll interface.
attribute |
type |
Mandatory |
description |
---|---|---|---|
cardcode |
String |
- |
|
EXTDATA
This tag contains information unrelated to the order but related to the context of communication with the external system. Information that is requested from the operator for integration purposes can be transmitted in this tag. Information provided by the customer and entered to the special dialog (for example, an authorization code sent to the customer in a text for two factor authentication) is transmitted in the clientinfoinput attribute starting from 27. The information type in clientinfoinput can be transmitted in the tag attribute which is filled in at the direction of the external system. To request this information, the external system has to return a special XML with the dialog tag, see Coupons are executed through farcards
CHECKDATA
receipt contents
attribute |
type |
Mandatory |
description |
---|---|---|---|
ordernum |
String |
+ |
order number |
orderguid |
String |
- |
order GUID |
guests |
Integer |
number of guests |
|
checknum |
String |
- |
receipt number, at the moment of transmission can be absent; appears only if the receipt is printed |
tablename |
String |
- |
table number, can be absent |
order_cat |
String |
- |
ver 1.5 order category (code), can be absent |
order_type |
String |
- |
ver 1.5 order type (code), can be absent |
startservice |
XMLDate |
+ |
service start time |
closedatetime |
XMLDateTime |
- |
service end time, transmitted only if service is completed |
checkguid |
String |
- |
GUID in the format {XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX} |
printnum |
String |
- |
Print receipt number, starting from version 30 |
extfiscid |
String |
- |
FR serial number, starting from version 30 |
delprintnum |
String |
- |
Print number of the receipt deletion document starting from version 31 |
fiscdocnum |
String |
- |
Fiscal number of the receipt print document starting from version 32 |
delfiscdocnum |
String |
- |
Fiscal number of the receipt deletion document starting from version 32 |
persistentcomment |
String |
- |
savable comment to visit starting from version 34 |
CHECKPERSONS, CHECKLINES, CHECKCATEGS, CHECKDISCOUNTS, CHECKBONUSES CHECKPAYMENTS
tags by receipt string types and their nested tags
сount |
Integer |
+ |
element counter |
|
|
||
attribute |
|
|
|
type |
Mandatory |
|
description |
---|---|---|---|---|---|---|---|
tag: PERSON, element: CHECKPERSONS |
|
|
|
|
|
|
|
id |
|
|
|
String |
+ |
|
Directory object ID 2) |
name |
|
|
|
String |
+ |
|
text: cashier's/waiter's name |
role |
|
|
|
String |
+ |
|
role code |
code |
|
|
|
String |
+ |
|
directory object code |
tag: LINE, element: CHECKLINES |
|
|
|
|
|
|
|
id |
|
|
|
String |
+ |
|
Directory object ID |
uni |
|
|
|
String |
- |
|
line identifier |
parent |
|
|
|
String |
- |
|
link to the parent line identifier |
type |
|
|
|
String |
+ |
|
string type 3) |
name |
|
|
|
String |
+ |
|
text: what is indicated in the receipt4)) |
code |
|
|
|
String |
+ |
|
directory object code |
quantity |
|
|
|
Real |
+ |
|
number of elements in the receipt string |
price |
|
|
|
Real |
+ |
|
price according to the current price list (before discounts and extra charges) |
sum |
|
|
|
Real |
+ |
|
sum after applying discounts/extra charges |
servprint |
|
|
|
String |
- |
|
category name of print service classification5) |
servprint_id |
|
|
|
String |
+ |
|
category ID of print service classification6) |
categ |
|
|
|
String |
- |
|
category name for reports |
categ_id |
|
|
|
String |
+ |
|
ver 2.2 category ID |
tag: DISCOUNTPART, element: DISCOUNTS |
|
|
|
|
|
|
|
id |
|
|
|
String |
+ |
|
|
disclineuni |
|
|
|
Integer |
+ |
|
|
sum |
|
|
|
Real |
+ |
|
|
tag: CATEG, element: CHECKCATEGS |
|
|
|
|
|
|
|
id |
|
|
|
String |
+ |
|
category ID of print service classification |
code |
|
|
|
String |
+ |
|
category code of print service classification |
sum |
|
|
|
Real |
+ |
|
paid amount |
discsum |
|
|
|
Real |
+ |
|
amount of actual discounts in this category |
name |
|
|
|
String |
+ |
|
name |
tag: BONUS, element: BONUSES (ver 1.4) |
|
|
|
|
|
|
|
id |
|
|
|
String |
+ |
|
discount ID |
code |
|
|
|
String |
+ |
|
discount code |
sum |
|
|
|
Real |
+ |
|
calculated bonus amount |
name |
|
|
|
String |
+ |
|
name |
cardcode |
|
|
|
String |
- |
|
card code |
interface |
|
|
|
Integer |
- |
|
interface (logical interface code in RK7) |
uni |
|
|
|
String |
- |
|
line (discount) identifier |
tag: DISCOUNT, element: CHECKDISCOUNTS |
|
|
|
|
|
|
|
id |
|
|
|
String |
+ |
|
discount ID |
code |
|
|
|
String |
+ |
|
discount code |
sum |
|
|
|
Real |
+ |
|
amount of the actually applied discount 7)) |
name |
|
|
|
String |
+ |
|
name |
cardcode |
|
|
|
String |
- |
|
card code |
interface |
|
|
|
Integer |
- |
|
interface (logical interface code in RK7) |
uni |
|
|
|
String |
- |
|
ver 1.4 line identifier in an order |
objectuni |
|
|
|
String |
- |
|
ver 1.4 object line identifier (dish line), can be empty if a discount is appied to the whole receipt (including a dish category) |
tag: PAYMENT, element: CHECKPAYMENTS |
|
|
|
|
|
|
|
code |
|
|
|
String |
+ |
|
currency key |
sum |
|
|
|
Real |
+ |
|
amount paid in this currency 8)) |
bsum |
|
|
|
Real |
- |
|
the sum paid in the base currency, must be equal to the sum in the LINE 9)) |
name |
|
|
|
String |
+ |
|
element name in the string |
interface |
|
|
|
Integer |
- |
|
interface (logical interface code in RK7) |
cardcode |
|
|
|
String |
- |
|
card code |
ownerinfo |
|
|
|
String |
- |
|
authorized guest name |
uni |
|
|
|
String |
- |
|
ver 1.4 line identifier |
exttransactioninfo |
|
|
|
String |
- |
|
ver 1.4 external information on transaction, for example, information from the authorization terminal |
paytype |
|
|
|
Integer |
- |
|
payment type characteristic (1 — cash, 2 — bank cards, 3 — other) |
For non-distributable extra charges in case there is a connection between the discount and the interface please write not only in the string of the dish type but also in CHECKDISCOUNTS
Type Attribute
String types in the receipt contents:
- undefined: discretionary element
- dish: dish string
- combo: combo dish
- modify: modifier
- ticket: ticket
Combo dishes are recorded the following way: a combo container of the modify type that is referenced by the dish type strings.
XML Document Example
<?xml version="1.0" encoding="utf-8"?>
<--
possible variation:
<?xml version="1.0" encoding="IBM866"?>
-->
<CHECK chmode="4" stationcode="5" restaurantcode="722500001" cashservername="RLSERV" generateddatetime="2012-04-15T21:32:00" shiftdate="xmldate" shiftnum="int">
<EXTINFO reservation="49">
<EXTDATA select="12,123" clientinfoinput="123412" tag="AUTHCODE"/>
<INTERFACES current="12348">
<INTERFACE type="PDS" id="12348" mode="3" interface="8" cardcode="11307">
<HOLDERS>
<ITEM cardcode="11307"/>
</HOLDERS>
<ALLCARDS>
<ITEM cardcode="-999999999"/>
<ITEM cardcode="ucs1"/>
<ITEM cardcode="9511234567"/>
</ALLCARDS>
</INTERFACE>
<INTERFACE type="VIDEO" id="1"/>
<INTERFACE type="KDS" posid="132" id="3"/>
</INTERFACES>
</EXTINFO>
<CHECKDATA checknum="102628" guests="2" tablename="1028" startservice="2012-04-15T20:32:00" closedatetime="2012-04-15T21:30:00" ordernum="2944804.1" >
<CHECKPERSONS count="2">
<PERSON role="K" name="B. A. Vdovin" code="1234" />
<PERSON role="W" name="A. A. Vdovina" code="3654" />
</CHECKPERSONS>
<CHECKLINES count="3">
<LINE id="432" type="dish" name="Herring with garnish" code="7644" quantity="2.00" price="23.60" sum="27.20" servprint="bar" categ="bar2" stored="1">
<ATTRS>
<ATTR type_id="{338D933D-B332-3339-8334-33B733B3733B}" type_name="some_type" key_id="{D38D99CD-BBE2-4939-8414-DFB78FB3776B}" key_name="some name" value="424rfwer5" />
<ATTR type_id="{344D9344-4432-3444-4444-33B73443733B}" type_name="other_type" key_id="{228229CD-B222-4229-8224-D2278223226B}" key_name="other name" value="rsdfsdfwer5" />
</ATTRS>
<LINETAXES count="2">
<TAX id="2" char="A" sum="3" />
<TAX id="5" char="B" sum="89" />
</LINETAXES>
</LINE>
<LINE id="433242" type="dish" name="Herring without garnish" code="8644" quantity="2.00" price="23.60" sum="27.20" servprint="bar" categ="bar2" last="1" stored="0">
<LINETAXES count="2">
<TAX id="{4DDEC90E-709B-4962-935D-F36B8FBB5B8D};1800" sum="3" />
<TAX id="{1B38B63A-60D9-4162-BFD6-B765CE7E05D5};1000" sum="89" />
</LINETAXES>
<DISCOUNTS count="2">
<DISCOUNTPART id="{0A021EF0-5ED6-45A4-934E-29C8A779B3C2}" sum="-20.00" disclineuni="21214"/>
</DISCOUNTS>
</LINE>
<LINE id="442" parent_line="433242" type="modify" name="without garnish" code="844" quantity="2.00" price="0" sum="0" servprint="bar" categ="bar2" last="1" stored="0"/>
<LINE id="412" type="ticket" name="Mega Movie" code="84" quantity="1.00" price="23.60" sum="27.20" categ="action" ticketkind="ordinary" stored="0" >
<LINEPROPS custom="values"/>
</LINE>
</CHECKLINES>
<CHECKCATEGS count="2">
<CATEG id="42" code="3" sum="1.17" discsum="0.99" name="FOOD" />
<CATEG id="2" code="3" sum="1.17" discsum="0.99" name="FOOD" />
</CHECKCATEGS>
<CHECKDISCOUNTS count="1">
<DISCOUNT id="4" code="19" sum="-0.18" name="15%" interface="8" cardcode="11301867" account="2312312312" uni="21214"/>
</CHECKDISCOUNTS>
<CHECKBONUSES count="1">
<BONUS id="2" code="12" sum="3" name="2%" interface="9" cardcode="11867" account="2312312312" />
</CHECKBONUSES>
<CHECKPAYMENTS count="2">
<PAYMENT id="32" code="HRCP" paytype="3" sum="0.990" name="HR Coupon" interface="8" cardcode="11301867" account="2312312312" ownerinfo="Roman Mikhailovich Pribytkov" extTransactionInfo="12" />
<PAYMENT id="2" code="RUR" paytype="1" sum="200" name="Rubles" />
</CHECKPAYMENTS>
<CHECKTAXES count="2">
<TAX id="2" char="A" code="12" rate="10.00" sum="3" name="VAT" />
<TAX id="2" char="B" code="12" rate="18.00" sum="10" name="VAT" />
<TAX id="5" char="B" code="02" rate="9.00" sum="89" name="Sales Tax" />
</CHECKTAXES>
</CHECKDATA>
</CHECK>
Getting Current Interface Code
function tSailPlayProcessor.CurrentInterfaceID(XML: IXmlDocument):Integer;
var
interfaces:IXmlNodeList;
i:integer;
begin
Result:=XML.DocumentElement.NeedChild('EXTINFO').NeedChild('INTERFACES').GetIntAttr('current');
interfaces:=XML.DocumentElement.NeedChild('EXTINFO').NeedChild('INTERFACES').SelectNodes('INTERFACE');
for i:=0 to interfaces.Count-1 do
if (interfaces[i].GetIntAttr('id',Result)=Result) or (Result=0) then begin
Result:=interfaces[i].GetIntAttr('interface',Result);
Break;
end;
end;
Checking Added Coupon
function tSailPlayProcessor.GiftExists(XML: IXmlDocument; sku:string):boolean;
var Discount:IXmlNode;
Lines,Discounts:IXmlNodeList;
i,j,CurrentIntf:integer;
begin
CurrentIntf:=CurrentInterfaceID(XML);
Lines:=XML.DocumentElement.NeedChild('CHECKDATA').NeedChild('CHECKLINES').SelectNodes('LINE');
Discounts:=XML.DocumentElement.NeedChild('CHECKDATA').EnsureChild('CHECKDISCOUNTS').SelectNodes('DISCOUNT');
Result:=False;
for i:=0 to Discounts.Count-1 do begin
Discount:=Discounts[i];
if (Discount.GetIntAttr('interface')=CurrentIntf) and (Discount.GetAttr('objectuni')<>'') then
for j:=0 to Lines.Count-1 do begin
if (Lines[j].GetAttr('uni')=Discount.GetAttr('objectuni')) and (Lines[j].GetAttr('code')=sku) then begin
Result:=True;
exit;
end;
end;
end;
end;
Writing-Off a Coupon for Transactions
procedure tSailPlayProcessor.ProcessGifts(XML: IXmlDocument; return: boolean; Connect: ISailPlayLow);
var Discount:IXmlNode;
Lines,Discounts:IXmlNodeList;
i,j,CurrentIntf:integer;
begin
CurrentIntf:=CurrentInterfaceID(XML);
Lines:=XML.DocumentElement.NeedChild('CHECKDATA').NeedChild('CHECKLINES').SelectNodes('LINE');
Discounts:=XML.DocumentElement.NeedChild('CHECKDATA').EnsureChild('CHECKDISCOUNTS').SelectNodes('DISCOUNT');
for i:=0 to Discounts.Count-1 do begin
Discount:=Discounts[i];
if (Discount.GetIntAttr('interface')=CurrentIntf) and (Discount.GetAttr('objectuni')<>'') and
(Discount.GetIntAttr('code')=GiftDiscountCode) then
for j:=0 to Lines.Count-1 do begin
if Lines[j].GetAttr('uni')=Discount.GetAttr('objectuni') then
Connect.GiftTransaction(Discount.GetAttr('cardcode'),
XML.DocumentElement.NeedChild('CHECKDATA').GetAttr('checkguid'),
Lines[j].GetAttr('code'),
return);
end;
end;
end;
[<span style="color: #0000ff"><span style="text-decoration: underline; "><sup>1)</sup></span></span>]
1
[<span style="color: #0000ff"><span style="text-decoration: underline; "><sup>2)</sup></span></span>]
hereinafter: sifr is for RK6, GUID is for RK7
[<span style="color: #0000ff"><span style="text-decoration: underline; "><sup>3)</sup></span></span>]
undefined: discretionary element, dish: dish string, combo: combo dish, modify: modifier, ticket: ticket, excluded: tip, not included in the revenue, zero in the receipt
[<span style="color: #0000ff"><span style="text-decoration: underline; "><sup>4)</sup></span></span>]
4
[<span style="color: #0000ff"><span style="text-decoration: underline; "><sup>5)</sup></span></span>] , [<span style="color: #0000ff"><span style="text-decoration: underline; "><sup>6)</sup></span></span>]
for RK7: 'Classification for aggregate shift report'
[<span style="color: #0000ff"><span style="text-decoration: underline; "><sup>7)</sup></span></span>]
5
[<span style="color: #0000ff"><span style="text-decoration: underline; "><sup>8)</sup></span></span>]
6
[<span style="color: #0000ff"><span style="text-decoration: underline; "><sup>9)</sup></span></span>]
7