mirror of
https://github.com/Karaka-Management/oms-Accounting.git
synced 2026-01-24 10:38:40 +00:00
Merge branch 'develop' of https://github.com/Orange-Management/Modules into develop
This commit is contained in:
commit
a8d7e08f7a
|
|
@ -17,6 +17,7 @@ namespace Modules\Accounting\Admin;
|
|||
use phpOMS\DataStorage\Database\DatabasePool;
|
||||
use phpOMS\DataStorage\Database\Schema\Builder;
|
||||
use phpOMS\Module\UninstallAbstract;
|
||||
use phpOMS\Module\InfoManager;
|
||||
|
||||
/**
|
||||
* Navigation class.
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@ namespace Modules\Accounting\Admin;
|
|||
use phpOMS\DataStorage\Database\DatabasePool;
|
||||
use phpOMS\Module\UpdateAbstract;
|
||||
use phpOMS\System\File\Directory;
|
||||
use phpOMS\Module\InfoManager;
|
||||
|
||||
|
||||
/**
|
||||
* Navigation class.
|
||||
|
|
@ -33,7 +35,7 @@ class Update extends UpdateAbstract
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function update(DatabasePool $dbPool, array $info)
|
||||
public static function update(DatabasePool $dbPool, InfoManager $info)
|
||||
{
|
||||
Directory::deletePath(__DIR__ . '/Update');
|
||||
mkdir('Update');
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
declare(strict_types=1);
|
||||
namespace Modules\Accounting\Models;
|
||||
|
||||
use Modules\Accounting\Models\PersonalAccount;
|
||||
use Modules\Accounting\Models\PersonalAccountAbstract;
|
||||
|
||||
/**
|
||||
* Creditor account class.
|
||||
|
|
@ -25,7 +25,7 @@ use Modules\Accounting\Models\PersonalAccount;
|
|||
* @link http://orange-management.com
|
||||
* @since 1.0.0
|
||||
*/
|
||||
abstract class CreditorAccount extends PersonalAccount
|
||||
abstract class CreditorAccount extends PersonalAccountAbstract
|
||||
{
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
declare(strict_types=1);
|
||||
namespace Modules\Accounting\Models;
|
||||
|
||||
use Modules\Accounting\Models\PersonalAccount;
|
||||
use Modules\Accounting\Models\PersonalAccountAbstract;
|
||||
|
||||
/**
|
||||
* DebitorAccount class.
|
||||
|
|
@ -25,7 +25,7 @@ use Modules\Accounting\Models\PersonalAccount;
|
|||
* @link http://orange-management.com
|
||||
* @since 1.0.0
|
||||
*/
|
||||
abstract class DebitorAccount extends PersonalAccount
|
||||
abstract class DebitorAccount extends PersonalAccountAbstract
|
||||
{
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,97 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
class Account implements StructureElementInterface {
|
||||
private $id = 0;
|
||||
private $name = '';
|
||||
private $account = 0;
|
||||
private $values = [];
|
||||
private $total = [];
|
||||
|
||||
private $type = 0; // GUV/Bilanz
|
||||
private $assigned = 0; // Ertrags/Aufwandskonto | active/passive
|
||||
private $currency = 0; // Currency type
|
||||
private $tax = 0;
|
||||
private $hasOP = false;
|
||||
private $activity = true;
|
||||
private $hasCostCenter = true;
|
||||
private $hasCostObject = true;
|
||||
private $defaultCostCenter = 0;
|
||||
private $isFixedCostCenter = false;
|
||||
private $isVirtual = false;
|
||||
private $isCashback = false;
|
||||
|
||||
private $isOutdated = false;
|
||||
|
||||
public function __construct(int $account, string $name, array $values = [])
|
||||
{
|
||||
$this->account = $account;
|
||||
$this->name = $name;
|
||||
$this->values = [];
|
||||
|
||||
if(!empty($values)) {
|
||||
$this->isOutdated = true;
|
||||
}
|
||||
}
|
||||
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getName() : string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function addValue(AccountValue $value)
|
||||
{
|
||||
$this->values[] = $value;
|
||||
$this->isOutdated = true;
|
||||
}
|
||||
|
||||
public function getValues() : array
|
||||
{
|
||||
return $this->values;
|
||||
}
|
||||
|
||||
public function getTotal() : Money
|
||||
{
|
||||
if($this->isOutdated) {
|
||||
$this->parseValues();
|
||||
}
|
||||
|
||||
$total = new Money(0);
|
||||
|
||||
foreach($this->total as $costCenter) {
|
||||
$total->add($costCenter);
|
||||
}
|
||||
|
||||
return $total;
|
||||
}
|
||||
|
||||
public function getTotalCostCenter(int $costCenter) : Money
|
||||
{
|
||||
if($this->isOutdated) {
|
||||
$this->parseValues();
|
||||
}
|
||||
|
||||
return $this->total[$costCenter] ?? new Money(0);
|
||||
}
|
||||
|
||||
private function parseValues() : array
|
||||
{
|
||||
$this->total = [];
|
||||
foreach($this->values as $value) {
|
||||
if(!isset($this->total[$value->getCostCenter()])) {
|
||||
$this->total[$value->getCostCenter()] = new Money(0);
|
||||
}
|
||||
|
||||
$this->total[$value->getCostCenter()]->add($value->getValue());
|
||||
}
|
||||
|
||||
$this->isOutdated = false;
|
||||
|
||||
return $this->total;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
|
@ -1,58 +0,0 @@
|
|||
<?php
|
||||
|
||||
class AccountValue {
|
||||
private $account = 0;
|
||||
private $costCenter = 0;
|
||||
private $date = null;
|
||||
private $value = null;
|
||||
private $contraAccount = 0;
|
||||
private $text = '';
|
||||
private $postingId = 0;
|
||||
|
||||
public function __construct($account, $costCenter, \DateTime $date, Money $value)
|
||||
{
|
||||
$this->account = $account;
|
||||
$this->costCenter = $costCenter;
|
||||
$this->date = $date;
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
public function getAccount()
|
||||
{
|
||||
return $this->account;
|
||||
}
|
||||
|
||||
public function getCostCenter()
|
||||
{
|
||||
return $this->costCenter;
|
||||
}
|
||||
|
||||
public function getDate()
|
||||
{
|
||||
return $this->date;
|
||||
}
|
||||
|
||||
public function getValue() : Money
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public static function group($values) : array
|
||||
{
|
||||
$accounts = [];
|
||||
|
||||
foreach($values as $value) {
|
||||
if(!isset($accounts[$value->getAccount()])) {
|
||||
$accounts[$value->getAccount()] = [];
|
||||
}
|
||||
|
||||
if(!isset($accounts[$value->getAccount()][$value->getCostCenter()])) {
|
||||
$accounts[$value->getAccount()][$value->getCostCenter()] = [];
|
||||
}
|
||||
|
||||
$accounts[$value->getAccount()][$value->getCostCenter()] = $value;
|
||||
}
|
||||
|
||||
return $accounts;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
<?php
|
||||
|
||||
class Balance {
|
||||
|
||||
}
|
||||
|
|
@ -1,55 +0,0 @@
|
|||
<?php
|
||||
|
||||
class Distribution {
|
||||
private $keyCollections = [];
|
||||
|
||||
public function __construct() {}
|
||||
|
||||
public function addKey(DistributionKey $key, $from, $to)
|
||||
{
|
||||
$keys = $this->normalizeKey($key, $from, $to);
|
||||
|
||||
foreach($keys as $key) {
|
||||
if(!isset($this->keyCollections[$key->getFromAccount()])) {
|
||||
$this->keyCollections[$key->getFromAccount()] = new KeyCollection(account here);
|
||||
}
|
||||
|
||||
$this->keyCollections[$key->getFromAccount()]->addKey($key);
|
||||
}
|
||||
}
|
||||
|
||||
public function distribute($from, $to)
|
||||
{
|
||||
$accounts = $from->getAccountValues();
|
||||
$values = [];
|
||||
|
||||
foreach($accounts as $account => $accountValues) {
|
||||
$values = array_merge($values, $this->keyCollections[$account]->distribute($accountValues));
|
||||
}
|
||||
|
||||
$values = AccountValue::group($values);
|
||||
$to->setAccountValues($values);
|
||||
|
||||
return $to;
|
||||
}
|
||||
|
||||
private function normalizeKey(DistributionKey $key, $from, $to) : array
|
||||
{
|
||||
$accountsSource = $from->getAccountsById($key->getFromAccount());
|
||||
$accountDestination = $to->getAccountsById($key->getToAccount());
|
||||
$keys = [];
|
||||
|
||||
foreach($accountsSource as $accountSource) {
|
||||
foreach($key as $rawKey) {
|
||||
$keys[$accountSource->getId()] = new DistributionKey(
|
||||
$accountSource->getId(),
|
||||
$rawKey->getFromCostCenters(),
|
||||
$accountDestination,
|
||||
$rawKey->getToCostCenters()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $keys;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
<?php
|
||||
|
||||
class DistributionKey {
|
||||
private $fromAccount = 0;
|
||||
private $fromCostCenter = 0;
|
||||
|
||||
private $toAccount = 0;
|
||||
private $toCostCenter = 0;
|
||||
|
||||
private $percentage = 1.0;
|
||||
|
||||
public function __construct(int $fromAC, int $fromCC, int $toAC, int $toCC) {
|
||||
$this->fromAccount = $fromAC;
|
||||
$this->fromCostCenter = $fromCC;
|
||||
$this->toAccount = $toAC;
|
||||
$this->toCostCenter = $toCC;
|
||||
}
|
||||
|
||||
public function getFromAccount() : int
|
||||
{
|
||||
return $this->fromAccount;
|
||||
}
|
||||
|
||||
public function getFromCostCenter() : int
|
||||
{
|
||||
return $this->fromCostCenter;
|
||||
}
|
||||
|
||||
public function distribute(AccountValue $value) : AccountValue
|
||||
{
|
||||
if($value->getAccount() !== $this->fromAccount) {
|
||||
throw new \Exception('Bad account.');
|
||||
}
|
||||
|
||||
if($value->getCostCenter() !== $this->fromCostCenter) {
|
||||
throw new \Exception('Bad costcenter.');
|
||||
}
|
||||
|
||||
return new AccountValue($this->toAccount, $this->toCostCenter, $value->getDate(), $value->getValue() * $this->percentage);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,74 +0,0 @@
|
|||
<?php
|
||||
|
||||
class Element extends StructureElementAbstract {
|
||||
private $id = 0;
|
||||
private $name = '';
|
||||
private $type = 0;
|
||||
|
||||
private $action = '';
|
||||
|
||||
private $children = [];
|
||||
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getName() : string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function getValues() : array
|
||||
{
|
||||
$values = [];
|
||||
foreach($this->children as $child) {
|
||||
if($child instanceof Account) {
|
||||
$values[$child->getAccount()] = $child->getValues();
|
||||
} else {
|
||||
$values += $child->getValues();
|
||||
}
|
||||
}
|
||||
|
||||
return $values;
|
||||
}
|
||||
|
||||
public function getAccounts() : array
|
||||
{
|
||||
$accounts = [];
|
||||
foreach($this->children as $child) {
|
||||
if($child instanceof Account) {
|
||||
$accounts[$child->getAccount()] = $child->getAccount();
|
||||
} else {
|
||||
$accounts += $child->getAccounts();
|
||||
}
|
||||
}
|
||||
|
||||
return $accounts;
|
||||
}
|
||||
|
||||
public function getTotal()
|
||||
{
|
||||
$total = new Money(0);
|
||||
foreach($this->children as $child) {
|
||||
$total->add($child->getTotal());
|
||||
}
|
||||
|
||||
return $total;
|
||||
}
|
||||
|
||||
public function getTotalCostCenter(int $costCenter)
|
||||
{
|
||||
$total = new Money(0);
|
||||
foreach($this->children as $child) {
|
||||
$total->add($child->getTotalCostCenter($costCenter));
|
||||
}
|
||||
|
||||
return $total;
|
||||
}
|
||||
|
||||
public function getChildren() : array
|
||||
{
|
||||
return $this->children;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
<?php
|
||||
|
||||
class KeyCollection {
|
||||
private $fromAccount = 0;
|
||||
|
||||
private $distributionKeys = [];
|
||||
|
||||
public function __construct(int $account, array $distributionKeys = []) {
|
||||
$this->fromAccount = $account;
|
||||
$this->distributionKeys = $distributionKeys;
|
||||
}
|
||||
|
||||
public function getAccount() : int
|
||||
{
|
||||
return $this->fromAccount;
|
||||
}
|
||||
|
||||
public function addKey(DistributionKey $key)
|
||||
{
|
||||
$this->distributionKeys[$key->getFromCostCenter()] = $key;
|
||||
}
|
||||
|
||||
public function distribute(array $accountValues) : array
|
||||
{
|
||||
$values = [];
|
||||
foreach($accountValues as $value) {
|
||||
$values[] = $this->distributionKeys[$value->getCostCenter()]->distribute($value);
|
||||
}
|
||||
|
||||
return $values;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,67 +0,0 @@
|
|||
<?php
|
||||
|
||||
class PL {
|
||||
private $name = '';
|
||||
|
||||
private $structure = [];
|
||||
|
||||
public function addStructureElement(StructureElementInterface $element, int $position = -1)
|
||||
{
|
||||
if(count($structure) >= $position) {
|
||||
$this->structure = array_merge(array_slice($this->structure, 0, $position - 1, false), [$element], array_slice($this->structure, $position-1, count($this->structure) - 1, false));
|
||||
} else {
|
||||
$this->structure[] = $element;
|
||||
}
|
||||
}
|
||||
|
||||
public function getStructure() : array
|
||||
{
|
||||
return $this->structure;
|
||||
}
|
||||
|
||||
public function getAccountValues() : array
|
||||
{
|
||||
$values = [];
|
||||
foreach($this->structure as $element) {
|
||||
$values += $element->getValues();
|
||||
}
|
||||
}
|
||||
|
||||
public function getAccountsById(int $id) : array
|
||||
{
|
||||
$accounts = $this->get($id);
|
||||
|
||||
if(!isset($accounts)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if($accounts instanceof Account) {
|
||||
return [$accounts];
|
||||
}
|
||||
|
||||
return $accounts->getAccounts();
|
||||
}
|
||||
|
||||
public function get(int $id)
|
||||
{
|
||||
if(isset($this->structure[$id])) {
|
||||
return $this->structure[$id];
|
||||
}
|
||||
|
||||
$found = null;
|
||||
foreach($this->structure as $element) {
|
||||
$found = $element->get($id);
|
||||
|
||||
if(isset($found)) {
|
||||
return $found;
|
||||
}
|
||||
}
|
||||
|
||||
return $found;
|
||||
}
|
||||
|
||||
public function getTotal(int $id, int $costCenter = null) : Money
|
||||
{
|
||||
return isset($costCenter) ? $this->structure[$id]->getTotalCostCenter($costCenter) : $this->structure[$id]->getTotal();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
<?php
|
||||
|
||||
class Position {
|
||||
private $accounts = [];
|
||||
|
||||
private $color = [];
|
||||
|
||||
}
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
<?php
|
||||
|
||||
interface StructureElementInterface {
|
||||
public function getId() : int;
|
||||
public function getName() : string;
|
||||
public function getValues() : array;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user