From 1a71e9b4a0377f2c42ebdccd65aa73c5bd73a6cb Mon Sep 17 00:00:00 2001 From: arnaud Date: Wed, 5 Jul 2017 16:57:03 +0200 Subject: [PATCH 1/4] FIX add supplierproposaldet without price (new product) --- htdocs/supplier_proposal/card.php | 5 +++-- htdocs/supplier_proposal/class/supplier_proposal.class.php | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 9ed38461180..e2bfb502028 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -526,7 +526,8 @@ if (empty($reshook)) $error = 0; // Set if we used free entry or predefined product - $predef=''; + $predef=''; + $ref_fourn = GETPOST('fourn_ref'); $product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):''); $date_start=dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start' . $predef . 'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); $date_end=dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end' . $predef . 'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); @@ -614,7 +615,7 @@ if (empty($reshook)) $price_base_type = $productsupplier->fourn_price_base_type; $type = $productsupplier->type; $label = $productsupplier->label; - $desc = $productsupplier->description; + $desc = $productsupplier->description; if (trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc); $tva_tx = get_default_tva($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice')); diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 8cbc3882fc4..6f973f4ce08 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -2738,6 +2738,7 @@ class SupplierProposalLine extends CommonObject if (empty($this->special_code)) $this->special_code=0; if (empty($this->fk_parent_line)) $this->fk_parent_line=0; if (empty($this->fk_fournprice)) $this->fk_fournprice=0; + if (empty($this->subprice)) $this->subprice=0; if (empty($this->pa_ht)) $this->pa_ht=0; @@ -2920,6 +2921,7 @@ class SupplierProposalLine extends CommonObject if (empty($this->special_code)) $this->special_code=0; if (empty($this->fk_parent_line)) $this->fk_parent_line=0; if (empty($this->fk_fournprice)) $this->fk_fournprice=0; + if (empty($this->subprice)) $this->subprice=0; if (empty($this->pa_ht)) $this->pa_ht=0; From 3d18c71201bc22c5ff5377418812e66caf774362 Mon Sep 17 00:00:00 2001 From: alexis Algoud Date: Wed, 5 Jul 2017 17:21:37 +0200 Subject: [PATCH 2/4] FIX invoice situation VAT total rounding into PDF crabe --- .../modules/facture/doc/pdf_crabe.modules.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 52971f76770..57c8d55c983 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -1120,7 +1120,26 @@ class pdf_crabe extends ModelePDFFactures } //} + // VAT + // Situations totals migth be wrong on huge amounts + if ($object->situation_cycle_ref && $object->situation_counter > 1) { + + $sum_pdf_tva = 0; + foreach($this->tva as $tvakey => $tvaval){ + $sum_pdf_tva+=$tvaval; // sum VAT amounts to compare to object + } + + if($sum_pdf_tva!=$object->total_tva) { // apply coef to recover the VAT object amount (the good one) + $coef_fix_tva = $object->total_tva / $sum_pdf_tva; + + foreach($this->tva as $tvakey => $tvaval) { + $this->tva[$tvakey]=$tvaval * $coef_fix_tva; + } + } + + } + foreach($this->tva as $tvakey => $tvaval) { if ($tvakey != 0) // On affiche pas taux 0 From f166c96ed5a5065c1fffedaefadee8b5eb972c8f Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sun, 9 Jul 2017 13:09:17 +0200 Subject: [PATCH 3/4] Fix : script to migrate photo path --- scripts/product/migrate_picture_path.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/product/migrate_picture_path.php b/scripts/product/migrate_picture_path.php index f8624ebc040..98a5c4d51bc 100755 --- a/scripts/product/migrate_picture_path.php +++ b/scripts/product/migrate_picture_path.php @@ -104,7 +104,7 @@ function migrate_product_photospath($product) global $conf; $dir = $conf->product->multidir_output[$product->entity]; - $origin = $dir .'/'. get_exdir($product->id,2) . $product->id ."/photos"; + $origin = $dir .'/'. get_exdir($product->id,2,0,0,$product,'product') . $product->id ."/photos"; $destin = $dir.'/'.dol_sanitizeFileName($product->ref); $error = 0; From f9b9a9972ebac4440825ad2cb70f5b5a98c3d8bf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 15 Jul 2017 17:22:57 +0200 Subject: [PATCH 4/4] Fix value not defined --- htdocs/accountancy/journal/bankjournal.php | 67 +++++++++++----------- 1 file changed, 34 insertions(+), 33 deletions(-) diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 05e54c7c167..a4840e47fcf 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -83,9 +83,9 @@ if ($user->societe_id > 0 && empty($id_bank_account)) /* * Actions */ - + $error = 0; - + $year_current = strftime("%Y", dol_now()); $pastmonth = strftime("%m", dol_now()) - 1; $pastmonthyear = $year_current; @@ -163,12 +163,13 @@ if ($result) { // one line for bank jounral = tabbq // one line for thirdparty journal = tabtp $i = 0; - while ( $i < $num ) + while ( $i < $num ) { $obj = $db->fetch_object($result); // Set accountancy code (for bank and thirdparty) $compta_bank = $obj->account_number; + $compta_soc = 'NotDefined'; if ($obj->label == '(SupplierInvoicePayment)' || $obj->label == '(SupplierInvoicePaymentBack)') $compta_soc = (! empty($obj->code_compta_fournisseur) ? $obj->code_compta_fournisseur : $account_supplier); if ($obj->label == '(CustomerInvoicePayment)' || $obj->label == '(CustomerInvoicePaymentBack)') @@ -179,7 +180,7 @@ if ($result) { 'name' => $obj->name, 'code_compta' => $compta_soc, ); - + $compta_user = (! empty($obj->accountancy_code) ? $obj->accountancy_code : $account_employee); $tabuser[$obj->rowid] = array ( @@ -205,10 +206,10 @@ if ($result) { if (is_array($links)) { // Now loop on each link of record in bank. foreach ( $links as $key => $val ) { - + if (in_array($links[$key]['type'], array('sc', 'payment_sc', 'payment', 'payment_supplier', 'payment_vat', 'payment_expensereport'))) // So we excluded 'company' here { - // We save tabtype for a future use, to remember what kind of payment it is + // We save tabtype for a future use, to remember what kind of payment it is $tabtype[$obj->rowid] = $links[$key]['type']; } @@ -225,12 +226,12 @@ if ($result) { $societestatic->id = $links[$key]['url_id']; $societestatic->name = $links[$key]['label']; $tabpay[$obj->rowid]["soclib"] = $societestatic->getNomUrl(1, '', 30); - $tabtp[$obj->rowid][$compta_soc] += $obj->amount; + if ($compta_soc) $tabtp[$obj->rowid][$compta_soc] += $obj->amount; } else if ($links[$key]['type'] == 'user') { $userstatic->id = $links[$key]['url_id']; $userstatic->name = $links[$key]['label']; $tabpay[$obj->rowid]["soclib"] = $userstatic->getNomUrl(1, '', 30); - $tabtp[$obj->rowid][$compta_user] += $obj->amount; + if ($compta_user) $tabtp[$obj->rowid][$compta_user] += $obj->amount; } else if ($links[$key]['type'] == 'sc') { $chargestatic->id = $links[$key]['url_id']; $chargestatic->ref = $links[$key]['url_id']; @@ -290,7 +291,7 @@ if ($result) { $tabbq[$obj->rowid][$compta_bank] += $obj->amount; - + // Check account number is ok /*if ($action == 'writebookkeeping') // Make test now in such a case { @@ -309,7 +310,7 @@ if ($result) { setEventMessages($langs->trans('ErrorAccountancyCodeOnThirdPartyNotDefined'), null, 'errors'); } }*/ - + // if($obj->socid)$tabtp[$obj->rowid][$compta_soc] += $obj->amount; $i ++; @@ -330,16 +331,16 @@ if (! $error && $action == 'writebookkeeping') { $error = 0; foreach ( $tabpay as $key => $val ) { // $key is rowid into llx_bank - + $errorforline = 0; - + $db->begin(); - + // Bank if (! $errorforline) { // Line into bank account - foreach ( $tabbq[$key] as $k => $mt ) + foreach ( $tabbq[$key] as $k => $mt ) { if ($mt) { $bookkeeping = new BookKeeping($db); @@ -357,10 +358,10 @@ if (! $error && $action == 'writebookkeeping') { $bookkeeping->code_journal = $journal; $bookkeeping->fk_user_author = $user->id; $bookkeeping->date_create = $now; - + if ($tabtype[$key] == 'payment') { $bookkeeping->code_tiers = $tabcompany[$key]['code_compta']; - + $sqlmid = 'SELECT fac.facnumber'; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture fac"; $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement_facture as payfac ON payfac.fk_facture=fac.rowid"; @@ -374,7 +375,7 @@ if (! $error && $action == 'writebookkeeping') { } } else if ($tabtype[$key] == 'payment_supplier') { $bookkeeping->code_tiers = $tabcompany[$key]['code_compta']; - + $sqlmid = 'SELECT facf.ref_supplier, facf.ref'; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf"; $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfacf ON payfacf.fk_facturefourn=facf.rowid"; @@ -388,7 +389,7 @@ if (! $error && $action == 'writebookkeeping') { } } else if ($tabtype[$key] == 'payment_expensereport') { $bookkeeping->code_tiers = $tabuser[$key]['accountancy_code']; - + $sqlmid = 'SELECT e.ref'; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "expensereport as e"; $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "payment_expensereport as payer ON payer.fk_expensereport=e.rowid"; @@ -400,7 +401,7 @@ if (! $error && $action == 'writebookkeeping') { $bookkeeping->doc_ref = $objmid->ref; // Ref of expensereport } } - + $result = $bookkeeping->create($user); if ($result < 0) { if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists @@ -419,7 +420,7 @@ if (! $error && $action == 'writebookkeeping') { } } } - + // Third party if (! $errorforline) { @@ -440,7 +441,7 @@ if (! $error && $action == 'writebookkeeping') { $bookkeeping->code_journal = $journal; $bookkeeping->fk_user_author = $user->id; $bookkeeping->date_create = $now; - + if (in_array($tabtype[$key], array('sc', 'payment_sc'))) { // If payment is payment of social contribution $bookkeeping->code_tiers = ''; $bookkeeping->numero_compte = $k; @@ -459,7 +460,7 @@ if (! $error && $action == 'writebookkeeping') { $bookkeeping->code_tiers = $tabcompany[$key]['code_compta']; $bookkeeping->numero_compte = $k; } else if ($tabtype[$key] == 'payment_supplier') { // If payment is payment of supplier invoice, we get ref of invoice - + $sqlmid = 'SELECT facf.ref_supplier,facf.ref'; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf "; $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfacf ON payfacf.fk_facturefourn=facf.rowid"; @@ -479,7 +480,7 @@ if (! $error && $action == 'writebookkeeping') { //$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER; $bookkeeping->numero_compte = 'CodeNotDef'; } - + $result = $bookkeeping->create($user); if ($result < 0) { if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists @@ -498,7 +499,7 @@ if (! $error && $action == 'writebookkeeping') { } } } - + if (! $errorforline) { $db->commit(); @@ -520,7 +521,7 @@ if (! $error && $action == 'writebookkeeping') { { setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings'); } - + $action = ''; } @@ -560,7 +561,7 @@ if ($action == 'export_csv') { if ($reflabel == '(ExpenseReportPayment)') { $reflabel = $langs->trans('Employee'); } - + $companystatic->id = $tabcompany[$key]['id']; $companystatic->name = $tabcompany[$key]['name']; @@ -704,7 +705,7 @@ if (empty($action) || $action == 'view') { $invoicestatic = new Facture($db); $invoicesupplierstatic = new FactureFournisseur($db); $expensereportstatic = new ExpenseReport($db); - + llxHeader('', $langs->trans("FinanceJournal")); $nom = $langs->trans("FinanceJournal") . ' - ' . $bank_code_journal->getNomUrl(1); @@ -714,7 +715,7 @@ if (empty($action) || $action == 'view') { $period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1); $varlink = 'id_account=' . $id_bank_account; - + report_header($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink); /*if ($conf->global->ACCOUNTING_EXPORT_MODELCSV != 1 && $conf->global->ACCOUNTING_EXPORT_MODELCSV != 2) { @@ -726,7 +727,7 @@ if (empty($action) || $action == 'view') { print '
'; print ''; print '
'; - + // TODO Avoid using js. We can use a direct link with $param print '