Skip to content

Commit

Permalink
FIX source template invoice not loaded/shown
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Jun 5, 2019
1 parent a70a14b commit e3812e3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
10 changes: 8 additions & 2 deletions htdocs/compta/facture/card.php
Expand Up @@ -3806,6 +3806,13 @@
print '. '.$langs->trans("CreditNoteConvertedIntoDiscount", $object->getLibType(1), $discount->getNomUrl(1, 'discount')).'<br>';
}
}

if ($object->fk_fac_rec_source > 0)
{
$tmptemplate = new FactureRec($db);
$result = $tmptemplate->fetch($object->fk_fac_rec_source);
if ($result > 0) print '. '.$langs->trans("GeneratedFromTemplate", $tmptemplate->ref);
}
print '</td></tr>';

// Relative and absolute discounts
Expand Down Expand Up @@ -4018,9 +4025,8 @@
print '</div>';
print '<div class="fichehalfright">';
print '<div class="ficheaddleft">';
print '<div class="underbanner clearboth"></div>';

print '<table class="border tableforfield centpercent">';
print '<table class="border bordertop tableforfield centpercent">';

if (!empty($conf->multicurrency->enabled) && ($object->multicurrency_code != $conf->currency))
{
Expand Down
10 changes: 6 additions & 4 deletions htdocs/compta/facture/class/facture.class.php
Expand Up @@ -349,7 +349,7 @@ public function create(User $user, $notrigger = 0, $forceduedate = 0)
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php';
$_facrec = new FactureRec($this->db);
$result=$_facrec->fetch($this->fac_rec);
$result=$_facrec->fetchObjectLinked(); // This load $_facrec->linkedObjectsIds
$result=$_facrec->fetchObjectLinked(null, '', null, '', 'OR', 1, 'sourcetype', 0); // This load $_facrec->linkedObjectsIds

// Define some dates
$originaldatewhen = $_facrec->date_when;
Expand Down Expand Up @@ -392,6 +392,8 @@ public function create(User $user, $notrigger = 0, $forceduedate = 0)
$this->brouillon = 1;

$this->linked_objects = $_facrec->linkedObjectsIds;
// We do not add link to template invoice or next invoice will be linked to all generated invoices
//$this->linked_objects['facturerec'][0] = $this->fac_rec;

$forceduedate = $this->calculate_date_lim_reglement();

Expand Down Expand Up @@ -436,7 +438,6 @@ public function create(User $user, $notrigger = 0, $forceduedate = 0)

//var_dump($substitutionarray);exit;

$substitutionisok=true;
complete_substitutions_array($substitutionarray, $outputlangs);

$this->note_public=make_substitutions($this->note_public, $substitutionarray);
Expand Down Expand Up @@ -564,7 +565,7 @@ public function create(User $user, $notrigger = 0, $forceduedate = 0)
require_once DOL_DOCUMENT_ROOT . '/expedition/class/expedition.class.php';
$exp = new Expedition($this->db);
$exp->fetch($this->origin_id);
$exp->fetchObjectLinked();
$exp->fetchObjectLinked(null, '', null, '', 'OR', 1, 'sourcetype', 0);
if (count($exp->linkedObjectsIds['commande']) > 0)
{
foreach ($exp->linkedObjectsIds['commande'] as $key => $value)
Expand Down Expand Up @@ -1323,7 +1324,7 @@ public function fetch($rowid, $ref = '', $ref_ext = '', $ref_int = '', $fetch_si
$sql.= ', f.date_valid as datev';
$sql.= ', f.tms as datem';
$sql.= ', f.note_private, f.note_public, f.fk_statut, f.paye, f.close_code, f.close_note, f.fk_user_author, f.fk_user_valid, f.model_pdf, f.last_main_doc';
$sql.= ', f.fk_facture_source';
$sql.= ', f.fk_facture_source, f.fk_fac_rec_source';
$sql.= ', f.fk_mode_reglement, f.fk_cond_reglement, f.fk_projet as fk_project, f.extraparams';
$sql.= ', f.situation_cycle_ref, f.situation_counter, f.situation_final';
$sql.= ', f.fk_account';
Expand Down Expand Up @@ -1391,6 +1392,7 @@ public function fetch($rowid, $ref = '', $ref_ext = '', $ref_int = '', $fetch_si
$this->fk_account = ($obj->fk_account>0)?$obj->fk_account:null;
$this->fk_project = $obj->fk_project;
$this->fk_facture_source = $obj->fk_facture_source;
$this->fk_fac_rec_source = $obj->fk_fac_rec_source;
$this->note = $obj->note_private; // deprecated
$this->note_private = $obj->note_private;
$this->note_public = $obj->note_public;
Expand Down
1 change: 1 addition & 0 deletions htdocs/langs/en_US/bills.lang
Expand Up @@ -365,6 +365,7 @@ InvoiceAutoValidate=Validate invoices automatically
GeneratedFromRecurringInvoice=Generated from template recurring invoice %s
DateIsNotEnough=Date not reached yet
InvoiceGeneratedFromTemplate=Invoice %s generated from recurring template invoice %s
GeneratedFromTemplate=Generated from template invoice %s
WarningInvoiceDateInFuture=Warning, the invoice date is higher than current date
WarningInvoiceDateTooFarInFuture=Warning, the invoice date is too far from current date
ViewAvailableGlobalDiscounts=View available discounts
Expand Down

0 comments on commit e3812e3

Please sign in to comment.