diff --git a/Admin/Install/db.json b/Admin/Install/db.json index 3c7b4d4..8d9c42e 100755 --- a/Admin/Install/db.json +++ b/Admin/Install/db.json @@ -31,8 +31,8 @@ "foreignTable": "calendar", "foreignKey": "calendar_id" }, - "projectmanagement_project_costs": { - "name": "projectmanagement_project_costs", + "projectmanagement_project_actualcosts": { + "name": "projectmanagement_project_actualcosts", "type": "INT", "null": false }, @@ -46,8 +46,8 @@ "type": "INT", "null": false }, - "projectmanagement_project_earnings": { - "name": "projectmanagement_project_earnings", + "projectmanagement_project_actualearnings": { + "name": "projectmanagement_project_actualearnings", "type": "INT", "null": false }, @@ -141,5 +141,197 @@ "foreignKey": "projectmanagement_project_id" } } + }, + "projectmanagement_project_attr_type": { + "name": "projectmanagement_project_attr_type", + "fields": { + "projectmanagement_project_attr_type_id": { + "name": "projectmanagement_project_attr_type_id", + "type": "INT", + "null": false, + "primary": true, + "autoincrement": true + }, + "projectmanagement_project_attr_type_name": { + "name": "projectmanagement_project_attr_type_name", + "type": "VARCHAR(255)", + "null": false + }, + "projectmanagement_project_attr_type_fields": { + "name": "projectmanagement_project_attr_type_fields", + "type": "INT(11)", + "null": false + }, + "projectmanagement_project_attr_type_custom": { + "name": "projectmanagement_project_attr_type_custom", + "type": "TINYINT(1)", + "null": false + }, + "projectmanagement_project_attr_type_required": { + "description": "Every project must have this attribute type if set to true.", + "name": "projectmanagement_project_attr_type_required", + "type": "TINYINT(1)", + "null": false + }, + "projectmanagement_project_attr_type_pattern": { + "description": "This is a regex validation pattern.", + "name": "projectmanagement_project_attr_type_pattern", + "type": "VARCHAR(255)", + "null": false + } + } + }, + "projectmanagement_project_attr_type_l11n": { + "name": "projectmanagement_project_attr_type_l11n", + "fields": { + "projectmanagement_project_attr_type_l11n_id": { + "name": "projectmanagement_project_attr_type_l11n_id", + "type": "INT", + "null": false, + "primary": true, + "autoincrement": true + }, + "projectmanagement_project_attr_type_l11n_title": { + "name": "projectmanagement_project_attr_type_l11n_title", + "type": "VARCHAR(255)", + "null": false + }, + "projectmanagement_project_attr_type_l11n_type": { + "name": "projectmanagement_project_attr_type_l11n_type", + "type": "INT(11)", + "null": false, + "foreignTable": "projectmanagement_project_attr_type", + "foreignKey": "projectmanagement_project_attr_type_id" + }, + "projectmanagement_project_attr_type_l11n_lang": { + "name": "projectmanagement_project_attr_type_l11n_lang", + "type": "VARCHAR(2)", + "null": false, + "foreignTable": "language", + "foreignKey": "language_639_1" + } + } + }, + "projectmanagement_project_attr_value": { + "name": "projectmanagement_project_attr_value", + "fields": { + "projectmanagement_project_attr_value_id": { + "name": "projectmanagement_project_attr_value_id", + "type": "INT", + "null": false, + "primary": true, + "autoincrement": true + }, + "projectmanagement_project_attr_value_default": { + "name": "projectmanagement_project_attr_value_default", + "type": "TINYINT(1)", + "null": false + }, + "projectmanagement_project_attr_value_type": { + "name": "projectmanagement_project_attr_value_type", + "type": "INT(11)", + "null": false + }, + "projectmanagement_project_attr_value_valueStr": { + "name": "projectmanagement_project_attr_value_valueStr", + "type": "VARCHAR(255)", + "null": true, + "default": null + }, + "projectmanagement_project_attr_value_valueInt": { + "name": "projectmanagement_project_attr_value_valueInt", + "type": "INT(11)", + "null": true, + "default": null + }, + "projectmanagement_project_attr_value_valueDec": { + "name": "projectmanagement_project_attr_value_valueDec", + "type": "DECIMAL(19,5)", + "null": true, + "default": null + }, + "projectmanagement_project_attr_value_valueDat": { + "name": "projectmanagement_project_attr_value_valueDat", + "type": "DATETIME", + "null": true, + "default": null + }, + "projectmanagement_project_attr_value_lang": { + "name": "projectmanagement_project_attr_value_lang", + "type": "VARCHAR(2)", + "null": true, + "default": null, + "foreignTable": "language", + "foreignKey": "language_639_1" + }, + "projectmanagement_project_attr_value_country": { + "name": "projectmanagement_project_attr_value_country", + "type": "VARCHAR(2)", + "null": true, + "default": null, + "foreignTable": "country", + "foreignKey": "country_code2" + } + } + }, + "projectmanagement_project_attr_default": { + "name": "projectmanagement_project_attr_default", + "fields": { + "projectmanagement_project_attr_default_id": { + "name": "projectmanagement_project_attr_default_id", + "type": "INT", + "null": false, + "primary": true, + "autoincrement": true + }, + "projectmanagement_project_attr_default_type": { + "name": "projectmanagement_project_attr_default_type", + "type": "INT(11)", + "null": false, + "foreignTable": "projectmanagement_project_attr_type", + "foreignKey": "projectmanagement_project_attr_type_id" + }, + "projectmanagement_project_attr_default_value": { + "name": "projectmanagement_project_attr_default_value", + "type": "INT(11)", + "null": false, + "foreignTable": "projectmanagement_project_attr_value", + "foreignKey": "projectmanagement_project_attr_value_id" + } + } + }, + "projectmanagement_project_attr": { + "name": "projectmanagement_project_attr", + "fields": { + "projectmanagement_project_attr_id": { + "name": "projectmanagement_project_attr_id", + "type": "INT", + "null": false, + "primary": true, + "autoincrement": true + }, + "projectmanagement_project_attr_project": { + "name": "projectmanagement_project_attr_project", + "type": "INT(11)", + "null": false, + "foreignTable": "projectmanagement_project", + "foreignKey": "projectmanagement_project_id" + }, + "projectmanagement_project_attr_type": { + "name": "projectmanagement_project_attr_type", + "type": "INT(11)", + "null": false, + "foreignTable": "projectmanagement_project_attr_type", + "foreignKey": "projectmanagement_project_attr_type_id" + }, + "projectmanagement_project_attr_value": { + "name": "projectmanagement_project_attr_value", + "type": "INT(11)", + "null": true, + "default": null, + "foreignTable": "projectmanagement_project_attr_value", + "foreignKey": "projectmanagement_project_attr_value_id" + } + } } } \ No newline at end of file diff --git a/Models/AttributeValueType.php b/Models/AttributeValueType.php new file mode 100644 index 0000000..eae62dc --- /dev/null +++ b/Models/AttributeValueType.php @@ -0,0 +1,36 @@ +id = $id; + } +} diff --git a/Models/NullProjectAttributeType.php b/Models/NullProjectAttributeType.php new file mode 100644 index 0000000..9aaaa6b --- /dev/null +++ b/Models/NullProjectAttributeType.php @@ -0,0 +1,38 @@ +id = $id; + } +} diff --git a/Models/NullProjectAttributeTypeL11n.php b/Models/NullProjectAttributeTypeL11n.php new file mode 100644 index 0000000..2755d39 --- /dev/null +++ b/Models/NullProjectAttributeTypeL11n.php @@ -0,0 +1,38 @@ +id = $id; + } +} diff --git a/Models/NullProjectAttributeValue.php b/Models/NullProjectAttributeValue.php new file mode 100644 index 0000000..dfb83b0 --- /dev/null +++ b/Models/NullProjectAttributeValue.php @@ -0,0 +1,38 @@ +id = $id; + } +} diff --git a/Models/Project.php b/Models/Project.php index 975c721..1e2cc55 100755 --- a/Models/Project.php +++ b/Models/Project.php @@ -95,14 +95,6 @@ class Project */ public Calendar $calendar; - /** - * Current total costs. - * - * @var Money - * @since 1.0.0 - */ - public Money $costs; - /** * Budget costs. * @@ -119,13 +111,21 @@ class Project */ public Money $budgetEarnings; + /** + * Current total costs. + * + * @var Money + * @since 1.0.0 + */ + public Money $actualCosts; + /** * Current total earnings. * * @var Money * @since 1.0.0 */ - public Money $earnings; + public Money $actualEarnings; /** * Progress percentage. @@ -175,6 +175,14 @@ class Project */ private $tasks = []; + /** + * Attributes. + * + * @var int[]|ProjectAttribute[] + * @since 1.0.0 + */ + private array $attributes = []; + /** * Constructor. * @@ -194,10 +202,10 @@ class Project $this->calendar = new Calendar(); - $this->costs = new Money(); + $this->actualCosts = new Money(); + $this->actualEarnings = new Money(); $this->budgetCosts = new Money(); $this->budgetEarnings = new Money(); - $this->earnings = new Money(); $this->setName($name); } @@ -373,6 +381,32 @@ class Project $this->calendar->name = $name; } + /** + * Add attribute to item + * + * @param ProjectAttribute $attribute Note + * + * @return void + * + * @since 1.0.0 + */ + public function addAttribute(ProjectAttribute $attribute) : void + { + $this->attributes[] = $attribute; + } + + /** + * Get attributes + * + * @return int[]|ProjectAttribute[] + * + * @since 1.0.0 + */ + public function getAttributes() : array + { + return $this->attributes; + } + /** * {@inheritdoc} */ @@ -385,10 +419,10 @@ class Project 'name' => $this->name, 'description' => $this->description, 'calendar' => $this->calendar, - 'costs' => $this->costs, 'budgetCosts' => $this->budgetCosts, 'budgetEarnings' => $this->budgetEarnings, - 'earnings' => $this->earnings, + 'actualCosts' => $this->actualCosts, + 'actualEarnings' => $this->actualEarnings, 'tasks' => $this->tasks, 'media' => $this->media, 'progress' => $this->progress, diff --git a/Models/ProjectAttribute.php b/Models/ProjectAttribute.php new file mode 100644 index 0000000..8a8b431 --- /dev/null +++ b/Models/ProjectAttribute.php @@ -0,0 +1,104 @@ +type = new NullProjectAttributeType(); + $this->value = new NullProjectAttributeValue(); + } + + /** + * Get id + * + * @return int + * + * @since 1.0.0 + */ + public function getId() : int + { + return $this->id; + } + + /** + * {@inheritdoc} + */ + public function toArray() : array + { + return [ + 'id' => $this->id, + 'item' => $this->item, + 'type' => $this->type, + 'value' => $this->value, + ]; + } + + /** + * {@inheritdoc} + */ + public function jsonSerialize() + { + return $this->toArray(); + } +} diff --git a/Models/ProjectAttributeMapper.php b/Models/ProjectAttributeMapper.php new file mode 100644 index 0000000..23b57df --- /dev/null +++ b/Models/ProjectAttributeMapper.php @@ -0,0 +1,74 @@ + + * @since 1.0.0 + */ + protected static array $columns = [ + 'projectmanagement_project_attr_id' => ['name' => 'projectmanagement_project_attr_id', 'type' => 'int', 'internal' => 'id'], + 'projectmanagement_project_attr_project' => ['name' => 'projectmanagement_project_attr_project', 'type' => 'int', 'internal' => 'project'], + 'projectmanagement_project_attr_type' => ['name' => 'projectmanagement_project_attr_type', 'type' => 'int', 'internal' => 'type'], + 'projectmanagement_project_attr_value' => ['name' => 'projectmanagement_project_attr_value', 'type' => 'int', 'internal' => 'value'], + ]; + + /** + * Has one relation. + * + * @var array + * @since 1.0.0 + */ + protected static array $ownsOne = [ + 'type' => [ + 'mapper' => ProjectAttributeTypeMapper::class, + 'external' => 'projectmanagement_project_attr_type', + ], + 'value' => [ + 'mapper' => ProjectAttributeValueMapper::class, + 'external' => 'projectmanagement_project_attr_value', + ], + ]; + + /** + * Primary table. + * + * @var string + * @since 1.0.0 + */ + protected static string $table = 'projectmanagement_project_attr'; + + /** + * Primary field name. + * + * @var string + * @since 1.0.0 + */ + protected static string $primaryField = 'projectmanagement_project_attr_id'; +} diff --git a/Models/ProjectAttributeType.php b/Models/ProjectAttributeType.php new file mode 100644 index 0000000..7613e31 --- /dev/null +++ b/Models/ProjectAttributeType.php @@ -0,0 +1,172 @@ +setL11n($name); + } + + /** + * Get id + * + * @return int + * + * @since 1.0.0 + */ + public function getId() : int + { + return $this->id; + } + + /** + * Set l11n + * + * @param string|ProjectAttributeTypeL11n $l11n Tag article l11n + * @param string $lang Language + * + * @return void + * + * @since 1.0.0 + */ + public function setL11n(string | ProjectAttributeTypeL11n $l11n, string $lang = ISO639x1Enum::_EN) : void + { + if ($l11n instanceof ProjectAttributeTypeL11n) { + $this->l11n = $l11n; + } elseif (isset($this->l11n) && $this->l11n instanceof ProjectAttributeTypeL11n) { + $this->l11n->title = $l11n; + } else { + $this->l11n = new ProjectAttributeTypeL11n(); + $this->l11n->title = $l11n; + $this->l11n->setLanguage($lang); + } + } + + /** + * @return string + * + * @since 1.0.0 + */ + public function getL11n() : string + { + return $this->l11n instanceof ProjectAttributeTypeL11n ? $this->l11n->title : $this->l11n; + } + + /** + * Set fields + * + * @param int $fields Fields + * + * @return void + * + * @since 1.0.0 + */ + public function setFields(int $fields) : void + { + $this->fields = $fields; + } + + /** + * {@inheritdoc} + */ + public function toArray() : array + { + return [ + 'id' => $this->id, + 'name' => $this->name, + 'validationPattern' => $this->validationPattern, + 'custom' => $this->custom, + 'isRequired' => $this->isRequired, + ]; + } + + /** + * {@inheritdoc} + */ + public function jsonSerialize() + { + return $this->toArray(); + } +} diff --git a/Models/ProjectAttributeTypeL11n.php b/Models/ProjectAttributeTypeL11n.php new file mode 100644 index 0000000..74787bd --- /dev/null +++ b/Models/ProjectAttributeTypeL11n.php @@ -0,0 +1,136 @@ +type = $type; + $this->title = $title; + $this->language = $language; + } + + /** + * Get id + * + * @return int + * + * @since 1.0.0 + */ + public function getId() : int + { + return $this->id; + } + + /** + * Get language + * + * @return string + * + * @since 1.0.0 + */ + public function getLanguage() : string + { + return $this->language; + } + + /** + * Set language + * + * @param string $language Language + * + * @return void + * + * @since 1.0.0 + */ + public function setLanguage(string $language) : void + { + $this->language = $language; + } + + /** + * {@inheritdoc} + */ + public function toArray() : array + { + return [ + 'id' => $this->id, + 'title' => $this->title, + 'type' => $this->type, + 'language' => $this->language, + ]; + } + + /** + * {@inheritdoc} + */ + public function jsonSerialize() + { + return $this->toArray(); + } +} diff --git a/Models/ProjectAttributeTypeL11nMapper.php b/Models/ProjectAttributeTypeL11nMapper.php new file mode 100644 index 0000000..39aba30 --- /dev/null +++ b/Models/ProjectAttributeTypeL11nMapper.php @@ -0,0 +1,57 @@ + + * @since 1.0.0 + */ + protected static array $columns = [ + 'projectmanagement_project_attr_type_l11n_id' => ['name' => 'projectmanagement_project_attr_type_l11n_id', 'type' => 'int', 'internal' => 'id'], + 'projectmanagement_project_attr_type_l11n_title' => ['name' => 'projectmanagement_project_attr_type_l11n_title', 'type' => 'string', 'internal' => 'title', 'autocomplete' => true], + 'projectmanagement_project_attr_type_l11n_type' => ['name' => 'projectmanagement_project_attr_type_l11n_type', 'type' => 'int', 'internal' => 'type'], + 'projectmanagement_project_attr_type_l11n_lang' => ['name' => 'projectmanagement_project_attr_type_l11n_lang', 'type' => 'string', 'internal' => 'language'], + ]; + + /** + * Primary table. + * + * @var string + * @since 1.0.0 + */ + protected static string $table = 'projectmanagement_project_attr_type_l11n'; + + /** + * Primary field name. + * + * @var string + * @since 1.0.0 + */ + protected static string $primaryField = 'projectmanagement_project_attr_type_l11n_id'; +} diff --git a/Models/ProjectAttributeTypeMapper.php b/Models/ProjectAttributeTypeMapper.php new file mode 100644 index 0000000..8ce2688 --- /dev/null +++ b/Models/ProjectAttributeTypeMapper.php @@ -0,0 +1,83 @@ + + * @since 1.0.0 + */ + protected static array $columns = [ + 'projectmanagement_project_attr_type_id' => ['name' => 'projectmanagement_project_attr_type_id', 'type' => 'int', 'internal' => 'id'], + 'projectmanagement_project_attr_type_name' => ['name' => 'projectmanagement_project_attr_type_name', 'type' => 'string', 'internal' => 'name', 'autocomplete' => true], + 'projectmanagement_project_attr_type_fields' => ['name' => 'projectmanagement_project_attr_type_fields', 'type' => 'int', 'internal' => 'fields'], + 'projectmanagement_project_attr_type_custom' => ['name' => 'projectmanagement_project_attr_type_custom', 'type' => 'bool', 'internal' => 'custom'], + 'projectmanagement_project_attr_type_pattern' => ['name' => 'projectmanagement_project_attr_type_pattern', 'type' => 'string', 'internal' => 'validationPattern'], + 'projectmanagement_project_attr_type_required' => ['name' => 'projectmanagement_project_attr_type_required', 'type' => 'bool', 'internal' => 'isRequired'], + ]; + + /** + * Has many relation. + * + * @var array + * @since 1.0.0 + */ + protected static array $hasMany = [ + 'l11n' => [ + 'mapper' => ProjectAttributeTypeL11nMapper::class, + 'table' => 'projectmanagement_project_attr_type_l11n', + 'self' => 'projectmanagement_project_attr_type_l11n_type', + 'column' => 'title', + 'conditional' => true, + 'external' => null, + ], + 'defaults' => [ + 'mapper' => ProjectAttributeValueMapper::class, + 'table' => 'projectmanagement_project_attr_default', + 'self' => 'projectmanagement_project_attr_default_type', + 'external' => 'projectmanagement_project_attr_default_value', + 'conditional' => false, + ], + ]; + + /** + * Primary table. + * + * @var string + * @since 1.0.0 + */ + protected static string $table = 'projectmanagement_project_attr_type'; + + /** + * Primary field name. + * + * @var string + * @since 1.0.0 + */ + protected static string $primaryField = 'projectmanagement_project_attr_type_id'; +} diff --git a/Models/ProjectAttributeValue.php b/Models/ProjectAttributeValue.php new file mode 100644 index 0000000..e2b011a --- /dev/null +++ b/Models/ProjectAttributeValue.php @@ -0,0 +1,255 @@ +type = $type; + $this->language = $language; + + $this->setValue($value); + } + + /** + * Get id + * + * @return int + * + * @since 1.0.0 + */ + public function getId() : int + { + return $this->id; + } + + /** + * Set value + * + * @param int|string|float|\DateTimeInterface $value Value + * + * @return void + * + * @since 1.0.0 + */ + public function setValue(mixed $value) : void + { + if (\is_string($value)) { + $this->valueStr = $value; + } elseif (\is_int($value)) { + $this->valueInt = $value; + } elseif (\is_float($value)) { + $this->valueDec = $value; + } elseif ($value instanceof \DateTimeInterface) { + $this->valueDat = $value; + } + } + + /** + * Get value + * + * @return null|int|string|float|\DateTimeInterface + * + * @since 1.0.0 + */ + public function getValue() : mixed + { + if (!empty($this->valueStr)) { + return $this->valueStr; + } elseif (!empty($this->valueInt)) { + return $this->valueInt; + } elseif (!empty($this->valueDec)) { + return $this->valueDec; + } elseif ($this->valueDat instanceof \DateTimeInterface) { + return $this->valueDat; + } + + return null; + } + + /** + * Set language + * + * @param string $language Language + * + * @return void + * + * @since 1.0.0 + */ + public function setLanguage(string $language) : void + { + $this->language = $language; + } + + /** + * Get language + * + * @return string + * + * @since 1.0.0 + */ + public function getLanguage() : string + { + return $this->language; + } + + /** + * Set country + * + * @param string $country Country + * + * @return void + * + * @since 1.0.0 + */ + public function setCountry(string $country) : void + { + $this->country = $country; + } + + /** + * Get country + * + * @return string + * + * @since 1.0.0 + */ + public function getCountry() : string + { + return $this->country; + } + + /** + * {@inheritdoc} + */ + public function toArray() : array + { + return [ + 'id' => $this->id, + 'type' => $this->type, + 'valueInt' => $this->valueInt, + 'valueStr' => $this->valueStr, + 'valueDec' => $this->valueDec, + 'valueDat' => $this->valueDat, + 'isDefault' => $this->isDefault, + 'language' => $this->language, + 'country' => $this->country, + ]; + } + + /** + * {@inheritdoc} + */ + public function jsonSerialize() + { + return $this->toArray(); + } +} diff --git a/Models/ProjectAttributeValueMapper.php b/Models/ProjectAttributeValueMapper.php new file mode 100644 index 0000000..c23669a --- /dev/null +++ b/Models/ProjectAttributeValueMapper.php @@ -0,0 +1,62 @@ + + * @since 1.0.0 + */ + protected static array $columns = [ + 'projectmanagement_project_attr_value_id' => ['name' => 'projectmanagement_project_attr_value_id', 'type' => 'int', 'internal' => 'id'], + 'projectmanagement_project_attr_value_default' => ['name' => 'projectmanagement_project_attr_value_default', 'type' => 'bool', 'internal' => 'isDefault'], + 'projectmanagement_project_attr_value_type' => ['name' => 'projectmanagement_project_attr_value_type', 'type' => 'int', 'internal' => 'type'], + 'projectmanagement_project_attr_value_valueStr' => ['name' => 'projectmanagement_project_attr_value_valueStr', 'type' => 'string', 'internal' => 'valueStr'], + 'projectmanagement_project_attr_value_valueInt' => ['name' => 'projectmanagement_project_attr_value_valueInt', 'type' => 'int', 'internal' => 'valueInt'], + 'projectmanagement_project_attr_value_valueDec' => ['name' => 'projectmanagement_project_attr_value_valueDec', 'type' => 'float', 'internal' => 'valueDec'], + 'projectmanagement_project_attr_value_valueDat' => ['name' => 'projectmanagement_project_attr_value_valueDat', 'type' => 'DateTime', 'internal' => 'valueDat'], + 'projectmanagement_project_attr_value_lang' => ['name' => 'projectmanagement_project_attr_value_lang', 'type' => 'string', 'internal' => 'language'], + 'projectmanagement_project_attr_value_country' => ['name' => 'projectmanagement_project_attr_value_country', 'type' => 'string', 'internal' => 'country'], + ]; + + /** + * Primary table. + * + * @var string + * @since 1.0.0 + */ + protected static string $table = 'projectmanagement_project_attr_value'; + + /** + * Primary field name. + * + * @var string + * @since 1.0.0 + */ + protected static string $primaryField = 'projectmanagement_project_attr_value_id'; +} diff --git a/Models/ProjectMapper.php b/Models/ProjectMapper.php index 96c7dfd..c2b6879 100755 --- a/Models/ProjectMapper.php +++ b/Models/ProjectMapper.php @@ -42,10 +42,10 @@ final class ProjectMapper extends DataMapperAbstract 'projectmanagement_project_description' => ['name' => 'projectmanagement_project_description', 'type' => 'string', 'internal' => 'description'], 'projectmanagement_project_description_raw' => ['name' => 'projectmanagement_project_description_raw', 'type' => 'string', 'internal' => 'descriptionRaw'], 'projectmanagement_project_calendar' => ['name' => 'projectmanagement_project_calendar', 'type' => 'int', 'internal' => 'calendar'], - 'projectmanagement_project_costs' => ['name' => 'projectmanagement_project_costs', 'type' => 'Serializable', 'internal' => 'costs'], 'projectmanagement_project_budgetcosts' => ['name' => 'projectmanagement_project_budgetcosts', 'type' => 'Serializable', 'internal' => 'budgetCosts'], 'projectmanagement_project_budgetearnings' => ['name' => 'projectmanagement_project_budgetearnings', 'type' => 'Serializable', 'internal' => 'budgetEarnings'], - 'projectmanagement_project_earnings' => ['name' => 'projectmanagement_project_earnings', 'type' => 'Serializable', 'internal' => 'earnings'], + 'projectmanagement_project_actualearnings' => ['name' => 'projectmanagement_project_actualearnings', 'type' => 'Serializable', 'internal' => 'actualEarnings'], + 'projectmanagement_project_actualcosts' => ['name' => 'projectmanagement_project_actualcosts', 'type' => 'Serializable', 'internal' => 'actualCosts'], 'projectmanagement_project_start' => ['name' => 'projectmanagement_project_start', 'type' => 'DateTime', 'internal' => 'start'], 'projectmanagement_project_end' => ['name' => 'projectmanagement_project_end', 'type' => 'DateTime', 'internal' => 'end'], 'projectmanagement_project_endestimated' => ['name' => 'projectmanagement_project_endestimated', 'type' => 'DateTime', 'internal' => 'endEstimated'], @@ -74,6 +74,13 @@ final class ProjectMapper extends DataMapperAbstract 'external' => 'projectmanagement_project_media_dst', 'self' => 'projectmanagement_project_media_src', ], + 'attributes' => [ + 'mapper' => ProjectAttributeMapper::class, + 'table' => 'projectmanagement_project_attr', + 'self' => 'projectmanagement_project_attr_project', + 'conditional' => true, + 'external' => null, + ], ]; /** diff --git a/tests/Models/ProjectMapperTest.php b/tests/Models/ProjectMapperTest.php index 664adad..a960bc7 100755 --- a/tests/Models/ProjectMapperTest.php +++ b/tests/Models/ProjectMapperTest.php @@ -44,10 +44,10 @@ final class ProjectMapperTest extends \PHPUnit\Framework\TestCase $money = new Money(); $money->setString('1.23'); - $project->costs = $money; $project->budgetCosts = $money; $project->budgetEarnings = $money; - $project->earnings = $money; + $project->actualCosts = $money; + $project->actualEarnings = $money; $task = new Task(); $task->title = 'ProjectTask 1'; @@ -80,10 +80,10 @@ final class ProjectMapperTest extends \PHPUnit\Framework\TestCase self::assertEquals($project->getName(), $projectR->getName()); self::assertEquals($project->description, $projectR->description); - self::assertEquals($project->costs->getAmount(), $projectR->costs->getAmount()); self::assertEquals($project->budgetEarnings->getAmount(), $projectR->budgetEarnings->getAmount()); self::assertEquals($project->budgetCosts->getAmount(), $projectR->budgetCosts->getAmount()); - self::assertEquals($project->earnings->getAmount(), $projectR->earnings->getAmount()); + self::assertEquals($project->actualCosts->getAmount(), $projectR->actualCosts->getAmount()); + self::assertEquals($project->actualEarnings->getAmount(), $projectR->actualEarnings->getAmount()); self::assertEquals($project->createdAt->format('Y-m-d'), $projectR->createdAt->format('Y-m-d')); self::assertEquals($project->start->format('Y-m-d'), $projectR->start->format('Y-m-d')); self::assertEquals($project->end->format('Y-m-d'), $projectR->end->format('Y-m-d')); diff --git a/tests/Models/ProjectTest.php b/tests/Models/ProjectTest.php index b6cf729..4f858af 100755 --- a/tests/Models/ProjectTest.php +++ b/tests/Models/ProjectTest.php @@ -50,10 +50,10 @@ final class ProjectTest extends \PHPUnit\Framework\TestCase self::assertEquals(0, $this->project->createdBy->getId()); self::assertEquals('', $this->project->getName()); self::assertEquals('', $this->project->description); - self::assertEquals(0, $this->project->costs->getInt()); self::assertEquals(0, $this->project->budgetCosts->getInt()); self::assertEquals(0, $this->project->budgetEarnings->getInt()); - self::assertEquals(0, $this->project->earnings->getInt()); + self::assertEquals(0, $this->project->actualCosts->getInt()); + self::assertEquals(0, $this->project->actualEarnings->getInt()); self::assertEquals(0, $this->project->progress); self::assertEquals([], $this->project->getMedia()); self::assertEquals(ProgressType::MANUAL, $this->project->getProgressType()); @@ -179,10 +179,10 @@ final class ProjectTest extends \PHPUnit\Framework\TestCase 'end' => $this->project->end, 'name' => 'Name', 'description' => 'Description', - 'costs' => new Money(), 'budgetCosts' => new Money(), 'budgetEarnings' => new Money(), - 'earnings' => new Money(), + 'actualCosts' => new Money(), + 'actualEarnings' => new Money(), 'tasks' => [], 'media' => [], 'progress' => 10,