For the complete documentation index, see llms.txt. This page is also available as Markdown.

Save a Gift Voucher

Creates one gift voucher in Logic ERP – a prefix and number, a ₹ value, the account it is booked to and, if you like, an expiry date, a barcode, a gift voucher group and the retail customer it was issued to – so that the tills can accept it. The voucher is created as already issued. If a voucher with the same prefix and number already exists, its expiry date and group are updated instead. Use it when gift vouchers are sold or given away from your own system (a website, an app, a corporate order).

Endpoint

Name
Detail

Address

https://your-server/api/SaveGiftVoucher

Method

POST

Authorization

Basic Auth

The response and the messages every endpoint can return are explained in How Every API Call Works.

Request fields

The body is one voucher (a JSON object, not a list). Field names are matched without regard to upper or lower case.

Field
Type
Required
Default
Meaning

Gift_Voucher_Prefix

text

Yes

""

Prefix of the voucher number, for example "GV". Up to 20 characters.

Gift_Voucher_Number

number

Yes

0

The voucher's number within the prefix, for example 10045. 0 is refused. The full voucher number the shopper quotes is the prefix followed by this number, for example GV10045.

Amount

number

Yes

0

Value of the voucher in ₹. Must be more than 0.

Gift_Voucher_AccountCode

text

Yes, unless Gift_Voucher_Account is sent

""

The code, as shown in Logic ERP, of the account the voucher is booked to. It must be a current-assets or current-liabilities account.

Gift_Voucher_Account

text

Only when Gift_Voucher_AccountCode is empty

""

The name of that account, used only when Gift_Voucher_AccountCode is empty. Same account types.

Creation_Branch_Code

number

No (see the rules)

0

Logic ERP's code of the branch that issued the voucher (Branch_Code in Get Branch Info). Must be a branch that exists.

Expiry_Date

date

No

empty

Last day the voucher may be used, yyyy-MM-dd. Today or later. Empty saves the voucher without an expiry date, and the till then does not check expiry.

Gift_Voucher_Barcode

text

No

""

Barcode printed on the voucher. Up to 25 characters. Must not already be used by another voucher.

RCU_Mobile_No

text

No

""

Mobile number of the retail customer the voucher is issued to. The customer must already exist in Logic ERP (see Get Retail Customers); the voucher is linked to that customer's membership number.

Gift_Voucher_Group

text

No

""

Name of the gift voucher group, for example "DIWALI GV". If no group of that name exists, Logic ERP creates it from the four GVG_ fields below.

GVG_ShortName

text

No

the group name

Short name of a new group.

GVG_AccountCode

text

Yes, when the group is new

""

Code, as shown in Logic ERP, of the account of a new group. Current-assets or current-liabilities account.

GVG_Commission_On

text

No

""

How the commission of a new group is worked out: VALUE BASED, PERCENTAGE or PER RUPEE, written exactly so, in capitals. Anything else means no commission.

GVG_Commission_Value

number

No

0

The commission of a new group. With PERCENTAGE, at most 100. Ignored (set to 0) when GVG_Commission_On is not one of the three values.

The four GVG_ fields are used only when Logic ERP creates the group; for a group that already exists they are ignored and the group is not changed.

Rules Logic ERP applies

  • Matching. Account codes, account names and group names are matched without regard to upper or lower case, but otherwise exactly. The mobile number must match the customer's mobile number exactly.

  • A new voucher is created as issued and not yet redeemed, with today's date (on the server) as its creation date. The response gives its number in Logic ERP in LastSavedCode.

  • A voucher that already exists – same Gift_Voucher_Prefix and Gift_Voucher_Number – is updated, not created again. Only these change:

    • the expiry date, when you send one (an empty Expiry_Date keeps the old date);

    • the group – it becomes the group you send (see the known issue below).

    The amount, accounts, barcode, branch and customer of an existing voucher are not changed and not checked, and there is no message saying so. This also happens to a voucher that has already been redeemed. LastSavedCode is the existing voucher's number in Logic ERP.

  • The first five checks (prefix, number, amount, expiry date, and a new group's account and commission) apply to existing vouchers too, so a past Expiry_Date is refused even when you only want to change the group.

  • The branch. Creation_Branch_Code must be a branch that exists in Logic ERP. Leaving it out (0) is normally accepted, because Logic ERP keeps a built-in "no branch" entry with code 0; the voucher is then not linked to any branch. Send the issuing branch.

  • Full voucher numbers must be unique. The full number is the prefix followed by the number, so prefix GV with number 11 and prefix GV1 with number 1 both give GV11; the second is refused with a database error. Use prefixes that do not begin with one another.

  • A new group is created together with the voucher: if saving the voucher fails, the group is not kept either.

  • The customer. When RCU_Mobile_No is sent, the customer is looked up even for an existing voucher, and the request is refused if none is found – but only a new voucher is linked to the customer. If several customers share the mobile number, one of them is used.

  • The voucher is saved in the company your API site is connected to; the branch and financial year of the request play no part.

Known issue – re-sending a voucher without its group removes the group. When the voucher already exists, its group is replaced by the Gift_Voucher_Group you send, and an empty Gift_Voucher_Group leaves the voucher with no group. When you re-send an existing voucher (for example to change its expiry date), always send its Gift_Voucher_Group again.

Known issue – a ' in a text field fails the request. A prefix, account code or name, group name, barcode or mobile number containing an apostrophe (') makes the request fail with a database error. Do not use ' in these fields.

Example request

A new ₹1,000 voucher in a group that does not exist yet:

Test it

Send a request to the Logic ERP sandbox (a test company) from this page: open the block below, enter the sandbox user name and password (ask your Logic ERP support team), change the request if you like, and press Test it. This really saves in the sandbox, so use test values like the example. The example creates (or, when sent again, updates) the sandbox's test voucher APTGV1001.

