Merge branch '10.0' of git@github.com:Dolibarr/dolibarr.git into develop

Conflicts:
	htdocs/core/lib/accounting.lib.php
	htdocs/product/stock/class/entrepot.class.php
This commit is contained in:
Laurent Destailleur 2019-06-20 18:24:43 +02:00
commit 8da5794777
13 changed files with 162 additions and 86 deletions

View File

@ -626,7 +626,7 @@ if ($action == 'create')
} }
else else
{ {
print '<input type="text" name="subledger_account" value="'.(GETPOSTISSET("subledger_account") ? GETPOST("subledger_account", "alpha") : $line->subledger_account).'">'; print '<input type="text" class="maxwidth150" name="subledger_account" value="'.(GETPOSTISSET("subledger_account") ? GETPOST("subledger_account", "alpha") : $line->subledger_account).'">';
} }
print '</td>'; print '</td>';
print '<td><input type="text" class="minwidth200" name="label_operation" value="' . (GETPOSTISSET("label_operation") ? GETPOST("label_operation", "alpha") : $line->label_operation). '"></td>'; print '<td><input type="text" class="minwidth200" name="label_operation" value="' . (GETPOSTISSET("label_operation") ? GETPOST("label_operation", "alpha") : $line->label_operation). '"></td>';
@ -683,7 +683,7 @@ if ($action == 'create')
} }
else else
{ {
print '<input type="text" name="subledger_account" value="">'; print '<input type="text" class="maxwidth150" name="subledger_account" value="">';
} }
print '</td>'; print '</td>';
print '<td><input type="text" class="minwidth200" name="label_operation" value="'.$label_operation.'"/></td>'; print '<td><input type="text" class="minwidth200" name="label_operation" value="'.$label_operation.'"/></td>';

View File

