Live verification. Verified live on a test company (2026-11-11) with this release: selling gift certificates (including automatic numbering, required barcodes and expiry), redeeming them with cash change, forfeit and a credit-note change, marking certificates used, activating the change credit note, the recovery commands, and the refusals before any write; every test invoice ended fully settled. Not exercised live: the reference lookup after a failed invoice create, because no create failed.
Values such as C-100, GB-1007, 1314 and 812 are examples. Payment ids are your company's own: list them with
devop-dk sales gift-certificate settings or Get-GiftCertificateSettings. The token comes from devop-dk login or
DKPLUS_API_TOKEN, see CLI setup.
devop-dk sales gift-certificate get GB-1007
devop-dk sales gift-certificate list --take 20
devop-dk sales credit-note get 2 --json
devop-dk sales gift-certificate settings
Get-GiftCertificate GB-1007
Get-GiftCertificate -Take 20
Get-CreditNote -Number 2 | ConvertTo-Json
Get-GiftCertificateSettings
Ordinary create and update commands run directly; only posting needs --yes, and an invoice with gift certificates is always
posted. Every line needs an explicit unit price with tax (-p 800 --prices-include-tax): the client computes the total from
the lines, and there is no option for it.
# Change handed back in cash (exchange payment, type 6)
devop-dk sales invoice create -c C-100 -i ITEM-1 -q 1 -p 800 --prices-include-tax --reference SALE-1007 \
--gift-certificate GB-1007 --gift-certificate-payment-id 1314 \
--change cash --change-payment-id 6 --post --yes
# Change as a new credit note (credit-note payment, type 8)
devop-dk sales invoice create -c C-100 -i ITEM-1 -p 800 --prices-include-tax --reference SALE-1007 \
--gift-certificate GB-1007 --gift-certificate-payment-id 1314 \
--change credit-note --change-payment-id 8 --post --yes
# Spend only 300 kr of a certificate; the rest of its value is forfeited (no change payment).
# invoice.json holds the customer, the reference and lines with unitPrice and pricesIncludeTax: true
devop-dk sales invoice create --file invoice.json --gift-certificate GB-1007=300 \
--gift-certificate-payment-id 1314 --change forfeit --post --yes --json
New-Invoice -Customer C-100 -Line @{ ItemCode = 'ITEM-1'; Quantity = 1; UnitPrice = 800; PricesIncludeTax = $true } `
-Reference SALE-1007 -GiftCertificate GB-1007 -GiftCertificatePaymentId 1314 -Change Cash -ChangePaymentId 6
New-Invoice -Path ./invoice.json -GiftCertificate 'GB-1007=300' -GiftCertificatePaymentId 1314 -Change Forfeit
An invoice.json for the third command looks like this (a UnitPrice and PricesIncludeTax on every line):
{
"customer": { "number": "C-100" },
"reference": "SALE-1007",
"lines": [ { "itemCode": "ITEM-1", "quantity": 1, "unitPrice": 800, "pricesIncludeTax": true } ]
}
-Post:$false is refused with gift certificates. On success the CLI prints the invoice and how many certificates were marked
used (--json: the whole result, where change is the forfeited amount with --change forfeit); PowerShell writes a
GiftCertificateInvoiceResult. When DK Plus creates the invoice with another total than the one computed from your lines,
the command exits with code 1, the certificates are marked used, and a change credit note and sold certificates are held:
correct the invoice in dkERP before you complete them, and do not run the create again.
devop-dk sales invoice create -c C-100 --reference SALE-1008 \
--sell-gift-certificate "item-code=GB;amount=10000;number=1007;barcode=5690000001007" --post --yes
New-Invoice -Customer C-100 -Reference SALE-1008 `
-SellGiftCertificate @{ ItemCode = 'GB'; Amount = 10000; Number = '1007'; Barcode = '5690000001007' }
Sell and redeem together by adding the redemption options to the same command; the invoice's own lines then need explicit prices too.
Without a payment the sale invoice stays an open receivable on the customer. Add the buyer's payment with --payment <payment-type-id>=<amount> (-Payment in PowerShell), and the invoice is created settled in the same request:
devop-dk payment type list
devop-dk sales invoice create -c C-100 --reference SALE-1009 \
--sell-gift-certificate "item-code=GB;amount=500;number=1009" --payment 1=500 --post --yes
Get-PaymentType
New-Invoice -Customer C-100 -Reference SALE-1009 `
-SellGiftCertificate @{ ItemCode = 'GB'; Amount = 500; Number = '1009' } -Payment @{ Id = 1; Amount = 500 }
Here payment type 1 is a cash payment; take the id from payment type list. Only ordinary payment types are accepted: a
gift-certificate or credit-note payment type (9 or 8) is refused before the invoice request. --payment and -Payment need
0.13.1 of the CLI and the module; with 0.13.0, put "payments": [ { "id": 1, "amount": 500 } ] in an invoice file and pass
it with --file. More in Selling: sell and take payment.
devop-dk sales invoice find --reference SALE-1007
Get-Invoice -Reference SALE-1007 -ErrorAction SilentlyContinue
A result means the invoice exists. No result is the best the lookup can tell, not a proof (the index can miss an invoice whose
create failed late). Do not run the create again until you have looked.
stderr (CLI) or the recommended action of the error DkPlus.GiftCertificateInvoice (PowerShell) lists these filled in:
devop-dk sales gift-certificate mark-used --record-id 3 --invoice-record-id 812
devop-dk sales gift-certificate mark-used GB-1007 --invoice-record-id 812
devop-dk sales credit-note activate --record-id 41 --invoice-record-id 812 --invoice-number 10452
devop-dk sales gift-certificate create --number 1007 --amount 10000 \
--source-invoice-record-id 812 --source-invoice-number 10452 --source-invoice-line 1 \
--barcode 5690000001007 --customer C-100
Set-GiftCertificateUsed -RecordId 3 -InvoiceRecordId 812
Enable-CreditNote -RecordId 41 -InvoiceRecordId 812 -InvoiceNumber 10452
New-GiftCertificate -InputObject $error[0].Exception.Pending[0].CreateRequest
These are ordinary updates and creates, so they run without --yes (use -WhatIf in PowerShell to preview). Run the
mark-used commands before activate: it verifies the change from the certificates marked used on the invoice.
sales gift-certificate create options: --number, --amount, --source-invoice-record-id, --source-invoice-number (all
required), and --source-invoice-line, --barcode, --customer, --sales-person, --valid-from and --valid-to
(yyyy-MM-dd; without --valid-to the certificate does not expire). New-GiftCertificate takes the same values as
-Number, -Amount, -SourceInvoiceRecordId, -SourceInvoiceNumber, -SourceInvoiceLine, -Barcode, -Customer,
-SalesPerson, -ValidFrom and -ValidTo, or a GiftCertificateCreateRequest through -InputObject.
A failed --sell-gift-certificate prints the create command with every value of the pending step; <number> and <barcode>
are placeholders, because they are spendable values: take them from the invoice line in dkERP (its text ends with nr. <number>,
its memo holds the barcode) or from the pending step of the --json partial result. An AmountMismatch or Conflict step prints
no command.
The cmdlets are part of the sales cmdlets and the commands part of the
CLI command reference. Go back to the overview.