diff --git a/include/class/anc_operation.class.php b/include/class/anc_operation.class.php index 49ff5aa44..70dc8f0e8 100644 --- a/include/class/anc_operation.class.php +++ b/include/class/anc_operation.class.php @@ -717,16 +717,15 @@ EOF; return $result; } /** - * Save the ND VAT with prorata + * @brief Save the ND VAT in ANL, and distribute the amount among ANL Axis proportionnaly to the source * - * @param $p_array usually $_POST - * @param $p_item item of the form - * @param $p_j_id jrnx.j_id concerned writing - * @param $p_nd amount nd vat + * @param $p_array array usually $_POST + * @param $p_item int nb of the item of the form + * @param $p_j_id int jrnx.j_id concerned writing + * @param $p_nd float amount nd vat * @see Anc_Operation::save_form_plan_vat_nd - * @return type */ - function save_form_plan_vat_nd($p_array,$p_item,$p_j_id,$p_nd) + function save_form_plan_vat_nd($p_array,$p_item,$p_j_id,$p_nd):void { bcscale(4); extract($p_array, EXTR_SKIP); @@ -787,12 +786,12 @@ EOF; { $tot=bcadd($tot,$a_Anc_Operation[$i]->oa_amount); } -// utilité ??? -// if ( $tot != $p_nd && count($a_Anc_Operation) > 0 ) -// { -// $diff= bcsub($tot, $p_nd); -// $a_Anc_Operation[0]->oa_amount=bcsub($a_Anc_Operation[0]->oa_amount,$diff); -// } + // security : if tot != nd so the amount is reduced by the difference between computed and max + if ( $tot != $p_nd && count($a_Anc_Operation) > 0 ) + { + $diff= bcsub($tot, $p_nd); + $a_Anc_Operation[0]->oa_amount=bcsub($a_Anc_Operation[0]->oa_amount,$diff); + } for ($i=0;$i<$nb_op;$i++) { $a_Anc_Operation[$i]->add();