From b17c44c6653a49256640742364934e27b7b96ed1 Mon Sep 17 00:00:00 2001 From: wdammak <26695620+wdammak@users.noreply.github.com> Date: Sun, 16 Sep 2018 16:53:35 +0100 Subject: [PATCH 01/64] Update html.form.class.php Add the ability to sort products by category --- htdocs/core/class/html.form.class.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index df485ea0ede..dce2192d10d 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2013,6 +2013,7 @@ class Form $selectFields = " p.rowid, p.label, p.ref, p.description, p.barcode, p.fk_product_type, p.price, p.price_ttc, p.price_base_type, p.tva_tx, p.duration, p.fk_price_expression"; (count($warehouseStatusArray)) ? $selectFieldsGrouped = ", sum(ps.reel) as stock" : $selectFieldsGrouped = ", p.stock"; + $selectFields .= ", pcat.fk_categorie as categorie_product_id"; $sql = "SELECT "; $sql.= $selectFields . $selectFieldsGrouped; @@ -2063,6 +2064,8 @@ class Form if (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD)) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_attribute_combination pac ON pac.fk_product_child = p.rowid"; } + //Product category + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as pcat ON pcat.fk_product=p.rowid"; $sql.= ' WHERE p.entity IN ('.getEntity('product').')'; if (count($warehouseStatusArray)) @@ -2113,9 +2116,10 @@ class Form { $sql.= ' GROUP BY'.$selectFields; } - $sql.= $db->order("p.ref"); - $sql.= $db->plimit($limit, 0); - + + (! empty($conf->global->PRODUIT_SORT_BY_CATEGORY)) ? $sql.= $db->order("pcat.fk_categorie") : $sql.= $db->order("p.ref"); + $sql.= $db->plimit($limit, 0) + // Build output string dol_syslog(get_class($this)."::select_produits_list search product", LOG_DEBUG); $result=$this->db->query($sql); From 7d25311ce57a9835c8b1577a393acb603a539fab Mon Sep 17 00:00:00 2001 From: Abbes Bahfir Date: Mon, 8 Oct 2018 10:53:36 +0100 Subject: [PATCH 02/64] New : Link to create new element on linked fields --- htdocs/core/class/commonobject.class.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index a11cd3dd49e..0f07feda680 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5799,6 +5799,10 @@ abstract class CommonObject $param_list=array_keys($param['options']); // $param_list='ObjectName:classPath' $showempty=(($required && $default != '')?0:1); $out=$form->selectForForms($param_list[0], $keyprefix.$key.$keysuffix, $value, $showempty); + list($class,$classfile)=explode(':',$param_list[0]); + if(file_exists(dol_buildpath(dirname(dirname($classfile)).'/card.php')))$url_path=dol_buildpath(dirname(dirname($classfile)).'/card.php',1); + else $url_path=dol_buildpath(dirname(dirname($classfile)).'/'.$class.'_card.php',1); + $out.=''; } elseif ($type == 'password') { From f0d8a5da9aaae861136c541cc0fb73a7e694063a Mon Sep 17 00:00:00 2001 From: Abbes Bahfir Date: Mon, 8 Oct 2018 12:39:14 +0100 Subject: [PATCH 03/64] Fix: Reminder : TODO Add Javascript code to add input fields contents to new elements urls --- htdocs/core/class/commonobject.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 0f07feda680..3c4b19e1c22 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5803,6 +5803,7 @@ abstract class CommonObject if(file_exists(dol_buildpath(dirname(dirname($classfile)).'/card.php')))$url_path=dol_buildpath(dirname(dirname($classfile)).'/card.php',1); else $url_path=dol_buildpath(dirname(dirname($classfile)).'/'.$class.'_card.php',1); $out.=''; + //TODO Add Javascript code to add input fields contents to new elements urls } elseif ($type == 'password') { From ff92572d5645c61964e1502180bf6cb9357c6b15 Mon Sep 17 00:00:00 2001 From: atm-greg Date: Thu, 18 Oct 2018 17:03:49 +0200 Subject: [PATCH 04/64] add insurance amount on loan --- .../install/mysql/migration/8.0.0-9.0.0.sql | 3 ++ htdocs/install/mysql/tables/llx_loan.sql | 1 + htdocs/loan/card.php | 18 ++++++++- htdocs/loan/class/loan.class.php | 16 +++++--- htdocs/loan/createschedule.php | 37 ++++++++++++++----- htdocs/loan/payment/payment.php | 6 +-- 6 files changed, 62 insertions(+), 19 deletions(-) diff --git a/htdocs/install/mysql/migration/8.0.0-9.0.0.sql b/htdocs/install/mysql/migration/8.0.0-9.0.0.sql index 09908ac86f5..dd2b55e17ca 100644 --- a/htdocs/install/mysql/migration/8.0.0-9.0.0.sql +++ b/htdocs/install/mysql/migration/8.0.0-9.0.0.sql @@ -129,3 +129,6 @@ CREATE TABLE llx_takepos_floor_tables( UPDATE llx_c_payment_term SET decalage = nbjour, nbjour = 0 where decalage IS NULL AND type_cdr = 2; + +ALTER TABLE llx_loan ADD COLUMN insurance_amount double(24,8) DEFAULT 0; + diff --git a/htdocs/install/mysql/tables/llx_loan.sql b/htdocs/install/mysql/tables/llx_loan.sql index 7277fa85d47..1fca2af50ba 100644 --- a/htdocs/install/mysql/tables/llx_loan.sql +++ b/htdocs/install/mysql/tables/llx_loan.sql @@ -28,6 +28,7 @@ create table llx_loan fk_bank integer, capital double(24,8) default 0 NOT NULL, + insurance_amount double(24,8) default 0, datestart date, dateend date, nbterm real, diff --git a/htdocs/loan/card.php b/htdocs/loan/card.php index 25651ac842a..2a6708655a8 100644 --- a/htdocs/loan/card.php +++ b/htdocs/loan/card.php @@ -135,6 +135,7 @@ if (empty($reshook)) $object->note_private = GETPOST('note_private','none'); $object->note_public = GETPOST('note_public','none'); $object->fk_project = GETPOST('projectid','int'); + $object->insurance_amount = GETPOST('insurance_amount', 'int'); $accountancy_account_capital = GETPOST('accountancy_account_capital'); $accountancy_account_insurance = GETPOST('accountancy_account_insurance'); @@ -148,7 +149,7 @@ if (empty($reshook)) if ($id <= 0) { $error++; - setEventMessages($object->error, $object->errors, 'errors'); + setEventMessages($object->db->lastqueryerror, $object->errors, 'errors'); $action = 'create'; } } @@ -301,6 +302,9 @@ if ($action == 'create') // Rate print ''.$langs->trans("Rate").' %'; + // insurance amount + print ''.$langs->trans("Insurance").''; + // Project if (! empty($conf->projet->enabled)) { @@ -495,6 +499,18 @@ if ($id > 0) { print ''.$langs->trans("LoanCapital").''.price($object->capital,0,$outputlangs,1,-1,-1,$conf->currency).''; } + + // Insurance + if ($action == 'edit') + { + print ''.$langs->trans("Insurance").''; + print ''; + print ''; + } + else + { + print ''.$langs->trans("Insurance").''.price($object->insurance_amount,0,$outputlangs,1,-1,-1,$conf->currency).''; + } // Date start print ''.$langs->trans("DateStart").""; diff --git a/htdocs/loan/class/loan.class.php b/htdocs/loan/class/loan.class.php index 0e4542b1d20..3805704fbb9 100644 --- a/htdocs/loan/class/loan.class.php +++ b/htdocs/loan/class/loan.class.php @@ -66,6 +66,8 @@ class Loan extends CommonObject public $date_creation; public $date_modification; public $date_validation; + + public $insurance_amount; /** * @var int Bank ID @@ -106,7 +108,7 @@ class Loan extends CommonObject */ function fetch($id) { - $sql = "SELECT l.rowid, l.label, l.capital, l.datestart, l.dateend, l.nbterm, l.rate, l.note_private, l.note_public,"; + $sql = "SELECT l.rowid, l.label, l.capital, l.datestart, l.dateend, l.nbterm, l.rate, l.note_private, l.note_public, l.insurance_amount,"; $sql.= " l.paid, l.accountancy_account_capital, l.accountancy_account_insurance, l.accountancy_account_interest, l.fk_projet as fk_project"; $sql.= " FROM ".MAIN_DB_PREFIX."loan as l"; $sql.= " WHERE l.rowid = ".$id; @@ -129,6 +131,7 @@ class Loan extends CommonObject $this->rate = $obj->rate; $this->note_private = $obj->note_private; $this->note_public = $obj->note_public; + $this->insurance_amount = $obj->insurance_amount; $this->paid = $obj->paid; $this->account_capital = $obj->accountancy_account_capital; @@ -169,6 +172,8 @@ class Loan extends CommonObject // clean parameters $newcapital=price2num($this->capital,'MT'); + if (empty($this->insurance_amount)) $this->insurance_amount = 0; + $newinsuranceamount=price2num($this->insurance_amount, 'MT'); if (isset($this->note_private)) $this->note_private = trim($this->note_private); if (isset($this->note_public)) $this->note_public = trim($this->note_public); if (isset($this->account_capital)) $this->account_capital = trim($this->account_capital); @@ -205,7 +210,7 @@ class Loan extends CommonObject $sql = "INSERT INTO ".MAIN_DB_PREFIX."loan (label, fk_bank, capital, datestart, dateend, nbterm, rate, note_private, note_public,"; $sql.= " accountancy_account_capital, accountancy_account_insurance, accountancy_account_interest, entity,"; - $sql.= " datec, fk_projet, fk_user_author)"; + $sql.= " datec, fk_projet, fk_user_author, insurance_amount)"; $sql.= " VALUES ('".$this->db->escape($this->label)."',"; $sql.= " '".$this->db->escape($this->fk_bank)."',"; $sql.= " '".price2num($newcapital)."',"; @@ -221,7 +226,8 @@ class Loan extends CommonObject $sql.= " ".$conf->entity.","; $sql.= " '".$this->db->idate($now)."',"; $sql.= " ".(empty($this->fk_project)?'NULL':$this->fk_project).","; - $sql.= " ".$user->id; + $sql.= " ".$user->id.","; + $sql.= " '".price2num($newinsuranceamount)."'"; $sql.= ")"; dol_syslog(get_class($this)."::create", LOG_DEBUG); @@ -339,7 +345,8 @@ class Loan extends CommonObject $sql.= " accountancy_account_insurance = '".$this->db->escape($this->account_insurance)."',"; $sql.= " accountancy_account_interest = '".$this->db->escape($this->account_interest)."',"; $sql.= " fk_projet=".(empty($this->fk_project)?'NULL':$this->fk_project).","; - $sql.= " fk_user_modif = ".$user->id; + $sql.= " fk_user_modif = ".$user->id.","; + $sql.= " insurance_amount = '".price2num($this->db->escape($this->insurance_amount))."'"; $sql.= " WHERE rowid=".$this->id; dol_syslog(get_class($this)."::update", LOG_DEBUG); @@ -549,7 +556,6 @@ class Loan extends CommonObject { $sql = 'SELECT l.rowid, l.datec, l.fk_user_author, l.fk_user_modif,'; $sql.= ' l.tms'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'loan as l'; $sql.= ' WHERE l.rowid = '.$id; dol_syslog(get_class($this).'::info', LOG_DEBUG); diff --git a/htdocs/loan/createschedule.php b/htdocs/loan/createschedule.php index 7cfd54ab998..7a68d3e38a8 100644 --- a/htdocs/loan/createschedule.php +++ b/htdocs/loan/createschedule.php @@ -35,7 +35,7 @@ $object = new Loan($db); $object->fetch($loanid); // Load translation files required by the page -$langs->loadLangs(array("loan")); +$langs->loadLangs(array("compta","bills","loan")); if ($action == 'createecheancier') { @@ -45,6 +45,7 @@ if ($action == 'createecheancier') { $date = GETPOST('hi_date'.$i,'int'); $mens = GETPOST('mens'.$i); $int = GETPOST('hi_interets'.$i); + $insurance = GETPOST('hi_insurance'.$i); $echeance = new LoanSchedule($db); @@ -53,10 +54,10 @@ if ($action == 'createecheancier') { $echeance->tms = dol_now(); $echeance->datep = $date; $echeance->amount_capital = $mens-$int; - $echeance->amount_insurance = 0; + $echeance->amount_insurance = $insurance; $echeance->amount_interest = $int; $echeance->fk_typepayment = 3; - $echeance->fk_bank = 1; + $echeance->fk_bank = 0; $echeance->fk_user_creat = $user->id; $echeance->fk_user_modif = $user->id; $result=$echeance->create($user); @@ -75,11 +76,13 @@ if ($action == 'updateecheancier') { $mens = GETPOST('mens'.$i); $int = GETPOST('hi_interets'.$i); $id = GETPOST('hi_rowid'.$i); + $insurance = GETPOST('hi_insurance'.$i); + $echeance = new LoanSchedule($db); $echeance->fetch($id); $echeance->tms = dol_now(); $echeance->amount_capital = $mens-$int; - $echeance->amount_insurance = 0; + $echeance->amount_insurance = $insurance; $echeance->amount_interest = $int; $echeance->fk_user_modif = $user->id; $result= $echeance->update($user,0); @@ -143,26 +146,33 @@ if(count($echeance->lines)>0) } print ''; print ''; -print ''; print ''; print ''; -Print ''; -Print ''; +Print ''; +Print ''; +print ''; Print ''; -Print ''; Print ''; +if (count($echeance->lines)>0) print ''; print ''."\n"; if ($object->nbterm > 0 && count($echeance->lines)==0) { $i=1; $capital = $object->capital; + $insurance = $object->insurance_amount/$object->nbterm; + $insurance = price2num($insurance, 'MT'); + $regulInsurance = price2num($object->insurance_amount - ($insurance * $object->nbterm)); while($i <$object->nbterm+1) { $mens = price2num($echeance->calcMonthlyPayments($capital, $object->rate/100, $object->nbterm-$i+1), 'MT'); @@ -172,8 +182,9 @@ if ($object->nbterm > 0 && count($echeance->lines)==0) print ''; print ''; print ''; - print ''; + print ''; print ''; + print ''; print ''; print ''."\n"; $i++; @@ -184,6 +195,9 @@ elseif(count($echeance->lines)>0) { $i=1; $capital = $object->capital; + $insurance = $object->insurance_amount/$object->nbterm; + $insurance = price2num($insurance, 'MT'); + $regulInsurance = price2num($object->insurance_amount - ($insurance * $object->nbterm)); foreach ($echeance->lines as $line){ $mens = $line->amount_capital+$line->amount_insurance+$line->amount_interest; $int = $line->amount_interest; @@ -191,13 +205,16 @@ elseif(count($echeance->lines)>0) print ''; print ''; print ''; + print ''; + print ''; if($line->datep > dol_now()){ print ''; }else{ print ''; } - print ''; + print ''; + print ''; print ''."\n"; $i++; $capital = $cap_rest; diff --git a/htdocs/loan/payment/payment.php b/htdocs/loan/payment/payment.php index 08937c1f389..ba6650c9c03 100644 --- a/htdocs/loan/payment/payment.php +++ b/htdocs/loan/payment/payment.php @@ -264,7 +264,7 @@ if ($action == 'create') print ''; print ''; print ''; - print ''; + print ''; print ''; if($line->datep > dol_now()){ print ''; @@ -221,7 +222,7 @@ elseif(count($echeance->lines)>0) print ''; print ''; print ''."\n"; $i++; From 582608cc572a982deb02a3969d8765898793dbe5 Mon Sep 17 00:00:00 2001 From: atm-greg Date: Fri, 19 Oct 2018 15:36:13 +0200 Subject: [PATCH 07/64] manage fk_bank on loanschedule --- htdocs/loan/class/paymentloan.class.php | 1 + htdocs/loan/payment/card.php | 3 +++ htdocs/loan/payment/payment.php | 26 ++++++++++++++++++++++--- htdocs/loan/schedule.php | 14 ++++++++++--- 4 files changed, 38 insertions(+), 6 deletions(-) diff --git a/htdocs/loan/class/paymentloan.class.php b/htdocs/loan/class/paymentloan.class.php index c4c29c99dce..7bed069cec2 100644 --- a/htdocs/loan/class/paymentloan.class.php +++ b/htdocs/loan/class/paymentloan.class.php @@ -530,6 +530,7 @@ class PaymentLoan extends CommonObject $result = $this->db->query($sql); if ($result) { + $this->fk_bank = $id_bank; return 1; } else diff --git a/htdocs/loan/payment/card.php b/htdocs/loan/payment/card.php index 919139bd6e3..110ad8d891c 100644 --- a/htdocs/loan/payment/card.php +++ b/htdocs/loan/payment/card.php @@ -54,6 +54,9 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->loan->del { $db->begin(); + $sql = "UPDATE ".MAIN_DB_PREFIX."loan_schedule SET fk_bank = 0 WHERE fk_bank = ".$payment->fk_bank; + $db->query($sql); + $result = $payment->delete($user); if ($result > 0) { diff --git a/htdocs/loan/payment/payment.php b/htdocs/loan/payment/payment.php index ba6650c9c03..2d81f95d034 100644 --- a/htdocs/loan/payment/payment.php +++ b/htdocs/loan/payment/payment.php @@ -24,6 +24,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; +require_once DOL_DOCUMENT_ROOT.'/loan/class/loanschedule.class.php'; require_once DOL_DOCUMENT_ROOT.'/loan/class/paymentloan.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; @@ -32,6 +33,7 @@ $langs->loadLangs(array("bills","loan")); $chid=GETPOST('id','int'); $action=GETPOST('action','aZ09'); $cancel=GETPOST('cancel','alpha'); +$line_id = GETPOST('line_id', 'int'); // Security check $socid=0; @@ -43,6 +45,17 @@ if ($user->societe_id > 0) $loan = new Loan($db); $loan->fetch($chid); +if (!empty($line_id)) +{ + $line = new LoanSchedule($db); + $res = $line->fetch($line_id); + if ($res > 0){ + $amount_capital = price($line->amount_capital); + $amount_insurance = price($line->amount_insurance); + $amount_interest = price($line->amount_interest); + } +} + /* * Actions */ @@ -121,6 +134,12 @@ if ($action == 'add_payment') setEventMessages($payment->error, $payment->errors, 'errors'); $error++; } + elseif(isset($line)) + { + $line->fk_bank = $payment->fk_bank; + $line->update($user); + } + } if (! $error) @@ -161,6 +180,7 @@ if ($action == 'create') print ''; print ''; print ''; + print ''; print ''; dol_fiche_head(); @@ -264,7 +284,7 @@ if ($action == 'create') print ''; print ''; @@ -204,17 +205,19 @@ elseif(count($echeance->lines)>0) $insurance = $object->insurance_amount/$object->nbterm; $insurance = price2num($insurance, 'MT'); $regulInsurance = price2num($object->insurance_amount - ($insurance * $object->nbterm)); + $printed = false; foreach ($echeance->lines as $line){ $mens = $line->amount_capital+$line->amount_insurance+$line->amount_interest; $int = $line->amount_interest; - $cap_rest = price2num($capital - ($mens-$int), 'MT'); $insu = ($insurance+(($i == 1) ? $regulInsurance : 0)); + $cap_rest = price2num($capital - ($mens-$int-$insu), 'MT'); + print ''; print ''; print ''; print ''; print ''; - if($line->datep > dol_now()){ + if($line->datep > dol_now() && empty($line->fk_bank)){ print ''; }else{ print ''; @@ -222,7 +225,12 @@ elseif(count($echeance->lines)>0) print ''; print ''; print ''."\n"; $i++; From 6a3661586ffdf9d6b3aa7b7d1ff471ea0d3b0644 Mon Sep 17 00:00:00 2001 From: atm-greg Date: Fri, 19 Oct 2018 16:12:21 +0200 Subject: [PATCH 08/64] create payment for the last loanschedule --- htdocs/loan/card.php | 2 +- htdocs/loan/payment/payment.php | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/htdocs/loan/card.php b/htdocs/loan/card.php index 8fef98075b1..c8da0262f38 100644 --- a/htdocs/loan/card.php +++ b/htdocs/loan/card.php @@ -795,7 +795,7 @@ if ($id > 0) // Emit payment if ($object->paid == 0 && ((price2num($object->capital) > 0 && round($staytopay) < 0) || (price2num($object->capital) > 0 && round($staytopay) > 0)) && $user->rights->loan->write) { - print ''.$langs->trans("DoPayment").''; + print ''.$langs->trans("DoPayment").''; } // Classify 'paid' diff --git a/htdocs/loan/payment/payment.php b/htdocs/loan/payment/payment.php index 2d81f95d034..b38a058126f 100644 --- a/htdocs/loan/payment/payment.php +++ b/htdocs/loan/payment/payment.php @@ -34,6 +34,7 @@ $chid=GETPOST('id','int'); $action=GETPOST('action','aZ09'); $cancel=GETPOST('cancel','alpha'); $line_id = GETPOST('line_id', 'int'); +$last=GETPOST('last'); // Security check $socid=0; @@ -45,6 +46,26 @@ if ($user->societe_id > 0) $loan = new Loan($db); $loan->fetch($chid); +if($last) +{ + $ls = new LoanSchedule($db); + // grab all loanschedule + $res = $ls->fetchAll($chid); + if ($res > 0) + { + foreach ($ls->lines as $l) + { + // get the last unpaid loanschedule + if (empty($l->fk_bank)) + { + $line_id = $l->id; + break; + } + } + } + +} + if (!empty($line_id)) { $line = new LoanSchedule($db); From 44b317e03e9dd9b4b87945904627ec66021915f0 Mon Sep 17 00:00:00 2001 From: atm-greg Date: Fri, 19 Oct 2018 16:49:32 +0200 Subject: [PATCH 09/64] fix display --- htdocs/loan/schedule.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/loan/schedule.php b/htdocs/loan/schedule.php index 9fb5a4397ee..30ba126aefb 100644 --- a/htdocs/loan/schedule.php +++ b/htdocs/loan/schedule.php @@ -207,10 +207,10 @@ elseif(count($echeance->lines)>0) $regulInsurance = price2num($object->insurance_amount - ($insurance * $object->nbterm)); $printed = false; foreach ($echeance->lines as $line){ - $mens = $line->amount_capital+$line->amount_insurance+$line->amount_interest; + $mens = $line->amount_capital+$line->amount_interest; $int = $line->amount_interest; $insu = ($insurance+(($i == 1) ? $regulInsurance : 0)); - $cap_rest = price2num($capital - ($mens-$int-$insu), 'MT'); + $cap_rest = price2num($capital - ($mens-$int), 'MT'); print ''; print ''; From bfadd39e8cda84dd477e8812829c177e71a19154 Mon Sep 17 00:00:00 2001 From: Abbes Bahfir Date: Fri, 19 Oct 2018 12:46:54 +0100 Subject: [PATCH 10/64] Fix: Grant right to child classes to use Category methods --- htdocs/categories/class/categorie.class.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index a9432234793..97bceaf082c 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -65,7 +65,7 @@ class Categorie extends CommonObject * * @note This array should be remove in future, once previous constants are moved to the string value. Deprecated */ - private $MAP_ID = array( + protected $MAP_ID = array( 'product' => 0, 'supplier' => 1, 'customer' => 2, @@ -93,7 +93,7 @@ class Categorie extends CommonObject * * @note Move to const array when PHP 5.6 will be our minimum target */ - private $MAP_CAT_FK = array( + protected $MAP_CAT_FK = array( 'product' => 'product', 'customer' => 'soc', 'supplier' => 'soc', @@ -109,7 +109,7 @@ class Categorie extends CommonObject * * @note Move to const array when PHP 5.6 will be our minimum target */ - private $MAP_CAT_TABLE = array( + protected $MAP_CAT_TABLE = array( 'product' => 'product', 'customer' => 'societe', 'supplier' => 'fournisseur', @@ -125,7 +125,7 @@ class Categorie extends CommonObject * * @note Move to const array when PHP 5.6 will be our minimum target */ - private $MAP_OBJ_CLASS = array( + protected $MAP_OBJ_CLASS = array( 'product' => 'Product', 'customer' => 'Societe', 'supplier' => 'Fournisseur', @@ -141,7 +141,7 @@ class Categorie extends CommonObject * * @note Move to const array when PHP 5.6 will be our minimum target */ - private $MAP_OBJ_TABLE = array( + protected $MAP_OBJ_TABLE = array( 'product' => 'product', 'customer' => 'societe', 'supplier' => 'societe', @@ -931,7 +931,7 @@ class Categorie extends CommonObject * * @return int <0 if KO, >0 if OK */ - private function load_motherof() + protected function load_motherof() { // phpcs:enable global $conf; From 064816242a9599d83e84c822822ca4908d232255 Mon Sep 17 00:00:00 2001 From: wdammak <26695620+wdammak@users.noreply.github.com> Date: Fri, 23 Nov 2018 21:26:10 +0100 Subject: [PATCH 11/64] Order by category --- htdocs/core/class/html.form.class.php | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index dce2192d10d..5279caeda98 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2017,6 +2017,14 @@ class Form $sql = "SELECT "; $sql.= $selectFields . $selectFieldsGrouped; + + //Product category + $sql.= ", (SELECT ".MAIN_DB_PREFIX."categorie_product.fk_categorie + FROM ".MAIN_DB_PREFIX."categorie_product + WHERE ".MAIN_DB_PREFIX."categorie_product.fk_product=p.rowid + LIMIT 1 + ) AS categorie_product_id "; + //Price by customer if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES) && !empty($socid)) { @@ -2064,8 +2072,6 @@ class Form if (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD)) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_attribute_combination pac ON pac.fk_product_child = p.rowid"; } - //Product category - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as pcat ON pcat.fk_product=p.rowid"; $sql.= ' WHERE p.entity IN ('.getEntity('product').')'; if (count($warehouseStatusArray)) @@ -2117,8 +2123,19 @@ class Form $sql.= ' GROUP BY'.$selectFields; } - (! empty($conf->global->PRODUIT_SORT_BY_CATEGORY)) ? $sql.= $db->order("pcat.fk_categorie") : $sql.= $db->order("p.ref"); - $sql.= $db->plimit($limit, 0) + //Sort by category + if(! empty($conf->global->PRODUCT_SORT_BY_CATEGORY)) + { + $sql .= " ORDER BY categorie_product_id "; + //ASC OR DESC order + ($conf->global->PRODUCT_SORT_BY_CATEGORY == 1) ? $sql .="ASC" : $sql .="DESC"; + } + else + { + $sql.= $db->order("p.ref"); + } + + $sql.= $db->plimit($limit, 0); // Build output string dol_syslog(get_class($this)."::select_produits_list search product", LOG_DEBUG); From 5c3daf4a6a475f6916b66c110026a1cf2c1f0713 Mon Sep 17 00:00:00 2001 From: wdammak <26695620+wdammak@users.noreply.github.com> Date: Fri, 23 Nov 2018 21:27:22 +0100 Subject: [PATCH 12/64] order by category --- htdocs/core/class/html.form.class.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 5279caeda98..40a7a47a94f 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2013,10 +2013,6 @@ class Form $selectFields = " p.rowid, p.label, p.ref, p.description, p.barcode, p.fk_product_type, p.price, p.price_ttc, p.price_base_type, p.tva_tx, p.duration, p.fk_price_expression"; (count($warehouseStatusArray)) ? $selectFieldsGrouped = ", sum(ps.reel) as stock" : $selectFieldsGrouped = ", p.stock"; - $selectFields .= ", pcat.fk_categorie as categorie_product_id"; - - $sql = "SELECT "; - $sql.= $selectFields . $selectFieldsGrouped; //Product category $sql.= ", (SELECT ".MAIN_DB_PREFIX."categorie_product.fk_categorie @@ -2025,6 +2021,9 @@ class Form LIMIT 1 ) AS categorie_product_id "; + $sql = "SELECT "; + $sql.= $selectFields . $selectFieldsGrouped; + //Price by customer if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES) && !empty($socid)) { From 5c9d5bb6ad53c825e42532afeecb6c0b0c735c07 Mon Sep 17 00:00:00 2001 From: wdammak <26695620+wdammak@users.noreply.github.com> Date: Fri, 23 Nov 2018 21:30:34 +0100 Subject: [PATCH 13/64] order by category --- htdocs/core/class/html.form.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 40a7a47a94f..721c1997086 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2014,6 +2014,9 @@ class Form $selectFields = " p.rowid, p.label, p.ref, p.description, p.barcode, p.fk_product_type, p.price, p.price_ttc, p.price_base_type, p.tva_tx, p.duration, p.fk_price_expression"; (count($warehouseStatusArray)) ? $selectFieldsGrouped = ", sum(ps.reel) as stock" : $selectFieldsGrouped = ", p.stock"; + $sql = "SELECT "; + $sql.= $selectFields . $selectFieldsGrouped; + //Product category $sql.= ", (SELECT ".MAIN_DB_PREFIX."categorie_product.fk_categorie FROM ".MAIN_DB_PREFIX."categorie_product @@ -2021,9 +2024,6 @@ class Form LIMIT 1 ) AS categorie_product_id "; - $sql = "SELECT "; - $sql.= $selectFields . $selectFieldsGrouped; - //Price by customer if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES) && !empty($socid)) { From 2e496ea83a3833d9d32ff4e4bc360e203aa8f7a3 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sun, 2 Dec 2018 14:31:45 +0100 Subject: [PATCH 14/64] QUAL rename facnumber by ref --- htdocs/accountancy/customer/card.php | 4 +-- htdocs/accountancy/customer/lines.php | 10 +++--- htdocs/accountancy/customer/list.php | 10 +++--- htdocs/accountancy/journal/bankjournal.php | 2 +- htdocs/accountancy/journal/sellsjournal.php | 4 +-- htdocs/accountancy/supplier/card.php | 4 +-- htdocs/blockedlog/class/blockedlog.class.php | 6 ++-- htdocs/comm/card.php | 6 ++-- htdocs/comm/propal/class/propal.class.php | 2 +- htdocs/comm/remx.php | 18 +++++----- htdocs/commande/orderstoinvoice.php | 6 ++-- htdocs/compta/bank/treso.php | 2 +- htdocs/compta/compta-files.php | 2 +- htdocs/compta/facture/card.php | 12 +++---- htdocs/compta/facture/class/facture.class.php | 36 +++++++++---------- htdocs/compta/facture/contact.php | 2 +- htdocs/compta/facture/document.php | 2 +- htdocs/compta/facture/info.php | 2 +- htdocs/compta/facture/list.php | 18 +++++----- htdocs/compta/facture/note.php | 2 +- htdocs/compta/facture/prelevement.php | 4 +-- htdocs/compta/index.php | 26 +++++++------- htdocs/compta/journal/sellsjournal.php | 4 +-- htdocs/compta/paiement.php | 10 +++--- htdocs/compta/paiement/card.php | 2 +- .../class/bonprelevement.class.php | 22 ++++++------ htdocs/compta/prelevement/create.php | 4 +-- htdocs/compta/prelevement/demandes.php | 6 ++-- htdocs/compta/prelevement/factures.php | 2 +- htdocs/compta/prelevement/index.php | 4 +-- htdocs/compta/prelevement/ligne.php | 2 +- htdocs/compta/prelevement/list.php | 6 ++-- htdocs/compta/recap-compta.php | 2 +- htdocs/compta/stats/index.php | 4 +-- htdocs/core/boxes/box_factures.php | 8 ++--- htdocs/core/boxes/box_factures_imp.php | 10 +++--- htdocs/core/class/commoninvoice.class.php | 4 +-- htdocs/core/class/discount.class.php | 2 +- htdocs/core/class/html.form.class.php | 10 +++--- htdocs/core/class/html.formprojet.class.php | 2 +- htdocs/core/lib/invoice2.lib.php | 8 ++--- htdocs/core/lib/tax.lib.php | 4 +-- .../core/modules/facture/mod_facture_mars.php | 16 ++++----- .../modules/facture/mod_facture_mercure.php | 2 +- .../modules/facture/mod_facture_terre.php | 20 +++++------ htdocs/core/modules/modApi.class.php | 4 +-- htdocs/core/modules/modBanque.class.php | 6 ++-- htdocs/core/modules/modFacture.class.php | 8 ++--- htdocs/core/modules/modGravatar.class.php | 4 +-- htdocs/core/modules/modHoliday.class.php | 6 ++-- .../core/modules/modMultiCurrency.class.php | 6 ++-- htdocs/core/modules/modPaybox.class.php | 4 +-- htdocs/core/modules/modPaypal.class.php | 4 +-- .../modules/rapport/pdf_paiement.class.php | 6 ++-- htdocs/fourn/commande/orderstoinvoice.php | 2 +- .../install/mysql/migration/9.0.0-10.0.0.sql | 31 ++++++++++++++++ htdocs/install/mysql/migration/repair.sql | 8 ++--- .../install/mysql/tables/llx_facture.key.sql | 2 +- htdocs/install/mysql/tables/llx_facture.sql | 2 +- htdocs/margin/checkMargins.php | 8 ++--- htdocs/margin/customerMargins.php | 8 ++--- htdocs/margin/productMargins.php | 8 ++--- htdocs/margin/tabs/productMargins.php | 8 ++--- htdocs/margin/tabs/thirdpartyMargins.php | 8 ++--- htdocs/product/stats/facture.php | 4 +-- .../societe/class/api_thirdparties.class.php | 2 +- htdocs/societe/consumption.php | 4 +-- htdocs/stripe/payment.php | 10 +++--- htdocs/takepos/customers.php | 2 +- htdocs/takepos/invoice.php | 8 ++--- htdocs/takepos/pay.php | 2 +- htdocs/takepos/receipt.php | 2 +- htdocs/webservices/server_invoice.php | 2 +- .../email_unpaid_invoices_to_customers.php | 8 ++--- ...ail_unpaid_invoices_to_representatives.php | 8 ++--- test/phpunit/ExportTest.php | 16 ++++----- test/phpunit/FactureTest.php | 2 +- 77 files changed, 284 insertions(+), 253 deletions(-) create mode 100644 htdocs/install/mysql/migration/9.0.0-10.0.0.sql diff --git a/htdocs/accountancy/customer/card.php b/htdocs/accountancy/customer/card.php index 677bc627c80..ebe88712949 100644 --- a/htdocs/accountancy/customer/card.php +++ b/htdocs/accountancy/customer/card.php @@ -94,7 +94,7 @@ $facture_static = new Facture($db); $formaccounting = new FormAccounting($db); if (! empty($id)) { - $sql = "SELECT f.facnumber, f.rowid as facid, l.fk_product, l.description, l.price,"; + $sql = "SELECT f.ref, f.rowid as facid, l.fk_product, l.description, l.price,"; $sql .= " l.qty, l.rowid, l.tva_tx, l.remise_percent, l.subprice, p.accountancy_code_sell as code_sell,"; $sql .= " l.fk_code_ventilation, aa.account_number, aa.label"; $sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as l"; @@ -128,7 +128,7 @@ if (! empty($id)) { // Ref facture print ''; - $facture_static->ref = $objp->facnumber; + $facture_static->ref = $objp->ref; $facture_static->id = $objp->facid; print ''; print ''; diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index 7d8599b683c..06a1f11dcbc 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -64,7 +64,7 @@ $pageprev = $page - 1; $pagenext = $page + 1; $offset = $limit * $page; if (! $sortfield) - $sortfield = "f.datef, f.facnumber, fd.rowid"; + $sortfield = "f.datef, f.ref, fd.rowid"; if (! $sortorder) { if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE > 0) { $sortorder = "DESC"; @@ -167,7 +167,7 @@ print '
'; +$colspan = 6; +if (count($echeance->lines)>0) $colspan++; +print ''; print $langs->trans("FinancialCommitment"); print '
'.$langs->trans("Term").''.$langs->trans("Date").''.$langs->trans("Term").''.$langs->trans("Date").''.$langs->trans("Insurance"); +Print ''.$langs->trans("InterestAmount").''.$langs->trans("Amount").''.$langs->trans("InterestAmount").''.$langs->trans("CapitalRemain"); print ' ('.price2num($object->capital).')'; print ''; print ''.$langs->trans('DoPayment').'
' . $i .'' . dol_print_date(dol_time_plus_duree($object->datestart, $i-1, 'm'),'day') . ''.price($insurance+(($i == 1) ? $regulInsurance : 0),0,'',1).' €'.price($int,0,'',1).' €'.price($cap_rest).' €
' . $i .'' . dol_print_date($line->datep,'day') . ''.price($insurance+(($i == 1) ? $regulInsurance : 0),0,'',1).' €'.price($int,0,'',1).' €' . price($mens) . ' €'.price($int,0,'',1).' €'.price($cap_rest).' €'.$langs->trans('DoPayment').'
'; if ($sumpaid < $loan->capital) { - print $langs->trans("LoanCapital") .': '; + print $langs->trans("LoanCapital") .': '; } else { @@ -273,7 +273,7 @@ if ($action == 'create') print '
'; if ($sumpaid < $loan->capital) { - print $langs->trans("Insurance") .': '; + print $langs->trans("Insurance") .': '; } else { @@ -282,7 +282,7 @@ if ($action == 'create') print '
'; if ($sumpaid < $loan->capital) { - print $langs->trans("Interest") .': '; + print $langs->trans("Interest") .': '; } else { From f0849aaf81e42b2725dc1403008d108191ee0216 Mon Sep 17 00:00:00 2001 From: atm-greg Date: Thu, 18 Oct 2018 17:16:38 +0200 Subject: [PATCH 05/64] schedule as a tab --- htdocs/core/lib/loan.lib.php | 5 + htdocs/loan/card.php | 2 +- htdocs/loan/schedule.php | 242 +++++++++++++++++++++++++++++++++++ 3 files changed, 248 insertions(+), 1 deletion(-) create mode 100644 htdocs/loan/schedule.php diff --git a/htdocs/core/lib/loan.lib.php b/htdocs/core/lib/loan.lib.php index b61c57b4bc3..0b617bb0d5c 100644 --- a/htdocs/core/lib/loan.lib.php +++ b/htdocs/core/lib/loan.lib.php @@ -40,6 +40,11 @@ function loan_prepare_head($object) $head[$tab][1] = $langs->trans('Card'); $head[$tab][2] = 'card'; $tab++; + + $head[$tab][0] = DOL_URL_ROOT.'/loan/schedule.php?loanid='.$object->id; + $head[$tab][1] = $langs->trans('FinancialCommitment'); + $head[$tab][2] = 'FinancialCommitment'; + $tab++; // Show more tabs from modules // Entries must be declared in modules descriptor with line diff --git a/htdocs/loan/card.php b/htdocs/loan/card.php index 2a6708655a8..8fef98075b1 100644 --- a/htdocs/loan/card.php +++ b/htdocs/loan/card.php @@ -787,7 +787,7 @@ if ($id > 0) // Edit if ($object->paid == 0 && $user->rights->loan->write) { - print ''.$langs->trans('CreateCalcSchedule').''; + // print ''.$langs->trans('CreateCalcSchedule').''; print ''.$langs->trans("Modify").''; } diff --git a/htdocs/loan/schedule.php b/htdocs/loan/schedule.php new file mode 100644 index 00000000000..58130c2c26a --- /dev/null +++ b/htdocs/loan/schedule.php @@ -0,0 +1,242 @@ + + * Copyright (C) 2018 Alexandre Spangaro + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/loan/createschedule.php + * \ingroup loan + * \brief Schedule card + */ + +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/loan.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/loan/class/loanschedule.class.php'; + +$loanid = GETPOST('loanid', 'int'); +$action = GETPOST('action','aZ09'); + +$object = new Loan($db); +$object->fetch($loanid); + +// Load translation files required by the page +$langs->loadLangs(array("compta","bills","loan")); + +$title = $langs->trans("Loan") . ' - ' . $langs->trans("Card"); +$help_url = 'EN:Module_Loan|FR:Module_Emprunt'; +llxHeader("",$title,$help_url); + +$head=loan_prepare_head($object); +dol_fiche_head($head, 'FinancialCommitment', $langs->trans("Loan"), -1, 'bill'); + +if ($action == 'createecheancier') { + + $i=1; + while($i <$object->nbterm+1){ + + $date = GETPOST('hi_date'.$i,'int'); + $mens = GETPOST('mens'.$i); + $int = GETPOST('hi_interets'.$i); + $insurance = GETPOST('hi_insurance'.$i); + + $echeance = new LoanSchedule($db); + + $echeance->fk_loan = $object->id; + $echeance->datec = dol_now(); + $echeance->tms = dol_now(); + $echeance->datep = $date; + $echeance->amount_capital = $mens-$int; + $echeance->amount_insurance = $insurance; + $echeance->amount_interest = $int; + $echeance->fk_typepayment = 3; + $echeance->fk_bank = 0; + $echeance->fk_user_creat = $user->id; + $echeance->fk_user_modif = $user->id; + $result=$echeance->create($user); + if ($result<0) { + setEventMessages($echeance->error, $echeance->errors,'errors'); + } + $i++; + } +} + +if ($action == 'updateecheancier') { + + $i=1; + while($i <$object->nbterm+1){ + + $mens = GETPOST('mens'.$i); + $int = GETPOST('hi_interets'.$i); + $id = GETPOST('hi_rowid'.$i); + $insurance = GETPOST('hi_insurance'.$i); + + $echeance = new LoanSchedule($db); + $echeance->fetch($id); + $echeance->tms = dol_now(); + $echeance->amount_capital = $mens-$int; + $echeance->amount_insurance = $insurance; + $echeance->amount_interest = $int; + $echeance->fk_user_modif = $user->id; + $result= $echeance->update($user,0); + if ($result<0) { + setEventMessages(null, $echeance->errors,'errors'); + } + $i++; + } +} + +$echeance = new LoanSchedule($db); +$echeance->fetchAll($object->id); + +$var = ! $var; + + +?> + +'; +print ''; +print ''; +if(count($echeance->lines)>0) +{ + print ''; +}else{ + print ''; +} +print ''; +print ''; +$colspan = 6; +if (count($echeance->lines)>0) $colspan++; +print ''; +print ''; + +print ''; +Print ''; +Print ''; +print ''; +Print ''; +Print ''; +if (count($echeance->lines)>0) print ''; +print ''."\n"; + +if ($object->nbterm > 0 && count($echeance->lines)==0) +{ + $i=1; + $capital = $object->capital; + $insurance = $object->insurance_amount/$object->nbterm; + $insurance = price2num($insurance, 'MT'); + $regulInsurance = price2num($object->insurance_amount - ($insurance * $object->nbterm)); + while($i <$object->nbterm+1) + { + $mens = price2num($echeance->calcMonthlyPayments($capital, $object->rate/100, $object->nbterm-$i+1), 'MT'); + $int = ($capital*($object->rate/12))/100; + $int = price2num($int, 'MT'); + $cap_rest = price2num($capital - ($mens-$int), 'MT'); + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''."\n"; + $i++; + $capital = $cap_rest; + } +} +elseif(count($echeance->lines)>0) +{ + $i=1; + $capital = $object->capital; + $insurance = $object->insurance_amount/$object->nbterm; + $insurance = price2num($insurance, 'MT'); + $regulInsurance = price2num($object->insurance_amount - ($insurance * $object->nbterm)); + foreach ($echeance->lines as $line){ + $mens = $line->amount_capital+$line->amount_insurance+$line->amount_interest; + $int = $line->amount_interest; + $cap_rest = price2num($capital - ($mens-$int), 'MT'); + print ''; + print ''; + print ''; + print ''; + print ''; + if($line->datep > dol_now()){ + print ''; + }else{ + print ''; + } + + print ''; + print ''; + print ''."\n"; + $i++; + $capital = $cap_rest; + } +} + +print '
'; +print $langs->trans("FinancialCommitment"); +print '
'.$langs->trans("Term").''.$langs->trans("Date").''.$langs->trans("Insurance"); +Print ''.$langs->trans("InterestAmount").''.$langs->trans("Amount").''.$langs->trans("CapitalRemain"); +print ' ('.price2num($object->capital).')'; +print ''; +print ''.$langs->trans('DoPayment').'
' . $i .'' . dol_print_date(dol_time_plus_duree($object->datestart, $i-1, 'm'),'day') . ''.price($insurance+(($i == 1) ? $regulInsurance : 0),0,'',1).' €'.price($int,0,'',1).' €'.price($cap_rest).' €
' . $i .'' . dol_print_date($line->datep,'day') . ''.price($insurance+(($i == 1) ? $regulInsurance : 0),0,'',1).' €'.price($int,0,'',1).' €' . price($mens) . ' €'.price($cap_rest).' €'; + print ''.$langs->trans('DoPayment').''; + print '
'; +print '
'; +print '
'; +if (count($echeance->lines)==0) $label = $langs->trans("Create"); +else $label = $langs->trans("Save"); +print '
'; +print ''; + +// End of page +llxFooter(); +$db->close(); From db2937715df40c1177567a03906482b760e059e3 Mon Sep 17 00:00:00 2001 From: atm-greg Date: Thu, 18 Oct 2018 17:27:08 +0200 Subject: [PATCH 06/64] create payment from loan schedule --- htdocs/loan/schedule.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/loan/schedule.php b/htdocs/loan/schedule.php index 58130c2c26a..d775ebaca84 100644 --- a/htdocs/loan/schedule.php +++ b/htdocs/loan/schedule.php @@ -208,10 +208,11 @@ elseif(count($echeance->lines)>0) $mens = $line->amount_capital+$line->amount_insurance+$line->amount_interest; $int = $line->amount_interest; $cap_rest = price2num($capital - ($mens-$int), 'MT'); + $insu = ($insurance+(($i == 1) ? $regulInsurance : 0)); print '
' . $i .'' . dol_print_date($line->datep,'day') . ''.price($insurance+(($i == 1) ? $regulInsurance : 0),0,'',1).' €'.price($insu,0,'',1).' €'.price($int,0,'',1).' €'.price($cap_rest).' €'; - print ''.$langs->trans('DoPayment').''; + print ''.$langs->trans('DoPayment').''; print '
'; if ($sumpaid < $loan->capital) { - print $langs->trans("LoanCapital") .': '; + print $langs->trans("LoanCapital") .': '; } else { @@ -273,7 +293,7 @@ if ($action == 'create') print '
'; if ($sumpaid < $loan->capital) { - print $langs->trans("Insurance") .': '; + print $langs->trans("Insurance") .': '; } else { @@ -282,7 +302,7 @@ if ($action == 'create') print '
'; if ($sumpaid < $loan->capital) { - print $langs->trans("Interest") .': '; + print $langs->trans("Interest") .': '; } else { diff --git a/htdocs/loan/schedule.php b/htdocs/loan/schedule.php index d775ebaca84..9fb5a4397ee 100644 --- a/htdocs/loan/schedule.php +++ b/htdocs/loan/schedule.php @@ -184,6 +184,7 @@ if ($object->nbterm > 0 && count($echeance->lines)==0) $mens = price2num($echeance->calcMonthlyPayments($capital, $object->rate/100, $object->nbterm-$i+1), 'MT'); $int = ($capital*($object->rate/12))/100; $int = price2num($int, 'MT'); + $insu = ($insurance+(($i == 1) ? $regulInsurance : 0)); $cap_rest = price2num($capital - ($mens-$int), 'MT'); print '
' . $i .'
' . $i .'' . dol_print_date($line->datep,'day') . ''.price($insu,0,'',1).' €'.price($int,0,'',1).' €' . price($mens) . ' €'.price($cap_rest).' €'; - print ''.$langs->trans('DoPayment').''; + if (!empty($line->fk_bank)) print $langs->trans('Paid'); + elseif (!$printed) + { + print ''.$langs->trans('DoPayment').''; + $printed = true; + } print '
' . $i .'
' . $langs->trans("Invoice") . '' . $facture_static->getNomUrl(1) . '