Fix: Detection of country of bank account failed

New: Can change order of fields in bank info
This commit is contained in:
Laurent Destailleur 2010-09-15 10:30:57 +00:00
parent ea47cebe6f
commit eacc9361ea
5 changed files with 93 additions and 59 deletions

View File

@ -477,7 +477,7 @@ class Facture extends CommonObject
$error=0;
$object=new Facture($this->db);
// Instantiate hooks of thirdparty module
if (is_array($conf->hooks_modules) && !empty($conf->hooks_modules))
{
@ -513,7 +513,7 @@ class Facture extends CommonObject
unset($object->products[$i]); // Tant que products encore utilise
}
}
// Create clone
$result=$object->create($user);
@ -535,7 +535,7 @@ class Facture extends CommonObject
if ($result < 0) $error++;
}
}
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
$interface=new Interfaces($this->db);
@ -788,7 +788,7 @@ class Facture extends CommonObject
$this->lignes[$i] = $line; // TODO deprecated
$this->lines[$i] = $line;
$i++;
}
$this->db->free($result);
@ -2883,7 +2883,7 @@ class Facture extends CommonObject
$this->cond_reglement_id = 1;
$this->cond_reglement_code = 'RECEP';
$this->mode_reglement_id = 7;
$this->mode_reglement_code = 'CHQ';
$this->mode_reglement_code = ''; // No particular payment mode defined
$this->note_public='SPECIMEN';
// Lines
$nbp = 5;
@ -2953,7 +2953,7 @@ class Facture extends CommonObject
return -1;
}
}
/**
* Return an array of invoice lines
*/
@ -3008,7 +3008,7 @@ class Facture extends CommonObject
$i++;
}
$this->db->free($resql);
return 1;
}
else
@ -3054,7 +3054,7 @@ class FactureLigne
var $info_bits = 0; // Liste d'options cumulables:
// Bit 0: 0 si TVA normal - 1 si TVA NPR
// Bit 1: 0 si ligne normal - 1 si bit discount (link to line into llx_remise_except)
var $special_code; // Liste d'options non cumulabels:
// 1: frais de port
// 2: ecotaxe

View File

@ -26,11 +26,11 @@ create table llx_societe_rib
datec datetime,
tms timestamp,
label varchar(30),
bank varchar(255),
code_banque varchar(7),
code_guichet varchar(6),
number varchar(255),
cle_rib varchar(5),
bank varchar(255), -- bank name
code_banque varchar(7), -- bank code
code_guichet varchar(6), -- desk code
number varchar(255), -- account number
cle_rib varchar(5), -- key of bank account
bic varchar(10),
iban_prefix varchar(34), -- 34 according to ISO 13616
domiciliation varchar(255),

View File

@ -781,7 +781,7 @@ SimpleNumRefModelDesc=Return the reference number with format %syymm-nnnn where
ListOfEntities=List of entities
AddEntity=Add entity
EditEntity=Edit entity
ShowProfIdInAddress=Show professionnal id into addresses on documents
ShowProfIdInAddress=Show professionnal id with addresses on documents
##### Module password generation
PasswordGenerationStandard=Return a password generated according to internal Dolibarr algorithm: 8 characters containing shared numbers and characters in lowercase.

View File

