Add field to track source module of invoice

This commit is contained in:
Laurent Destailleur 2018-10-07 13:59:40 +02:00
parent f9f93f58df
commit 19cf649b48
3 changed files with 17 additions and 9 deletions

View File

@ -215,6 +215,7 @@ switch ($action)
$invoice->note_private=$note;
$invoice->cond_reglement_id=$cond_reglement_id;
$invoice->mode_reglement_id=$mode_reglement_id;
$invoice->module_source = 'cashdesk';
//print "c=".$invoice->cond_reglement_id." m=".$invoice->mode_reglement_id; exit;
// Si paiement differe ...

View File

@ -126,6 +126,10 @@ class Facture extends CommonInvoice
public $close_note;
//! 1 if invoice paid COMPLETELY, 0 otherwise (do not use it anymore, use statut and close_code)
public $paye;
//! key of module source when invoice generated from a dedicated module ('cashdesk', 'takepos', ...)
public $module_source;
//! id of template invoice when generated from a template invoice
public $fk_fac_rec_source;
//! id of source invoice if replacement invoice or credit note
public $fk_facture_source;
public $linked_objects=array();
@ -443,7 +447,7 @@ class Facture extends CommonInvoice
$sql.= ", note_public";
$sql.= ", ref_client, ref_int";
$sql.= ", fk_account";
$sql.= ", fk_fac_rec_source, fk_facture_source, fk_user_author, fk_projet";
$sql.= ", module_source, fk_fac_rec_source, fk_facture_source, fk_user_author, fk_projet";
$sql.= ", fk_cond_reglement, fk_mode_reglement, date_lim_reglement, model_pdf";
$sql.= ", situation_cycle_ref, situation_counter, situation_final";
$sql.= ", fk_incoterms, location_incoterms";
@ -467,6 +471,7 @@ class Facture extends CommonInvoice
$sql.= ", ".($this->ref_client?"'".$this->db->escape($this->ref_client)."'":"null");
$sql.= ", ".($this->ref_int?"'".$this->db->escape($this->ref_int)."'":"null");
$sql.= ", ".($this->fk_account>0?$this->fk_account:'NULL');
$sql.= ", ".($this->module_source ? "'".$this->db->escape($this->module_source)."'" : "null");
$sql.= ", ".($this->fk_fac_rec_source?"'".$this->db->escape($this->fk_fac_rec_source)."'":"null");
$sql.= ", ".($this->fk_facture_source?"'".$this->db->escape($this->fk_facture_source)."'":"null");
$sql.= ", ".($user->id > 0 ? "'".$user->id."'":"null");

View File

@ -75,16 +75,18 @@ if ($action == 'valid' && $user->rights->facture->creer){
$invoice->set_paid($user);
}
if (($action=="addline" or $action=="freezone") and $placeid==0)
if (($action=="addline" || $action=="freezone") and $placeid==0)
{
if ($placeid==0) {
$invoice = new Facture($db);
$invoice->socid=$conf->global->CASHDESK_ID_THIRDPARTY;
$invoice->date=mktime();
$invoice->ref="asdf";
$placeid=$invoice->create($user);
$sql="UPDATE ".MAIN_DB_PREFIX."facture set facnumber='(PROV-POS-".$place.")' where rowid=".$placeid;
$db->query($sql);
$invoice = new Facture($db);
$invoice->socid=$conf->global->CASHDESK_ID_THIRDPARTY;
$invoice->date=dol_now();
$invoice->ref="(PROV-POS)";
$invoice->module_source = 'takepos';
$placeid=$invoice->create($user);
$sql="UPDATE ".MAIN_DB_PREFIX."facture set facnumber='(PROV-POS-".$place.")' where rowid=".$placeid;
$db->query($sql);
}
}