From e31a93929a0c26724bda4000571fbd4d2e18ee28 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Wed, 29 Jan 2020 14:01:48 +0100 Subject: [PATCH 1/6] FIX doc of dictionnary API --- htdocs/api/class/api_setup.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index a42888aad27..f5ed406a2a1 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -53,7 +53,7 @@ class Setup extends DolibarrApi * @param int $limit Number of items per page * @param int $page Page number {@min 0} * @param int $active Payment type is active or not {@min 0} {@max 1} - * @param string $sqlfilters SQL criteria to filter with. Syntax example "(t.code:=:'CHQ')" + * @param string $sqlfilters SQL criteria to filter with. Syntax example "(t.code:=:'OrderByWWW')" * * @url GET dictionary/ordering_methods * @@ -911,7 +911,7 @@ class Setup extends DolibarrApi * @throws 400 RestException * @throws 200 OK */ - public function getPaymentTerms($sortfield = "sortorder", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') + public function getPaymentTerms($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') { $list = array(); From 8f2c87b0d4af8d557b881a13e6dc902ca624b807 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Thu, 30 Jan 2020 13:52:13 +0100 Subject: [PATCH 2/6] Update api_setup.class.php --- htdocs/api/class/api_setup.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index f5ed406a2a1..66c4c1358cb 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -911,7 +911,7 @@ class Setup extends DolibarrApi * @throws 400 RestException * @throws 200 OK */ - public function getPaymentTerms($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') + public function getPaymentTerms($sortfield = "sortorder", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') { $list = array(); From e8b9ca3276bfb3f2fc72fa01ba4ff5fa09c60c45 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sat, 1 Feb 2020 08:23:19 +0100 Subject: [PATCH 3/6] FIX: FEC export have specific name --- htdocs/accountancy/tpl/export_journal.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/accountancy/tpl/export_journal.tpl.php b/htdocs/accountancy/tpl/export_journal.tpl.php index 5c9f7ad48ed..0dec55630d3 100644 --- a/htdocs/accountancy/tpl/export_journal.tpl.php +++ b/htdocs/accountancy/tpl/export_journal.tpl.php @@ -35,7 +35,7 @@ $endaccountingperiod = dol_print_date(dol_now(), '%Y%m%d'); header('Content-Type: text/csv'); -if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == "11" && $type_export == "general_ledger") // Specific filename for FEC model export into the general ledger +if ($this->getFormatCode($formatexportset) == "fec" && $type_export == "general_ledger") // Specific filename for FEC model export into the general ledger { // FEC format is defined here: https://www.legifrance.gouv.fr/affichCodeArticle.do?idArticle=LEGIARTI000027804775&cidTexte=LEGITEXT000006069583&dateTexte=20130802&oldAction=rechCodeArticle if (empty($search_date_end)) From e59d118b8cfb3d7b9f6a83634c5f0189370d3d80 Mon Sep 17 00:00:00 2001 From: ATM john Date: Sun, 2 Feb 2020 06:36:06 +0100 Subject: [PATCH 4/6] Fix project loan data --- htdocs/loan/class/loan.class.php | 2 +- htdocs/projet/element.php | 22 ++++++++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/htdocs/loan/class/loan.class.php b/htdocs/loan/class/loan.class.php index 586b6b59036..f655b3adcb2 100644 --- a/htdocs/loan/class/loan.class.php +++ b/htdocs/loan/class/loan.class.php @@ -556,7 +556,7 @@ class Loan extends CommonObject $table = 'payment_loan'; $field = 'fk_loan'; - $sql = 'SELECT sum(amount) as amount'; + $sql = 'SELECT sum(amount_capital) as amount'; $sql .= ' FROM '.MAIN_DB_PREFIX.$table; $sql .= ' WHERE '.$field.' = '.$this->id; diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 9be63cad242..9b49f2814a9 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -829,11 +829,13 @@ foreach ($listofreferent as $key => $value) // Amount HT //if (empty($value['disableamount']) && ! in_array($tablename, array('projet_task'))) print ''.$langs->trans("AmountHT").''; //elseif (empty($value['disableamount']) && in_array($tablename, array('projet_task'))) print ''.$langs->trans("Amount").''; - if (empty($value['disableamount'])) print ''.$langs->trans("AmountHT").''; + if ($key == 'loan') print ''.$langs->trans("LoanCapital").''; + elseif (empty($value['disableamount'])) print ''.$langs->trans("AmountHT").''; else print ''; // Amount TTC //if (empty($value['disableamount']) && ! in_array($tablename, array('projet_task'))) print ''.$langs->trans("AmountTTC").''; - if (empty($value['disableamount'])) print ''.$langs->trans("AmountTTC").''; + if ($key == 'loan') print ''.$langs->trans("RemainderToPay").''; + elseif (empty($value['disableamount'])) print ''.$langs->trans("AmountTTC").''; else print ''; // Status if (in_array($tablename, array('projet_task'))) print ''.$langs->trans("ProgressDeclared").''; @@ -928,6 +930,10 @@ foreach ($listofreferent as $key => $value) print $element->getNomUrl(1, 'withproject', 'time'); print ' - '.dol_trunc($element->label, 48); } + elseif ($key == 'loan'){ + print $element->getNomUrl(1); + print ' - '.dol_trunc($element->label, 48); + } else print $element->getNomUrl(1); $element_doc = $element->element; @@ -977,6 +983,10 @@ foreach ($listofreferent as $key => $value) if (empty($date)) $date = $element->datev; } } + elseif ($key == 'loan'){ + $date = $element->datestart; + } + print ''; if ($tablename == 'actioncomm') { @@ -1050,6 +1060,7 @@ foreach ($listofreferent as $key => $value) $othermessage = $form->textwithpicto($langs->trans("NotAvailable"), $langs->trans("ModuleSalaryToDefineHourlyRateMustBeEnabled")); } } + elseif ($key == 'loan') $total_ht_by_line = $element->capital; else { $total_ht_by_line = $element->total_ht; @@ -1097,6 +1108,7 @@ foreach ($listofreferent as $key => $value) $othermessage = $form->textwithpicto($langs->trans("NotAvailable"), $langs->trans("ModuleSalaryToDefineHourlyRateMustBeEnabled")); } } + elseif ($key == 'loan') $total_ttc_by_line = $element->capital - $element->getSumPayment(); else { $total_ttc_by_line = $element->total_ttc; @@ -1204,7 +1216,8 @@ foreach ($listofreferent as $key => $value) print ''; if (empty($value['disableamount'])) { - if ($tablename != 'projet_task' || !empty($conf->salaries->enabled)) print ''.$langs->trans("TotalHT").' : '.price($total_ht); + if ($key == 'loan') print $langs->trans("Total").' '.$langs->trans("LoanCapital").' : '.price($total_ttc); + elseif ($tablename != 'projet_task' || !empty($conf->salaries->enabled)) print ''.$langs->trans("TotalHT").' : '.price($total_ht); } print ''; //if (empty($value['disableamount']) && ! in_array($tablename, array('projet_task'))) print ''.$langs->trans("TotalTTC").' : '.price($total_ttc).''; @@ -1212,7 +1225,8 @@ foreach ($listofreferent as $key => $value) print ''; if (empty($value['disableamount'])) { - if ($tablename != 'projet_task' || !empty($conf->salaries->enabled)) print $langs->trans("TotalTTC").' : '.price($total_ttc); + if ($key == 'loan') print $langs->trans("Total").' '.$langs->trans("RemainderToPay").' : '.price($total_ttc); + elseif ($tablename != 'projet_task' || !empty($conf->salaries->enabled)) print $langs->trans("TotalTTC").' : '.price($total_ttc); } print ''; print ' '; From fe009c384251396429c75adebf35beda0339df95 Mon Sep 17 00:00:00 2001 From: ATM john Date: Sun, 2 Feb 2020 09:06:02 +0100 Subject: [PATCH 5/6] Fix project profit for loan part --- htdocs/projet/class/project.class.php | 15 ++++++++++++-- htdocs/projet/element.php | 30 +++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 54d13a51549..746fdacd381 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -607,18 +607,29 @@ class Project extends CommonObject { $sql = 'SELECT ms.rowid, ms.fk_user_author as fk_user FROM '.MAIN_DB_PREFIX."stock_mouvement as ms, ".MAIN_DB_PREFIX."entrepot as e WHERE e.rowid = ms.fk_entrepot AND e.entity IN (".getEntity('stock').") AND ms.origintype = 'project' AND ms.fk_origin IN (".$ids.") AND ms.type_mouvement = 1"; } + elseif ($type == 'loan') + { + $sql = 'SELECT l.rowid, l.fk_user_author as fk_user FROM '.MAIN_DB_PREFIX."loan as l WHERE l.entity IN (".getEntity('loan').")"; + } else { $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX.$tablename." WHERE ".$projectkey." IN (".$ids.") AND entity IN (".getEntity($type).")"; } - if ($dates > 0 && ($type != 'project_task')) // For table project_taks, we want the filter on date apply on project_time_spent table + if($dates > 0 && $type == 'loan'){ + $sql .= " AND (dateend > '".$this->db->idate($dates)."' OR dateend IS NULL)"; + } + elseif ($dates > 0 && ($type != 'project_task')) // For table project_taks, we want the filter on date apply on project_time_spent table { if (empty($datefieldname) && !empty($this->table_element_date)) $datefieldname = $this->table_element_date; if (empty($datefieldname)) return 'Error this object has no date field defined'; $sql .= " AND (".$datefieldname." >= '".$this->db->idate($dates)."' OR ".$datefieldname." IS NULL)"; } - if ($datee > 0 && ($type != 'project_task')) // For table project_taks, we want the filter on date apply on project_time_spent table + + if($datee > 0 && $type == 'loan'){ + $sql .= " AND (datestart < '".$this->db->idate($datee)."' OR datestart IS NULL)"; + } + elseif ($datee > 0 && ($type != 'project_task')) // For table project_taks, we want the filter on date apply on project_time_spent table { if (empty($datefieldname) && !empty($this->table_element_date)) $datefieldname = $this->table_element_date; if (empty($datefieldname)) return 'Error this object has no date field defined'; diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 9b49f2814a9..2aa112bd722 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -49,6 +49,7 @@ if (! empty($conf->expensereport->enabled)) require_once DOL_DOCUMENT_ROOT.'/exp if (! empty($conf->agenda->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; if (! empty($conf->don->enabled)) require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; if (! empty($conf->loan->enabled)) require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; +if (! empty($conf->loan->enabled)) require_once DOL_DOCUMENT_ROOT.'/loan/class/loanschedule.class.php'; if (! empty($conf->stock->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; if (! empty($conf->tax->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; if (! empty($conf->banque->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php'; @@ -650,6 +651,32 @@ foreach ($listofreferent as $key => $value) $total_ht_by_line = price2num($tmp['amount'], 'MT'); } } + elseif ($key == 'loan'){ + if((empty($dates) && empty($datee)) || (intval($dates) <= $element->datestart && intval($datee) >= $element->dateend)){ + // Get total loan + $total_ht_by_line = -$element->capital; + } + else{ + // Get loan schedule according to date filter + $total_ht_by_line = 0; + $loanScheduleStatic = new LoanSchedule($element->db); + $loanScheduleStatic->fetchAll($element->id); + if(!empty($loanScheduleStatic->lines)){ + foreach($loanScheduleStatic->lines as $loanSchedule){ + /** + * @var $loanSchedule LoanSchedule + */ + if( ($loanSchedule->datep >= $dates && $loanSchedule->datep <= $datee) // dates filter is defined + || !empty($dates) && empty($datee) && $loanSchedule->datep >= $dates && $loanSchedule->datep <= dol_now() + || empty($dates) && !empty($datee) && $loanSchedule->datep <= $datee + ){ + $total_ht_by_line = -$loanSchedule->amount_capital; + } + } + } + } + + } else $total_ht_by_line = $element->total_ht; // Define $total_ttc_by_line @@ -661,6 +688,9 @@ foreach ($listofreferent as $key => $value) $defaultvat = get_default_tva($mysoc, $mysoc); $total_ttc_by_line = price2num($total_ht_by_line * (1 + ($defaultvat / 100)), 'MT'); } + elseif ($key == 'loan'){ + $total_ttc_by_line = $total_ht_by_line; // For loan there is actually no taxe managed in Dolibarr + } else $total_ttc_by_line = $element->total_ttc; // Change sign of $total_ht_by_line and $total_ttc_by_line for some cases From 01b1667eedc9683a7fa36a9a6a4d585cd4d13823 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sun, 2 Feb 2020 08:13:09 +0000 Subject: [PATCH 6/6] Fixing style errors. --- htdocs/projet/element.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 2aa112bd722..dd89b3ca9c4 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -675,7 +675,6 @@ foreach ($listofreferent as $key => $value) } } } - } else $total_ht_by_line = $element->total_ht;