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

View File

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

View File

@ -781,7 +781,7 @@ SimpleNumRefModelDesc=Return the reference number with format %syymm-nnnn where
ListOfEntities=List of entities ListOfEntities=List of entities
AddEntity=Add entity AddEntity=Add entity
EditEntity=Edit entity EditEntity=Edit entity
ShowProfIdInAddress=Show professionnal id into addresses on documents ShowProfIdInAddress=Show professionnal id with addresses on documents
##### Module password generation ##### Module password generation
PasswordGenerationStandard=Return a password generated according to internal Dolibarr algorithm: 8 characters containing shared numbers and characters in lowercase. 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) if ($usedetailedbban)
{ {
$pdf->SetFont('','',6); $savcurx=$curx;
$pdf->SetFont('','',6);
$pdf->SetXY ($curx, $cury); $pdf->SetXY ($curx, $cury);
$pdf->MultiCell(90, 3, $outputlangs->transnoentities("Bank").': ' . $outputlangs->convToOutputCharset($account->bank), 0, 'L', 0); $pdf->MultiCell(90, 3, $outputlangs->transnoentities("Bank").': ' . $outputlangs->convToOutputCharset($account->bank), 0, 'L', 0);
$cury+=3; $cury+=3;
$pdf->SetFont('','B',6);
$pdf->line($curx+1, $cury+1, $curx+1, $cury+10 ); $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); $fieldstoshow=array('bank','desk','number','key');
$pdf->SetXY ($curx, $cury+6); //if ($account->pays_code == 'ES') $fieldstoshow=array('bank','desk','key','number');
$pdf->MultiCell(18, 3, $outputlangs->convToOutputCharset($account->code_banque), 0, 'C', 0);
$pdf->SetXY ($curx+18, $cury+6); foreach ($fieldstoshow as $val)
$pdf->MultiCell(18, 3, $outputlangs->convToOutputCharset($account->code_guichet), 0, 'C', 0); {
$pdf->SetXY ($curx+36, $cury+6); if ($val == 'bank')
$pdf->MultiCell(24, 3, $outputlangs->convToOutputCharset($account->number), 0, 'C', 0); {
$pdf->SetXY ($curx+60, $cury+6); // Bank code
$pdf->MultiCell(13, 3, $outputlangs->convToOutputCharset($account->cle_rib), 0, 'C', 0); $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 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); $pdf->MultiCell(90, 3, $outputlangs->transnoentities("BankAccountNumber").': ' . $outputlangs->convToOutputCharset($account->number), 0, 'L', 0);
$cury-=9; $cury-=9;
} }
$pdf->SetXY ($curx, $cury+1);
// Use correct name of bank id according to country // Use correct name of bank id according to country
$ibankey="IBANNumber"; $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; $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 $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; $note=$object->lines[$i]->note;
if (!empty($object->hooks) && $object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) 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); $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); if ($issupplierline) $prodser = new ProductFournisseur($db);
else $prodser = new Product($db); else $prodser = new Product($db);
if ($idprod) if ($idprod)
{ {
$prodser->fetch($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"]; if (! empty($prodser->multilangs[$outputlangs->defaultlang]["note"])) $note=$prodser->multilangs[$outputlangs->defaultlang]["note"];
} }
} }
// Description short of product line // Description short of product line
$libelleproduitservice=$label; $libelleproduitservice=$label;
// Description long of product line // Description long of product line
if ($desc && ($desc != $label)) if ($desc && ($desc != $label))
{ {
if ($libelleproduitservice && !$hidedesc) $libelleproduitservice.="\n"; if ($libelleproduitservice && !$hidedesc) $libelleproduitservice.="\n";
if ($desc == '(CREDIT_NOTE)' && $object->lines[$i]->fk_remise_except) if ($desc == '(CREDIT_NOTE)' && $object->lines[$i]->fk_remise_except)
{ {
$discount=new DiscountAbsolute($db); $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 line linked to a product
if ($idprod) if ($idprod)
{ {
@ -472,15 +505,15 @@ function pdf_getlinedesc($object,$i,$outputlangs,$hideref=0,$hidedesc=0,$issuppl
$prefix_prodserv = $outputlangs->transnoentitiesnoconv("Product")." "; $prefix_prodserv = $outputlangs->transnoentitiesnoconv("Product")." ";
} }
} }
if (!$hideref) if (!$hideref)
{ {
if ($issupplierline) $ref_prodserv = $prodser->ref.' ('.$outputlangs->trans("SupplierRef").' '.$ref_supplier.')'; // Show local ref and supplier ref 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 else $ref_prodserv = $prodser->ref; // Show local ref only
$ref_prodserv .= " - "; $ref_prodserv .= " - ";
} }
$libelleproduitservice=$prefix_prodserv.$ref_prodserv.$libelleproduitservice; $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); $libelleproduitservice.="<br>".dol_htmlentitiesbr($period,1);
//print $libelleproduitservice; //print $libelleproduitservice;
} }
return $libelleproduitservice; return $libelleproduitservice;
} }

View File

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