Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX Accountancy - Blocking on annual closing #30653

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ FIX: fatal error on loading pictures in attached documents of an event (#30553)
FIX: for country type (#29745)
FIX: group by qty in product margin tab (#29853)
FIX: init total amounts in margin module (#29854)
FIX: issue to get the right files exported in Quadratrus export.php (#30004)
FIX: issue to get the right files exported in Quadratus export.php (#30004)
FIX: lang output for sales representative on PDF (#30469)
FIX: langs in common docgenerator (#29774)
FIX: langs overwrite (#29630)
Expand All @@ -46,26 +46,26 @@ FIX: Missing expense report picto in menu (#29908)
FIX: Missing the description in tooltip when option show in tooltip on
FIX: mo cloning (#29686)
FIX: modification date from label in accounting bookkeeping list (#30038)
FIX: move porpale ref pdf cornas (#29989)
FIX: move proposal ref pdf cornas (#29989)
FIX: Not qualified lines for reception (#29473)
FIX: on change ref for bank account attachement are lost (#30529)
FIX: on change ref for bank account attachment are lost (#30529)
FIX: orders to bill menu (#30179)
FIX: Page expands when ticket messages are too long (#29785)
FIX: parameter name (#29666)
FIX: PHP8 warning if $conf->reception is checked the old fashion way (#29697)
FIX: PHP 8 warning on output of successful cronjob (#29922)
FIX: PHP exception on getSpecialCode (#29646)
FIX: php warning if cookie doesn’t exist (#29723)
FIX: pos: invoice date incorrectly set beacause of timezome mismatches (reverts #36e91da) (#30184)
FIX: pos: invoice date incorrectly set because of timezome mismatches (reverts #36e91da) (#30184)
FIX: public project form return an error if SOCIETE_EMAIL_UNIQUE (#29942)
FIX: REPLENISH MANY FOURN WHEN ORDER ALREADY CREATE (#29710)
FIX: Supplier Order search on date valid (#30448)
FIX: Ternary operator condition is always true/false (#29649)
FIX: to avoid error during upgrade with pgsql (#30443)
FIX: transfer in accountancy for expense reports.
FIX: unitialised var (#29728)
FIX: uninitialized var (#29728)
FIX: - Unknown Character on HTML (#30257)
FIX: Unsigned propal having signing date (#29825)
FIX: Unsigned proposal having signing date (#29825)
FIX: Update asset.class.php
FIX: update date_echeance of supplier invoices when we update invoice date in the past (#29886)
FIX: User List - Function is show in wrong column when module HRM enabled (#30186)
Expand Down
1 change: 1 addition & 0 deletions dev/tools/codespell/codespell-ignore.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ udo
ue
ro
ws
zar
# Code string
ect
tempdate
Expand Down
30 changes: 19 additions & 11 deletions htdocs/accountancy/class/bookkeeping.class.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
/* Copyright (C) 2014-2017 Olivier Geffroy <[email protected]>
* Copyright (C) 2015-2022 Alexandre Spangaro <[email protected]>
* Copyright (C) 2015-2020 Florian Henry <[email protected]>
* Copyright (C) 2018-2020 Frédéric France <frederic.france@netlogic.fr>
/* Copyright (C) 2014-2017 Olivier Geffroy <[email protected]>
* Copyright (C) 2015-2024 Alexandre Spangaro <[email protected]>
* Copyright (C) 2015-2020 Florian Henry <[email protected]>
* Copyright (C) 2018-2020 Frédéric France <frederic.france@free.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -384,6 +384,15 @@ public function create(User $user, $notrigger = false)
$this->piece_num = 1;
}

if (empty($this->label_compte)) {
$accountingaccount = new AccountingAccount($this->db);
$accountingaccount->fetch('', $this->numero_compte);

dol_syslog(get_class($this).":: fetch label_compte if empty for number =".$accountingaccount->label, LOG_DEBUG);

$this->label_compte = $accountingaccount->label;
}

$now = dol_now();

$sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element." (";
Expand Down Expand Up @@ -2692,7 +2701,6 @@ public function closeFiscalPeriod($fiscal_period_id, $new_fiscal_period_id, $sep

$sql = 'SELECT';
$sql .= " t.numero_compte,";
$sql .= " t.label_compte,";
if ($separate_auxiliary_account) {
$sql .= " t.subledger_account,";
$sql .= " t.subledger_label,";
Expand All @@ -2707,7 +2715,7 @@ public function closeFiscalPeriod($fiscal_period_id, $new_fiscal_period_id, $sep
$sql .= ' AND aa.pcg_type IN (' . $this->db->sanitize(implode(',', $pcg_type_filter), 1) . ')';
$sql .= " AND DATE(t.doc_date) >= '" . $this->db->idate($fiscal_period->date_start) . "'";
$sql .= " AND DATE(t.doc_date) <= '" . $this->db->idate($fiscal_period->date_end) . "'";
$sql .= ' GROUP BY t.numero_compte, t.label_compte, aa.pcg_type';
$sql .= ' GROUP BY t.numero_compte, aa.pcg_type';
Copy link
Member

@eldy eldy Aug 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Imagine you have in database
1 line: account = 12345, label = 'A label for the transaction", amount 10
1 line: account = 12345, label = 'A different transaction', amount 15

What do we want after creating the "A nouveau" lines ?
Just 1 line with amount 25 and label = 'A nouveau for closure abc' ?

Can you confirm ?

Copy link
Member Author

@aspangaro aspangaro Aug 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can confirm that this is exactly what we're aiming for. It's the a-nouveaux principle.

The a-nouveaux entry is similar to a trial balance in reality.

In France, this consists of summarizing all class 1 to 5 accounts (CAPIT to FINAN) in a single account.

And the annual result class 7 - 6 (INCOME - EXPENSE) goes to account 120 or 129.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So PR seems good to me.

if ($separate_auxiliary_account) {
$sql .= ' ,t.subledger_account, t.subledger_label';
}
Expand All @@ -2732,10 +2740,10 @@ public function closeFiscalPeriod($fiscal_period_id, $new_fiscal_period_id, $sep
$bookkeeping = new BookKeeping($this->db);
$bookkeeping->doc_date = $new_fiscal_period->date_start;
$bookkeeping->date_lim_reglement = '';
$bookkeeping->doc_ref = $new_fiscal_period->label;
$bookkeeping->doc_ref = $fiscal_period->label;
$bookkeeping->date_creation = $now;
$bookkeeping->doc_type = 'closure';
$bookkeeping->fk_doc = $new_fiscal_period->id;
$bookkeeping->fk_doc = $fiscal_period->id;
$bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add
$bookkeeping->thirdparty_code = '';

Expand All @@ -2750,7 +2758,7 @@ public function closeFiscalPeriod($fiscal_period_id, $new_fiscal_period_id, $sep
$bookkeeping->numero_compte = $obj->numero_compte;
$bookkeeping->label_compte = $obj->label_compte;

$bookkeeping->label_operation = $new_fiscal_period->label;
$bookkeeping->label_operation = $fiscal_period->label;
$bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt >= 0) ? 'C' : 'D';
$bookkeeping->debit = ($mt < 0) ? -$mt : 0;
Expand Down Expand Up @@ -2779,10 +2787,10 @@ public function closeFiscalPeriod($fiscal_period_id, $new_fiscal_period_id, $sep
$bookkeeping = new BookKeeping($this->db);
$bookkeeping->doc_date = $new_fiscal_period->date_start;
$bookkeeping->date_lim_reglement = '';
$bookkeeping->doc_ref = $new_fiscal_period->label;
$bookkeeping->doc_ref = $fiscal_period->label;
$bookkeeping->date_creation = $now;
$bookkeeping->doc_type = 'closure';
$bookkeeping->fk_doc = $new_fiscal_period->id;
$bookkeeping->fk_doc = $fiscal_period->id;
$bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add
$bookkeeping->thirdparty_code = '';

Expand Down
Loading