FIX When changing date of payment, change also record in bank if not

conciliated yet.
This commit is contained in:
Laurent Destailleur 2019-01-09 13:28:12 +01:00
parent 890abd28d5
commit d1e062cafa
4 changed files with 71 additions and 31 deletions

View File

@ -221,7 +221,12 @@ print '</td></tr>';
// Payment type (VIR, LIQ, ...)
$labeltype=$langs->trans("PaymentType".$object->type_code)!=("PaymentType".$object->type_code)?$langs->trans("PaymentType".$object->type_code):$object->type_libelle;
print '<tr><td>'.$langs->trans('PaymentMode').'</td><td>'.$labeltype.'</td></tr>';
print '<tr><td>'.$langs->trans('PaymentMode').'</td><td>'.$labeltype;
print $object->num_paiement?' - '.$object->num_paiement:'';
print '</td></tr>';
// Amount
print '<tr><td>'.$langs->trans('Amount').'</td><td>'.price($object->amount,'',$langs,0,-1,-1,$conf->currency).'</td></tr>';
$disable_delete = 0;
// Bank account
@ -302,9 +307,6 @@ print '<tr><td class="tdtop">'.$form->editfieldkey("Comments",'note',$object->no
print $form->editfieldval("Note",'note',$object->note,$object,$user->rights->facture->paiement,'textarea:'.ROWS_3.':90%');
print '</td></tr>';
// Amount
print '<tr><td>'.$langs->trans('Amount').'</td><td>'.price($object->amount,'',$langs,0,-1,-1,$conf->currency).'</td></tr>';
print '</table>';
print '</div>';

View File

@ -804,23 +804,55 @@ class Paiement extends CommonObject
function update_date($date)
{
// phpcs:enable
if (!empty($date) && $this->statut!=1)
$error=0;
if (!empty($date) && $this->statut != 1)
{
$this->db->begin();
dol_syslog(get_class($this)."::update_date with date = ".$date, LOG_DEBUG);
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
$sql.= " SET datep = '".$this->db->idate($date)."'";
$sql.= " WHERE rowid = ".$this->id;
dol_syslog(get_class($this)."::update_date", LOG_DEBUG);
$result = $this->db->query($sql);
if ($result)
if (! $result)
{
$this->datepaye = $date;
$error++;
$this->error='Error -1 '.$this->db->error();
}
$type = $this->element;
$sql = "UPDATE ".MAIN_DB_PREFIX.'bank';
$sql.= " SET dateo = '".$this->db->idate($date)."', datev = '".$this->db->idate($date)."'";
$sql.= " WHERE rowid IN (SELECT fk_bank FROM ".MAIN_DB_PREFIX."bank_url WHERE type = '".$type."' AND url_id = ".$this->id.")";
$sql.= " AND rappro = 0";
$result = $this->db->query($sql);
if (! $result)
{
$error++;
$this->error='Error -1 '.$this->db->error();
}
if (! $error)
{
}
if (! $error)
{
$this->datepaye = $date;
$this->date = $date;
$this->db->commit();
return 0;
}
else
{
$this->error='Error -1 '.$this->db->error();
$this->db->rollback();
return -2;
}
}

View File

@ -114,6 +114,7 @@ class PaiementFourn extends Paiement
$this->date = $this->db->jdate($obj->dp);
$this->datepaye = $this->db->jdate($obj->dp);
$this->numero = $obj->num_paiement;
$this->num_paiement = $obj->num_paiement;
$this->bank_account = $obj->fk_account;
$this->bank_line = $obj->fk_bank;
$this->montant = $obj->amount;

View File

@ -198,12 +198,16 @@ if ($result > 0)
// Payment mode
$labeltype=$langs->trans("PaymentType".$object->type_code)!=("PaymentType".$object->type_code)?$langs->trans("PaymentType".$object->type_code):$object->type_libelle;
print '<tr><td colspan="2">'.$langs->trans('PaymentMode').'</td><td colspan="3">'.$labeltype.'</td></tr>';
print '<tr><td colspan="2">'.$langs->trans('PaymentMode').'</td><td colspan="3">'.$labeltype;
print $object->num_paiement?' - '.$object->num_paiement:'';
print '</td></tr>';
// Payment numero
print '<tr><td colspan="2">'.$form->editfieldkey("Numero",'num_paiement',$object->numero,$object,$object->statut == 0 && $user->rights->fournisseur->facture->creer).'</td><td colspan="3">';
print $form->editfieldval("Numero",'num_paiement',$object->numero,$object,$object->statut == 0 && $user->rights->fournisseur->facture->creer,'string','',null,$langs->trans('PaymentNumberUpdateSucceeded'));
/* TODO Add field num_payment into payment table and save it
print '<tr><td colspan="2">'.$form->editfieldkey("Numero",'num_paiement',$object->num_paiement,$object,$object->statut == 0 && $user->rights->fournisseur->facture->creer).'</td><td colspan="3">';
print $form->editfieldval("Numero",'num_paiement',$object->num_paiement,$object,$object->statut == 0 && $user->rights->fournisseur->facture->creer,'string','',null,$langs->trans('PaymentNumberUpdateSucceeded'));
print '</td></tr>';
*/
// Amount
print '<tr><td colspan="2">'.$langs->trans('Amount').'</td><td colspan="3">'.price($object->montant,'',$langs,0,0,-1,$conf->currency).'</td></tr>';
@ -213,11 +217,6 @@ if ($result > 0)
print '<tr><td colspan="2">'.$langs->trans('Status').'</td><td colspan="3">'.$object->getLibStatut(4).'</td></tr>';
}
// Note
print '<tr><td colspan="2">'.$form->editfieldkey("Note",'note',$object->note,$object,$user->rights->fournisseur->facture->creer).'</td><td colspan="3">';
print $form->editfieldval("Note",'note',$object->note,$object,$user->rights->fournisseur->facture->creer,'textarea');
print '</td></tr>';
$allow_delete = 1 ;
// Bank account
if (! empty($conf->banque->enabled))
@ -232,13 +231,6 @@ if ($result > 0)
$title_button = dol_escape_htmltag($langs->transnoentitiesnoconv("CantRemoveConciliatedPayment"));
}
print '<tr>';
print '<td colspan="2">'.$langs->trans('BankTransactionLine').'</td>';
print '<td colspan="3">';
print $bankline->getNomUrl(1,0,'showconciliated');
print '</td>';
print '</tr>';
print '<tr>';
print '<td colspan="2">'.$langs->trans('BankAccount').'</td>';
print '<td colspan="3">';
@ -247,9 +239,21 @@ if ($result > 0)
print $accountstatic->getNomUrl(1);
print '</td>';
print '</tr>';
print '<tr>';
print '<td colspan="2">'.$langs->trans('BankTransactionLine').'</td>';
print '<td colspan="3">';
print $bankline->getNomUrl(1,0,'showconciliated');
print '</td>';
print '</tr>';
}
}
// Note
print '<tr><td colspan="2">'.$form->editfieldkey("Note",'note',$object->note,$object,$user->rights->fournisseur->facture->creer).'</td><td colspan="3">';
print $form->editfieldval("Note",'note',$object->note,$object,$user->rights->fournisseur->facture->creer,'textarea');
print '</td></tr>';
print '</table>';
print '</div>';
@ -276,9 +280,9 @@ if ($result > 0)
print '<td>'.$langs->trans('Ref').'</td>';
print '<td>'.$langs->trans('RefSupplier').'</td>';
print '<td>'.$langs->trans('Company').'</td>';
print '<td align="right">'.$langs->trans('ExpectedToPay').'</td>';
print '<td align="center">'.$langs->trans('Status').'</td>';
print '<td align="right">'.$langs->trans('PayedByThisPayment').'</td>';
print '<td class="right">'.$langs->trans('ExpectedToPay').'</td>';
print '<td class="right">'.$langs->trans('PayedByThisPayment').'</td>';
print '<td class="right">'.$langs->trans('Status').'</td>';
print "</tr>\n";
if ($num > 0)
@ -302,12 +306,13 @@ if ($result > 0)
// Third party
print '<td><a href="'.DOL_URL_ROOT.'/fourn/card.php?socid='.$objp->socid.'">'.img_object($langs->trans('ShowCompany'),'company').' '.$objp->name.'</a></td>';
// Expected to pay
print '<td align="right">'.price($objp->total_ttc).'</td>';
// Status
print '<td align="center">'.$facturestatic->LibStatut($objp->paye,$objp->fk_statut,2,1).'</td>';
print '<td class="right">'.price($objp->total_ttc).'</td>';
// Payed
print '<td align="right">'.price($objp->amount).'</td>';
print '<td class="right">'.price($objp->amount).'</td>';
// Status
print '<td class="right">'.$facturestatic->LibStatut($objp->paye, $objp->fk_statut, 6, 1).'</td>';
print "</tr>\n";
if ($objp->paye == 1)
{
$allow_delete = 0;