File: D:/HostingSpaces/SBogers10/shop.komma.nl/resources/js/components/vue/discounts/models/Discount.js
import AbstractTranslatable from "../../../../global/models/AbstractTranslatable";
import DiscountTranslation from "./DiscountTranslation";
import Condition from "./Condition";
import Action from "./Action";
export default class Discount extends AbstractTranslatable {
/**
* @return {boolean}
*/
get active() {
return this._active;
}
/**
* @param {boolean} value
*/
set active(value) {
if(typeof value !== 'boolean' && typeof value !== 'number') {
this._active = true
} else {
this._active = !!value
}
}
/**
* @return {boolean}
*/
get stop_processing() {
return this._stop_processing;
}
/**
* @param {boolean} value
*/
set stop_processing(value) {
if(typeof value !== 'boolean' && typeof value !== 'number') {
this._stop_processing = false
} else {
this._stop_processing = !!value
}
}
/**
* @return {DiscountTranslation[]}
*/
get translations() {
if(!Array.isArray(this._translations)) this._translations = [];
return this._translations;
}
/**
* @param {DiscountTranslation[]|[{}]} values
*/
set translations(values) {
this._translations = [];
if(typeof values === "undefined") values = []
values.forEach((translation) => {
if(translation instanceof DiscountTranslation) this._translations.push(translation)
else this._translations.push(new DiscountTranslation(translation))
});
}
/**
* @return {DiscountTranslation|{}}
*/
get translation() {
return this._translation;
}
/**
* @param {DiscountTranslation|{}} value
*/
set translation(value) {
if(typeof value === "undefined") this._translation = null
else if(value instanceof DiscountTranslation) this._translation = value;
else this._translation = new DiscountTranslation(value)
}
/**
* @return {Condition[]|[]}
*/
get conditions() {
if(!Array.isArray(this._conditions)) this._conditions = [];
return this._conditions
}
/**
* @param {Condition[]|[{}]} values
*/
set conditions(values) {
this._conditions = [];
if(typeof values === "undefined") values = []
values.forEach((value) => {
if(value instanceof Condition) this._conditions.push(value)
else this._conditions.push(new Condition(value))
});
}
/**
* @return {Action[]|[]}
*/
get actions() {
if(!Array.isArray(this._actions)) this._actions = [];
return this._actions
}
/**
* @param {Action[]|[{}]} values
*/
set actions(values) {
this._actions = [];
if(typeof values === "undefined") values = []
values.forEach((value) => {
if(value instanceof Action) this._actions.push(value)
else this._actions.push(new Action(value))
});
}
}