mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
FIX : VAT rate recalculation
set a checkbox on clone formquestion
This commit is contained in:
parent
629689b13f
commit
cec9725ced
|
|
@ -207,8 +207,12 @@ if (empty($reshook)) {
|
|||
$objectutil = dol_clone($object, 1); // To avoid to denaturate loaded object when setting some properties for clone. We use native clone to keep this->db valid.
|
||||
|
||||
$objectutil->date = dol_mktime(12, 0, 0, GETPOST('newdatemonth', 'int'), GETPOST('newdateday', 'int'), GETPOST('newdateyear', 'int'));
|
||||
|
||||
$objectutil->socid = $socid;
|
||||
$result = $objectutil->createFromClone($user, $id);
|
||||
|
||||
$targetThirdPartyVat = GETPOSTISSET('targetThirdPartyVat');
|
||||
$result = $objectutil->createFromClone($user, $id, $targetThirdPartyVat);
|
||||
|
||||
if ($result > 0) {
|
||||
header("Location: ".$_SERVER['PHP_SELF'].'?facid='.$result);
|
||||
exit();
|
||||
|
|
@ -4174,9 +4178,10 @@ if ($action == 'create') {
|
|||
// Create an array for form
|
||||
$formquestion = array(
|
||||
array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company($object->socid, 'socid', '(s.client=1 OR s.client=2 OR s.client=3)', 1)),
|
||||
array('type' => 'date', 'name' => 'newdate', 'label' => $langs->trans("Date"), 'value' => dol_now())
|
||||
array('type' => 'date', 'name' => 'newdate', 'label' => $langs->trans("Date"), 'value' => dol_now()),
|
||||
array('type' => 'checkbox', 'name' => 'targetThirdPartyVat', 'label' => $langs->trans("targetThirdPartyVat"), 'value' => 0 ),
|
||||
);
|
||||
// Ask confirmatio to clone
|
||||
// Ask confirmation to clone
|
||||
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?facid='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneInvoice', $object->ref), 'confirm_clone', $formquestion, 'yes', 1, 250);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1192,7 +1192,7 @@ class Facture extends CommonInvoice
|
|||
* @param int $fromid Id of object to clone
|
||||
* @return int New id of clone
|
||||
*/
|
||||
public function createFromClone(User $user, $fromid = 0)
|
||||
public function createFromClone(User $user, $fromid = 0, $targetThirdPartyVat = false)
|
||||
{
|
||||
global $conf, $hookmanager;
|
||||
|
||||
|
|
@ -1277,6 +1277,14 @@ class Facture extends CommonInvoice
|
|||
|
||||
$object->lines[$i]->ref_ext = ''; // Do not clone ref_ext
|
||||
}
|
||||
// we have a different thirdparty selected and we checked $targetThirdPartyVat
|
||||
if ($objFrom->socid != $object->socid && $targetThirdPartyVat) {
|
||||
global $mysoc;
|
||||
|
||||
foreach ($object->lines as $line) {
|
||||
$line->tva_tx = get_default_tva($mysoc, $objsoc, $line->fk_product);
|
||||
}
|
||||
}
|
||||
|
||||
// Create clone
|
||||
$object->context['createfromclone'] = 'createfromclone';
|
||||
|
|
|
|||
|
|
@ -609,4 +609,5 @@ NoPaymentAvailable=No payment available for %s
|
|||
PaymentRegisteredAndInvoiceSetToPaid=Payment registered and invoice %s set to paid
|
||||
SendEmailsRemindersOnInvoiceDueDate=Send reminder by email for unpaid invoices
|
||||
MakePaymentAndClassifyPayed=Record payment
|
||||
BulkPaymentNotPossibleForInvoice=Bulk payment is not possible for invoice %s (bad type or status)
|
||||
BulkPaymentNotPossibleForInvoice=Bulk payment is not possible for invoice %s (bad type or status)
|
||||
targetThirdPartyVat=Modify the VAT rate to use the default rate depending on the new thirdparty
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user