New : option to allow credit note without related invoice

This commit is contained in:
Maxime Kohlhaas 2015-07-08 14:32:57 +02:00
parent b8b337ff52
commit 9f9ba12802
4 changed files with 52 additions and 18 deletions

View File

@ -280,6 +280,24 @@ if ($action == 'set_FAC_AUTO_FILLJS')
}
}
if ($action == 'set_INVOICE_CREDIT_NOTE_STANDALONE')
{
$freetext = GETPOST('INVOICE_CREDIT_NOTE_STANDALONE'); // No alpha here, we want exact string
$res = dolibarr_set_const($db, "INVOICE_CREDIT_NOTE_STANDALONE",$freetext,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
if (! $error)
{
setEventMessage($langs->trans("SetupSaved"));
}
else
{
setEventMessage($langs->trans("Error"),'errors');
}
}
/*
* View
@ -750,6 +768,34 @@ print '<input type="submit" class="button" value="'.$langs->trans("Modify").'" /
print "</td></tr>\n";
print '</form>';
// Add js auto fill amount on paiement form
$var=! $var;
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'" />';
print '<input type="hidden" name="action" value="set_FAC_AUTO_FILLJS" />';
print '<tr '.$bc[$var].'><td>';
print $langs->trans("JSOnPaimentBill");
print '</td><td width="60" align="center">';
print $form->selectyesno("FAC_AUTO_FILLJS",$conf->global->FAC_AUTO_FILLJS,1);
print '</td><td align="right">';
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'" />';
print "</td></tr>\n";
print '</form>';
// Allow to create credit note not related to an invoice
$var=! $var;
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'" />';
print '<input type="hidden" name="action" value="set_INVOICE_CREDIT_NOTE_STANDALONE" />';
print '<tr '.$bc[$var].'><td>';
print $langs->trans("AllowCreditNoteWithoutRelatedInvoice");
print '</td><td width="60" align="center">';
print $form->selectyesno("INVOICE_CREDIT_NOTE_STANDALONE",$conf->global->INVOICE_CREDIT_NOTE_STANDALONE,1);
print '</td><td align="right">';
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'" />';
print "</td></tr>\n";
print '</form>';
$var=! $var;
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'" />';
@ -774,20 +820,6 @@ print '<input type="submit" class="button" value="'.$langs->trans("Modify").'" /
print "</td></tr>\n";
print '</form>';
// Add js auto fill amount on paiement form
$var=! $var;
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'" />';
print '<input type="hidden" name="action" value="set_FAC_AUTO_FILLJS" />';
print '<tr '.$bc[$var].'><td>';
print $langs->trans("JSOnPaimentBill");
print '</td><td width="60" align="center">';
print $form->selectyesno("FAC_AUTO_FILLJS",$conf->global->FAC_AUTO_FILLJS,1);
print '</td><td align="right">';
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'" />';
print "</td></tr>\n";
print '</form>';
print '</table>';

View File

@ -706,7 +706,8 @@ if (empty($reshook))
// Credit note invoice
if ($_POST['type'] == Facture::TYPE_CREDIT_NOTE)
{
if (! ($_POST['fac_avoir'] > 0))
$sourceinvoice = GETPOST('fac_avoir');
if (! ($sourceinvoice > 0) && empty($conf->global->INVOICE_CREDIT_NOTE_STANDALONE))
{
$error ++;
setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CorrectInvoice")), 'errors');
@ -739,7 +740,7 @@ if (empty($reshook))
$object->location_incoterms = GETPOST('location_incoterms', 'alpha');
// Proprietes particulieres a facture avoir
$object->fk_facture_source = $_POST['fac_avoir'];
$object->fk_facture_source = $sourceinvoice > 0 ? $sourceinvoice : '';
$object->type = Facture::TYPE_CREDIT_NOTE;
$id = $object->create($user);
@ -2878,7 +2879,7 @@ else if ($id > 0 || ! empty($ref))
$facreplaced->fetch($object->fk_facture_source);
print ' (' . $langs->transnoentities("ReplaceInvoice", $facreplaced->getNomUrl(1)) . ')';
}
if ($object->type == Facture::TYPE_CREDIT_NOTE) {
if ($object->type == Facture::TYPE_CREDIT_NOTE && !empty($object->fk_facture_source)) {
$facusing = new Facture($db);
$facusing->fetch($object->fk_facture_source);
print ' (' . $langs->transnoentities("CorrectInvoice", $facusing->getNomUrl(1)) . ')';

View File

@ -1500,7 +1500,7 @@ class pdf_crabe extends ModelePDFFactures
$pdf->SetTextColor(0,0,60);
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ReplacementInvoice").' : '.$outputlangs->convToOutputCharset($objectreplaced->ref), '', 'R');
}
if ($object->type == 2)
if ($object->type == 2 && !empty($object->fk_facture_source))
{
$objectreplaced=new Facture($this->db);
$objectreplaced->fetch($object->fk_facture_source);

View File

@ -1165,6 +1165,7 @@ CreditNotePDFModules=Credit note document models
CreditNote=Credit note
CreditNotes=Credit notes
ForceInvoiceDate=Force invoice date to validation date
AllowCreditNoteWithoutRelatedInvoice=Allow to create credit note without a related invoice
DisableRepeatable=Disable repeatable invoices
SuggestedPaymentModesIfNotDefinedInInvoice=Suggested payments mode on invoice by default if not defined for invoice
EnableEditDeleteValidInvoice=Enable the possibility to edit/delete valid invoice with no payment