@ -309,8 +309,10 @@ if ($action == 'delbookkeeping') {
if ($result < 0) { if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
Header("Location: list.php");
exit(); // Make a redirect to avoid to launch the delete later after a back button
header("Location: list.php".($param?'?'.$param:''));
exit;
} }
} }
if ($action == 'delbookkeepingyearconfirm') { if ($action == 'delbookkeepingyearconfirm') {
@ -334,14 +336,14 @@ if ($action == 'delbookkeepingyearconfirm') {
{ {
setEventMessages("RecordDeleted", null, 'mesgs'); setEventMessages("RecordDeleted", null, 'mesgs');
} }
Header("Location: list.php");
// Make a redirect to avoid to launch the delete later after a back button
header("Location: list.php".($param?'?'.$param:''));
exit; exit;
} }
else else
{ {
setEventMessages("NoRecordDeleted", null, 'warnings'); setEventMessages("NoRecordDeleted", null, 'warnings');
Header("Location: list.php");
exit;
} }
} }
if ($action == 'delmouvconfirm') { if ($action == 'delmouvconfirm') {
@ -358,7 +360,7 @@ if ($action == 'delmouvconfirm') {
setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs'); setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
} }
Header("Location: list.php?noreset=1".($param?'&'.$param:'')); header("Location: list.php?noreset=1".($param?'&'.$param:''));
exit; exit;
} }
} }
@ -481,7 +483,7 @@ if ($action == 'delbookkeepingyear') {
'default' => $deljournal 'default' => $deljournal
); );
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'delbookkeepingyearconfirm', $form_question, 0, 1, 250); $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?'.$param, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'delbookkeepingyearconfirm', $form_question, 0, 1, 250);
print $formconfirm; print $formconfirm;
} }
@ -510,7 +512,7 @@ if (! empty($conf->global->ACCOUNTING_REEXPORT)) {
} else { } else {
$newcardbutton ='<a href="'.$_SERVER['PHP_SELF'].'?action=setreexport&value=1'.($param?'&'.$param:'').'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a> '; $newcardbutton ='<a href="'.$_SERVER['PHP_SELF'].'?action=setreexport&value=1'.($param?'&'.$param:'').'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a> ';
} }
$newcardbutton.= $langs->trans("IncludeDocsAlreadyExported"); $newcardbutton.= '<span class="valignmiddle marginrightonly">'.$langs->trans("IncludeDocsAlreadyExported").'</span>';
$newcardbutton.= dolGetButtonTitle($buttonLabel, $langs->trans("ExportFilteredList").' ('.$listofformat[$conf->global->ACCOUNTING_EXPORT_MODELCSV].')', 'fa fa-file-export paddingleft', $_SERVER["PHP_SELF"].'?action=export_file'.($param?'&'.$param:'')); $newcardbutton.= dolGetButtonTitle($buttonLabel, $langs->trans("ExportFilteredList").' ('.$listofformat[$conf->global->ACCOUNTING_EXPORT_MODELCSV].')', 'fa fa-file-export paddingleft', $_SERVER["PHP_SELF"].'?action=export_file'.($param?'&'.$param:''));
@ -581,7 +583,7 @@ if (! empty($arrayfields['t.subledger_account']['checked']))
} }
else else
{ {
print '<input type="text" name="search_accountancy_aux_code_start" value="'.$search_accountancy_aux_code_start.'">'; print '<input type="text" class="maxwidth100" name="search_accountancy_aux_code_start" value="'.$search_accountancy_aux_code_start.'">';
} }
print '</div>'; print '</div>';
print '<div class="nowrap">'; print '<div class="nowrap">';
@ -594,7 +596,7 @@ if (! empty($arrayfields['t.subledger_account']['checked']))
} }
else else
{ {
print '<input type="text" name="search_accountancy_aux_code_end" value="'.$search_accountancy_aux_code_end.'">'; print '<input type="text" class="maxwidth100" name="search_accountancy_aux_code_end" value="'.$search_accountancy_aux_code_end.'">';
} }
print '</div>'; print '</div>';
print '</td>'; print '</td>';
@ -817,8 +819,8 @@ if ($num > 0)
// Action column // Action column
print '<td class="nowraponall center">'; print '<td class="nowraponall center">';
if(empty($line->date_export)) { if(empty($line->date_export)) {
print '<a href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?piece_num=' . $line->piece_num . $param . '&page=' . $page . ($sortfield ? '&sortfield='.$sortfield : '') . ($sortorder ? '&sortorder='.$sortorder : '') . '">' . img_edit() . '</a>&nbsp;'; print '<a href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?piece_num=' . urlencode($line->piece_num) . $param . '&page=' . $page . ($sortfield ? '&sortfield='.$sortfield : '') . ($sortorder ? '&sortorder='.$sortorder : '') . '">' . img_edit() . '</a>&nbsp;';
print '<a href="' . $_SERVER['PHP_SELF'] . '?action=delmouv&mvt_num=' . $line->piece_num . $param . '&page=' . $page . ($sortfield ? '&sortfield='.$sortfield : '') . ($sortorder ? '&sortorder='.$sortorder : '') . '">' . img_delete() . '</a>'; print '<a href="' . $_SERVER['PHP_SELF'] . '?action=delmouv&mvt_num=' . urlencode($line->piece_num) . $param . '&page=' . $page . ($sortfield ? '&sortfield='.$sortfield : '') . ($sortorder ? '&sortorder='.$sortorder : '') . '">' . img_delete() . '</a>';
} }
print '</td>'; print '</td>';
if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['nbfield']++;

View File

