Merge branch '7.0' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur 2018-02-02 10:41:20 +01:00
commit 2e705b5a88
5 changed files with 55 additions and 27 deletions

View File

@ -4,6 +4,8 @@ English Dolibarr ChangeLog
***** ChangeLog for 7.0.0 compared to 6.0.5 ***** ***** ChangeLog for 7.0.0 compared to 6.0.5 *****
For users: For users:
NEW: When payment is registered, PDF of invoices are also regenerated so payments
appears with no need to click on regenerate.
NEW: #5711 Add shipment line deleting and editing for draft shipments. NEW: #5711 Add shipment line deleting and editing for draft shipments.
NEW: Accept substitution key __[ABC]__ replaced with value of const ABC NEW: Accept substitution key __[ABC]__ replaced with value of const ABC
NEW: Accountancy Add variant on sell account for intracommunity sales & export sales NEW: Accountancy Add variant on sell account for intracommunity sales & export sales

View File

@ -257,7 +257,7 @@ if (empty($reshook))
if (! $error) if (! $error)
{ {
$paiement_id = $paiement->create($user, (GETPOST('closepaidinvoices')=='on'?1:0)); // This include closing invoices $paiement_id = $paiement->create($user, (GETPOST('closepaidinvoices')=='on'?1:0)); // This include closing invoices and regenerating documents
if ($paiement_id < 0) if ($paiement_id < 0)
{ {
setEventMessages($paiement->error, $paiement->errors, 'errors'); setEventMessages($paiement->error, $paiement->errors, 'errors');

View File

@ -141,7 +141,7 @@ class Paiement extends CommonObject
/** /**
* Create payment of invoices into database. * Create payment of invoices into database.
* Use this->amounts to have list of invoices for the payment. * Use this->amounts to have list of invoices for the payment.
* For payment of a customer invoice, amounts are postive, for payment of credit note, amounts are negative * For payment of a customer invoice, amounts are positive, for payment of credit note, amounts are negative
* *
* @param User $user Object user * @param User $user Object user
* @param int $closepaidinvoices 1=Also close payed invoices to paid, 0=Do nothing more * @param int $closepaidinvoices 1=Also close payed invoices to paid, 0=Do nothing more
@ -233,11 +233,12 @@ class Paiement extends CommonObject
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if ($resql)
{ {
$invoice=new Facture($this->db);
$invoice->fetch($facid);
// If we want to closed payed invoices // If we want to closed payed invoices
if ($closepaidinvoices) if ($closepaidinvoices)
{ {
$invoice=new Facture($this->db);
$invoice->fetch($facid);
$paiement = $invoice->getSommePaiement(); $paiement = $invoice->getSommePaiement();
$creditnotes=$invoice->getSumCreditNotesUsed(); $creditnotes=$invoice->getSumCreditNotesUsed();
$deposits=$invoice->getSumDepositsUsed(); $deposits=$invoice->getSumDepositsUsed();
@ -339,7 +340,9 @@ class Paiement extends CommonObject
} }
} }
} }
}
// Regenerate documents of invoices
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{ {
$outputlangs = $langs; $outputlangs = $langs;
@ -348,14 +351,11 @@ class Paiement extends CommonObject
$outputlangs = new Translate("", $conf); $outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang); $outputlangs->setDefaultLang($newlang);
} }
$ret = $invoice->fetch($id); // Reload to get new records $ret = $invoice->fetch($facid); // Reload to get new records
$result = $invoice->generateDocument($invoice->modelpdf, $outputlangs); $result = $invoice->generateDocument($invoice->modelpdf, $outputlangs);
if ($result < 0) { if ($result < 0) {
setEventMessages($invoice->error, $invoice->errors, 'errors'); setEventMessages($invoice->error, $invoice->errors, 'errors');
$error++; $error++;
}
} }
} }
} }

View File

@ -1706,7 +1706,15 @@ function dol_convert_file($fileinput, $ext='png', $fileoutput='')
if (empty($fileoutput)) $fileoutput=$fileinput.".".$ext; if (empty($fileoutput)) $fileoutput=$fileinput.".".$ext;
$count = $image->getNumberImages(); $count = $image->getNumberImages();
if (! dol_is_file($fileoutput) || is_writeable($fileoutput))
{
$ret = $image->writeImages($fileoutput, true); $ret = $image->writeImages($fileoutput, true);
}
else
{
dol_syslog("Warning: Failed to write cache preview file '.$fileoutput.'. Check permission on file/dir", LOG_ERR);
}
if ($ret) return $count; if ($ret) return $count;
else return -3; else return -3;
} }

View File

@ -210,11 +210,12 @@ class PaiementFourn extends Paiement
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if ($resql)
{ {
$invoice=new FactureFournisseur($this->db);
$invoice->fetch($facid);
// If we want to closed payed invoices // If we want to closed payed invoices
if ($closepaidinvoices) if ($closepaidinvoices)
{ {
$invoice=new FactureFournisseur($this->db);
$invoice->fetch($facid);
$paiement = $invoice->getSommePaiement(); $paiement = $invoice->getSommePaiement();
//$creditnotes=$invoice->getSumCreditNotesUsed(); //$creditnotes=$invoice->getSumCreditNotesUsed();
$creditnotes=0; $creditnotes=0;
@ -228,17 +229,34 @@ class PaiementFourn extends Paiement
} }
else dol_syslog("Remain to pay for invoice ".$facid." not null. We do nothing."); else dol_syslog("Remain to pay for invoice ".$facid." not null. We do nothing.");
} }
// Regenerate documents of invoices
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{
$outputlangs = $langs;
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $invoice->thirdparty->default_lang;
if (! empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}
$ret = $invoice->fetch($facid); // Reload to get new records
$result = $invoice->generateDocument($invoice->modelpdf, $outputlangs);
if ($result < 0) {
setEventMessages($invoice->error, $invoice->errors, 'errors');
$error++;
}
}
} }
else else
{ {
dol_syslog('Paiement::Create Erreur INSERT dans paiement_facture '.$facid); $this->error=$this->db->lasterror();
$error++; $error++;
} }
} }
else else
{ {
dol_syslog('PaiementFourn::Create Montant non numerique',LOG_ERR); dol_syslog(get_class($this).'::Create Amount line '.$key.' not a number. We discard it.');
} }
} }