.
This commit is contained in:
parent
ddf68c32c1
commit
1f5bd18665
@ -1,11 +1,10 @@
|
|||||||
import type { UniqueID } from "@repo/rdx-ddd";
|
import type { UniqueID } from "@repo/rdx-ddd";
|
||||||
import { Result } from "@repo/rdx-utils";
|
import { Result } from "@repo/rdx-utils";
|
||||||
|
|
||||||
import {
|
import { IssuedInvoice } from "../../../domain";
|
||||||
IssuedInvoice,
|
|
||||||
} from "../../../domain";
|
|
||||||
import type { IInvoiceSeriesNumberAssigner } from "../../invoice-series";
|
import type { IInvoiceSeriesNumberAssigner } from "../../invoice-series";
|
||||||
import type { IIssuedInvoiceRepository } from "../repositories";
|
import type { IIssuedInvoiceRepository } from "../repositories";
|
||||||
|
|
||||||
import type { ProformaToIssuedInvoiceCreateProps } from "./proforma-to-issued-invoice-props-converter";
|
import type { ProformaToIssuedInvoiceCreateProps } from "./proforma-to-issued-invoice-props-converter";
|
||||||
|
|
||||||
export interface IIssuedInvoiceCreatorParams {
|
export interface IIssuedInvoiceCreatorParams {
|
||||||
|
|||||||
@ -1,15 +1,18 @@
|
|||||||
import { AggregateRoot, Name, type TextValue, type UniqueID, type UtcDate } from "@repo/rdx-ddd";
|
import {
|
||||||
import { Maybe, Result } from "@repo/rdx-utils";
|
AggregateRoot,
|
||||||
|
type Name,
|
||||||
|
type TextValue,
|
||||||
|
type UniqueID,
|
||||||
|
type UtcDate,
|
||||||
|
} from "@repo/rdx-ddd";
|
||||||
|
import { type Maybe, Result } from "@repo/rdx-utils";
|
||||||
|
|
||||||
import {
|
import { DocumentSeriesInactiveError, DocumentSeriesOutOfValidityError } from "../errors";
|
||||||
DocumentSeriesInactiveError,
|
import type {
|
||||||
DocumentSeriesOutOfValidityError,
|
AssignedDocumentNumber,
|
||||||
} from "../errors";
|
|
||||||
import {
|
|
||||||
type AssignedDocumentNumber,
|
|
||||||
DocumentSeriesCode,
|
DocumentSeriesCode,
|
||||||
DocumentSeriesNumber,
|
DocumentSeriesNumber,
|
||||||
type DocumentType,
|
DocumentType,
|
||||||
} from "../value-objects";
|
} from "../value-objects";
|
||||||
|
|
||||||
export type DocumentSeriesCreateProps = {
|
export type DocumentSeriesCreateProps = {
|
||||||
@ -41,7 +44,9 @@ export class DocumentSeries extends AggregateRoot<DocumentSeriesInternalProps> {
|
|||||||
|
|
||||||
public static create(props: DocumentSeriesCreateProps, id?: UniqueID) {
|
public static create(props: DocumentSeriesCreateProps, id?: UniqueID) {
|
||||||
if (props.padding < 0) {
|
if (props.padding < 0) {
|
||||||
return Result.fail(new Error("Document series padding must be greater than or equal to zero."));
|
return Result.fail(
|
||||||
|
new Error("Document series padding must be greater than or equal to zero.")
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
@ -49,7 +54,9 @@ export class DocumentSeries extends AggregateRoot<DocumentSeriesInternalProps> {
|
|||||||
props.validTo.isSome() &&
|
props.validTo.isSome() &&
|
||||||
props.validFrom.unwrap().isAfter(props.validTo.unwrap())
|
props.validFrom.unwrap().isAfter(props.validTo.unwrap())
|
||||||
) {
|
) {
|
||||||
return Result.fail(new Error("Document series validFrom must be before or equal to validTo."));
|
return Result.fail(
|
||||||
|
new Error("Document series validFrom must be before or equal to validTo.")
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Result.ok(new DocumentSeries(props, id));
|
return Result.ok(new DocumentSeries(props, id));
|
||||||
@ -136,7 +143,9 @@ export class DocumentSeries extends AggregateRoot<DocumentSeriesInternalProps> {
|
|||||||
nextValidTo.isSome() &&
|
nextValidTo.isSome() &&
|
||||||
nextValidFrom.unwrap().isAfter(nextValidTo.unwrap())
|
nextValidFrom.unwrap().isAfter(nextValidTo.unwrap())
|
||||||
) {
|
) {
|
||||||
return Result.fail(new Error("Document series validFrom must be before or equal to validTo."));
|
return Result.fail(
|
||||||
|
new Error("Document series validFrom must be before or equal to validTo.")
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.props.branchId = props.branchId ?? this.props.branchId;
|
this.props.branchId = props.branchId ?? this.props.branchId;
|
||||||
|
|||||||
705
pnpm-lock.yaml
705
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user