NEW: deposit payment terms: set deposit percentage in proposals/orders + get from origin document or company
This commit is contained in:
parent
4d6c1d892b
commit
b0aa502ed4
@ -397,6 +397,7 @@ if (empty($reshook)) {
|
||||
$object->warehouse_id = GETPOST('warehouse_id', 'int');
|
||||
$object->duree_validite = $duration;
|
||||
$object->cond_reglement_id = GETPOST('cond_reglement_id');
|
||||
$object->deposit_percent = GETPOST('cond_reglement_id_deposit_percent', 'int');
|
||||
$object->mode_reglement_id = GETPOST('mode_reglement_id');
|
||||
$object->fk_account = GETPOST('fk_account', 'int');
|
||||
$object->remise_percent = price2num(GETPOST('remise_percent'), '', 2);
|
||||
@ -429,6 +430,7 @@ if (empty($reshook)) {
|
||||
$object->warehouse_id = GETPOST('warehouse_id', 'int');
|
||||
$object->duree_validite = price2num(GETPOST('duree_validite', 'alpha'));
|
||||
$object->cond_reglement_id = GETPOST('cond_reglement_id', 'int');
|
||||
$object->deposit_percent = GETPOST('cond_reglement_id_deposit_percent', 'int');
|
||||
$object->mode_reglement_id = GETPOST('mode_reglement_id', 'int');
|
||||
$object->fk_account = GETPOST('fk_account', 'int');
|
||||
$object->contact_id = GETPOST('contactid', 'int');
|
||||
@ -1358,7 +1360,7 @@ if (empty($reshook)) {
|
||||
$result = $object->set_demand_reason($user, GETPOST('demand_reason_id', 'int'));
|
||||
} elseif ($action == 'setconditions' && $usercancreate) {
|
||||
// Terms of payment
|
||||
$result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int'));
|
||||
$result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int'), GETPOST('cond_reglement_id_deposit_percent', 'int'));
|
||||
} elseif ($action == 'setremisepercent' && $usercancreate) {
|
||||
$result = $object->set_remise_percent($user, price2num(GETPOST('remise_percent'), '', 2));
|
||||
} elseif ($action == 'setremiseabsolue' && $usercancreate) {
|
||||
@ -1647,7 +1649,7 @@ if ($action == 'create') {
|
||||
// Terms of payment
|
||||
print '<tr><td class="nowrap">'.$langs->trans('PaymentConditionsShort').'</td><td>';
|
||||
print img_picto('', 'paiment');
|
||||
$form->select_conditions_paiements((GETPOSTISSET('cond_reglement_id') ? GETPOST('cond_reglement_id', 'int') : $soc->cond_reglement_id), 'cond_reglement_id', -1, 1);
|
||||
$form->select_conditions_paiements((GETPOSTISSET('cond_reglement_id') ? GETPOST('cond_reglement_id', 'int') : $soc->cond_reglement_id), 'cond_reglement_id', -1, 1, 0, '', (GETPOSTISSET('cond_reglement_id_deposit_percent') ? GETPOST('cond_reglement_id_deposit_percent', 'int') : $soc->deposit_percent));
|
||||
print '</td></tr>';
|
||||
|
||||
// Mode of payment
|
||||
@ -2155,9 +2157,9 @@ if ($action == 'create') {
|
||||
print '</tr></table>';
|
||||
print '</td><td class="valuefield">';
|
||||
if ($object->statut == Propal::STATUS_DRAFT && $action == 'editconditions' && $usercancreate) {
|
||||
$form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'cond_reglement_id');
|
||||
$form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'cond_reglement_id', 0, $object->deposit_percent);
|
||||
} else {
|
||||
$form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'none');
|
||||
$form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'none', 0, $object->deposit_percent);
|
||||
}
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
@ -268,6 +268,7 @@ if (empty($reshook)) {
|
||||
$object->ref_client = GETPOST('ref_client', 'alpha');
|
||||
$object->model_pdf = GETPOST('model');
|
||||
$object->cond_reglement_id = GETPOST('cond_reglement_id');
|
||||
$object->deposit_percent = GETPOST('cond_reglement_id_deposit_percent', 'int');
|
||||
$object->mode_reglement_id = GETPOST('mode_reglement_id');
|
||||
$object->fk_account = GETPOST('fk_account', 'int');
|
||||
$object->availability_id = GETPOST('availability_id');
|
||||
@ -548,7 +549,7 @@ if (empty($reshook)) {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
} elseif ($action == 'setmode' && $usercancreate) {
|
||||
$result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int'));
|
||||
$result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int'), GETPOST('mode_reglement_id_deposit_percent', 'int'));
|
||||
if ($result < 0) {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
@ -569,7 +570,7 @@ if (empty($reshook)) {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
} elseif ($action == 'setconditions' && $usercancreate) {
|
||||
$result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int'));
|
||||
$result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int'), GETPOST('cond_reglement_id_deposit_percent', 'int'));
|
||||
if ($result < 0) {
|
||||
dol_print_error($db, $object->error);
|
||||
} else {
|
||||
@ -1437,6 +1438,10 @@ if ($action == 'create' && $usercancreate) {
|
||||
|
||||
$currency_code = $conf->currency;
|
||||
|
||||
$cond_reglement_id = GETPOST('cond_reglement_id', 'int');
|
||||
$deposit_percent = GETPOST('cond_reglement_id_deposit_percent', 'int');
|
||||
$mode_reglement_id = GETPOST('mode_reglement_id', 'int');
|
||||
|
||||
if (!empty($origin) && !empty($originid)) {
|
||||
// Parse element/subelement (ex: project_task)
|
||||
$element = $subelement = $origin;
|
||||
@ -1452,6 +1457,9 @@ if ($action == 'create' && $usercancreate) {
|
||||
if (!$cond_reglement_id) {
|
||||
$cond_reglement_id = $soc->cond_reglement_id;
|
||||
}
|
||||
if (!$deposit_percent) {
|
||||
$deposit_percent = $soc->deposit_percent;
|
||||
}
|
||||
if (!$mode_reglement_id) {
|
||||
$mode_reglement_id = $soc->mode_reglement_id;
|
||||
}
|
||||
@ -1492,6 +1500,7 @@ if ($action == 'create' && $usercancreate) {
|
||||
|
||||
$soc = $objectsrc->thirdparty;
|
||||
$cond_reglement_id = (!empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 0)); // TODO maybe add default value option
|
||||
$deposit_percent = (!empty($objectsrc->deposit_percent) ? $objectsrc->deposit_percent : (!empty($soc->deposit_percent) ? $soc->deposit_percent : null));
|
||||
$mode_reglement_id = (!empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0));
|
||||
$fk_account = (!empty($objectsrc->fk_account) ? $objectsrc->fk_account : (!empty($soc->fk_account) ? $soc->fk_account : 0));
|
||||
$availability_id = (!empty($objectsrc->availability_id) ? $objectsrc->availability_id : (!empty($soc->availability_id) ? $soc->availability_id : 0));
|
||||
@ -1524,6 +1533,7 @@ if ($action == 'create' && $usercancreate) {
|
||||
}
|
||||
} else {
|
||||
$cond_reglement_id = $soc->cond_reglement_id;
|
||||
$deposit_percent = $soc->deposit_percent;
|
||||
$mode_reglement_id = $soc->mode_reglement_id;
|
||||
$fk_account = $soc->fk_account;
|
||||
$availability_id = $soc->availability_id;
|
||||
@ -1649,7 +1659,7 @@ if ($action == 'create' && $usercancreate) {
|
||||
// Terms of the settlement
|
||||
print '<tr><td class="nowrap">'.$langs->trans('PaymentConditionsShort').'</td><td>';
|
||||
print img_picto('', 'paiment');
|
||||
$form->select_conditions_paiements($cond_reglement_id, 'cond_reglement_id', - 1, 1);
|
||||
$form->select_conditions_paiements($cond_reglement_id, 'cond_reglement_id', - 1, 1, 0, '', $deposit_percent);
|
||||
print '</td></tr>';
|
||||
|
||||
// Mode de reglement
|
||||
@ -2215,9 +2225,9 @@ if ($action == 'create' && $usercancreate) {
|
||||
print $form->editfieldkey("PaymentConditionsShort", 'conditions', '', $object, $editenable);
|
||||
print '</td><td class="valuefield">';
|
||||
if ($action == 'editconditions') {
|
||||
$form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'cond_reglement_id', 1);
|
||||
$form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'cond_reglement_id', 1, $object->deposit_percent);
|
||||
} else {
|
||||
$form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'none', 1);
|
||||
$form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'none', 1, $object->deposit_percent);
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
|
||||
@ -2554,7 +2554,7 @@ abstract class CommonObject
|
||||
*/
|
||||
public function setPaymentTerms($id, $deposit_percent = null)
|
||||
{
|
||||
dol_syslog(get_class($this).'::setPaymentTerms('.$id.')');
|
||||
dol_syslog(get_class($this).'::setPaymentTerms('.$id.', '.var_export($deposit_percent, true).')');
|
||||
if ($this->statut >= 0 || $this->element == 'societe') {
|
||||
// TODO uniformize field name
|
||||
$fieldname = 'fk_cond_reglement';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user