NEW Accountancy - Add option to dissociate cash sales (#38160)

* NEW Accountancy - Add option to dissociate cash sales

* CI

* CI
This commit is contained in:
Alexandre SPANGARO 2026-05-22 11:21:28 +02:00 committed by GitHub
parent 42a314ec41
commit fa6d1902f0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 1535 additions and 21 deletions

View file

@ -435,6 +435,20 @@ if ($action == 'setenabletabonthirdparty') {
}
}
if ($action == 'setenabledissociatecashsales') {
$setenabledissociatecashsales = GETPOSTINT('value');
$res = dolibarr_set_const($db, "ACCOUNTING_DISSOCIATE_CASH_SALES", $setenabledissociatecashsales, 'yesno', 0, '', $conf->entity);
if (!($res > 0)) {
$error++;
}
if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else {
setEventMessages($langs->trans("Error"), null, 'mesgs');
}
}
if ($action == 'setexportenablelettering') {
$setexportenablelettering = GETPOSTINT('value');
$res = dolibarr_set_const($db, "ACCOUNTING_DEFAULT_NOT_EXPORT_LETTERING", $setexportenablelettering, 'yesno', 0, '', $conf->entity);
@ -929,6 +943,20 @@ if (getDolGlobalString('ACCOUNTING_ENABLE_TABONTHIRDPARTY')) {
}
print '</tr>';
print '<tr class="oddeven">';
print '<td>';
print $form->textwithpicto($langs->trans("AccountingDissociateCashSales"), $langs->trans("AccountingDissociateCashSalesDesc")).'</td>';
if (getDolGlobalString('ACCOUNTING_DISSOCIATE_CASH_SALES')) {
print '<td class="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?token=' . newToken() . '&action=setenabledissociatecashsales&value=0">';
print img_picto($langs->trans("Activated"), 'switch_on');
print '</a></td>';
} else {
print '<td class="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?token=' . newToken() . '&action=setenabledissociatecashsales&value=1">';
print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a></td>';
}
print '</tr>';
print '</table>';
print '</div>';

View file

@ -164,6 +164,10 @@ $sourceList = array(
'9' => $langs->trans('AccountingJournalType9'),
);
if (getDolGlobalInt('ACCOUNTING_DISSOCIATE_CASH_SALES')) {
$sourceList['6'] = $langs->trans('AccountingJournalType6');
}
/*
* Actions
*/

View file

@ -1,9 +1,9 @@
<?php
/* Copyright (C) 2017-2022 OpenDSI <support@open-dsi.fr>
* Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 Alexandre Janniaux <alexandre.janniaux@gmail.com>
* Copyright (C) 2025 Alexandre Spangaro <alexandre@inovea-conseil.com>
/* Copyright (C) 2017-2022 OpenDSI <support@open-dsi.fr>
* Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 Alexandre Janniaux <alexandre.janniaux@gmail.com>
* Copyright (C) 2025-2026 Alexandre Spangaro <alexandre@inovea-conseil.com>
*
* 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
@ -89,6 +89,7 @@ class AccountingJournal extends CommonObject
3 => 'purchases',
4 => 'bank',
5 => 'expensereports',
6 => 'cash_sells',
8 => 'inventories',
9 => 'hasnew',
);
@ -312,6 +313,8 @@ class AccountingJournal extends CommonObject
$prefix = '';
if ($nature == 9) {
return $langs->trans('AccountingJournalType9');
} elseif ($nature == 6 && getDolGlobalInt('ACCOUNTING_DISSOCIATE_CASH_SALES')) {
return $langs->trans('AccountingJournalType6');
} elseif ($nature == 5) {
return $langs->trans('AccountingJournalType5');
} elseif ($nature == 4) {
@ -326,6 +329,8 @@ class AccountingJournal extends CommonObject
} elseif ($mode == 1) {
if ($nature == 9) {
return $langs->trans('AccountingJournalType9');
} elseif ($nature == 6 && getDolGlobalInt('ACCOUNTING_DISSOCIATE_CASH_SALES')) {
return $langs->trans('AccountingJournalType6');
} elseif ($nature == 5) {
return $langs->trans('AccountingJournalType5');
} elseif ($nature == 4) {

File diff suppressed because it is too large Load diff

View file

@ -4,7 +4,7 @@
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2013 Christophe Battarel <christophe.battarel@altairis.fr>
* Copyright (C) 2013-2025 Alexandre Spangaro <alexandre@inovea-conseil.com>
* Copyright (C) 2013-2026 Alexandre Spangaro <alexandre@inovea-conseil.com>
* Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
@ -34,15 +34,6 @@
// Load Dolibarr environment
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
/**
* @var Conf $conf
* @var DoliDB $db
@ -51,6 +42,14 @@ require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
* @var Translate $langs
* @var User $user
*/
require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
// Load translation files required by the page
$langs->loadLangs(array("commercial", "compta", "bills", "other", "accountancy", "errors"));
@ -140,7 +139,7 @@ if (!GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))
$date_end = dol_get_last_day((int) $pastmonthyear, (int) $pastmonth, false);
}
$sql = "SELECT f.rowid, f.ref, f.type, f.situation_cycle_ref, f.datef as df, f.ref_client, f.date_lim_reglement as dlr, f.close_code, f.retained_warranty, f.revenuestamp, f.situation_final,";
$sql = "SELECT f.rowid, f.ref, f.type, f.module_source, f.situation_cycle_ref, f.datef as df, f.ref_client, f.date_lim_reglement as dlr, f.close_code, f.retained_warranty, f.revenuestamp, f.situation_final,";
$sql .= " fd.rowid as fdid, fd.description, fd.product_type, fd.total_ht, fd.total_tva, fd.total_localtax1, fd.total_localtax2, fd.tva_tx, fd.localtax1_tx, fd.localtax2_tx, fd.total_ttc, fd.situation_percent, fd.vat_src_code, fd.info_bits,";
$sql .= " s.rowid as socid, s.nom as name, s.code_client, s.code_fournisseur,";
if (getDolGlobalString('MAIN_COMPANY_PERENTITY_SHARED')) {
@ -189,6 +188,9 @@ $sql .= " AND fd.product_type IN (0,1)";
if ($date_start && $date_end) {
$sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
}
if (getDolGlobalInt('ACCOUNTING_DISSOCIATE_CASH_SALES')) {
$sql .= " AND (f.module_source IS NULL OR f.module_source <> 'takepos')";
}
// Define begin binding date
if (getDolGlobalInt('ACCOUNTING_DATE_START_BINDING')) {
$sql .= " AND f.datef >= '".$db->idate(getDolGlobalInt('ACCOUNTING_DATE_START_BINDING'))."'";

View file

@ -1837,21 +1837,33 @@ function get_left_menu_accountancy($mainmenu, &$newmenu, $usemenuhider = 1, $lef
$nature = '';
// Must match array $sourceList defined into journals_list.php
if ($objp->nature == 2 && isModEnabled('invoice') && !getDolGlobalString('ACCOUNTING_DISABLE_BINDING_ON_SALES')) {
if ($objp->nature == 2
&& isModEnabled('invoice')
&& !getDolGlobalInt('ACCOUNTING_DISABLE_BINDING_ON_SALES')) {
$nature = "sells";
}
if ($objp->nature == 6
&& isModEnabled('takepos')
&& getDolGlobalInt('ACCOUNTING_DISSOCIATE_CASH_SALES')
&& !getDolGlobalInt('ACCOUNTING_DISABLE_BINDING_ON_SALES')) {
$nature = "cashsells";
}
if ($objp->nature == 3
&& isModEnabled('supplier_invoice')
&& !getDolGlobalString('ACCOUNTING_DISABLE_BINDING_ON_PURCHASES')) {
&& !getDolGlobalInt('ACCOUNTING_DISABLE_BINDING_ON_PURCHASES')) {
$nature = "purchases";
}
if ($objp->nature == 4 && isModEnabled('bank')) {
if ($objp->nature == 4
&& isModEnabled('bank')) {
$nature = "bank";
}
if ($objp->nature == 5 && isModEnabled('expensereport') && !getDolGlobalString('ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS')) {
if ($objp->nature == 5
&& isModEnabled('expensereport')
&& !getDolGlobalInt('ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS')) {
$nature = "expensereports";
}
if ($objp->nature == 1 && (isModEnabled('asset') || isModEnabled('invoice') || isModEnabled('supplier_invoice'))) {
if ($objp->nature == 1
&& (isModEnabled('asset') || isModEnabled('invoice') || isModEnabled('supplier_invoice'))) {
$nature = "various";
}
if ($objp->nature == 8) {

View file

@ -371,6 +371,7 @@ AccountingJournalType2=Sales
AccountingJournalType3=Purchases
AccountingJournalType4=Bank
AccountingJournalType5=Expense reports
AccountingJournalType6=Cash sales
AccountingJournalType8=Inventory
AccountingJournalType9=Retained earnings
GenerationOfAccountingEntries=Generation of accounting entries
@ -395,6 +396,8 @@ ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE=Activate the management of VAT revers
ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE_DESC=When this option is enabled, you can define that a supplier or a given vendor invoice must be transferred into accountancy differently: A additional debit and a credit line will generated into the accounting on 2 given accounts from the chart of account defined into the "%s" setup page.
ACCOUNTING_ENABLE_TABONTHIRDPARTY=Activate a tab on third-party cards to view the subsidiary ledger
ACCOUNTING_ENABLE_TABONTHIRDPARTY_DESC=When this option is enabled, a new tab is showing in third-party cards to view and manage accounting for the third-party as to reconcile, print & more
AccountingDissociateCashSales=Distinguish cash sales from traditional sales
AccountingDissociateCashSalesDesc=When this option is enabled, a new journal type appears (Cash Sales) that allows you to record cash register sales in a separate journal
AccountingDefaultNotExportLettering=By default, do not export lettering when generating the file
AccountingDefaultNotExportLetteringDesc=If enabled, the lettering information of accounting entries will not be included in the generated export file.
AccountingDefaultNotNotifiedExportDate=By default, mark not yet exported lines as "Exported"