UNPKG

@invoicing-sdk/domain

Version:

Core domain logic for the invoicing system including entities, value objects, services, and events

191 lines (102 loc) 10 kB
# @invoicing-sdk/domain ## 0.10.0 ### Minor Changes - [#24](https://github.com/benjamin-kraatz/invoicing-sdk/pull/24) [`3bf1224`](https://github.com/benjamin-kraatz/invoicing-sdk/commit/3bf122496ae04bafb642210a915b35adc7d04af7) Thanks [@copilot-swe-agent](https://github.com/apps/copilot-swe-agent)! - Add Issue Invoice API with backwards compatibility for Create Invoice terminology ### ✨ New Features - **Issue Invoice API**: Added new `IssueInvoice` use case and related types that align with real-world accounting terminology - **Issue Invoice Events**: Added `InvoiceIssuedEvent` for better semantic clarity when invoices are issued to customers - **Backwards Compatibility**: All existing `Create*` APIs remain functional with deprecation warnings ### 🔧 API Changes #### New APIs (Recommended) - `makeIssueInvoice()` / `createIssueInvoiceUseCase()` - `IssueInvoiceCommand` / `IssueInvoiceResult` types - `Invoice.issue()` method for domain objects - `InvoiceIssuedEvent` domain event #### Deprecated APIs (Still Available) - `makeCreateInvoice()` / `createCreateInvoiceUseCase()` - `CreateInvoiceCommand` / `CreateInvoiceResult` types - `Invoice.create()` method - `InvoiceCreatedEvent` domain event ### 🏗️ Field Name Changes | Old Field Name | New Field Name | Context | | -------------- | -------------- | --------------- | | `createdBy` | `issuedBy` | Command objects | | `createdOn` | `issuedOn` | Result objects | ### 📚 Migration See the [migration guide](./docs/migration-guides/create-to-issue-invoice.md) for detailed instructions on updating your code. ### ⚠️ Breaking Changes Timeline - **Current**: Both Create* and Issue* APIs available - **Next Minor**: Create\* APIs deprecated with warnings - **Next Major**: Create\* APIs removed completely ## 0.9.0 ### Minor Changes - [`c909854`](https://github.com/benjamin-kraatz/invoicing-sdk/commit/c909854b672e1291571419d3123c0c9166ff6568) Thanks [@benjamin-kraatz](https://github.com/benjamin-kraatz)! - Deprecate `transitionTo` and add notes on the `create` function. ## 0.8.1 ### Patch Changes - [`82e23bd`](https://github.com/benjamin-kraatz/invoicing-sdk/commit/82e23bd7c071434fb700455c4595d6cbabc8d97e) Thanks [@benjamin-kraatz](https://github.com/benjamin-kraatz)! - streamline publish ## 0.8.0 ### Minor Changes - [#16](https://github.com/benjamin-kraatz/invoicing-sdk/pull/16) [`ed08383`](https://github.com/benjamin-kraatz/invoicing-sdk/commit/ed083839f41fed94678e0467c059bdb54c788c2c) Thanks [@benjamin-kraatz](https://github.com/benjamin-kraatz)! - Fixed a bunch of tests and re-order stuff around - [#16](https://github.com/benjamin-kraatz/invoicing-sdk/pull/16) [`8e00369`](https://github.com/benjamin-kraatz/invoicing-sdk/commit/8e00369e51db0f4d15738247fd144f58dd66a474) Thanks [@benjamin-kraatz](https://github.com/benjamin-kraatz)! - Save the invoice draft to the repository to be able to retrieve it later - [#16](https://github.com/benjamin-kraatz/invoicing-sdk/pull/16) [`e18deaa`](https://github.com/benjamin-kraatz/invoicing-sdk/commit/e18deaabdd3ba2f57d09480698b35866fa2fc391) Thanks [@benjamin-kraatz](https://github.com/benjamin-kraatz)! - Enhance `Invoice` class with status validation and new error handling for invoice drafts ### Patch Changes - [#16](https://github.com/benjamin-kraatz/invoicing-sdk/pull/16) [`b7ce03a`](https://github.com/benjamin-kraatz/invoicing-sdk/commit/b7ce03ae958700c43e7c4431358f26740f06e73f) Thanks [@benjamin-kraatz](https://github.com/benjamin-kraatz)! - Require `pdfBytes` in `transitionTo` when status is FINALIZED - [#16](https://github.com/benjamin-kraatz/invoicing-sdk/pull/16) [`b836a70`](https://github.com/benjamin-kraatz/invoicing-sdk/commit/b836a70e91fde65ccaa3f68ca080fdbbb0be7aea) Thanks [@benjamin-kraatz](https://github.com/benjamin-kraatz)! - Rename `getStatus()` back to a field `status` in InvoiceDraf ## 0.7.0 ### Minor Changes - [#11](https://github.com/benjamin-kraatz/invoicing-sdk/pull/11) [`32ba1f2`](https://github.com/benjamin-kraatz/invoicing-sdk/commit/32ba1f2e985a0123921ee982033b924cc266e4a0) Thanks [@benjamin-kraatz](https://github.com/benjamin-kraatz)! - Application layer's `RequestInvoice` command now correctly creates and returns a draft - [#11](https://github.com/benjamin-kraatz/invoicing-sdk/pull/11) [`030bc93`](https://github.com/benjamin-kraatz/invoicing-sdk/commit/030bc9362e6b2322b04bef900f58dd709f9a947d) Thanks [@benjamin-kraatz](https://github.com/benjamin-kraatz)! - Rename invoice transition errors and add one for status violation - [#11](https://github.com/benjamin-kraatz/invoicing-sdk/pull/11) [`4f76ee3`](https://github.com/benjamin-kraatz/invoicing-sdk/commit/4f76ee338bbd7c58261ba7f0aa80f69884e42bf9) Thanks [@benjamin-kraatz](https://github.com/benjamin-kraatz)! - Set `version` to a constant value of 1 in DomainEvent and all implements - [#11](https://github.com/benjamin-kraatz/invoicing-sdk/pull/11) [`540693a`](https://github.com/benjamin-kraatz/invoicing-sdk/commit/540693a3a1902611c30f89c82beee1c5d545766a) Thanks [@benjamin-kraatz](https://github.com/benjamin-kraatz)! - Update `CreateInvoiceData` type to derive fields from `InvoiceDraft`. It is therefore now an alias, but it improves clarity of purpose in the domain model (plus it now has a `status: InvoiceStatus.DRAFT` field). - [#11](https://github.com/benjamin-kraatz/invoicing-sdk/pull/11) [`5e3d9d8`](https://github.com/benjamin-kraatz/invoicing-sdk/commit/5e3d9d80eccdc168bf188793c0f853a6de2f4409) Thanks [@benjamin-kraatz](https://github.com/benjamin-kraatz)! - Introduce `InvoiceDraft` class for draft invoice management and update invoice creation process - [#11](https://github.com/benjamin-kraatz/invoicing-sdk/pull/11) [`e9f87ce`](https://github.com/benjamin-kraatz/invoicing-sdk/commit/e9f87cef0db21ef32b43f4ad87f3ad0e9ff10857) Thanks [@benjamin-kraatz](https://github.com/benjamin-kraatz)! - Add `status: InvoiceStatus` to the Invoice aggregate and add `transitionTo(status)` to, safely validated, transition an invoice to another state. - [#11](https://github.com/benjamin-kraatz/invoicing-sdk/pull/11) [`57d6d0a`](https://github.com/benjamin-kraatz/invoicing-sdk/commit/57d6d0a74dadf6d967841b94b586984b7c156fca) Thanks [@benjamin-kraatz](https://github.com/benjamin-kraatz)! - Improve use-cases to support the new state transition model and prepare for a future change to the CreateInvoiceCommand type - [#11](https://github.com/benjamin-kraatz/invoicing-sdk/pull/11) [`e93e714`](https://github.com/benjamin-kraatz/invoicing-sdk/commit/e93e71424a5fe04f1cd3ad16ad0fc195d037d899) Thanks [@benjamin-kraatz](https://github.com/benjamin-kraatz)! - Invoice aggregate makes use of the new type alias ### Patch Changes - [#11](https://github.com/benjamin-kraatz/invoicing-sdk/pull/11) [`3d50958`](https://github.com/benjamin-kraatz/invoicing-sdk/commit/3d50958c94a35dc096556014d62ce7a577b11591) Thanks [@benjamin-kraatz](https://github.com/benjamin-kraatz)! - Update `createDraft` method to generate invoice number without reservation ## 0.6.3 ### Patch Changes - Streamline publishing ## 0.6.2 ### Patch Changes - Streamline publishing ## 0.6.1 ### Patch Changes - streamline package release ## 0.6.0 ### Minor Changes - [`2391e19`](https://github.com/benjamin-kraatz/invoicing-sdk/commit/2391e1924b0e44d5942d040f83ee058c15b6b1e5) Thanks [@benjamin-kraatz](https://github.com/benjamin-kraatz)! - Add new `InvoiceRequested` event and serialization utilities to reduce repetition in future implementations. ### Patch Changes - [`049a05a`](https://github.com/benjamin-kraatz/invoicing-sdk/commit/049a05a3c1c95500e558f5e6e0b5fe9be8b247e2) Thanks [@benjamin-kraatz](https://github.com/benjamin-kraatz)! - Rename `createdBy` to `requestedBy` in InvoiceRequested event - [`f322f2a`](https://github.com/benjamin-kraatz/invoicing-sdk/commit/f322f2a00579b9d83fa555405ca124fa5a61e0c8) Thanks [@benjamin-kraatz](https://github.com/benjamin-kraatz)! - Correctly export new `InvoiceRequested` event ## 0.5.0 ### Minor Changes - [`49051ae`](https://github.com/benjamin-kraatz/invoicing-sdk/commit/49051aeda61cfbf1c0881f51f2bf4fac8245b05a) Thanks [@benjamin-kraatz](https://github.com/benjamin-kraatz)! - Add new optional dependency for the `DomainEventPublisher` to the Create Invoice use-case. This allows it to publish all uncommitted events, which was not possible before. Other use-cases might still lack of this feature - it will be implemented in future versions. We also refactored the `AggregateRoot` interface to now live in `entities` instead of `events`. ## 0.4.0 ### Minor Changes - [#3](https://github.com/benjamin-kraatz/invoicing-sdk/pull/3) [`c574ae6`](https://github.com/benjamin-kraatz/invoicing-sdk/commit/c574ae6b4d9c6d58c05f40722a683bf3865d03f5) Thanks [@benjamin-kraatz](https://github.com/benjamin-kraatz)! - Add `InvoiceIdGenerator` interface to let callers decide how internal ids get generated. Provides a fallback to `uuid.v4` ## 0.3.0 ### Minor Changes - Packages are now considered "public beta" ## 0.2.2 ### Patch Changes - Remove `crypto.randomUUID` from Invocie aggregate root and use `uuid`. This keeps the domain package platform-agnostic. ## 0.2.1 ### Patch Changes - Fix READMEs to be a) correct and b) more clear about each package's purpose and design. Add PDF package (unreleased) ## 0.2.0 ### Minor Changes - Prepare release for all packages with latest readmes ## 0.1.4 ### Patch Changes - Enhanced npm publishing configuration for all packages. Added explicit registry configuration, repository metadata, improved files arrays, and prepublishOnly scripts to ensure packages are properly built and tested before publishing. ## 0.1.3 ### Patch Changes - Implement `invoice-sdk` entry package, improve docs ## 0.1.2 ### Patch Changes - Export `ShippingCost` value object ## 0.1.1 ### Patch Changes - Fix dependencies to use workspace versions