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

NEW Accountancy - Add general account on thirdparty - Code supplier part #31318

Open
wants to merge 19 commits into
base: develop
Choose a base branch
from
Open
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
7 changes: 6 additions & 1 deletion htdocs/accountancy/journal/bankjournal.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,12 @@
if (getDolGlobalString('MAIN_COMPANY_PERENTITY_SHARED')) {
$sql .= " spe.accountancy_code_customer_general,";
$sql .= " spe.accountancy_code_customer as code_compta_client,";
$sql .= " spe.accountancy_code_supplier_general,";
$sql .= " spe.accountancy_code_supplier as code_compta_fournisseur,";
} else {
$sql .= " soc.accountancy_code_customer_general,";
$sql .= " soc.code_compta as code_compta_client,";
$sql .= " soc.accountancy_code_supplier_general,";
$sql .= " soc.code_compta_fournisseur,";
}
$sql .= " u.accountancy_code, u.rowid as userid, u.lastname as lastname, u.firstname as firstname, u.email as useremail, u.statut as userstatus,";
Expand Down Expand Up @@ -228,6 +230,7 @@
';

$account_customer = 'NotDefined';
$account_supplier = 'NotDefined';

//print $sql;
dol_syslog("accountancy/journal/bankjournal.php", LOG_DEBUG);
Expand Down Expand Up @@ -285,6 +288,7 @@
$compta_soc = 'NotDefined';
$accountancy_code_general = 'NotDefined';
if ($lineisapurchase > 0) {
$accountancy_code_general = (!empty($obj->accountancy_code_supplier_general)) ? $obj->accountancy_code_supplier_general : $account_supplier;
$compta_soc = (($obj->code_compta_fournisseur != "") ? $obj->code_compta_fournisseur : $account_supplier);
}
if ($lineisasale > 0) {
Expand Down Expand Up @@ -1034,7 +1038,8 @@
print '"'.$val["type_payment"].'"'.$sep;
print '"'.length_accountg(html_entity_decode($k)).'"'.$sep;
if ($tabtype[$key] == 'payment_supplier') {
print '"'.getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER').'"'.$sep;
$account_ledger = (!empty($obj->accountancy_code_supplier_general)) ? $obj->accountancy_code_supplier_general : $account_supplier;
print '"'.$account_ledger.'"'.$sep;
} elseif ($tabtype[$key] == 'payment') {
$account_ledger = (!empty($obj->accountancy_code_customer_general)) ? $obj->accountancy_code_customer_general : $account_customer;
print '"'.$account_ledger.'"'.$sep;
Expand Down
21 changes: 16 additions & 5 deletions htdocs/accountancy/journal/purchasesjournal.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@
$tabrclocaltax2 = array();
$tabpay = array();

$cptcli = 'NotDefined';
$cptfour = 'NotDefined';

/*
* Actions
Expand Down Expand Up @@ -133,10 +135,14 @@
$sql .= " co.code as country_code, co.label as country_label,";
$sql .= " s.rowid as socid, s.nom as name, s.fournisseur, s.code_client, s.code_fournisseur, s.fk_pays,";
if (getDolGlobalString('MAIN_COMPANY_PERENTITY_SHARED')) {
$sql .= " spe.accountancy_code_customer_general,";
$sql .= " spe.accountancy_code_customer as code_compta,";
$sql .= " spe.accountancy_code_supplier_general,";
$sql .= " spe.accountancy_code_supplier as code_compta_fournisseur,";
} else {
$sql .= " s.accountancy_code_customer_general,";
$sql .= " s.code_compta as code_compta,";
$sql .= " s.accountancy_code_supplier_general,";
$sql .= " s.code_compta_fournisseur,";
}
if (getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED')) {
Expand Down Expand Up @@ -221,6 +227,7 @@
$obj = $db->fetch_object($result);

// Controls
$accountancy_code_supplier_general = (!empty($obj->accountancy_code_supplier_general)) ? $obj->accountancy_code_supplier_general : $cptfour;
$compta_soc = ($obj->code_compta_fournisseur != "") ? $obj->code_compta_fournisseur : $cptfour;

$compta_prod = $obj->compte;
Expand Down Expand Up @@ -339,6 +346,7 @@
'id' => $obj->socid,
'name' => $obj->name,
'code_fournisseur' => $obj->code_fournisseur,
'accountancy_code_supplier_general' => $accountancy_code_supplier_general,
'code_compta_fournisseur' => $compta_soc
);

Expand Down Expand Up @@ -427,6 +435,7 @@

$companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name'];
$companystatic->accountancy_code_supplier_general = $tabcompany[$key]['accountancy_code_supplier_general'];
$companystatic->code_compta_fournisseur = $tabcompany[$key]['code_compta_fournisseur'];
$companystatic->code_fournisseur = $tabcompany[$key]['code_fournisseur'];
$companystatic->fournisseur = 1;
Expand Down Expand Up @@ -479,7 +488,7 @@
$bookkeeping->subledger_account = $tabcompany[$key]['code_compta_fournisseur'];
$bookkeeping->subledger_label = $tabcompany[$key]['name'];

$bookkeeping->numero_compte = getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER');
$bookkeeping->numero_compte = $tabcompany[$key]['accountancy_code_supplier_general'];
$bookkeeping->label_compte = $accountingaccountsupplier->label;

$bookkeeping->label_operation = $bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref_supplier, $langs->trans("SubledgerAccount"));
Expand Down Expand Up @@ -546,7 +555,7 @@

if (getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER_USE_AUXILIARY_ON_DEPOSIT')) {
if ($k == getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER_DEPOSIT')) {
$bookkeeping->subledger_account = $tabcompany[$key]['code_compta'];
$bookkeeping->subledger_account = $tabcompany[$key]['code_compta_fournisseur'];
$bookkeeping->subledger_label = $tabcompany[$key]['name'];
} else {
$bookkeeping->subledger_account = '';
Expand Down Expand Up @@ -803,6 +812,7 @@
foreach ($tabfac as $key => $val) {
$companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name'];
$companystatic->accountancy_code_supplier_general = !empty($tabcompany[$key]['accountancy_code_supplier_general']) ? $tabcompany[$key]['accountancy_code_supplier_general'] : $cptfour;
$companystatic->code_compta_fournisseur = $tabcompany[$key]['code_compta_fournisseur'];
$companystatic->code_fournisseur = $tabcompany[$key]['code_fournisseur'];
$companystatic->fournisseur = 1;
Expand Down Expand Up @@ -839,7 +849,7 @@
print '"'.$val["refsologest"].'"'.$sep;
print '"'.csvClean(dol_trunc($companystatic->name, 32)).'"'.$sep;
print '"'.length_accounta(html_entity_decode($k)).'"'.$sep;
print '"'.length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER')).'"'.$sep;
print '"'.length_accountg($companystatic->accountancy_code_supplier_general).'"'.$sep;
print '"'.length_accounta(html_entity_decode($k)).'"'.$sep;
print '"'.$langs->trans("Thirdparty").'"'.$sep;
print '"'.csvClean($bookkeepingstatic->accountingLabelForOperation($companystatic->name, $val["refsuppliersologest"], $langs->trans("Thirdparty"))).'"'.$sep;
Expand Down Expand Up @@ -1057,6 +1067,7 @@ function writebookkeeping() {
foreach ($tabfac as $key => $val) {
$companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name'];
$companystatic->accountancy_code_supplier_general = !empty($tabcompany[$key]['accountancy_code_supplier_general']) ? $tabcompany[$key]['accountancy_code_supplier_general'] : $cptfour;
$companystatic->code_compta_fournisseur = $tabcompany[$key]['code_compta_fournisseur'];
$companystatic->code_fournisseur = $tabcompany[$key]['code_fournisseur'];
$companystatic->fournisseur = 1;
Expand Down Expand Up @@ -1131,7 +1142,7 @@ function writebookkeeping() {
print "<td>".$invoicestatic->getNomUrl(1)."</td>";
// Account
print "<td>";
$accountoshow = length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER'));
$accountoshow = length_accountg(!empty($tabcompany[$key]['accountancy_code_supplier_general']) ? $tabcompany[$key]['accountancy_code_supplier_general'] : $cptfour);
if (($accountoshow == "") || $accountoshow == 'NotDefined') {
print '<span class="error">'.$langs->trans("MainAccountForSuppliersNotDefined").'</span>';
} else {
Expand Down Expand Up @@ -1182,7 +1193,7 @@ function writebookkeeping() {
print "<td>";
if (getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER_USE_AUXILIARY_ON_DEPOSIT')) {
if ($k == getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER_DEPOSIT')) {
print length_accounta($tabcompany[$key]['code_compta']);
print length_accounta($tabcompany[$key]['code_compta_fournisseur']);
}
} elseif (($accountoshow == "") || $accountoshow == 'NotDefined') {
print '<span class="error">' . $langs->trans("ThirdpartyAccountNotDefined") . '</span>';
Expand Down
2 changes: 2 additions & 0 deletions htdocs/accountancy/journal/sellsjournal.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,12 @@
if (getDolGlobalString('MAIN_COMPANY_PERENTITY_SHARED')) {
$sql .= " spe.accountancy_code_customer_general,";
$sql .= " spe.accountancy_code_customer as code_compta_client,";
$sql .= " spe.accountancy_code_supplier_general,";
$sql .= " spe.accountancy_code_supplier as code_compta_fournisseur,";
} else {
$sql .= " s.accountancy_code_customer_general,";
$sql .= " s.code_compta as code_compta_client,";
$sql .= " s.accountancy_code_supplier_general,";
$sql .= " s.code_compta_fournisseur,";
}
$sql .= " p.rowid as pid, p.ref as pref, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte,";
Expand Down
16 changes: 14 additions & 2 deletions htdocs/comm/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@
if (isModEnabled('intervention')) {
require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
}
if (isModEnabled('accounting')) {
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
}

// Load translation files required by the page
$langs->loadLangs(array('companies', 'banks'));
Expand Down Expand Up @@ -373,12 +377,20 @@
print '</td></tr>';

if (isModEnabled('accounting')) {
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
$formaccounting = new FormAccounting($db);

print '<tr>';
print '<td>';
print $form->editfieldkey("CustomerAccountancyCodeGeneral", 'customeraccountancycodegeneral', length_accountg($object->accountancy_code_customer_general), $object, $user->hasRight('societe', 'creer'));
print '</td><td>';
print $form->editfieldval("CustomerAccountancyCodeGeneral", 'customeraccountancycodegeneral', length_accountg($object->accountancy_code_customer_general), $object, $user->hasRight('societe', 'creer'));
if ($action == 'editcustomeraccountancycodegeneral' && $user->hasRight('societe', 'creer')) {
print $formaccounting->formAccountingAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->accountancy_code_customer_general, 'customeraccountancycodegeneral', 0, 1, '', 1);
} else {
$accountingaccount = new AccountingAccount($db);
$accountingaccount->fetch(0, $object->accountancy_code_customer_general, 1);

print $accountingaccount->getNomUrl(0, 1, 1, '', 1);
}
$accountingAccountByDefault = " (" . $langs->trans("AccountingAccountByDefaultShort") . ": " . length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER')) . ")";
print (getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER') ? $accountingAccountByDefault : '');
print '</td>';
Expand Down
58 changes: 46 additions & 12 deletions htdocs/fourn/card.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
<?php
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <[email protected]>
* Copyright (C) 2003 Eric Seigne <[email protected]>
* Copyright (C) 2004-2016 Laurent Destailleur <[email protected]>
* Copyright (C) 2005-2010 Regis Houssin <[email protected]>
* Copyright (C) 2010-2015 Juanjo Menent <[email protected]>
* Copyright (C) 2014 Jean Heimburger <[email protected]>
* Copyright (C) 2015 Marcos García <[email protected]>
* Copyright (C) 2015 Raphaël Doursenaud <[email protected]>
* Copyright (C) 2021 Frédéric France <frederic.france@netlogic.fr>
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <[email protected]>
* Copyright (C) 2003 Eric Seigne <[email protected]>
* Copyright (C) 2004-2016 Laurent Destailleur <[email protected]>
* Copyright (C) 2005-2010 Regis Houssin <[email protected]>
* Copyright (C) 2010-2015 Juanjo Menent <[email protected]>
* Copyright (C) 2014 Jean Heimburger <[email protected]>
* Copyright (C) 2015 Marcos García <[email protected]>
* Copyright (C) 2015 Raphaël Doursenaud <[email protected]>
* Copyright (C) 2021 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <[email protected]>
* Copyright (C) 2024 Alexandre Spangaro <[email protected]>
*
* 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 All @@ -34,7 +35,7 @@
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php';
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture-rec.class.php';
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture-rec.class.php';
require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php';
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
Expand All @@ -46,7 +47,8 @@
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
}
if (isModEnabled('accounting')) {
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
}

// Load translation files required by page
Expand Down Expand Up @@ -106,7 +108,18 @@
$action = "";
}

// Set supplier accounting account
// set general supplier accounting account
if ($action == 'setsupplieraccountancycodegeneral' && $user->hasRight('societe', 'creer')) {
$result = $object->fetch($id);
$object->accountancy_code_supplier_general = GETPOST("supplieraccountancycodegeneral");
$result = $object->update($object->id, $user, 1, 0, 1);
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
$_GET['action'] = 'editsupplieraccountancycode';
}
}

// Set auxiliary supplier accounting account
if ($action == 'setsupplieraccountancycode' && $user->hasRight('societe', 'creer')) {
$result = $object->fetch($id);
$object->code_compta_fournisseur = GETPOST("supplieraccountancycode");
Expand Down Expand Up @@ -248,6 +261,27 @@
print '</td>';
print '</tr>';

if (isModEnabled('accounting')) {
$formaccounting = new FormAccounting($db);

print '<tr>';
print '<td>';
print $form->editfieldkey("SupplierAccountancyCodeGeneral", 'supplieraccountancycodegeneral', length_accountg($object->accountancy_code_supplier_general), $object, $user->hasRight('societe', 'creer'));
print '</td><td>';
if ($action == 'editsupplieraccountancycodegeneral' && $user->hasRight('societe', 'creer')) {
print $formaccounting->formAccountingAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->accountancy_code_supplier_general, 'supplieraccountancycodegeneral', 0, 1, '', 1);
} else {
$accountingaccount = new AccountingAccount($db);
$accountingaccount->fetch(0, $object->accountancy_code_supplier_general, 1);

print $accountingaccount->getNomUrl(0, 1, 1, '', 1);
}
$accountingAccountByDefault = " (" . $langs->trans("AccountingAccountByDefaultShort") . ": " . length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER')) . ")";
print (getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER') ? $accountingAccountByDefault : '');
print '</td>';
print '</tr>';
}

$langs->load('compta');
print '<tr>';
print '<td>';
Expand Down
Loading
Loading