defrance69-patch-14

Conflicts:
	htdocs/install/mysql/migration/3.4.0-3.5.0.sql
This commit is contained in:
Laurent Destailleur 2013-10-20 14:12:56 +02:00
commit 315e2e4c13
10 changed files with 153 additions and 8 deletions

View File

@ -64,6 +64,7 @@ For users:
- New: Can choose contact on event (action com) creation, and filtred by thirdparty.
- New: Add hidden option MAIN_FORCE_DEFAULT_STATE_ID.
- New: Add page to make mass stock movement.
- New: Add field oustanding limit into thirdparty properties.
For translators:
- Qual: Normalized sort order of all languages files with english reference files.

View File

@ -128,6 +128,14 @@ if ($action == 'cstc')
if ($result < 0) setEventMessage($object->error,'errors');
}
// Update communication level
if ($action == 'setOutstandingBill')
{
$object->fetch($id);
$object->outstanding_limit=GETPOST('OutstandingBill');
$result=$object->set_OutstandingBill($user);
if ($result < 0) setEventMessage($object->error,'errors');
}
/*
@ -369,6 +377,18 @@ if ($id > 0)
print '</td>';
print '</tr>';
if ($object->client)
{
print '<tr>';
print '<td>';
print $form->editfieldkey("OutstandingBill",'OutstandingBill',$object->outstanding_limit,$object,$user->rights->societe->creer);
print '</td><td colspan="3">';
print $form->editfieldval("OutstandingBill",'OutstandingBill',$object->outstanding_limit,$object,$user->rights->societe->creer);
print '</td>';
print '</tr>';
}
// Multiprice level
if (! empty($conf->global->PRODUIT_MULTIPRICES))
{
@ -898,4 +918,4 @@ dol_htmloutput_mesg('',$mesgs);
// End of page
llxFooter();
$db->close();
?>
?>

View File

@ -1885,6 +1885,18 @@ else
print '</tr>';
}
if ($soc->outstanding_limit)
{
// Outstanding Bill
print '<tr><td>';
print $langs->trans('OutstandingBill');
print '</td><td align=right colspan=3>';
print price($soc->get_OutstandingBill()).' / ';
print price($soc->outstanding_limit, 0, '', 1, -1, -1, $conf->currency);
print '</td>';
print '</tr>';
}
// Other attributes
$res=$object->fetch_optionals($object->id,$extralabels);
$parameters=array('colspan' => ' colspan="3"');

View File

@ -2195,6 +2195,19 @@ else
print '</td></tr>';
}
if ($soc->outstanding_limit)
{
// Outstanding Bill
print '<tr><td>';
print $langs->trans('OutstandingBill');
print '</td><td align=right colspan=3>';
print price($soc->get_OutstandingBill()).' / ';
print price($soc->outstanding_limit, 0, '', 1, -1, -1, $conf->currency);
print '</td>';
print '</tr>';
}
// Other attributes
$res=$object->fetch_optionals($object->id,$extralabels);
$parameters=array('colspan' => ' colspan="3"');

View File

@ -2318,6 +2318,18 @@ if ($action == 'create')
print '</td></tr>';
}
if ($soc->outstanding_limit)
{
// Outstanding Bill
print '<tr><td>';
print $langs->trans('OutstandingBill');
print '</td><td align=right>';
print price($soc->get_OutstandingBill()).' / ';
print price($soc->outstanding_limit).'</td><td colspan=2>';
print '</td>';
print '</tr>';
}
// Other attributes
$parameters=array('objectsrc' => $objectsrc, 'colspan' => ' colspan="3"');
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
@ -3034,6 +3046,7 @@ else if ($id > 0 || ! empty($ref))
$nbrows=8; $nbcols=2;
if (! empty($conf->projet->enabled)) $nbrows++;
if (! empty($conf->banque->enabled)) $nbcols++;
if (! empty($soc->outstandingbill)) $nbrows++;
if($mysoc->localtax1_assuj=="1") $nbrows++;
if($mysoc->localtax2_assuj=="1") $nbrows++;
if ($selleruserevenustamp) $nbrows++;
@ -3305,6 +3318,18 @@ else if ($id > 0 || ! empty($ref))
}
print '</td></tr>';
if ($soc->outstandingbill)
{
// Outstanding Bill
print '<tr><td>';
print $langs->trans('OutstandingBill');
print '</td><td align=right>';
print price($soc->get_OutstandingBill()).' / ';
print price($soc->outstandingbill);
print '</td>';
print '</tr>';
}
// Amount
print '<tr><td>'.$langs->trans('AmountHT').'</td>';
print '<td align="right" colspan="3" nowrap>'.price($object->total_ht,1,'',1,-1,-1,$conf->currency).'</td></tr>';
@ -3955,4 +3980,4 @@ dol_htmloutput_mesg('',$mesgs);
llxFooter();
$db->close();
?>
?>

View File

@ -299,7 +299,8 @@ ALTER TABLE llx_facture_fourn MODIFY COLUMN fk_mode_reglement integer NULL;
ALTER TABLE llx_facture_fourn MODIFY COLUMN fk_cond_reglement integer NULL;
insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (9,'COMPANY_SENTBYMAIL','Mails sent from third party card','Executed when you send email from third party card','societe',1);
INSERT INTO llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (9,'COMPANY_SENTBYMAIL','Mails sent from third party card','Executed when you send email from third party card','societe',1);
ALTER TABLE llx_contratdet ADD column product_type integer DEFAULT 1 after total_ttc;
@ -311,3 +312,7 @@ create table llx_contrat_extrafields
import_key varchar(14) -- import key
) ENGINE=innodb;
-- add outstanding bill
ALTER TABLE llx_societe ADD outstanding_limit double(24,8) DEFAULT NULL AFTER mode_reglement_supplier;

View File

@ -52,7 +52,7 @@ create table llx_societe
fk_effectif integer DEFAULT 0, --
fk_typent integer DEFAULT 0, --
fk_forme_juridique integer DEFAULT 0, -- juridical status
fk_currency integer DEFAULT 0, -- currency
fk_currency integer DEFAULT 0, -- currency
siren varchar(128), -- IDProf1: siren or RCS for france
siret varchar(128), -- IDProf2: siret for france
ape varchar(128), -- IDProf3: code ape for france
@ -61,7 +61,7 @@ create table llx_societe
idprof6 varchar(128), -- IDProf6: nu for france
tva_intra varchar(20), -- tva
capital real, -- capital de la societe
fk_stcomm integer DEFAULT 0 NOT NULL, -- commercial statut
fk_stcomm integer DEFAULT 0 NOT NULL, -- commercial statut
note_private text, --
note_public text, --
prefix_comm varchar(5), -- prefix commercial
@ -85,6 +85,7 @@ create table llx_societe
barcode varchar(255), -- barcode
fk_barcode_type integer NULL DEFAULT 0, -- barcode type
price_level integer NULL, -- level of price for multiprices
outstanding_limit double(24,8) DEFAULT NULL, -- allowed outstanding limit
default_lang varchar(6), -- default language
logo varchar(255),
canvas varchar(32), -- type of canvas if used (null by default)

View File

@ -397,7 +397,7 @@ InActivity=Open
ActivityCeased=Closed
ActivityStateFilter=Activity status
ProductsIntoElements=List of products into
OutstandingBill=Outstanding Bill
# Monkey
MonkeyNumRefModelDesc=Return numero with format %syymm-nnnn for customer code and %syymm-nnnn for supplier code where yy is year, mm is month and nnnn is a sequence with no break and no return to 0.
# Leopard

View File

@ -397,7 +397,7 @@ InActivity=En activité
ActivityCeased=Clos
ActivityStateFilter=Statut d'activité
ProductsIntoElements=Liste des produits dans les %s
OutstandingBill=Encours de facturation
# Monkey
MonkeyNumRefModelDesc=Renvoie le numéro sous la forme %syymm-nnnn pour les codes clients et %syymm-nnnn pour les codes fournisseurs où yy est l'année, mm le mois et nnnn un compteur séquentiel sans rupture et sans remise à 0.
# Leopard

View File

@ -124,6 +124,7 @@ class Societe extends CommonObject
var $statut_commercial;
var $price_level;
var $outstanding_limit;
var $datec;
var $date_update;
@ -707,7 +708,7 @@ class Societe extends CommonObject
$sql .= ', s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur, s.parent, s.barcode';
$sql .= ', s.fk_departement, s.fk_pays as country_id, s.fk_stcomm, s.remise_client, s.mode_reglement, s.cond_reglement, s.tva_assuj';
$sql .= ', s.mode_reglement_supplier, s.cond_reglement_supplier, s.localtax1_assuj, s.localtax2_assuj, s.fk_prospectlevel, s.default_lang, s.logo';
$sql .= ', s.import_key, s.canvas';
$sql .= ', s.outstanding_limit, s.import_key, s.canvas';
$sql .= ', fj.libelle as forme_juridique';
$sql .= ', e.libelle as effectif';
$sql .= ', p.code as country_code, p.libelle as country';
@ -836,6 +837,8 @@ class Societe extends CommonObject
$this->default_lang = $obj->default_lang;
$this->logo = $obj->logo;
$this->outstanding_limit = $obj->outstanding_limit;
// multiprix
$this->price_level = $obj->price_level;
@ -2767,6 +2770,71 @@ class Societe extends CommonObject
}
}
/**
* Set outstanding value
*
* @param User $user User making change
* @return int <0 if KO, >0 if OK
*/
function set_outstanding($user)
{
if ($this->id)
{
$this->db->begin();
$now=dol_now();
$outstanding = price2num($this->outstanding_limit);
// Positionne l'encours de facturaiton
$sql = "UPDATE ".MAIN_DB_PREFIX."societe SET ";
$sql.= " outstanding_limit=".$outstanding;
$sql.= " WHERE rowid = ".$this->id;
dol_syslog(get_class($this)."::set_outstanding sql=".$sql);
$resql=$this->db->query($sql);
if (! $resql)
{
$this->db->rollback();
$this->error=$this->db->error();
return -1;
}
$this->db->commit();
return 1;
}
}
/**
* return amount of bill not paid
*
* @return boolean Yes or no
*/
function get_OutstandingBill()
{
/* Accurate value of remain to pay is to sum remaintopay for each invoice
$paiement = $invoice->getSommePaiement();
$creditnotes=$invoice->getSumCreditNotesUsed();
$deposits=$invoice->getSumDepositsUsed();
$alreadypayed=price2num($paiement + $creditnotes + $deposits,'MT');
$remaintopay=price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits,'MT');
*/
$sql = "SELECT sum(total) as amount FROM ".MAIN_DB_PREFIX."facture as f";
$sql .= " WHERE fk_soc = ". $this->id;
$sql .= " AND paye = 0";
$sql .= " AND fk_statut <> 0";
dol_syslog("get_OutstandingBill sql=".$sql);
$resql=$this->db->query($sql);
if ($resql)
{
$obj=$this->db->fetch_object($resql);
return ($obj->amount);
}
else
return 0;
}
/**
* Return label of status customer is prospect/customer
*