@ -201,35 +201,67 @@ function pdf_bank(&$pdf,$outputlangs,$curx,$cury,$account)
if ($usedetailedbban)
{
$pdf->SetFont('','',6);
$savcurx=$curx;
$pdf->SetFont('','',6);
$pdf->SetXY ($curx, $cury);
$pdf->MultiCell(90, 3, $outputlangs->transnoentities("Bank").': ' . $outputlangs->convToOutputCharset($account->bank), 0, 'L', 0);
$cury+=3;
$pdf->SetFont('','B',6);
$pdf->line($curx+1, $cury+1, $curx+1, $cury+10 );
$pdf->SetXY ($curx, $cury+1);
$pdf->MultiCell(18, 3, $outputlangs->transnoentities("BankCode"), 0, 'C', 0);
$pdf->line($curx+18, $cury+1, $curx+18, $cury+10 );
$pdf->SetXY ($curx+18, $cury+1);
$pdf->MultiCell(18, 3, $outputlangs->transnoentities("DeskCode"), 0, 'C', 0);
$pdf->line($curx+36, $cury+1, $curx+36, $cury+10 );
$pdf->SetXY ($curx+36, $cury+1);
$pdf->MultiCell(24, 3, $outputlangs->transnoentities("BankAccountNumber"), 0, 'C', 0);
$pdf->line($curx+60, $cury+1, $curx+60, $cury+10 );
$pdf->SetXY ($curx+60, $cury+1);
$pdf->MultiCell(13, 3, $outputlangs->transnoentities("BankAccountNumberKey"), 0, 'C', 0);
$pdf->line($curx+73, $cury+1, $curx+73, $cury+10 );
$pdf->SetFont('','',8);
$pdf->SetXY ($curx, $cury+6);
$pdf->MultiCell(18, 3, $outputlangs->convToOutputCharset($account->code_banque), 0, 'C', 0);
$pdf->SetXY ($curx+18, $cury+6);
$pdf->MultiCell(18, 3, $outputlangs->convToOutputCharset($account->code_guichet), 0, 'C', 0);
$pdf->SetXY ($curx+36, $cury+6);
$pdf->MultiCell(24, 3, $outputlangs->convToOutputCharset($account->number), 0, 'C', 0);
$pdf->SetXY ($curx+60, $cury+6);
$pdf->MultiCell(13, 3, $outputlangs->convToOutputCharset($account->cle_rib), 0, 'C', 0);
$fieldstoshow=array('bank','desk','number','key');
//if ($account->pays_code == 'ES') $fieldstoshow=array('bank','desk','key','number');
foreach ($fieldstoshow as $val)
{
if ($val == 'bank')
{
// Bank code
$tmplength=18;
$pdf->SetXY ($curx, $cury+6);
$pdf->SetFont('','',8);$pdf->MultiCell($tmplength, 3, $outputlangs->convToOutputCharset($account->code_banque), 0, 'C', 0);
$pdf->SetXY ($curx, $cury+1);
$curx+=$tmplength;
$pdf->SetFont('','B',6);$pdf->MultiCell($tmplength, 3, $outputlangs->transnoentities("BankCode"), 0, 'C', 0);
$pdf->line($curx, $cury+1, $curx, $cury+10 );
}
if ($val == 'desk')
{
// Desk
$tmplength=18;
$pdf->SetXY ($curx, $cury+6);
$pdf->SetFont('','',8);$pdf->MultiCell($tmplength, 3, $outputlangs->convToOutputCharset($account->code_guichet), 0, 'C', 0);
$pdf->SetXY ($curx, $cury+1);
$curx+=$tmplength;
$pdf->SetFont('','B',6);$pdf->MultiCell($tmplength, 3, $outputlangs->transnoentities("DeskCode"), 0, 'C', 0);
$pdf->line($curx, $cury+1, $curx, $cury+10 );
}
if ($val == 'number')
{
// Number
$tmplength=24;
$pdf->SetXY ($curx, $cury+6);
$pdf->SetFont('','',8);$pdf->MultiCell($tmplength, 3, $outputlangs->convToOutputCharset($account->number), 0, 'C', 0);
$pdf->SetXY ($curx, $cury+1);
$curx+=$tmplength;
$pdf->SetFont('','B',6);$pdf->MultiCell($tmplength, 3, $outputlangs->transnoentities("BankAccountNumber"), 0, 'C', 0);
$pdf->line($curx, $cury+1, $curx, $cury+10 );
}
if ($val == 'key')
{
// Key
$tmplength=13;
$pdf->SetXY ($curx, $cury+6);
$pdf->SetFont('','',8);$pdf->MultiCell($tmplength, 3, $outputlangs->convToOutputCharset($account->cle_rib), 0, 'C', 0);
$pdf->SetXY ($curx, $cury+1);
$curx+=$tmplength;
$pdf->SetFont('','B',6);$pdf->MultiCell($tmplength, 3, $outputlangs->transnoentities("BankAccountNumberKey"), 0, 'C', 0);
$pdf->line($curx, $cury+1, $curx, $cury+10 );
}
}
$curx=$savcurx;
}
else
{
@ -243,6 +275,7 @@ function pdf_bank(&$pdf,$outputlangs,$curx,$cury,$account)
$pdf->MultiCell(90, 3, $outputlangs->transnoentities("BankAccountNumber").': ' . $outputlangs->convToOutputCharset($account->number), 0, 'L', 0);
$cury-=9;
}
$pdf->SetXY ($curx, $cury+1);
// Use correct name of bank id according to country
$ibankey="IBANNumber";
@ -404,7 +437,7 @@ function pdf_getlinedesc($object,$i,$outputlangs,$hideref=0,$hidedesc=0,$issuppl
$desc=$object->lines[$i]->desc; if (empty($desc)) $desc=$object->lines[$i]->description;
$ref_supplier=$object->lines[$i]->ref_supplier; if (empty($ref_supplier)) $ref_supplier=$object->lines[$i]->ref_fourn; // TODO Not yeld saved for supplier invoices, only supplier orders
$note=$object->lines[$i]->note;
if (!empty($object->hooks) && $object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code))
{
$libelleproduitservice = $object->hooks[$object->lines[$i]->special_code]->pdf_getlinedesc($object,$i,$outputlangs);
@ -413,7 +446,7 @@ function pdf_getlinedesc($object,$i,$outputlangs,$hideref=0,$hidedesc=0,$issuppl
{
if ($issupplierline) $prodser = new ProductFournisseur($db);
else $prodser = new Product($db);
if ($idprod)
{
$prodser->fetch($idprod);
@ -425,15 +458,15 @@ function pdf_getlinedesc($object,$i,$outputlangs,$hideref=0,$hidedesc=0,$issuppl
if (! empty($prodser->multilangs[$outputlangs->defaultlang]["note"])) $note=$prodser->multilangs[$outputlangs->defaultlang]["note"];
}
}
// Description short of product line
$libelleproduitservice=$label;
// Description long of product line
if ($desc && ($desc != $label))
{
if ($libelleproduitservice && !$hidedesc) $libelleproduitservice.="\n";
if ($desc == '(CREDIT_NOTE)' && $object->lines[$i]->fk_remise_except)
{
$discount=new DiscountAbsolute($db);
@ -452,7 +485,7 @@ function pdf_getlinedesc($object,$i,$outputlangs,$hideref=0,$hidedesc=0,$issuppl
}
}
}
// If line linked to a product
if ($idprod)
{
@ -472,15 +505,15 @@ function pdf_getlinedesc($object,$i,$outputlangs,$hideref=0,$hidedesc=0,$issuppl
$prefix_prodserv = $outputlangs->transnoentitiesnoconv("Product")." ";
}
}
if (!$hideref)
{
if ($issupplierline) $ref_prodserv = $prodser->ref.' ('.$outputlangs->trans("SupplierRef").' '.$ref_supplier.')'; // Show local ref and supplier ref
else $ref_prodserv = $prodser->ref; // Show local ref only
$ref_prodserv .= " - ";
}
$libelleproduitservice=$prefix_prodserv.$ref_prodserv.$libelleproduitservice;
}
}
@ -507,7 +540,7 @@ function pdf_getlinedesc($object,$i,$outputlangs,$hideref=0,$hidedesc=0,$issuppl
$libelleproduitservice.="<br>".dol_htmlentitiesbr($period,1);
//print $libelleproduitservice;
}
return $libelleproduitservice;
}

