diff --git a/Admin/Uninstaller.php b/Admin/Uninstaller.php index 85d7120..caef30c 100644 --- a/Admin/Uninstaller.php +++ b/Admin/Uninstaller.php @@ -29,23 +29,4 @@ use phpOMS\Module\UninstallerAbstract; */ class Uninstaller extends UninstallerAbstract { - - /** - * {@inheritdoc} - */ - public static function uninstall(DatabasePool $dbPool, InfoManager $info) : void - { - parent::uninstall($dbPool, $info); - - $query = new Builder($dbPool->get()); - - $query->prefix($dbPool->get()->getPrefix())->drop( - 'accounting_posting_ele', - 'accounting_posting', - 'accounting_batch', - 'accounting_account' - ); - - $dbPool->get()->con->prepare($query->toSql())->execute(); - } } diff --git a/Models/AccountAbstract.php b/Models/AccountAbstract.php index 893c450..3b810e3 100644 --- a/Models/AccountAbstract.php +++ b/Models/AccountAbstract.php @@ -36,22 +36,18 @@ abstract class AccountAbstract /** * Type. * - * @var \Modules\Accounting\Models\AccountType + * @var AccountType * @since 1.0.0 */ - protected $type = null; - - protected $positiveParent = null; - - protected $negativeParent = null; + protected $type = AccountType::IMPERSONAL; /** * Entry list. * - * @var \Modules\Accounting\Models\EntryInterface[] + * @var EntryInterface[] * @since 1.0.0 */ - protected $entryList = []; + protected $entries = []; /** * Constructor. @@ -65,6 +61,13 @@ abstract class AccountAbstract $this->id = $id; } + /** + * Get account id. + * + * @return int + * + * @since 1.0.0 + */ public function getId() : int { return $this->id; @@ -75,12 +78,13 @@ abstract class AccountAbstract * * @param int $id Entry ID * - * @return void + * @return null|EntryInterface * * @since 1.0.0 */ - public function getEntryById($id) + public function getEntryById(int $id) : ?EntryInterface { + return $this->entries[$id] ?? null; } /** @@ -90,31 +94,12 @@ abstract class AccountAbstract * @param \DateTime $end Interval end * @param int $dateType * - * @internal \Modules\Accounting\Models\TimeRangeType $dateTime Time range type + * @return array * * @since 1.0.0 */ - public function getEntriesByDate($start, $end, $dateType = TimeRangeType::RECEIPT_DATE) + public function getEntriesByDate(\DateTime $start, \DateTime $end, int $dateType = TimeRangeType::RECEIPT_DATE) : array { - } - - public function getPositiveParent() - { - return $this->positiveParent; - } - - public function setPositiveParent($parent) - { - $this->positiveParent = $parent; - } - - public function getNegativeParent() - { - return $this->negativeParent; - } - - public function setNegativeParent($parent) - { - $this->negativeParent = $parent; + return []; } } diff --git a/Models/Balance.php b/Models/Balance.php index 668d5ee..b8261f3 100644 --- a/Models/Balance.php +++ b/Models/Balance.php @@ -14,7 +14,6 @@ declare(strict_types=1); namespace Modules\Accounting\Models; - /** * Balance class. * @@ -43,21 +42,82 @@ class Balance private $balance = []; /** - * Constructor. + * Balance name. * - * @since 1.0.0 + * @var string + * @since 1.0.0 */ - public function __construct() - { - } + private $name = ''; /** + * Balance description. + * + * @var string + * @since 1.0.0 + */ + private $description = ''; + + /** + * Get balance id + * * @return int * * @since 1.0.0 */ - public function getId() + public function getId() : int { return $this->id; } + + /** + * Set name + * + * @param string $name Balance name + * + * @return void + * + * @since 1.0.0 + */ + public function setName(string $name) : void + { + $this->name = $name; + } + + /** + * Get name + * + * @return string + * + * @since 1.0.0 + */ + public function getName() : string + { + return $this->name; + } + + /** + * Set description + * + * @param string $description Balance description + * + * @return void + * + * @since 1.0.0 + */ + public function setDescription(string $description) : void + { + $this->description = $description; + } + + /** + * Get description + * + * @return string + * + * @since 1.0.0 + */ + public function getDescription() : string + { + return $this->description; + } } diff --git a/Models/BatchPosting.php b/Models/BatchPosting.php index 13df748..0622ccb 100644 --- a/Models/BatchPosting.php +++ b/Models/BatchPosting.php @@ -60,7 +60,7 @@ class BatchPosting implements \Countable /** * Postings. * - * @var \Modules\Accounting\Models\PostingAbstract[] + * @var PostingAbstract[] * @since 1.0.0 */ private $postings = []; @@ -82,7 +82,7 @@ class BatchPosting implements \Countable * * @since 1.0.0 */ - public function getId() + public function getId() : int { return $this->id; } @@ -108,7 +108,7 @@ class BatchPosting implements \Countable * * @since 1.0.0 */ - public function setDescription(string $desc) + public function setDescription(string $desc) : void { $this->description = $desc; } @@ -146,7 +146,7 @@ class BatchPosting implements \Countable * * @since 1.0.0 */ - public function setCreator($creator) + public function setCreator($creator) : void { $this->creator = $creator; } @@ -156,13 +156,13 @@ class BatchPosting implements \Countable * * @param int $id Posting ID * - * @return \Modules\Accounting\Models\PostingAbstract + * @return null|PostingAbstract * * @since 1.0.0 */ - public function getPosting($id) + public function getPosting(int $id) : ?PostingAbstract { - return $this->postings[$id]; + return $this->postings[$id] ?? null; } /** @@ -170,25 +170,31 @@ class BatchPosting implements \Countable * * @param int $id Posting ID * - * @return void + * @return bool * * @since 1.0.0 */ - public function removePosting($id) + public function removePosting($id) : bool { + if (!isset($this->postings[$id])) { + return false; + } + unset($this->postings[$id]); + + return true; } /** * Add posting. * - * @param \Modules\Accounting\Models\PostingAbstract $posting Posting + * @param PostingAbstract $posting Posting * * @return void * * @since 1.0.0 */ - public function addPosting($posting) + public function addPosting(PostingAbstract $posting) : void { $this->postings[] = $posting; } @@ -196,7 +202,7 @@ class BatchPosting implements \Countable /** * {@inheritdoc} */ - public function count() + public function count() : int { return count($this->postings); } diff --git a/Models/CostCenter.php b/Models/CostCenter.php index e69de29..29e30ed 100644 --- a/Models/CostCenter.php +++ b/Models/CostCenter.php @@ -0,0 +1,148 @@ +id; + } + + /** + * Set code + * + * @param string $code Balance code + * + * @return void + * + * @since 1.0.0 + */ + public function setCode(string $code) : void + { + $this->code = $code; + } + + /** + * Get code + * + * @return string + * + * @since 1.0.0 + */ + public function getCode() : string + { + return $this->code; + } + + /** + * Set name + * + * @param string $name Balance name + * + * @return void + * + * @since 1.0.0 + */ + public function setName(string $name) : void + { + $this->name = $name; + } + + /** + * Get name + * + * @return string + * + * @since 1.0.0 + */ + public function getName() : string + { + return $this->name; + } + + /** + * Set description + * + * @param string $description Balance description + * + * @return void + * + * @since 1.0.0 + */ + public function setDescription(string $description) : void + { + $this->description = $description; + } + + /** + * Get description + * + * @return string + * + * @since 1.0.0 + */ + public function getDescription() : string + { + return $this->description; + } +} \ No newline at end of file diff --git a/Models/CostObject.php b/Models/CostObject.php index e69de29..a5207e8 100644 --- a/Models/CostObject.php +++ b/Models/CostObject.php @@ -0,0 +1,148 @@ +id; + } + + /** + * Set code + * + * @param string $code Balance code + * + * @return void + * + * @since 1.0.0 + */ + public function setCode(string $code) : void + { + $this->code = $code; + } + + /** + * Get code + * + * @return string + * + * @since 1.0.0 + */ + public function getCode() : string + { + return $this->code; + } + + /** + * Set name + * + * @param string $name Balance name + * + * @return void + * + * @since 1.0.0 + */ + public function setName(string $name) : void + { + $this->name = $name; + } + + /** + * Get name + * + * @return string + * + * @since 1.0.0 + */ + public function getName() : string + { + return $this->name; + } + + /** + * Set description + * + * @param string $description Balance description + * + * @return void + * + * @since 1.0.0 + */ + public function setDescription(string $description) : void + { + $this->description = $description; + } + + /** + * Get description + * + * @return string + * + * @since 1.0.0 + */ + public function getDescription() : string + { + return $this->description; + } +} \ No newline at end of file diff --git a/Models/CreditPosting.php b/Models/CreditPosting.php deleted file mode 100644 index e69de29..0000000 diff --git a/Models/Creditor.php b/Models/Creditor.php index 00bdf1a..a379023 100644 --- a/Models/Creditor.php +++ b/Models/Creditor.php @@ -14,6 +14,8 @@ declare(strict_types=1); namespace Modules\Accounting\Models; +use Modules\Admin\Models\Account; + /** * Creditor class. * @@ -26,11 +28,42 @@ class Creditor { /** - * Constructor. + * Creditor ID. + * + * @var int + * @since 1.0.0 + */ + protected $id = 0; + + /** + * Account. + * + * @var int + * @since 1.0.0 + */ + protected $account = null; + + /** + * Get id. + * + * @return int * * @since 1.0.0 */ - public function __construct() + public function getId() : int { + return $this->id; + } + + /** + * Get account. + * + * @return null|int|Account + * + * @since 1.0.0 + */ + public function getAccount() + { + return $this->account; } } diff --git a/Models/CreditorAccount.php b/Models/CreditorAccount.php deleted file mode 100644 index b6fba1d..0000000 --- a/Models/CreditorAccount.php +++ /dev/null @@ -1,45 +0,0 @@ -id; + } + + /** + * Get account. + * + * @return null|int|Account + * + * @since 1.0.0 + */ + public function getAccount() + { + return $this->account; } } diff --git a/Models/DebitorAccount.php b/Models/DebitorAccount.php deleted file mode 100644 index 4114ffc..0000000 --- a/Models/DebitorAccount.php +++ /dev/null @@ -1,49 +0,0 @@ -