NEW On invoices generated by template, we save if of source template.

This commit is contained in:
Laurent Destailleur 2017-05-16 02:43:05 +02:00
parent 789fbb6dc3
commit ce84990414
6 changed files with 25 additions and 6 deletions

View File

@ -446,7 +446,7 @@ class FactureRec extends CommonInvoice
}
else
{
$this->error=$this->db-lasterror();
$this->error=$this->db->lasterror();
return -3;
}
}
@ -849,6 +849,8 @@ class FactureRec extends CommonInvoice
$facture = new Facture($db);
$facture->fac_rec = $facturerec->id; // We will create $facture from this recurring invoice
$facture->fk_fac_rec_source = $facturerec->id; // We will create $facture from this recurring invoice
$facture->type = self::TYPE_STANDARD;
$facture->brouillon = 1;
$facture->date = $facturerec->date_when; // We could also use dol_now here but we prefer date_when so invoice has real date when we would like even if we generate later.

View File

@ -279,6 +279,8 @@ class Facture extends CommonInvoice
// Create invoice from a template invoice
if ($this->fac_rec > 0)
{
$this->fk_fac_rec_source = $this->fac_rec;
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php';
$_facrec = new FactureRec($this->db);
$result=$_facrec->fetch($this->fac_rec);
@ -386,7 +388,7 @@ class Facture extends CommonInvoice
$sql.= ", note_public";
$sql.= ", ref_client, ref_int";
$sql.= ", fk_account";
$sql.= ", fk_facture_source, fk_user_author, fk_projet";
$sql.= ", 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";
@ -410,6 +412,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->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");
$sql.= ", ".($this->fk_project?$this->fk_project:"null");

View File

@ -44,6 +44,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/lib/invoice.lib.php';
$langs->load('bills');
$langs->load('compta');
$langs->load('admin');
$langs->load('other');
// Security check
$id=(GETPOST('facid','int')?GETPOST('facid','int'):GETPOST('id','int'));
@ -940,7 +941,7 @@ if ($action == 'create')
'__INVOICE_YEAR__' => $langs->trans("PreviousYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($object->date,'%Y').')',
'__INVOICE_NEXT_YEAR__' => $langs->trans("NextYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, 1, 'y'),'%Y').')'
);
$substitutionarray['__(TRANSKEY)__']=$langs->trans("TransKey");
$substitutionarray['__(TransKey)__']=$langs->trans("TransKey");
$htmltext = '<i>'.$langs->trans("FollowingConstantsWillBeSubstituted").':<br>';
foreach($substitutionarray as $key => $val)
@ -1258,7 +1259,7 @@ else
'__INVOICE_YEAR__' => $langs->trans("PreviousYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample,'%Y').')',
'__INVOICE_NEXT_YEAR__' => $langs->trans("NextYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'y'),'%Y').')'
);
$substitutionarray['__(TRANSKEY)__']=$langs->trans("TransKey");
$substitutionarray['__(TransKey)__']=$langs->trans("TransKey");
$htmltext = '<i>'.$langs->trans("FollowingConstantsWillBeSubstituted").':<br>';
foreach($substitutionarray as $key => $val)

View File

@ -278,7 +278,7 @@ insert into llx_c_tva(fk_pays,taux,code,recuperableonly,localtax1,localtax1_type
ALTER TABLE llx_events MODIFY COLUMN ip varchar(250);
ALTER TABLE llx_facture ADD COLUMN fk_fac_rec_source integer;

View File

@ -63,7 +63,8 @@ create table llx_facture
fk_user_modif integer, -- user making last change
fk_user_valid integer, -- user validating
fk_facture_source integer, -- facture origine si facture avoir
fk_fac_rec_source integer, -- facture rec source
fk_facture_source integer, -- facture origin if credit notes or replacement invoice
fk_projet integer DEFAULT NULL, -- projet auquel est associee la facture
fk_account integer, -- bank account

View File

@ -9,6 +9,18 @@ BirthdayDate=Birthday date
DateToBirth=Date of birth
BirthdayAlertOn=birthday alert active
BirthdayAlertOff=birthday alert inactive
TransKey=Translation of the key TransKey
MonthOfInvoice=Month (number 1-12) of invoice date
TextMonthOfInvoice=Month (tex) of invoice date
PreviousMonthOfInvoice=Previous month (number 1-12) of invoice date
TextPreviousMonthOfInvoice=Previous month (text) of invoice date
NextMonthOfInvoice=Following month (number 1-12) of invoice date
TextNextMonthOfInvoice=Following month (text) of invoice date
YearOfInvoice=Year of invoice date
PreviousYearOfInvoice=Previous year of invoice date
NextYearOfInvoice=Following year of invoice date
Notify_FICHINTER_ADD_CONTACT=Added contact to Intervention
Notify_FICHINTER_VALIDATE=Intervention validated
Notify_FICHINTER_SENTBYMAIL=Intervention sent by mail