.
This commit is contained in:
parent
bcfc517a26
commit
7cf1e713c9
@ -10,9 +10,11 @@ import Joi from "joi";
|
|||||||
|
|
||||||
export enum QUOTE_STATUS {
|
export enum QUOTE_STATUS {
|
||||||
DRAFT = "draft",
|
DRAFT = "draft",
|
||||||
EMITTED = "emitted",
|
READY = "ready",
|
||||||
SENT = "sent",
|
DELIVERED = "delivered",
|
||||||
|
ACCEPTED = "accepted",
|
||||||
REJECTED = "rejected",
|
REJECTED = "rejected",
|
||||||
|
ARCHIVED = "archived",
|
||||||
}
|
}
|
||||||
export interface IQuoteStatusOptions extends IValueObjectOptions {}
|
export interface IQuoteStatusOptions extends IValueObjectOptions {}
|
||||||
|
|
||||||
@ -21,7 +23,14 @@ export class QuoteStatus extends ValueObject<string> {
|
|||||||
|
|
||||||
protected static validate(value: string, options: IValueObjectOptions) {
|
protected static validate(value: string, options: IValueObjectOptions) {
|
||||||
const rule = Joi.string()
|
const rule = Joi.string()
|
||||||
.valid(QUOTE_STATUS.DRAFT, QUOTE_STATUS.EMITTED, QUOTE_STATUS.SENT, QUOTE_STATUS.REJECTED)
|
.valid(
|
||||||
|
QUOTE_STATUS.DRAFT,
|
||||||
|
QUOTE_STATUS.READY,
|
||||||
|
QUOTE_STATUS.DELIVERED,
|
||||||
|
QUOTE_STATUS.ACCEPTED,
|
||||||
|
QUOTE_STATUS.REJECTED,
|
||||||
|
QUOTE_STATUS.DRAFT
|
||||||
|
)
|
||||||
.label(options.label ? options.label : "status");
|
.label(options.label ? options.label : "status");
|
||||||
|
|
||||||
return RuleValidator.validate<string>(rule, value);
|
return RuleValidator.validate<string>(rule, value);
|
||||||
@ -35,18 +44,26 @@ export class QuoteStatus extends ValueObject<string> {
|
|||||||
return new QuoteStatus(QUOTE_STATUS.DRAFT);
|
return new QuoteStatus(QUOTE_STATUS.DRAFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static createEmitted(): QuoteStatus {
|
public static createReady(): QuoteStatus {
|
||||||
return new QuoteStatus(QUOTE_STATUS.EMITTED);
|
return new QuoteStatus(QUOTE_STATUS.READY);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static createSent(): QuoteStatus {
|
public static createDelivered(): QuoteStatus {
|
||||||
return new QuoteStatus(QUOTE_STATUS.SENT);
|
return new QuoteStatus(QUOTE_STATUS.DELIVERED);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static createAccepted(): QuoteStatus {
|
||||||
|
return new QuoteStatus(QUOTE_STATUS.ACCEPTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static createRejected(): QuoteStatus {
|
public static createRejected(): QuoteStatus {
|
||||||
return new QuoteStatus(QUOTE_STATUS.REJECTED);
|
return new QuoteStatus(QUOTE_STATUS.REJECTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static createArchived(): QuoteStatus {
|
||||||
|
return new QuoteStatus(QUOTE_STATUS.ARCHIVED);
|
||||||
|
}
|
||||||
|
|
||||||
public static create(status: string, options: IQuoteStatusOptions = {}) {
|
public static create(status: string, options: IQuoteStatusOptions = {}) {
|
||||||
const _options = {
|
const _options = {
|
||||||
label: "status",
|
label: "status",
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user