View File

@ -140,19 +140,20 @@ class CompanyBankAccount
{
if (empty($id) && empty($socid)) return -1;
$sql = "SELECT rowid, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix as iban, domiciliation, proprio, adresse_proprio";
$sql = "SELECT rowid, fk_soc, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix as iban, domiciliation, proprio, adresse_proprio";
$sql.= " FROM ".MAIN_DB_PREFIX."societe_rib";
if ($id) $sql.= " WHERE rowid = ".$id;
if ($socid) $sql.= " WHERE fk_soc = ".$socid;
$result = $this->db->query($sql);
if ($result)
$resql = $this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($result))
if ($this->db->num_rows($resql))
{
$obj = $this->db->fetch_object($result);
$obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid;
$this->id = $obj->rowid;
$this->socid = $obj->fk_soc;
$this->bank = $obj->bank;
$this->courant = $obj->courant;
$this->clos = $obj->clos;
@ -214,8 +215,9 @@ class CompanyBankAccount
}
/**
* \brief Return account country code
* \return String country code
* Return account country code.
* Use this->iban and this->socid.
* @return String country code
*/
function getCountryCode()
{
@ -234,8 +236,8 @@ class CompanyBankAccount
}
/**
* \brief Return if a bank account is defined with detailed information (bank code, desk code, number and key)
* \return boolean true or false
* Return if a bank account is defined with detailed information (bank code, desk code, number and key)
* @return boolean true or false
*/
function useDetailedBBAN()
{
@ -245,8 +247,7 @@ class CompanyBankAccount
}
/**
*
*
* Initialize properties with test values
*/
function initAsSpecimen()
{