diff --git a/htdocs/comm/remx.php b/htdocs/comm/remx.php index ad6c1f33a97..177b4456912 100644 --- a/htdocs/comm/remx.php +++ b/htdocs/comm/remx.php @@ -276,12 +276,12 @@ if ($socid > 0) dol_print_error($db); } - print ''.$langs->trans("CustomerAbsoluteDiscountAllUsers").''; // TODO adapt text + print ''.$langs->trans("CustomerAbsoluteDiscountAllUsers").''; print ''.$remise_all.' '.$langs->trans("Currency".$conf->currency).' '.$langs->trans("HT").''; if (! empty($user->fk_soc)) // No need to show this for external users { - print ''.$langs->trans("CustomerAbsoluteDiscountMy").''; // TODO adapt text + print ''.$langs->trans("CustomerAbsoluteDiscountMy").''; print ''.$remise_user.' '.$langs->trans("Currency".$conf->currency).' '.$langs->trans("HT").''; } @@ -307,12 +307,12 @@ if ($socid > 0) dol_print_error($db); } - print ''.$langs->trans("CustomerAbsoluteDiscountAllUsers").''; // TODO adapt text + print ''.$langs->trans("SupplierAbsoluteDiscountAllUsers").''; print ''.$remise_all.' '.$langs->trans("Currency".$conf->currency).' '.$langs->trans("HT").''; if (! empty($user->fk_soc)) // No need to show this for external users { - print ''.$langs->trans("CustomerAbsoluteDiscountMy").''; // TODO adapt text + print ''.$langs->trans("SupplierAbsoluteDiscountMy").''; print ''.$remise_user.' '.$langs->trans("Currency".$conf->currency).' '.$langs->trans("HT").''; } } @@ -330,9 +330,10 @@ if ($socid > 0) print '
'; print ''; if($conf->global->MAIN_FEATURES_LEVEL > 0) { - print ''; - print ''; + print ''; + print ''; } print ''; print '
'.$langs->trans('DiscountType').' '; - print '
'.$langs->trans('DiscountType').' '; + print ' '; + print '
'.$langs->trans("AmountHT").''; @@ -401,7 +402,7 @@ if ($socid > 0) if ($resql) { if($conf->global->MAIN_FEATURES_LEVEL > 0) { - print load_fiche_titre($langs->trans("CustomerDiscounts"), '', ''); // TODO translate + print load_fiche_titre($langs->trans("CustomerDiscounts"), '', ''); } print ''; print ''; @@ -536,7 +537,7 @@ if ($socid > 0) $resql=$db->query($sql); if ($resql) { - print load_fiche_titre($langs->trans("SupplierDiscounts"), '', ''); // TODO translate + print load_fiche_titre($langs->trans("SupplierDiscounts"), '', ''); print '
'; print ''; print ''; // Need 120+ for format with AM/PM @@ -585,7 +586,7 @@ if ($socid > 0) $facturefournstatic->id=$obj->fk_invoice_supplier_source; $facturefournstatic->ref=$obj->ref; $facturefournstatic->type=$obj->type; - print preg_replace('/\(EXCESS PAID\)/',$langs->trans("ExcessPaid"),$obj->description).' '.$facturefournstatic->getNomURl(1); // TODO translate ExcessPaid + print preg_replace('/\(EXCESS PAID\)/',$langs->trans("ExcessPaid"),$obj->description).' '.$facturefournstatic->getNomURl(1); print ''; } else @@ -705,7 +706,7 @@ if ($socid > 0) if ($resql2) { if($conf->global->MAIN_FEATURES_LEVEL > 0) { - print load_fiche_titre($langs->trans("CustomerDiscounts"), '', ''); // TODO translate + print load_fiche_titre($langs->trans("CustomerDiscounts"), '', ''); } print '
'.$langs->trans("Date").'
'; print ''; @@ -855,7 +856,7 @@ if ($socid > 0) if ($resql) $resql2=$db->query($sql2); if ($resql2) { - print load_fiche_titre($langs->trans("SupplierDiscounts"), '', ''); // TODO translate + print load_fiche_titre($langs->trans("SupplierDiscounts"), '', ''); print '
'; print ''; print ''; // Need 120+ for format with AM/PM @@ -934,12 +935,12 @@ if ($socid > 0) print $obj->description; print ''; } - print ''; // TODO adapt to supplier invoice of use getNomUrl + print ''; print ''; print ''; print ''; print ''; print ''; print ''; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index e45acea7675..5abf5e3a0e1 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3963,7 +3963,13 @@ abstract class CommonObject $discount=new DiscountAbsolute($this->db); $discount->fetch($line->fk_remise_except); $this->tpl['description'] = $langs->transnoentities("DiscountFromExcessReceived",$discount->getNomUrl(0)); - } // TODO handle (EXCESS PAID) + } + elseif ($line->desc == '(EXCESS PAID)') + { + $discount=new DiscountAbsolute($this->db); + $discount->fetch($line->fk_remise_except); + $this->tpl['description'] = $langs->transnoentities("DiscountFromExcessPaid",$discount->getNomUrl(0)); + } else { $this->tpl['description'] = dol_trunc($line->desc,60); diff --git a/htdocs/core/class/discount.class.php b/htdocs/core/class/discount.class.php index b62e35c183e..b71d84130a1 100644 --- a/htdocs/core/class/discount.class.php +++ b/htdocs/core/class/discount.class.php @@ -46,6 +46,7 @@ class DiscountAbsolute public $fk_facture; // Id invoice when a discount line is used into an invoice (for credit note) public $fk_facture_source; // Id facture avoir a l'origine de la remise public $ref_facture_source; // Ref facture avoir a l'origine de la remise + public $ref_invoive_supplier_source; /** * Constructor @@ -568,10 +569,11 @@ class DiscountAbsolute $result=''; if ($option == 'invoice') { + $facid=! empty($this->discount_type)?$this->fk_invoice_supplier_source:$this->fk_facture_source; $label=$langs->trans("ShowDiscount").': '.$this->ref_facture_source; - $link = ''; + $link = ''; $linkend=''; - $ref=$this->ref_facture_source; + $ref=! empty($this->discount_type)?$this->ref_invoice_supplier_source:$this->ref_facture_source; $picto='bill'; } if ($option == 'discount') { diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index e6ab69dff95..f65a3bec36c 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1236,7 +1236,7 @@ class Form if (preg_match('/\(CREDIT_NOTE\)/', $desc)) $desc=preg_replace('/\(CREDIT_NOTE\)/', $langs->trans("CreditNote"), $desc); if (preg_match('/\(DEPOSIT\)/', $desc)) $desc=preg_replace('/\(DEPOSIT\)/', $langs->trans("Deposit"), $desc); if (preg_match('/\(EXCESS RECEIVED\)/', $desc)) $desc=preg_replace('/\(EXCESS RECEIVED\)/', $langs->trans("ExcessReceived"), $desc); - // TODO handle (EXCESS PAID) + if (preg_match('/\(EXCESS PAID\)/', $desc)) $desc=preg_replace('/\(EXCESS PAID\)/', $langs->trans("ExcessPaid"), $desc); $selectstring=''; if ($selected > 0 && $selected == $obj->rowid) $selectstring=' selected'; diff --git a/htdocs/core/lib/doc.lib.php b/htdocs/core/lib/doc.lib.php index 20eaa9a71f7..447c7c2149e 100644 --- a/htdocs/core/lib/doc.lib.php +++ b/htdocs/core/lib/doc.lib.php @@ -73,13 +73,15 @@ function doc_getlinedesc($line,$outputlangs,$hideref=0,$hidedesc=0,$issupplierli { $discount=new DiscountAbsolute($db); $discount->fetch($line->fk_remise_except); - $libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromCreditNote",$discount->ref_facture_source); + $sourceref=!empty($discount_type)?$discount->ref_invoive_supplier_source:$discount->ref_facture_source; + $libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromCreditNote",$sourceref); } elseif ($desc == '(DEPOSIT)' && $line->fk_remise_except) { $discount=new DiscountAbsolute($db); $discount->fetch($line->fk_remise_except); $libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromDeposit",$discount->ref_facture_source); + $sourceref=!empty($discount_type)?$discount->ref_invoive_supplier_source:$discount->ref_facture_source; // Add date of deposit if (! empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) $libelleproduitservice.=' ('.dol_print_date($discount->datec,'day','',$outputlangs).')'; } @@ -88,7 +90,13 @@ function doc_getlinedesc($line,$outputlangs,$hideref=0,$hidedesc=0,$issupplierli $discount=new DiscountAbsolute($db); $discount->fetch($line->fk_remise_except); $libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromExcessReceived",$discount->ref_facture_source); - } // TODO handle (EXCESS PAID) + } + elseif ($desc == '(EXCESS PAID)' && $line->fk_remise_except) + { + $discount=new DiscountAbsolute($db); + $discount->fetch($line->fk_remise_except); + $libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromExcessPaid",$discount->ref_invoice_supplier_source); + } else { if ($idprod) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 0fb649506cb..31fcc519051 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1236,13 +1236,15 @@ function pdf_getlinedesc($object,$i,$outputlangs,$hideref=0,$hidedesc=0,$issuppl { $discount=new DiscountAbsolute($db); $discount->fetch($object->lines[$i]->fk_remise_except); - $libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromCreditNote",$discount->ref_facture_source); + $sourceref=!empty($discount->discount_type)?$discount->ref_invoive_supplier_source:$discount->ref_facture_source; + $libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromCreditNote",$sourceref); } elseif ($desc == '(DEPOSIT)' && $object->lines[$i]->fk_remise_except) { $discount=new DiscountAbsolute($db); $discount->fetch($object->lines[$i]->fk_remise_except); - $libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromDeposit",$discount->ref_facture_source); + $sourceref=!empty($discount->discount_type)?$discount->ref_invoive_supplier_source:$discount->ref_facture_source; + $libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromDeposit",$sourceref); // Add date of deposit if (! empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) echo ' ('.dol_print_date($discount->datec,'day','',$outputlangs).')'; } @@ -1251,7 +1253,13 @@ function pdf_getlinedesc($object,$i,$outputlangs,$hideref=0,$hidedesc=0,$issuppl $discount=new DiscountAbsolute($db); $discount->fetch($object->lines[$i]->fk_remise_except); $libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromExcessReceived",$discount->ref_facture_source); - } // TODO handle (EXCESS PAID) + } + elseif ($desc == '(EXCESS PAID)' && $object->lines[$i]->fk_remise_except) + { + $discount=new DiscountAbsolute($db); + $discount->fetch($object->lines[$i]->fk_remise_except); + $libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromExcessPaid",$discount->ref_invoice_supplier_source); + } else { if ($idprod) diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index bc5d950ab8e..6371e289207 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -72,7 +72,8 @@ if (empty($outputalsopricetotalwithtax)) $outputalsopricetotalwithtax=0; $txt=''; print img_object($langs->trans("ShowReduc"),'reduc').' '; if ($line->description == '(DEPOSIT)') $txt=$langs->trans("Deposit"); - elseif ($line->description == '(EXCESS RECEIVED)') $txt=$langs->trans("ExcessReceived"); // TODO handle (EXCESS PAID) + elseif ($line->description == '(EXCESS RECEIVED)') $txt=$langs->trans("ExcessReceived"); + elseif ($line->description == '(EXCESS PAID)') $txt=$langs->trans("ExcessPaid"); //else $txt=$langs->trans("Discount"); print $txt; ?> @@ -100,7 +101,13 @@ if (empty($outputalsopricetotalwithtax)) $outputalsopricetotalwithtax=0; $discount=new DiscountAbsolute($this->db); $discount->fetch($line->fk_remise_except); echo ($txt?' - ':'').$langs->transnoentities("DiscountFromExcessReceived",$discount->getNomUrl(0)); - } // TODO handle (EXCESS PAID) + } + elseif ($line->description == '(EXCESS PAID)' && $objp->fk_remise_except > 0) + { + $discount=new DiscountAbsolute($this->db); + $discount->fetch($line->fk_remise_except); + echo ($txt?' - ':'').$langs->transnoentities("DiscountFromExcessPaid",$discount->getNomUrl(0)); + } else { echo ($txt?' - ':'').dol_htmlentitiesbr($line->description); diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 3fe59d66ff7..4ebab7d0bc4 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1049,6 +1049,8 @@ class FactureFournisseur extends CommonInvoice } } + // TODO Delete related discounts + if (! $error) { // Delete linked object diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 255c917b6a9..ca29e7299a6 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -2167,10 +2167,10 @@ else // Confirmation de la conversion de l'avoir en reduc if ($action == 'converttoreduc') { - if($object->type == FactureFournisseur::TYPE_STANDARD) $type_fac = 'ExcessReceived'; // TODO translation trop-perçu => trop-payé + if($object->type == FactureFournisseur::TYPE_STANDARD) $type_fac = 'ExcessPaid'; elseif($object->type == FactureFournisseur::TYPE_CREDIT_NOTE) $type_fac = 'CreditNote'; elseif($object->type == FactureFournisseur::TYPE_DEPOSIT) $type_fac = 'Deposit'; - $text = $langs->trans('ConfirmConvertToReduc', strtolower($langs->transnoentities($type_fac))); // TODO translation client => fournisseur + $text = $langs->trans('ConfirmConvertToReducSupplier', strtolower($langs->transnoentities($type_fac))); $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $langs->trans('ConvertToReduc'), $text, 'confirm_converttoreduc', '', "yes", 2); } @@ -2872,7 +2872,7 @@ else print ' :'; print ''; print ''; $i ++; if ($invoice->type == FactureFournisseur::TYPE_CREDIT_NOTE) @@ -2929,7 +2929,7 @@ else if ($resteapayeraffiche >= 0) print $langs->trans('RemainderToPay'); else - print $langs->trans('ExcessReceived'); + print $langs->trans('ExcessPaid'); print ' :'; print ''; print ''; @@ -3113,7 +3113,7 @@ else // For standard invoice with excess paid if ($object->type == FactureFournisseur::TYPE_STANDARD && empty($object->paye) && ($object->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits) < 0 && $user->rights->fournisseur->facture->creer && empty($discount->id)) { - print ''; // TODO translation : trop-perçu => trop payé + print ''; } // For credit note if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE && $object->statut == 1 && $object->paye == 0 && $user->rights->fournisseur->facture->creer && $object->getSommePaiement() == 0) { diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index 668090129ff..62386adbe99 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -67,6 +67,7 @@ PaidBack=Paid back DeletePayment=Delete payment ConfirmDeletePayment=Are you sure you want to delete this payment? ConfirmConvertToReduc=Do you want to convert this %s into an absolute discount ?
The amount will so be saved among all discounts and could be used as a discount for a current or a future invoice for this customer. +ConfirmConvertToReducSupplier=Do you want to convert this %s into an absolute discount ?
The amount will so be saved among all discounts and could be used as a discount for a current or a future invoice for this supplier. SupplierPayments=Suppliers payments ReceivedPayments=Received payments ReceivedCustomersPayments=Payments received from customers @@ -91,7 +92,7 @@ PaymentAmount=Payment amount ValidatePayment=Validate payment PaymentHigherThanReminderToPay=Payment higher than reminder to pay HelpPaymentHigherThanReminderToPay=Attention, the payment amount of one or more bills is higher than the rest to pay.
Edit your entry, otherwise confirm and think about creating a credit note of the excess received for each overpaid invoices. -HelpPaymentHigherThanReminderToPaySupplier=Attention, the payment amount of one or more bills is higher than the rest to pay.
Edit your entry, otherwise confirm. +HelpPaymentHigherThanReminderToPaySupplier=Attention, the payment amount of one or more bills is higher than the rest to pay.
Edit your entry, otherwise confirm and think about creating a credit note of the excess paid for each overpaid invoice. ClassifyPaid=Classify 'Paid' ClassifyPaidPartially=Classify 'Paid partially' ClassifyCanceled=Classify 'Abandoned' @@ -110,6 +111,7 @@ DoPayment=Enter payment DoPaymentBack=Enter refund ConvertToReduc=Convert into future discount ConvertExcessReceivedToReduc=Convert excess received into future discount +ConvertExcessPaidToReduc=Convert excess paid into future discount EnterPaymentReceivedFromCustomer=Enter payment received from customer EnterPaymentDueToCustomer=Make payment due to customer DisabledBecauseRemainderToPayIsZero=Disabled because remaining unpaid is zero @@ -220,6 +222,7 @@ RemainderToPayBack=Remaining amount to refund Rest=Pending AmountExpected=Amount claimed ExcessReceived=Excess received +ExcessPaid=Excess paid EscompteOffered=Discount offered (payment before term) EscompteOfferedShort=Discount SendBillRef=Submission of invoice %s @@ -284,15 +287,19 @@ Deposits=Down payments DiscountFromCreditNote=Discount from credit note %s DiscountFromDeposit=Down payments from invoice %s DiscountFromExcessReceived=Payments from excess received of invoice %s +DiscountFromExcessPaid=Payments from excess paid of invoice %s AbsoluteDiscountUse=This kind of credit can be used on invoice before its validation CreditNoteDepositUse=Invoice must be validated to use this kind of credits NewGlobalDiscount=New absolute discount NewRelativeDiscount=New relative discount +DiscountType=Discount type NoteReason=Note/Reason ReasonDiscount=Reason DiscountOfferedBy=Granted by DiscountStillRemaining=Discounts available DiscountAlreadyCounted=Discounts already consumed +CustomerDiscounts=Customer discounts +SupplierDiscounts=Supplier discounts BillAddress=Bill address HelpEscompte=This discount is a discount granted to customer because its payment was made before term. HelpAbandonBadCustomer=This amount has been abandoned (customer said to be a bad customer) and is considered as an exceptional loose. diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang index 7d2b878c5cc..2eb1ba88e57 100644 --- a/htdocs/langs/en_US/companies.lang +++ b/htdocs/langs/en_US/companies.lang @@ -271,8 +271,10 @@ CompanyHasAbsoluteDiscount=This customer has discount available (credits notes o CompanyHasDownPaymentOrCommercialDiscount=This customer has discount available (commercial, down payments) for %s %s CompanyHasCreditNote=This customer still has credit notes for %s %s CompanyHasNoAbsoluteDiscount=This customer has no discount credit available -CustomerAbsoluteDiscountAllUsers=Absolute discounts (granted by all users) -CustomerAbsoluteDiscountMy=Absolute discounts (granted by yourself) +CustomerAbsoluteDiscountAllUsers=Absolute customer discounts (granted by all users) +CustomerAbsoluteDiscountMy=Absolute customer discounts (granted by yourself) +SupplierAbsoluteDiscountAllUsers=Absolute supplier discounts (granted by all users) +SupplierAbsoluteDiscountMy=Absolute supplier discounts (granted by yourself) DiscountNone=None Supplier=Supplier AddContact=Create contact diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php index 1420562da19..1a6a4be6199 100644 --- a/htdocs/societe/consumption.php +++ b/htdocs/societe/consumption.php @@ -490,7 +490,8 @@ if ($sql_select) $txt=''; print img_object($langs->trans("ShowReduc"),'reduc').' '; if ($objp->description == '(DEPOSIT)') $txt=$langs->trans("Deposit"); - elseif ($objp->description == '(EXCESS RECEIVED)') $txt=$langs->trans("ExcessReceived"); // TODO handle (EXCESS PAID) + elseif ($objp->description == '(EXCESS RECEIVED)') $txt=$langs->trans("ExcessReceived"); + elseif ($objp->description == '(EXCESS PAID)') $txt=$langs->trans("ExcessPaid"); //else $txt=$langs->trans("Discount"); print $txt; ?> @@ -510,6 +511,12 @@ if ($sql_select) $discount->fetch($objp->fk_remise_except); echo ($txt?' - ':'').$langs->transnoentities("DiscountFromExcessReceived",$discount->getNomUrl(0)); } + elseif ($objp->description == '(EXCESS PAID)' && $objp->fk_remise_except > 0) + { + $discount=new DiscountAbsolute($db); + $discount->fetch($objp->fk_remise_except); + echo ($txt?' - ':'').$langs->transnoentities("DiscountFromExcessPaid",$discount->getNomUrl(0)); + } elseif ($objp->description == '(DEPOSIT)' && $objp->fk_remise_except > 0) { $discount=new DiscountAbsolute($db); @@ -517,7 +524,7 @@ if ($sql_select) echo ($txt?' - ':'').$langs->transnoentities("DiscountFromDeposit",$discount->getNomUrl(0)); // Add date of deposit if (! empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) echo ' ('.dol_print_date($discount->datec).')'; - } // TODO handle (EXCESS PAID) + } else { echo ($txt?' - ':'').dol_htmlentitiesbr($objp->description);
'.$langs->trans("Date").''.img_object($langs->trans("ShowBill"),'bill').' '.$obj->facnumber.''.img_object($langs->trans("ShowBill"),'bill').' '.$obj->facnumber.''.price($obj->amount_ht).''.price2num($obj->tva_tx,'MU').'%'.price($obj->amount_ttc).''; - print ''.img_object($langs->trans("ShowUser"),'user').' '.$obj->login.''; // TODO getNomUrl ? + print ''.img_object($langs->trans("ShowUser"),'user').' '.$obj->login.''; print ' 
' . price($obj->amount_ttc) . ''; - print 'rowid . '">' . img_delete() . ''; // TODO unlinkdiscount + print 'rowid . '">' . img_delete() . ''; print '
' . price($resteapayeraffiche) . '