Skip to content

Commit

Permalink
Fix: [ bug #1167 ] Supplier IBAN account number set but no account
Browse files Browse the repository at this point in the history
specified warning
  • Loading branch information
eldy committed Dec 4, 2013
1 parent f2ba1a5 commit 24ce511
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 11 deletions.
2 changes: 1 addition & 1 deletion htdocs/core/lib/bank.lib.php
Expand Up @@ -99,7 +99,7 @@ function checkBanForAccount($account)
if (empty($account->number)) $account->number=$account->num_compte;
if (empty($account->cle)) $account->cle=$account->cle_rib;

dol_syslog("Bank.lib::checkBanForAccount account->code_banque=".$account->code_banque." account->code_guichet=".$account->code_guichet." account->number=".$account->number." account->cle=".$account->cle." account->iban=".$account->iban." country_code=".$country_code, LOG_DEBUG);
dol_syslog("bank.lib::checkBanForAccount account->code_banque=".$account->code_banque." account->code_guichet=".$account->code_guichet." account->number=".$account->number." account->cle=".$account->cle." account->iban=".$account->iban." country_code=".$country_code, LOG_DEBUG);

if ($country_code == 'FR') // France rules
{
Expand Down
63 changes: 56 additions & 7 deletions htdocs/societe/class/companybankaccount.class.php
Expand Up @@ -241,23 +241,72 @@ function delete($user)
/**
* Return RIB
*
* @param boolean $displayriblabel Show or Hide Label
* @param boolean $displayriblabel Prepend or Hide Label
* @return string RIB
*/
function getRibLabel($displayriblabel = true)
{
global $langs;
global $langs,$conf;

if ($this->code_banque || $this->code_guichet || $this->number || $this->cle_rib)
{
if ($this->label && $displayriblabel)
$rib = $this->label." : ";
$rib.= $this->code_banque." ".$this->code_guichet." ".$this->number;
$rib.=($this->cle_rib?" (".$this->cle_rib.")":"");
if ($this->label && $displayriblabel) $rib = $this->label." : ";

// Show fields of bank account
$fieldlists='BankCode DeskCode AccountNumber BankAccountNumberKey';
if (! empty($conf->global->BANK_SHOW_ORDER_OPTION))
{
if (is_numeric($conf->global->BANK_SHOW_ORDER_OPTION))
{
if ($conf->global->BANK_SHOW_ORDER_OPTION == '1') $fieldlists='BankCode DeskCode BankAccountNumberKey AccountNumber';
}
else $fieldlists=$conf->global->BANK_SHOW_ORDER_OPTION;
}
$fieldlistsarray=explode(' ',$fieldlists);

foreach($fieldlistsarray as $val)
{
if ($val == 'BankCode')
{
if ($this->useDetailedBBAN() == 1)
{
$rib.=$this->code_banque.' ';
}
}

if ($val == 'DeskCode')
{
if ($this->useDetailedBBAN() == 1)
{
$rib.=$this->code_guichet.' ';
}
}

if ($val == 'BankCode')
{
if ($this->useDetailedBBAN() == 2)
{
$rib.=$this->code_banque.' ';
}
}

if ($val == 'AccountNumber')
{
$rib.=$this->number.' ';
}

if ($val == 'BankAccountNumberKey')
{
if ($this->useDetailedBBAN() == 1)
{
$rib.=$this->cle_rib.' ';
}
}
}
}
else
{
$rib=$langs->trans("NoRIB");
$rib='';
}

return $rib;
Expand Down
2 changes: 1 addition & 1 deletion htdocs/societe/class/societe.class.php
Expand Up @@ -1751,7 +1751,7 @@ function display_rib()
require_once DOL_DOCUMENT_ROOT . '/societe/class/companybankaccount.class.php';
$bac = new CompanyBankAccount($this->db);
$bac->fetch(0,$this->id);
return $bac->getRibLabel();
return $bac->getRibLabel(true);
}

/**
Expand Down
17 changes: 15 additions & 2 deletions htdocs/societe/rib.php
@@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2002-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2013 Peter Fontaine <contact@peterfontaine.fr>
*
Expand Down Expand Up @@ -317,23 +317,34 @@

$rib_list = $soc->get_all_rib();
$var = false;
if (is_array($rib_list)) {
if (is_array($rib_list))
{
print '<table class="liste" width="100%">';

print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("LabelRIB"));
print_liste_field_titre($langs->trans("Bank"));
print_liste_field_titre($langs->trans("RIB"));
print_liste_field_titre($langs->trans("IBAN"));
print_liste_field_titre($langs->trans("BIC"));
print_liste_field_titre($langs->trans("DefaultRIB"), '', '', '', '', 'align="center"');
print '<td width="40"></td>';
print '</tr>';

foreach ($rib_list as $rib)
{
print "<tr $bc[$var]>";
// Label
print '<td>'.$rib->label.'</td>';
// Bank name
print '<td>'.$rib->bank.'</td>';
// Account number
print '<td>'.$rib->getRibLabel(false).'</td>';
// IBAN
print '<td>'.$rib->iban.'</td>';
// BIC
print '<td>'.$rib->bic.'</td>';
// Default
print '<td align="center" width="70">';
if (!$rib->default_rib) {
print '<a href="'.DOL_URL_ROOT.'/societe/rib.php?socid='.$soc->id.'&ribid='.$rib->id.'&action=setasdefault">';
Expand All @@ -343,6 +354,8 @@
print img_picto($langs->trans("Enabled"),'on');
}
print '</td>';

// Edit/Delete
print '<td align="right">';
if ($user->rights->societe->creer)
{
Expand Down

0 comments on commit 24ce511

Please sign in to comment.