Save a Gift Voucher

post

Creates one gift voucher in Logic ERP – a prefix and number, a ₹ value, the account it is booked to and, if you like, an expiry date, a barcode, a gift voucher group and the retail customer it was issued to – so that the tills can accept it. The voucher is created as already issued. If a voucher with the same prefix and number already exists, its expiry date and group are updated instead. Use it when gift vouchers are sold or given away from your own system (a website, an app, a corporate order).

Authorizations
AuthorizationstringRequired

The user name and password of your API site.

Body
Gift_Voucher_PrefixstringOptional

Prefix of the voucher number, for example "GV". Up to 20 characters.

Gift_Voucher_NumberintegerOptional

The voucher's number within the prefix, for example 10045. 0 is refused. The full voucher number the shopper quotes is the prefix followed by this number, for example GV10045.

AmountintegerOptional

Value of the voucher in ₹. Must be more than 0.

Gift_Voucher_AccountCodestringOptional

The code, as shown in Logic ERP, of the account the voucher is booked to. It must be a current-assets or current-liabilities account.

Creation_Branch_CodeintegerOptional

Logic ERP's code of the branch that issued the voucher (Branch_Code in Get Branch Info). Must be a branch that exists.

Expiry_DatestringOptional

Last day the voucher may be used, yyyy-MM-dd. Today or later. Empty saves the voucher without an expiry date, and the till then does not check expiry.

Gift_Voucher_BarcodestringOptional

Barcode printed on the voucher. Up to 25 characters. Must not already be used by another voucher.

RCU_Mobile_NostringOptional

Mobile number of the retail customer the voucher is issued to. The customer must already exist in Logic ERP (see Get Retail Customers); the voucher is linked to that customer's membership number.

Gift_Voucher_GroupstringOptional

Name of the gift voucher group, for example "DIWALI GV". If no group of that name exists, Logic ERP creates it from the four GVG_ fields below.

Responses
200

Always HTTP 200. Check Status and Message.

application/json
StatusbooleanOptional

See the Status rules on this page.

MessagestringOptional

Why the call failed, or a note. The reason may be followed by technical detail - read the first line.

LastSavedCodeintegerOptional

See this page.

request_IDstringOptional

Logic ERP request number of this call.

post/SaveGiftVoucher
POST /api/SaveGiftVoucher HTTP/1.1
Host: demo.logicerp.com
Authorization: Basic username:password
Content-Type: application/json
Accept: */*
Content-Length: 251

{
  "Gift_Voucher_Prefix": "APTGV",
  "Gift_Voucher_Number": 1001,
  "Amount": 500,
  "Gift_Voucher_AccountCode": "APITESTGV1",
  "Creation_Branch_Code": 2,
  "Expiry_Date": "2027-03-31",
  "Gift_Voucher_Barcode": "APTGV1001",
  "RCU_Mobile_No": "9000000001",
  "Gift_Voucher_Group": ""
}
{
  "Status": true,
  "Message": "text",
  "LastSavedCode": 1,
  "request_ID": "text"
}

Response

  • Status – true when the voucher was created or updated.

  • Message – Success when saved; otherwise the reason (see below).

  • LastSavedCode – Logic ERP's number of the voucher created or updated. 0 when nothing was saved, except that a failed update of an existing voucher still returns that voucher's number – always check Status first.

  • request_ID – the ID of this request, as described in How Every API Call Works. null when the request was refused before saving began: by one of the checks whose message ends in (local), or by a database error during those checks.

Example response

Messages you may see

Nothing is saved when Status is false.

Message
Meaning
What to do

Gift Voucher Prefix is missing...(local)

Gift_Voucher_Prefix was empty or left out.

Send a prefix.

Gift Voucher Number is not defined...(local)

Gift_Voucher_Number was 0 or left out.

Send the voucher's number.

Invalid Gift Voucher Amount...(local)

Amount was 0, negative or left out.

Send the value in ₹.

Invalid Gift Voucher Expiry Date...(local)

Expiry_Date could not be read as a date.

Send it as yyyy-MM-dd, or leave it empty.

Gift Voucher Expiry Date Cannot be less than Current Date...(local)

Expiry_Date is before today.

Send today or a later date.

Invalid Gift Voucher Group Account Code...(…)(local)

The group is new and GVG_AccountCode (shown in the brackets) is empty or not a current-assets or current-liabilities account.

Send the code of such an account, or the name of an existing group.

Gift Voucher Group Commission Percentage Cannot be more than 100...(local)

The group is new, GVG_Commission_On is PERCENTAGE and GVG_Commission_Value is more than 100.

Send a percentage of 100 or less.

Invalid Gift Voucher Account Code...(local)

Gift_Voucher_AccountCode is not the code of a current-assets or current-liabilities account.

Correct the code.

Gift Voucher Account is not defined...(local)

Both Gift_Voucher_AccountCode and Gift_Voucher_Account were empty.

Send the account code.

Invalid Gift Voucher Account Selected...(local)

No current-assets or current-liabilities account has the name in Gift_Voucher_Account.

Correct the name, or send the code instead.

Same Gift Voucher Barcode Already Exists...(local)

Another voucher already has this barcode.

Send a different barcode.

Invalid Creation Branch Code defined...(local)

No branch has the code in Creation_Branch_Code.

Send a branch code from Get Branch Info.

Unable to found Retail Customer againts Mobile_No. : … (the mobile number you sent)

No retail customer has this mobile number.

Create the customer first, or leave RCU_Mobile_No out.

A database error (with Status: false)

Saving failed – for example the full voucher number is already used by another prefix, a text field contained ' or was too long.

Correct the request and send it again.

Last updated