Task # 1011 : now supplier order and invoice deal with payment terms and mode
This commit is contained in:
parent
dae36229a4
commit
5a38a43c87
@ -938,7 +938,8 @@ class CommandeFournisseur extends CommonOrder
|
||||
$sql.= ", fk_statut";
|
||||
$sql.= ", source";
|
||||
$sql.= ", model_pdf";
|
||||
//$sql.= ", fk_mode_reglement";
|
||||
$sql.= ", fk_mode_reglement";
|
||||
$sql.= ", fk_cond_reglement";
|
||||
$sql.= ") ";
|
||||
$sql.= " VALUES (";
|
||||
$sql.= "''";
|
||||
@ -953,7 +954,8 @@ class CommandeFournisseur extends CommonOrder
|
||||
$sql.= ", 0";
|
||||
$sql.= ", 0";
|
||||
$sql.= ", '".$conf->global->COMMANDE_SUPPLIER_ADDON_PDF."'";
|
||||
//$sql.= ", ".$this->mode_reglement_id;
|
||||
$sql.= ", ".$this->mode_reglement_id;
|
||||
$sql.= ", ".$this->cond_reglement_id;
|
||||
$sql.= ")";
|
||||
|
||||
dol_syslog(get_class($this)."::create sql=".$sql);
|
||||
|
||||
@ -76,6 +76,10 @@ class FactureFournisseur extends CommonInvoice
|
||||
var $note_private;
|
||||
var $note_public;
|
||||
var $propalid;
|
||||
var $cond_reglement_id;
|
||||
var $cond_reglement_code;
|
||||
var $mode_reglement_id;
|
||||
var $mode_reglement_code;
|
||||
|
||||
var $lines;
|
||||
var $fournisseur; // deprecated
|
||||
@ -143,6 +147,8 @@ class FactureFournisseur extends CommonInvoice
|
||||
$sql.= ", datec";
|
||||
$sql.= ", datef";
|
||||
$sql.= ", fk_projet";
|
||||
$sql.= ", fk_cond_reglement";
|
||||
$sql.= ", fk_mode_reglement";
|
||||
$sql.= ", note_private";
|
||||
$sql.= ", note_public";
|
||||
$sql.= ", fk_user_author";
|
||||
@ -157,6 +163,8 @@ class FactureFournisseur extends CommonInvoice
|
||||
$sql.= ", '".$this->db->idate($now)."'";
|
||||
$sql.= ", '".$this->db->idate($this->date)."'";
|
||||
$sql.= ", ".(isset($this->fk_project)?$this->fk_project:"null");
|
||||
$sql.= ", ".(isset($this->cond_reglement_id)?$this->cond_reglement_id:"null");
|
||||
$sql.= ", ".(isset($this->mode_reglement_id)?$this->mode_reglement_id:"null");
|
||||
$sql.= ", '".$this->db->escape($this->note_private)."'";
|
||||
$sql.= ", '".$this->db->escape($this->note_public)."'";
|
||||
$sql.= ", ".$user->id.",";
|
||||
@ -300,17 +308,22 @@ class FactureFournisseur extends CommonInvoice
|
||||
$sql.= " t.fk_facture_source,";
|
||||
$sql.= " t.fk_projet,";
|
||||
$sql.= " t.fk_cond_reglement,";
|
||||
$sql.= " t.fk_mode_reglement,";
|
||||
$sql.= " t.date_lim_reglement,";
|
||||
$sql.= " t.note_private,";
|
||||
$sql.= " t.note_public,";
|
||||
$sql.= " t.model_pdf,";
|
||||
$sql.= " t.import_key,";
|
||||
$sql.= " t.extraparams,";
|
||||
$sql.= " cr.code as cond_reglement_code, cr.libelle as cond_reglement_libelle,";
|
||||
$sql.= " p.code as mode_reglement_code, p.libelle as mode_reglement_libelle,";
|
||||
$sql.= ' s.nom as socnom, s.rowid as socid';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'facture_fourn as t,'.MAIN_DB_PREFIX.'societe as s';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'facture_fourn as t';
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON (t.fk_soc = s.rowid)";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_payment_term as cr ON (t.fk_cond_reglement = cr.rowid)";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as p ON (t.fk_mode_reglement = p.id)";
|
||||
if ($id) $sql.= " WHERE t.rowid=".$id;
|
||||
if ($ref) $sql.= " WHERE t.ref='".$this->db->escape($ref)."'";
|
||||
$sql.= ' AND t.fk_soc = s.rowid';
|
||||
|
||||
dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG);
|
||||
$resql=$this->db->query($sql);
|
||||
@ -352,7 +365,13 @@ class FactureFournisseur extends CommonInvoice
|
||||
$this->fk_user_valid = $obj->fk_user_valid;
|
||||
$this->fk_facture_source = $obj->fk_facture_source;
|
||||
$this->fk_project = $obj->fk_projet;
|
||||
$this->fk_cond_reglement = $obj->fk_cond_reglement;
|
||||
$this->cond_reglement_id = $obj->fk_cond_reglement;
|
||||
$this->cond_reglement_code = $obj->cond_reglement_code;
|
||||
$this->cond_reglement = $obj->cond_reglement_libelle;
|
||||
$this->cond_reglement_doc = $obj->cond_reglement_libelle;
|
||||
$this->mode_reglement_id = $obj->fk_mode_reglement;
|
||||
$this->mode_reglement_code = $obj->mode_reglement_code;
|
||||
$this->mode_reglement = $obj->mode_reglement_libelle;
|
||||
$this->date_echeance = $this->db->jdate($obj->date_lim_reglement);
|
||||
$this->note = $obj->note_private; // deprecated
|
||||
$this->note_private = $obj->note_private;
|
||||
|
||||
@ -687,6 +687,8 @@ else if ($action == 'add' && $user->rights->fournisseur->commande->creer)
|
||||
// Creation commande
|
||||
$object->ref_supplier = GETPOST('refsupplier');
|
||||
$object->socid = $socid;
|
||||
$object->cond_reglement_id = GETPOST('cond_reglement_id');
|
||||
$object->mode_reglement_id = GETPOST('mode_reglement_id');
|
||||
$object->note_private = GETPOST('note_private');
|
||||
$object->note_public = GETPOST('note_public');
|
||||
|
||||
@ -980,6 +982,9 @@ if ($action=="create")
|
||||
$societe=new Societe($db);
|
||||
$societe->fetch($socid);
|
||||
}
|
||||
|
||||
$cond_reglement_id = $societe->cond_reglement_supplier_id;
|
||||
$mode_reglement_id = $societe->mode_reglement_supplier_id;
|
||||
|
||||
print '<form name="add" action="'.$_SERVER["PHP_SELF"].'" method="post">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
@ -1009,6 +1014,16 @@ if ($action=="create")
|
||||
print '</tr>';
|
||||
|
||||
print '</td></tr>';
|
||||
|
||||
// Payment term
|
||||
print '<tr><td class="nowrap">'.$langs->trans('PaymentConditionsShort').'</td><td colspan="2">';
|
||||
$form->select_conditions_paiements(isset($_POST['cond_reglement_id'])?$_POST['cond_reglement_id']:$cond_reglement_id,'cond_reglement_id');
|
||||
print '</td></tr>';
|
||||
|
||||
// Payment mode
|
||||
print '<tr><td>'.$langs->trans('PaymentMode').'</td><td colspan="2">';
|
||||
$form->select_types_paiements(isset($_POST['mode_reglement_id'])?$_POST['mode_reglement_id']:$mode_reglement_id,'mode_reglement_id');
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans('NotePublic').'</td>';
|
||||
print '<td>';
|
||||
|
||||
@ -192,6 +192,18 @@ if ($action == 'setref_supplier' && $user->rights->fournisseur->commande->creer)
|
||||
if ($result < 0) dol_print_error($db, $object->error);
|
||||
}
|
||||
|
||||
// conditions de reglement
|
||||
if ($action == 'setconditions' && $user->rights->fournisseur->commande->creer)
|
||||
{
|
||||
$result=$object->setPaymentTerms(GETPOST('cond_reglement_id','int'));
|
||||
}
|
||||
|
||||
// mode de reglement
|
||||
else if ($action == 'setmode' && $user->rights->fournisseur->commande->creer)
|
||||
{
|
||||
$result = $object->setPaymentMethods(GETPOST('mode_reglement_id','int'));
|
||||
}
|
||||
|
||||
|
||||
// Set label
|
||||
elseif ($action == 'setlabel' && $user->rights->fournisseur->facture->creer)
|
||||
@ -201,7 +213,6 @@ elseif ($action == 'setlabel' && $user->rights->fournisseur->facture->creer)
|
||||
$result=$object->update($user);
|
||||
if ($result < 0) dol_print_error($db);
|
||||
}
|
||||
|
||||
elseif ($action == 'setdatef' && $user->rights->fournisseur->facture->creer)
|
||||
{
|
||||
$object->fetch($id);
|
||||
@ -293,6 +304,8 @@ elseif ($action == 'add' && $user->rights->fournisseur->facture->creer)
|
||||
$object->date_echeance = $datedue;
|
||||
$object->note_public = GETPOST('note_public');
|
||||
$object->note_private = GETPOST('note_private');
|
||||
$object->cond_reglement_id = GETPOST('cond_reglement_id');
|
||||
$object->mode_reglement_id = GETPOST('mode_reglement_id');
|
||||
$object->fk_project = ($tmpproject > 0) ? $tmpproject : null;
|
||||
|
||||
// If creation from another object of another module
|
||||
@ -1025,9 +1038,9 @@ if ($action == 'create')
|
||||
$projectid = (!empty($objectsrc->fk_project)?$objectsrc->fk_project:'');
|
||||
//$ref_client = (!empty($objectsrc->ref_client)?$object->ref_client:'');
|
||||
|
||||
$soc = $objectsrc->client;
|
||||
$cond_reglement_id = (!empty($objectsrc->cond_reglement_id)?$objectsrc->cond_reglement_id:(!empty($soc->cond_reglement_id)?$soc->cond_reglement_id:1));
|
||||
$mode_reglement_id = (!empty($objectsrc->mode_reglement_id)?$objectsrc->mode_reglement_id:(!empty($soc->mode_reglement_id)?$soc->mode_reglement_id:0));
|
||||
$soc = $objectsrc->thirdparty;
|
||||
$cond_reglement_id = (!empty($objectsrc->cond_reglement_id)?$objectsrc->cond_reglement_id:(!empty($soc->cond_reglement_supplier_id)?$soc->cond_reglement_supplier_id:1));
|
||||
$mode_reglement_id = (!empty($objectsrc->mode_reglement_id)?$objectsrc->mode_reglement_id:(!empty($soc->mode_reglement_supplier_id)?$soc->mode_reglement_supplier_id:0));
|
||||
$remise_percent = (!empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(!empty($soc->remise_percent)?$soc->remise_percent:0));
|
||||
$remise_absolue = (!empty($objectsrc->remise_absolue)?$objectsrc->remise_absolue:(!empty($soc->remise_absolue)?$soc->remise_absolue:0));
|
||||
$dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0;
|
||||
@ -1040,6 +1053,8 @@ if ($action == 'create')
|
||||
}
|
||||
else
|
||||
{
|
||||
$cond_reglement_id = $societe->cond_reglement_supplier_id;
|
||||
$mode_reglement_id = $societe->mode_reglement_supplier_id;
|
||||
$datetmp=dol_mktime(12,0,0,$_POST['remonth'],$_POST['reday'],$_POST['reyear']);
|
||||
$dateinvoice=($datetmp==''?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0):$datetmp);
|
||||
$datetmp=dol_mktime(12,0,0,$_POST['echmonth'],$_POST['echday'],$_POST['echyear']);
|
||||
@ -1170,6 +1185,16 @@ if ($action == 'create')
|
||||
print '<tr><td>'.$langs->trans('DateMaxPayment').'</td><td>';
|
||||
$form->select_date($datedue,'ech','','','',"add",1,1);
|
||||
print '</td></tr>';
|
||||
|
||||
// Payment term
|
||||
print '<tr><td class="nowrap">'.$langs->trans('PaymentConditionsShort').'</td><td colspan="2">';
|
||||
$form->select_conditions_paiements(isset($_POST['cond_reglement_id'])?$_POST['cond_reglement_id']:$cond_reglement_id,'cond_reglement_id');
|
||||
print '</td></tr>';
|
||||
|
||||
// Payment mode
|
||||
print '<tr><td>'.$langs->trans('PaymentMode').'</td><td colspan="2">';
|
||||
$form->select_types_paiements(isset($_POST['mode_reglement_id'])?$_POST['mode_reglement_id']:$mode_reglement_id,'mode_reglement_id');
|
||||
print '</td></tr>';
|
||||
|
||||
// Project
|
||||
if (! empty($conf->projet->enabled))
|
||||
@ -1585,6 +1610,47 @@ else
|
||||
if ($action != 'editdate_lim_reglement' && $object->statut < 2 && $object->date_echeance && $object->date_echeance < ($now - $conf->facture->fournisseur->warning_delay)) print img_warning($langs->trans('Late'));
|
||||
print '</td>';
|
||||
|
||||
// Conditions de reglement par defaut
|
||||
$langs->load('bills');
|
||||
$form = new Form($db);
|
||||
print '<tr><td class="nowrap">';
|
||||
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
|
||||
print $langs->trans('PaymentConditions');
|
||||
print '<td>';
|
||||
if ($action != 'editconditions') print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editconditions&id='.$object->id.'">'.img_edit($langs->trans('SetConditions'),1).'</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td colspan="2">';
|
||||
if ($action == 'editconditions')
|
||||
{
|
||||
$form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id,'cond_reglement_id');
|
||||
}
|
||||
else
|
||||
{
|
||||
$form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id,'none');
|
||||
}
|
||||
print "</td>";
|
||||
print '</tr>';
|
||||
|
||||
// Mode of payment
|
||||
$langs->load('bills');
|
||||
$form = new Form($db);
|
||||
print '<tr><td class="nowrap">';
|
||||
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
|
||||
print $langs->trans('PaymentMode');
|
||||
print '</td>';
|
||||
if ($action != 'editmode') print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editmode&id='.$object->id.'">'.img_edit($langs->trans('SetMode'),1).'</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td colspan="2">';
|
||||
if ($action == 'editmode')
|
||||
{
|
||||
$form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->mode_reglement_id,'mode_reglement_id');
|
||||
}
|
||||
else
|
||||
{
|
||||
$form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->mode_reglement_id,'none');
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// Status
|
||||
$alreadypaid=$object->getSommePaiement();
|
||||
print '<tr><td>'.$langs->trans('Status').'</td><td colspan="3">'.$object->getLibStatut(4,$alreadypaid).'</td></tr>';
|
||||
|
||||
@ -283,4 +283,5 @@ ALTER TABLE llx_bordereau_cheque ADD tms timestamp;
|
||||
|
||||
-- Task 1011
|
||||
ALTER TABLE `llx_societe` ADD `mode_reglement_supplier` TINYINT NOT NULL AFTER `cond_reglement` ,
|
||||
ADD `cond_reglement_supplier` TINYINT NOT NULL AFTER `mode_reglement_supplier`;
|
||||
ADD `cond_reglement_supplier` TINYINT NOT NULL AFTER `mode_reglement_supplier`;
|
||||
ALTER TABLE `llx_facture_fourn` ADD `fk_mode_reglement` TINYINT NOT NULL AFTER `fk_cond_reglement`;
|
||||
@ -59,6 +59,7 @@ create table llx_facture_fourn
|
||||
fk_projet integer, -- projet auquel est associee la facture
|
||||
|
||||
fk_cond_reglement integer DEFAULT 1 NOT NULL, -- condition de reglement (30 jours, fin de mois ...)
|
||||
fk_mode_reglement integer DEFAULT 0 NOT NULL, -- mode de reglement (CHQ, VIR, ...)
|
||||
date_lim_reglement date, -- date limite de reglement
|
||||
|
||||
note_private text,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user