Orchardcore receipts

From CrestApps/CrestApps.AgentSkills · View interactive version

Orchardcore receipts is an AI agent skill from the GitHub repository CrestApps/CrestApps.AgentSkills. Skill for the CrestApps Orchard Core Receipts module (CrestApps.OrchardCore.Receipts), the reusable builder of branded, printable proof-of-purchase documents. Covers IReceiptService.BuildAsync with ReceiptRequest, ReceiptDocument, ReceiptLineItem, ReceiptTaxLine and ReceiptStatus (Paid, Pending, Fai

How to use this skill

Skill file

CrestApps Orchard Core Receipts

Receipts turns purchase data a module already holds into a branded, printable document. It stores nothing: the consumer's ledger stays the source of truth and the receipt is built on demand. Transactions (payment receipts and invoices), Orders (invoices and packing slips) and Point of Sale use it.

Related skills: orchardcore-business-documents (the document model, templates, renderers and number series receipts print with), orchardcore-transactions (printable payment requests and receipts, the Send Payment Receipts feature and the Financial.Receipt number series), orchardcore-invoicing (real invoices and credit notes), orchardcore-orders, orchardcore-commerce (store setup step that fills the store details).

Feature

| Feature ID | Name | Depends on |

| --- | --- | --- |

| CrestApps.OrchardCore.Receipts | Receipts | Business Documents (CrestApps.OrchardCore.BusinessDocuments) |

ReceiptsConstants.Feature.Area; settings group receipts (ReceiptsConstants.SettingsGroupId). Subscriptions depends on it. Install CrestApps.OrchardCore.Receipts in the web project; a module that only builds receipts references CrestApps.OrchardCore.Receipts.Abstractions (no commerce dependencies).

{
  "steps": [
    {
      "name": "Feature",
      "enable": [ "CrestApps.OrchardCore.Receipts" ],
      "disable": []
    }
  ]
}

Layers

Building a receipt

using CrestApps.OrchardCore.Receipts;
using CrestApps.OrchardCore.Receipts.Models;
using Microsoft.AspNetCore.Mvc;

namespace Contoso.Registrations.Controllers;

public sealed class RegistrationReceiptController : Controller
{
    private readonly IReceiptService _receiptService;

    public RegistrationReceiptController(IReceiptService receiptService)
    {
        _receiptService = receiptService;
    }

    [HttpGet("registrations/{id}/receipt")]
    public async Task<IActionResult> Receipt(string id)
    {
        // Load your own record and check its owner first.
        var document = await _receiptService.BuildAsync(new ReceiptRequest
        {
            BilledToName = "Ada Lovelace",
            BilledToEmail = "ada@example.test",
            Reference = "REG-1024",
            SourceLabel = "Registration",
            IssuedAt = DateTime.Today,
            Currency = "USD",
            LineItems =
            [
                new ReceiptLineItem { Description = "Season fee", Quantity = 1, UnitAmount = 100m, Amount = 100m },
            ],
            TaxLines =
            [
                new ReceiptTaxLine { Description = "HST", Amount = 13m },
            ],
            TaxAmount = 13m,
            Total = 113m,
            Status = ReceiptStatus.Paid,
            IsTest = false,
        });

        return View(document);
    }
}

BuildAsync returns a ValueTask<ReceiptDocument>: the request merged with the branding (HeaderTitle, BusinessName falling back to the site name, LogoUrl, BusinessAddress, ContactEmail, ContactPhone, Website, FooterText, ShowTestBadge) and a computed Subtotal (Total - TaxAmount). ReceiptStatus is Paid, Pending, Failed or Due (an invoice not yet paid). IsTest comes from the gateway mode (GatewayMode.Testing) and shows the test badge when the setting allows.

Render the shared layout from your own view with a full-path partial (module views compile under ~/Areas/{ModuleId}/Views):

@using CrestApps.OrchardCore.Receipts.Models
@model ReceiptDocument

<partial name="~/Areas/CrestApps.OrchardCore.Receipts/Views/ReceiptDocument.cshtml" model="Model" />

Printing outputs only the receipt; the print stylesheet hides the site header and admin menu. For an email body, resolve IReceiptHtmlRenderer and call await RenderAsync(document): tables with inline styles, safe for mail clients. Resolve both as optional (GetService<IReceiptService>()) when Receipts is not a hard dependency.

Printed as business documents

Receipts are business documents of the Receipt kind (see orchardcore-business-documents). ReceiptBusinessDocumentMapper.Map(receipt) turns a ReceiptDocument into a BusinessDocument: the issuer with its address lines, contact details and website, the Billed to party, the reference (titled with SourceLabel), the date and the ISO Currency code as fields, a Description / Qty / Amount table, the subtotal, tax lines (muted) and the total (Total paid when paid), the notes as a section, the footer, a status badge (Paid success, Failed danger, Due warning, otherwise Pending), and a Test payment watermark for a test payment when the badge is on. Amounts are written with IMoneyFormatter (for example $108.00).

var document = await _receiptService.BuildAsync(request);
var businessDocument = _mapper.Map(document);           // ReceiptBusinessDocumentMapper

await _templates.ApplyAsync(businessDocument);          // IBusinessDocumentTemplateManager
var pdfRenderer = _serviceProvider.GetService<IBusinessDocumentPdfRenderer>();
var pdf = pdfRenderer is null ? null : await pdfRenderer.RenderAsync(businessDocument);

Settings

Settings > Commerce > Receipts, permission ManageReceiptSettings (registered for the receipts group, so a role with only that permission can open it). Stored as ReceiptSettings:

{
  "steps": [
    {
      "name": "Settings",
      "ReceiptSettings": {
        "HeaderTitle": "Payment receipt",
        "BusinessName": "Contoso Club",
        "LogoUrl": "/media/logo.png",
        "BusinessAddress": "100 King Street West, Toronto ON M5X 1C7",
        "ContactEmail": "billing@contoso.example",
        "ContactPhone": "+1 416 555 0100",
        "Website": "https://contoso.example",
        "FooterText": "Thank you for your payment.",
        "ShowTestPaymentBadge": true
      }
    }
  ]
}

Empty HeaderTitle prints Payment receipt. Empty BusinessName, LogoUrl, BusinessAddress, ContactEmail and ContactPhone fall back to the Store Profile (StoreProfileSettings, see orchardcore-commerce; the address on one line as its country writes it), then the site name for the business name. The fallback reads the settings directly, so it works whether or not the Store Profile feature is on. The store setup guide fills these from the store details step.

Consumers

Upgrading from 2.x

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.