@ -107,8 +107,6 @@ if (! GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end)
$date_end = dol_get_last_day($pastmonthyear, $pastmonth, false); $date_end = dol_get_last_day($pastmonthyear, $pastmonth, false);
} }
$idpays = $mysoc->country_id;
$sql = "SELECT b.rowid, b.dateo as do, b.datev as dv, b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type, b.fk_account,"; $sql = "SELECT b.rowid, b.dateo as do, b.datev as dv, b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type, b.fk_account,";
$sql .= " ba.courant, ba.ref as baref, ba.account_number, ba.fk_accountancy_journal,"; $sql .= " ba.courant, ba.ref as baref, ba.account_number, ba.fk_accountancy_journal,";
$sql .= " soc.code_compta, soc.code_compta_fournisseur, soc.rowid as socid, soc.nom as name, soc.email as email, bu1.type as typeop_company,"; $sql .= " soc.code_compta, soc.code_compta_fournisseur, soc.rowid as socid, soc.nom as name, soc.email as email, bu1.type as typeop_company,";
@ -154,6 +152,9 @@ $paymentloanstatic = new PaymentLoan($db);
$accountLinestatic=new AccountLine($db); $accountLinestatic=new AccountLine($db);
$paymentsubscriptionstatic = new Subscription($db); $paymentsubscriptionstatic = new Subscription($db);
$tmppayment = new Paiement($db);
$tmpinvoice = new Facture($db);
$accountingaccount = new AccountingAccount($db); $accountingaccount = new AccountingAccount($db);
// Get code of finance journal // Get code of finance journal
@ -185,6 +186,7 @@ if ($result) {
$tabbq = array (); $tabbq = array ();
$tabtp = array (); $tabtp = array ();
$tabtype = array (); $tabtype = array ();
$tabmoreinfo = array();
// Loop on each line into llx_bank table. For each line, we should get: // Loop on each line into llx_bank table. For each line, we should get:
// one line tabpay = line into bank // one line tabpay = line into bank
@ -215,7 +217,7 @@ if ($result) {
// Set accountancy code for bank // Set accountancy code for bank
$compta_bank = $obj->account_number; $compta_bank = $obj->account_number;
// Set accountancy code for thirdparty // Set accountancy code for thirdparty (example: '411CU...' or '411' if no subledger account defined on customer)
$compta_soc = 'NotDefined'; $compta_soc = 'NotDefined';
if ($lineisapurchase > 0) if ($lineisapurchase > 0)
$compta_soc = (($obj->code_compta_fournisseur != "") ? $obj->code_compta_fournisseur : $account_supplier); $compta_soc = (($obj->code_compta_fournisseur != "") ? $obj->code_compta_fournisseur : $account_supplier);
@ -257,10 +259,12 @@ if ($result) {
//var_dump($i); //var_dump($i);
//var_dump($tabpay); //var_dump($tabpay);
//var_dump($tabcompany);
// By default // By default
$tabpay[$obj->rowid]['type'] = 'unknown'; // Can be SOLD, miscellaneous entry, payment of patient, or any old record with no links in bank_url. $tabpay[$obj->rowid]['type'] = 'unknown'; // Can be SOLD, miscellaneous entry, payment of patient, or any old record with no links in bank_url.
$tabtype[$obj->rowid] = 'unknown'; $tabtype[$obj->rowid] = 'unknown';
$tabmoreinfo[$obj->rowid] = array();
// get_url may return -1 which is not traversable // get_url may return -1 which is not traversable
if (is_array($links) && count($links) > 0) { if (is_array($links) && count($links) > 0) {
@ -285,6 +289,10 @@ if ($result) {
} }
} }
if ($links[$key]['type'] == 'withdraw') {
$tabmoreinfo[$obj->rowid]['withdraw']=1;
}
if ($links[$key]['type'] == 'payment') { if ($links[$key]['type'] == 'payment') {
$paymentstatic->id = $links[$key]['url_id']; $paymentstatic->id = $links[$key]['url_id'];
$paymentstatic->ref = $links[$key]['url_id']; $paymentstatic->ref = $links[$key]['url_id'];
@ -411,7 +419,29 @@ if ($result) {
$tabbq[$obj->rowid][$compta_bank] += $obj->amount; $tabbq[$obj->rowid][$compta_bank] += $obj->amount;
// If not links were found to know amount on thirdparty, we init it. // If no links were found to know the amount on thirdparty, we try to guess it.
// This may happens on bank entries without the links lines to 'company'.
if (empty($tabtp[$obj->rowid]) && ! empty($tabmoreinfo[$obj->rowid]['withdraw'])) // If we dont find 'company' link because it is an old 'withdraw' record
{
foreach ($links as $key => $val) {
if ($links[$key]['type'] == 'payment') {
// Get thirdparty
$tmppayment->fetch($links[$key]['url_id']);
$arrayofamounts = $tmppayment->getAmountsArray();
foreach($arrayofamounts as $invoiceid => $amount)
{
$tmpinvoice->fetch($invoiceid);
$tmpinvoice->fetch_thirdparty();
if ($tmpinvoice->thirdparty->code_compta)
{
$tabtp[$obj->rowid][$tmpinvoice->thirdparty->code_compta] += $amount;
}
}
}
}
}
// If no links were found to know the amount on thirdparty, we init it to account 'NotDefined'.
if (empty($tabtp[$obj->rowid])) $tabtp[$obj->rowid]['NotDefined'] = $tabbq[$obj->rowid][$compta_bank]; if (empty($tabtp[$obj->rowid])) $tabtp[$obj->rowid]['NotDefined'] = $tabbq[$obj->rowid][$compta_bank];
// Check account number is ok // Check account number is ok
@ -441,11 +471,12 @@ if ($result) {
dol_print_error($db); dol_print_error($db);
} }
/*
var_dump($tabpay); /*var_dump($tabpay);
var_dump($tabcompany);
var_dump($tabbq); var_dump($tabbq);
var_dump($tabtp); var_dump($tabtp);
*/ var_dump($tabtype);*/
// Write bookkeeping // Write bookkeeping
if (! $error && $action == 'writebookkeeping') { if (! $error && $action == 'writebookkeeping') {
@ -561,15 +592,15 @@ if (! $error && $action == 'writebookkeeping') {
$bookkeeping->date_create = $now; $bookkeeping->date_create = $now;
if ($tabtype[$key] == 'payment') { // If payment is payment of customer invoice, we get ref of invoice if ($tabtype[$key] == 'payment') { // If payment is payment of customer invoice, we get ref of invoice
$bookkeeping->subledger_account = $tabcompany[$key]['code_compta']; $bookkeeping->subledger_account = $k; // For payment, the subledger account is stored as $key of $tabtp
$bookkeeping->subledger_label = $tabcompany[$key]['name']; $bookkeeping->subledger_label = $tabcompany[$key]['name']; // $tabcompany is defined only if we are sure there is 1 thirdparty for the bank transaction
$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER; $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER;
$accountingaccount->fetch(null, $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER, true); $accountingaccount->fetch(null, $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER, true);
$bookkeeping->label_compte = $accountingaccount->label; $bookkeeping->label_compte = $accountingaccount->label;
} elseif ($tabtype[$key] == 'payment_supplier') { // If payment is payment of supplier invoice, we get ref of invoice } elseif ($tabtype[$key] == 'payment_supplier') { // If payment is payment of supplier invoice, we get ref of invoice
$bookkeeping->subledger_account = $tabcompany[$key]['code_compta']; $bookkeeping->subledger_account = $k; // For payment, the subledger account is stored as $key of $tabtp
$bookkeeping->subledger_label = $tabcompany[$key]['name']; $bookkeeping->subledger_label = $tabcompany[$key]['name']; // $tabcompany is defined only if we are sure there is 1 thirdparty for the bank transaction
$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER; $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER;
$accountingaccount->fetch(null, $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER, true); $accountingaccount->fetch(null, $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER, true);
@ -701,6 +732,7 @@ if (! $error && $action == 'writebookkeeping') {
$totalcredit += $bookkeeping->credit; $totalcredit += $bookkeeping->credit;
$result = $bookkeeping->create($user); $result = $bookkeeping->create($user);
if ($result < 0) { if ($result < 0) {
if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists
{ {
@ -1071,7 +1103,6 @@ if (empty($action) || $action == 'view') {
if ($tabtype[$key] == 'payment_salary') $account_ledger = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT; if ($tabtype[$key] == 'payment_salary') $account_ledger = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT;
if ($tabtype[$key] == 'payment_vat') $account_ledger = $conf->global->ACCOUNTING_VAT_PAY_ACCOUNT; if ($tabtype[$key] == 'payment_vat') $account_ledger = $conf->global->ACCOUNTING_VAT_PAY_ACCOUNT;
if ($tabtype[$key] == 'member') $account_ledger = $conf->global->ADHERENT_SUBSCRIPTION_ACCOUNTINGACCOUNT; if ($tabtype[$key] == 'member') $account_ledger = $conf->global->ADHERENT_SUBSCRIPTION_ACCOUNTINGACCOUNT;
$accounttoshow = length_accounta($account_ledger); $accounttoshow = length_accounta($account_ledger);
if (empty($accounttoshow) || $accounttoshow == 'NotDefined') if (empty($accounttoshow) || $accounttoshow == 'NotDefined')
{ {
@ -1104,6 +1135,7 @@ if (empty($action) || $action == 'view') {
print "</td>"; print "</td>";
// Subledger account // Subledger account
print "<td>"; print "<td>";
if (in_array($tabtype[$key], array('payment', 'payment_supplier', 'payment_expensereport', 'payment_salary'))) // Type of payment with subledger if (in_array($tabtype[$key], array('payment', 'payment_supplier', 'payment_expensereport', 'payment_salary'))) // Type of payment with subledger
{ {
$accounttoshowsubledger = length_accounta($k); $accounttoshowsubledger = length_accounta($k);
@ -1115,7 +1147,14 @@ if (empty($action) || $action == 'view') {
var_dump($tabtype[$key]); var_dump($tabtype[$key]);
var_dump($tabbq[$key]);*/ var_dump($tabbq[$key]);*/
//print '<span class="error">'.$langs->trans("ThirdpartyAccountNotDefined").'</span>'; //print '<span class="error">'.$langs->trans("ThirdpartyAccountNotDefined").'</span>';
print '<span class="error">'.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknown").'</span>'; if (! empty($tabcompany[$key]['code_compta']))
{
print '<span class="warning">'.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknown", $tabcompany[$key]['code_compta']).'</span>';
}
else
{
print '<span class="error">'.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknownBlocking").'</span>';
}
} }
else print $accounttoshowsubledger; else print $accounttoshowsubledger;
} }

View File

@ -87,15 +87,11 @@ if (! GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end)
$date_end = dol_get_last_day($pastmonthyear, $pastmonth, false); $date_end = dol_get_last_day($pastmonthyear, $pastmonth, false);
} }
$idpays = $mysoc->country_id;
$sql = "SELECT er.rowid, er.ref, er.date_debut as de,"; $sql = "SELECT er.rowid, er.ref, er.date_debut as de,";
$sql .= " erd.rowid as erdid, erd.comments, erd.total_ht, erd.total_tva, erd.total_localtax1, erd.total_localtax2, erd.tva_tx, erd.total_ttc, erd.fk_code_ventilation, erd.vat_src_code, "; $sql .= " erd.rowid as erdid, erd.comments, erd.total_ht, erd.total_tva, erd.total_localtax1, erd.total_localtax2, erd.tva_tx, erd.total_ttc, erd.fk_code_ventilation, erd.vat_src_code, ";
$sql .= " u.rowid as uid, u.firstname, u.lastname, u.accountancy_code as user_accountancy_account,"; $sql .= " u.rowid as uid, u.firstname, u.lastname, u.accountancy_code as user_accountancy_account,";
$sql .= " f.accountancy_code, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte"; $sql .= " f.accountancy_code, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte";
//$sql .= " ct.accountancy_code_buy as account_tva";
$sql .= " FROM " . MAIN_DB_PREFIX . "expensereport_det as erd"; $sql .= " FROM " . MAIN_DB_PREFIX . "expensereport_det as erd";
//$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_tva as ct ON erd.tva_tx = ct.taux AND ct.fk_pays = '" . $idpays . "'";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_type_fees as f ON f.id = erd.fk_c_type_fees"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_type_fees as f ON f.id = erd.fk_c_type_fees";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = erd.fk_code_ventilation"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = erd.fk_code_ventilation";
$sql .= " JOIN " . MAIN_DB_PREFIX . "expensereport as er ON er.rowid = erd.fk_expensereport"; $sql .= " JOIN " . MAIN_DB_PREFIX . "expensereport as er ON er.rowid = erd.fk_expensereport";

View File

@ -92,8 +92,6 @@ if (! GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end)
$date_end = dol_get_last_day($pastmonthyear, $pastmonth, false); $date_end = dol_get_last_day($pastmonthyear, $pastmonth, false);
} }
$idpays = $mysoc->country_id;
$sql = "SELECT f.rowid, f.ref as ref, f.type, f.datef as df, f.libelle,f.ref_supplier, f.date_lim_reglement as dlf, f.close_code,"; $sql = "SELECT f.rowid, f.ref as ref, f.type, f.datef as df, f.libelle,f.ref_supplier, f.date_lim_reglement as dlf, f.close_code,";
$sql .= " fd.rowid as fdid, fd.description, fd.product_type, fd.total_ht, fd.tva as total_tva, fd.total_localtax1, fd.total_localtax2, fd.tva_tx, fd.total_ttc, fd.vat_src_code,"; $sql .= " fd.rowid as fdid, fd.description, fd.product_type, fd.total_ht, fd.tva as total_tva, fd.total_localtax1, fd.total_localtax2, fd.tva_tx, fd.total_ttc, fd.vat_src_code,";
$sql .= " s.rowid as socid, s.nom as name, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; $sql .= " s.rowid as socid, s.nom as name, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,";

View File

@ -95,8 +95,6 @@ if (! GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end)
$date_end = dol_get_last_day($pastmonthyear, $pastmonth, false); $date_end = dol_get_last_day($pastmonthyear, $pastmonth, false);
} }
$idpays = $mysoc->country_id;
$sql = "SELECT f.rowid, f.ref, f.type, f.datef as df, f.ref_client, f.date_lim_reglement as dlr, f.close_code,"; $sql = "SELECT f.rowid, f.ref, f.type, f.datef as df, f.ref_client, f.date_lim_reglement as dlr, f.close_code,";
$sql .= " fd.rowid as fdid, fd.description, fd.product_type, fd.total_ht, fd.total_tva, fd.total_localtax1, fd.total_localtax2, fd.tva_tx, fd.total_ttc, fd.situation_percent, fd.vat_src_code,"; $sql .= " fd.rowid as fdid, fd.description, fd.product_type, fd.total_ht, fd.total_tva, fd.total_localtax1, fd.total_localtax2, fd.tva_tx, fd.total_ttc, fd.situation_percent, fd.vat_src_code,";
$sql .= " s.rowid as socid, s.nom as name, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; $sql .= " s.rowid as socid, s.nom as name, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,";

View File

@ -382,7 +382,7 @@ if ($action == 'create')
} }
else else
{ {
print '<input type="text" name="subledger_account" value="'.$subledger_account.'">'; print '<input type="text" class="maxwidth200" name="subledger_account" value="'.$subledger_account.'">';
} }
print '</td></tr>'; print '</td></tr>';
} }

View File

@ -991,16 +991,16 @@ class Paiement extends CommonObject
} }
/** /**
* Retourne la liste des factures sur lesquels porte le paiement * Return list of invoices the payment is related to.
* *
* @param string $filter Critere de filtre * @param string $filter Filter
* @return array Tableau des id de factures * @return int|array <0 if KO or array of invoice id
*/ */
public function getBillsArray($filter = '') public function getBillsArray($filter = '')
{ {
$sql = 'SELECT fk_facture'; $sql = 'SELECT pf.fk_facture';
$sql.= ' FROM '.MAIN_DB_PREFIX.'paiement_facture as pf, '.MAIN_DB_PREFIX.'facture as f'; $sql.= ' FROM '.MAIN_DB_PREFIX.'paiement_facture as pf, '.MAIN_DB_PREFIX.'facture as f'; // We keep link on invoice to allow use of some filters on invoice
$sql.= ' WHERE pf.fk_facture = f.rowid AND fk_paiement = '.$this->id; $sql.= ' WHERE pf.fk_facture = f.rowid AND pf.fk_paiement = '.$this->id;
if ($filter) $sql.= ' AND '.$filter; if ($filter) $sql.= ' AND '.$filter;
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)
@ -1026,6 +1026,40 @@ class Paiement extends CommonObject
} }
} }
/**
* Return list of amounts of payments.
*
* @return int|array Array of amount of payments
*/
public function getAmountsArray()
{
$sql = 'SELECT pf.fk_facture, pf.amount';
$sql.= ' FROM '.MAIN_DB_PREFIX.'paiement_facture as pf';
$sql.= ' WHERE pf.fk_paiement = '.$this->id;
$resql = $this->db->query($sql);
if ($resql)
{
$i=0;
$num=$this->db->num_rows($resql);
$amounts = array();
while ($i < $num)
{
$obj = $this->db->fetch_object($resql);
$amounts[$obj->fk_facture]=$obj->amount;
$i++;
}
return $amounts;
}
else
{
$this->error=$this->db->error();
dol_syslog(get_class($this).'::getAmountsArray Error '.$this->error.' -', LOG_DEBUG);
return -1;
}
}
/** /**
* Return next reference of customer invoice not already used (or last reference) * Return next reference of customer invoice not already used (or last reference)
* according to numbering module defined into constant FACTURE_ADDON * according to numbering module defined into constant FACTURE_ADDON

View File

@ -28,7 +28,7 @@ create table llx_paiement
datep datetime, -- payment date datep datetime, -- payment date
amount double(24,8) DEFAULT 0, -- amount paid in Dolibarr currency amount double(24,8) DEFAULT 0, -- amount paid in Dolibarr currency
multicurrency_amount double(24,8) DEFAULT 0, -- amount paid in invoice currency multicurrency_amount double(24,8) DEFAULT 0, -- amount paid in invoice currency
fk_paiement integer NOT NULL, fk_paiement integer NOT NULL, -- type of payment in llx_c_paiement
num_paiement varchar(50), num_paiement varchar(50),
note text, note text,
ext_payment_id varchar(128), -- external id of payment (for example Stripe charge id) ext_payment_id varchar(128), -- external id of payment (for example Stripe charge id)

View File

@ -216,7 +216,8 @@ DescThirdPartyReport=Consult here the list of third-party customers and vendors
ListAccounts=List of the accounting accounts ListAccounts=List of the accounting accounts
UnknownAccountForThirdparty=Unknown third-party account. We will use %s UnknownAccountForThirdparty=Unknown third-party account. We will use %s
UnknownAccountForThirdpartyBlocking=Unknown third-party account. Blocking error UnknownAccountForThirdpartyBlocking=Unknown third-party account. Blocking error
ThirdpartyAccountNotDefinedOrThirdPartyUnknown=Third-party account not defined or third party unknown. Blocking error. ThirdpartyAccountNotDefinedOrThirdPartyUnknown=Third-party account not defined or third party unknown. We will use %s
ThirdpartyAccountNotDefinedOrThirdPartyUnknownBlocking=Third-party account not defined or third party unknown. Blocking error.
UnknownAccountForThirdpartyAndWaitingAccountNotDefinedBlocking=Unknown third-party account and waiting account not defined. Blocking error UnknownAccountForThirdpartyAndWaitingAccountNotDefinedBlocking=Unknown third-party account and waiting account not defined. Blocking error
PaymentsNotLinkedToProduct=Payment not linked to any product / service PaymentsNotLinkedToProduct=Payment not linked to any product / service

View File

@ -294,6 +294,8 @@ class Entrepot extends CommonObject
$error = 0; $error = 0;
dol_syslog(get_class($this)."::delete id=".$this->id, LOG_DEBUG);
$this->db->begin(); $this->db->begin();
if (! $error && empty($notrigger)) if (! $error && empty($notrigger))
@ -311,7 +313,7 @@ class Entrepot extends CommonObject
{ {
$sql = "DELETE FROM ".MAIN_DB_PREFIX.$table; $sql = "DELETE FROM ".MAIN_DB_PREFIX.$table;
$sql.= " WHERE fk_entrepot = " . $this->id; $sql.= " WHERE fk_entrepot = " . $this->id;
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$result=$this->db->query($sql); $result=$this->db->query($sql);
if (! $result) if (! $result)
{ {
@ -321,30 +323,41 @@ class Entrepot extends CommonObject
} }
} }
// Removed extrafields
if (! $error)
{
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{
$result=$this->deleteExtraFields();
if ($result < 0)
{
$error++;
dol_syslog(get_class($this)."::delete Error ".$this->error, LOG_ERR);
}
}
}
if (! $error) if (! $error)
{ {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."entrepot"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."entrepot";
$sql.= " WHERE rowid = " . $this->id; $sql.= " WHERE rowid = " . $this->id;
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$resql1=$this->db->query($sql); $resql1=$this->db->query($sql);
if (!$resql1) $error++; if (! $resql1)
{
$error++;
$this->errors[] = $this->db->lasterror();
}
}
if (! $error)
{
// Update denormalized fields because we change content of produt_stock. Warning: Do not use "SET p.stock", does not works with pgsql // Update denormalized fields because we change content of produt_stock. Warning: Do not use "SET p.stock", does not works with pgsql
$sql = "UPDATE ".MAIN_DB_PREFIX."product as p SET stock = (SELECT SUM(ps.reel) FROM ".MAIN_DB_PREFIX."product_stock as ps WHERE ps.fk_product = p.rowid)"; $sql = "UPDATE ".MAIN_DB_PREFIX."product as p SET stock = (SELECT SUM(ps.reel) FROM ".MAIN_DB_PREFIX."product_stock as ps WHERE ps.fk_product = p.rowid)";
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$resql2=$this->db->query($sql); $resql2=$this->db->query($sql);
if (!$resql2) $error++; if (! $resql2)
// Removed extrafields
if (! $error) {
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{ {
$result=$this->deleteExtraFields();
if ($result < 0) {
$error++; $error++;
$errorflag=-4; $this->errors[] = $this->db->lasterror();
dol_syslog(get_class($this)."::delete erreur ".$errorflag." ".$this->error, LOG_ERR);
}
} }
} }
@ -356,14 +369,6 @@ class Entrepot extends CommonObject
else else
{ {
$this->db->rollback(); $this->db->rollback();
$this->error=$this->db->lasterror();
return -2;
}
}
else
{
$this->db->rollback();
$this->error=$this->db->lasterror();
return -1; return -1;
} }
} }

View File

@ -211,6 +211,7 @@ class EntrepotTest extends PHPUnit_Framework_TestCase
$langs=$this->savlangs; $langs=$this->savlangs;
$db=$this->savdb; $db=$this->savdb;
//$this->assertLessThan(1, 0);
return $localobject->id; return $localobject->id;
} }
@ -257,6 +258,8 @@ class EntrepotTest extends PHPUnit_Framework_TestCase
$localobject=new Entrepot($db); $localobject=new Entrepot($db);
//$this->assertLessThan(1, 0);
return; return;
} }
} }