2024-09-11 10:41:16 +00:00
|
|
|
import { DocValue } from 'fyo/core/types';
|
2024-09-11 10:38:41 +00:00
|
|
|
import { ValidationMap } from 'fyo/model/types';
|
|
|
|
import { InvoiceItem } from '../InvoiceItem/InvoiceItem';
|
2024-10-08 06:54:48 +00:00
|
|
|
import { validateCouponCode } from 'models/helpers';
|
2024-09-11 10:38:41 +00:00
|
|
|
|
|
|
|
export class AppliedCouponCodes extends InvoiceItem {
|
|
|
|
coupons?: string;
|
|
|
|
|
2024-09-11 10:41:16 +00:00
|
|
|
validations: ValidationMap = {
|
|
|
|
coupons: async (value: DocValue) => {
|
|
|
|
if (!value) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-10-08 06:54:48 +00:00
|
|
|
await validateCouponCode(this as AppliedCouponCodes, value as string);
|
2024-09-11 10:41:16 +00:00
|
|
|
},
|
|
|
|
};
|
2024-09-11 10:38:41 +00:00
|
|
|
}
|