diff --git a/accounting.services.yml b/accounting.services.yml index 9a89fa0b374a7530db293abd7f497b8e2b47f517..ac694db9c7a5a9771991593fd87be44e9734d70f 100644 --- a/accounting.services.yml +++ b/accounting.services.yml @@ -11,7 +11,7 @@ services: accounting.book_entry: class: Drupal\accounting\BookEntryService - arguments: [] + arguments: ['@logger.channel.accounting'] accounting.accounts: class: Drupal\accounting\AccountingAccountsService diff --git a/src/BookEntryService.php b/src/BookEntryService.php index 3ea902128322dbee4aa38c01c9404b6ba6653929..9a6e0d023f3d11528a736ca16cfdcf47d8b3c841 100644 --- a/src/BookEntryService.php +++ b/src/BookEntryService.php @@ -2,6 +2,7 @@ namespace Drupal\accounting; +use Drupal\Core\Logger\LoggerChannel; use Drupal\accounting\Entity\JournalEntry; use Drupal\accounting\Entity\JournalEntryLine; use Drupal\accounting\Entity\AccountingAccount; @@ -14,10 +15,17 @@ use Drupal\accounting\Entity\Reconciliation; class BookEntryService implements BookEntryServiceInterface { /** - * Constructs a new BookEntryService object. + * The logger.channel.accounting service. + * + * @var \Drupal\Core\Logger\LoggerChannel */ - public function __construct() { + protected $logger; + /** + * Constructs a new BookEntryService object. + */ + public function __construct(LoggerChannel $logger) { + $this->logger = logger; } /** @@ -113,7 +121,6 @@ class BookEntryService implements BookEntryServiceInterface { foreach ($lines as $line) { if (!$line['account_id']) { error_log('Cannot book entry: account not set!'); - error_log(print_r($line, TRUE)); } } @@ -139,7 +146,7 @@ class BookEntryService implements BookEntryServiceInterface { */ public function reconcileEntryLines($entry_lines) { if (count($entry_lines) < 2) { - error_log("not reconciling entries: less than 2 entry lines !"); + $this->logger->error("not reconciling entries: less than 2 entry lines !"); return; } @@ -147,7 +154,7 @@ class BookEntryService implements BookEntryServiceInterface { $account = FALSE; foreach ($entry_lines as $entry_line) { if ($entry_line->getState() !== 'valid' || $entry_line->getEntry()->getState() !== 'valid') { - error_log("not reconciling entries: not in state valid !"); + $this->logger->error("not reconciling entries: not in state valid !"); return; } @@ -157,7 +164,7 @@ class BookEntryService implements BookEntryServiceInterface { $account = $entry_line->get('accounting_account_id')->target_id; } if ($entry_line->get('accounting_account_id')->target_id != $account) { - error_log("not reconciling entries: not for same account !"); + $this->logger->error("not reconciling entries: not for same account !"); return; } } @@ -172,7 +179,7 @@ class BookEntryService implements BookEntryServiceInterface { } } else { - error_log("not reconciling entries: total {$sum} != 0 !"); + $this->logger->error("not reconciling entries: total {$sum} != 0 !"); } } diff --git a/src/Entity/AccountingAccount.php b/src/Entity/AccountingAccount.php index a97d0e6d1208d6270aff13fe70d173c4113b7b7b..7ac2fc0fd49a8e43030ae67d27d87dea93ab94b0 100644 --- a/src/Entity/AccountingAccount.php +++ b/src/Entity/AccountingAccount.php @@ -289,7 +289,6 @@ class AccountingAccount extends ContentEntityBase implements AccountingAccountIn $total = bcsub($total, $line->getCredit(), 2); } if (bccomp($total, $value['balance'], 2) != 0) { - error_log("{$total} - {$value['balance']}"); throw new \Exception("Internal error"); } } diff --git a/src/Plugin/views/filter/AccountingAccountBalanceFilter.php b/src/Plugin/views/filter/AccountingAccountBalanceFilter.php index 3d62a0f15f048379a7306440448490972be964b5..33ebc192f70be678f003cf89e8bbd8bfc241b5ed 100644 --- a/src/Plugin/views/filter/AccountingAccountBalanceFilter.php +++ b/src/Plugin/views/filter/AccountingAccountBalanceFilter.php @@ -78,7 +78,6 @@ class AccountingAccountBalanceFilter extends Equality { * {@inheritdoc} */ public function getCacheTags() { - error_log("#################### AccountingAccountBalanceFilter : getCacheTags"); $tags = parent::getCacheTags(); $tags[] = 'journal_entry_line_list'; return $tags;