Reads were observed against a real company. They need no --yes and write nothing.
client.Sales.GiftCertificate and client.Sales.CreditNote are DK-specific resources of IDkPlusClient.
| Member | GiftCertificate |
CreditNote |
Notes |
|---|---|---|---|
Query() |
yes | yes | Fluent list; only ModifiedSince and Take apply, any other filter throws NotSupportedException |
GetAsync(number) |
yes | yes | Returns null when there is none |
GetByBarcodeAsync(barcode) |
yes | no | Two certificates with one barcode throw InvalidOperationException naming their record ids; use the number or record id |
GetByRecordIdAsync(recordId) |
yes | yes | |
CountAsync() |
yes | yes | Exact count made with ordinary reads, no row limit |
GetSettingsAsync() |
yes | no | The seven retail settings and the type 9, 8 and 6 payment types (for reference: invoices check payment ids elsewhere) |
using DevOp.DK.Plus;
using DevOp.DK.Plus.Models;
public sealed class GiftCertificateReader(IDkPlusClient dkPlus)
{
public async Task<bool> CanSpendAsync(string number, CancellationToken cancellationToken)
{
var certificate = await dkPlus.Sales.GiftCertificate.GetAsync(number, cancellationToken);
return certificate?.IsRedeemable(DateTimeOffset.UtcNow) == true;
}
public Task<IReadOnlyList<GiftCertificate>> RecentAsync(CancellationToken cancellationToken) =>
dkPlus.Sales.GiftCertificate.Query()
.ModifiedSince(DateTimeOffset.UtcNow.AddDays(-7))
.Take(50)
.ToListAsync(cancellationToken);
public async Task<GiftCertificateSettings> SettingsAsync(CancellationToken cancellationToken) =>
await dkPlus.Sales.GiftCertificate.GetSettingsAsync(cancellationToken);
}
Both models also have RecordId, Number, AliasNumber, Barcode, Amount, ValidFrom, ValidTo, IsValid,
Status, UsedOn, Customer, SalesPerson, SourceInvoicePosted, SourceInvoiceRecordId, SourceInvoiceLine,
and DestinationInvoiceRecordId. ToString() and AsString() return Gift certificate {RecordId} or
Credit note {RecordId}, never the number.
*, =, , or ; throws ArgumentException before any request:* as a pattern and split the value on the others.1899-12-30 in table rows) read as null: a certificate that does not expire has noValidTo, and an unused one has no UsedOn. A reference DK stores as 0 reads as null.null; a present value that cannot be read (an Amount that is not aDkPlusContractException naming the column, never the value.Status (PaperStatus: not defined, inactive, active, used) is unreliable on real data: it was 0 on every row ofIsRedeemable(now) and UsedOn, not Status alone.SourceInvoicePosted, SourceInvoiceRecordId and SourceInvoiceLine as null.devop-dk sales gift-certificate get 1007
devop-dk sales gift-certificate get --barcode 2000123456789 --json
devop-dk sales gift-certificate get --record-id 11
devop-dk sales gift-certificate list --take 50
devop-dk sales gift-certificate list --all --yes --json
devop-dk sales gift-certificate count
devop-dk sales gift-certificate settings --json
devop-dk sales credit-note get 2
devop-dk sales credit-note list -m 2026-10-01
devop-dk sales credit-note count --json
get takes exactly one of the number (the argument), --barcode (gift certificates only), or --record-id.list has --modified-since (-m), --take (1-1000, default 100), --all (needs --yes: it reads every--json.count prints the bare number, or {"count": n} with --json.settings shows the seven settings and, for reference, the payment types of type 9, 8 and 6; --json writes one object. The payment-typesales invoice create checks the payment ids you give against the dkERP payment-mode table instead.Column profiles sales.gift-certificate, sales.gift-certificate.settings and sales.credit-note are configurable like
the other tables, see CLI output.
Get-GiftCertificate GB-1007
Get-GiftCertificate -Barcode 2000123456789
Get-GiftCertificate -RecordId 11
Get-GiftCertificate -Take 50
Get-GiftCertificate -All -ModifiedSince (Get-Date).AddDays(-7)
Get-GiftCertificateCount
Get-GiftCertificateSettings
Get-CreditNote -Number 2
Get-CreditNote -RecordId 41
Get-CreditNoteCount
Get-GiftCertificate and Get-CreditNote have the parameter sets -Number (positional), -RecordId, the paging set
(-ModifiedSince, -Take) and -All; Get-GiftCertificate also has -Barcode. As with the other Get- cmdlets, -All
asks for confirmation because it reads every record. See PowerShell safety.
Next: Redeeming on an invoice.