Prepare convertion of field "montant" into "amount"

This commit is contained in:
Laurent Destailleur 2020-06-17 12:45:56 +02:00
parent 4627f06c70
commit 7d3c176727
14 changed files with 67 additions and 55 deletions

View File

@ -114,11 +114,13 @@ if ($action == "confirm_update") {
$object->credit = $credit;
if (floatval($debit) != 0.0) {
$object->montant = $debit;
$object->montant = $debit; // deprecated
$object->amount = $debit;
$object->sens = 'D';
}
if (floatval($credit) != 0.0) {
$object->montant = $credit;
$object->montant = $credit; // deprecated
$object->amount = $credit;
$object->sens = 'C';
}
@ -173,12 +175,14 @@ if ($action == "confirm_update") {
$object->fk_docdet = (int) GETPOST('fk_docdet', 'int');
if (floatval($debit) != 0.0) {
$object->montant = $debit;
$object->montant = $debit; // deprecated
$object->amount = $debit;
$object->sens = 'D';
}
if (floatval($credit) != 0.0) {
$object->montant = $credit;
$object->montant = $credit; // deprecated
$object->amount = $credit;
$object->sens = 'C';
}
@ -241,7 +245,8 @@ if ($action == "confirm_update") {
$object->journal_label = $journal_label;
$object->fk_doc = 0;
$object->fk_docdet = 0;
$object->montant = 0;
$object->montant = 0; // deprecated
$object->amount = 0;
$result = $object->createStd($user, 0, $mode);
if ($result < 0) {

View File

@ -412,7 +412,7 @@ $sql .= " t.label_operation,";
$sql .= " t.debit,";
$sql .= " t.credit,";
$sql .= " t.lettering_code,";
$sql .= " t.montant,";
$sql .= " t.montant as amount,";
$sql .= " t.sens,";
$sql .= " t.fk_user_author,";
$sql .= " t.import_key,";
@ -860,7 +860,8 @@ while ($i < min($num, $limit))
$line->label_operation = $obj->label_operation;
$line->debit = $obj->debit;
$line->credit = $obj->credit;
$line->montant = $obj->montant;
$line->montant = $obj->amount; // deprecated
$line->amount = $obj->amount;
$line->sens = $obj->sens;
$line->lettering_code = $obj->lettering_code;
$line->fk_user_author = $obj->fk_user_author;

View File

@ -129,9 +129,15 @@ class BookKeeping extends CommonObject
/**
* @var float FEC:Amount (Not necessary)
* @deprecated Use $amount
*/
public $montant;
/**
* @var float FEC:Amount (Not necessary)
*/
public $amount;
/**
* @var string FEC:Sens (Not necessary)
*/

View File

@ -45,7 +45,7 @@ if (isset($_SESSION['serObjFacturation']))
$obj_facturation->calculTotaux(); // Redefine prix_total_ttc, prix_total_ht et montant_tva from $_SESSION['poscart']
$total_ttc = $obj_facturation->prixTotalTtc();
$total_ttc = $obj_facturation->amountWithTax();
/*var_dump($obj_facturation);
var_dump($_SESSION['poscart']);

View File

@ -140,7 +140,7 @@ class Facturation
$remise_percent = 0;
}
$montant_remise_ht = ($resultarray[6] - $resultarray[0]);
$this->montantRemise($montant_remise_ht);
$this->amountDiscount($montant_remise_ht);
$newcartarray = $_SESSION['poscart'];
@ -256,7 +256,7 @@ class Facturation
$this->qte('RESET');
$this->stock('RESET');
$this->remisePercent('RESET');
$this->montantRemise('RESET');
$this->amountDiscount('RESET');
$this->prix('RESET');
$this->tva('RESET');
}
@ -270,13 +270,13 @@ class Facturation
{
$this->numInvoice('RESET');
$this->getSetPaymentMode('RESET');
$this->montantEncaisse('RESET');
$this->montantRendu('RESET');
$this->amountCollected('RESET');
$this->amountReturned('RESET');
$this->paiementLe('RESET');
$this->prixTotalHt('RESET');
$this->montantTva('RESET');
$this->prixTotalTtc('RESET');
$this->amountWithoutTax('RESET');
$this->amountVat('RESET');
$this->amountWithTax('RESET');
}
@ -387,7 +387,7 @@ class Facturation
* @param int $aMontantRemise Amount
* @return string Amount
*/
public function montantRemise($aMontantRemise = null)
public function amountDiscount($aMontantRemise = null)
{
if (is_null($aMontantRemise)) {
@ -475,7 +475,7 @@ class Facturation
* @param int $aMontantEncaisse Amount
* @return int Amount
*/
public function montantEncaisse($aMontantEncaisse = null)
public function amountCollected($aMontantEncaisse = null)
{
if (is_null($aMontantEncaisse)) {
@ -493,7 +493,7 @@ class Facturation
* @param int $aMontantRendu Amount
* @return int Amount
*/
public function montantRendu($aMontantRendu = null)
public function amountReturned($aMontantRendu = null)
{
if (is_null($aMontantRendu)) {
@ -528,7 +528,7 @@ class Facturation
* @param int $aTotalHt Total amount
* @return int Total amount
*/
public function prixTotalHt($aTotalHt = null)
public function amountWithoutTax($aTotalHt = null)
{
if (is_null($aTotalHt)) {
return $this->prix_total_ht;
@ -545,7 +545,7 @@ class Facturation
* @param int $aMontantTva Amount vat
* @return int Amount vat
*/
public function montantTva($aMontantTva = null)
public function amountVat($aMontantTva = null)
{
if (is_null($aMontantTva)) {
return $this->montant_tva;
@ -562,7 +562,7 @@ class Facturation
* @param int $aTotalTtc Amount ttc
* @return int Amount ttc
*/
public function prixTotalTtc($aTotalTtc = null)
public function amountWithTax($aTotalTtc = null)
{
if (is_null($aTotalTtc))
{

View File

@ -145,8 +145,8 @@ $i = 0;
// Reinitialisation du mode de paiement, en cas de retour aux achats apres validation
$obj_facturation->getSetPaymentMode('RESET');
$obj_facturation->montantEncaisse('RESET');
$obj_facturation->montantRendu('RESET');
$obj_facturation->amountCollected('RESET');
$obj_facturation->amountReturned('RESET');
$obj_facturation->paiementLe('RESET');

View File

@ -149,7 +149,7 @@ for ($i = 0; $i < $nbtoshow; $i++)
<tr><th class="label1"><?php echo $langs->trans("TotalTicket"); ?></th><th class="label1"><?php echo $langs->trans("Received"); ?></th><th class="label1"><?php echo $langs->trans("Change"); ?></th></tr>
<tr>
<!-- Affichage du montant du -->
<td><input class="texte2_off maxwidth100onsmartphone" type="text" name="txtDu" value="<?php echo price2num($obj_facturation->prixTotalTtc(), 'MT'); ?>" disabled /></td>
<td><input class="texte2_off maxwidth100onsmartphone" type="text" name="txtDu" value="<?php echo price2num($obj_facturation->amountWithTax(), 'MT'); ?>" disabled /></td>
<!-- Choix du montant encaisse -->
<td><input class="texte2 maxwidth100onsmartphone" type="text" id="txtEncaisse" name="txtEncaisse" value="" onkeyup="javascript: verifDifference();" onfocus="javascript: this.select();" />
<?php print genkeypad("txtEncaisse", "frmDifference"); ?>

View File

@ -102,13 +102,13 @@ $object->fetch($facid);
<table class="totaux">
<tr>
<th class="nowrap"><?php echo $langs->trans("TotalHT"); ?></th>
<td class="nowrap"><?php echo price(price2num($obj_facturation->prixTotalHt(), 'MT'), '', $langs, 0, -1, -1, $conf->currency)."\n"; ?></td>
<td class="nowrap"><?php echo price(price2num($obj_facturation->amountWithoutTax(), 'MT'), '', $langs, 0, -1, -1, $conf->currency)."\n"; ?></td>
</tr>
<tr>
<th class="nowrap"><?php echo $langs->trans("TotalVAT").'</th><td class="nowrap">'.price(price2num($obj_facturation->montantTva(), 'MT'), '', $langs, 0, -1, -1, $conf->currency)."\n"; ?></td>
<th class="nowrap"><?php echo $langs->trans("TotalVAT").'</th><td class="nowrap">'.price(price2num($obj_facturation->amountVat(), 'MT'), '', $langs, 0, -1, -1, $conf->currency)."\n"; ?></td>
</tr>
<tr>
<th class="nowrap"><?php echo ''.$langs->trans("TotalTTC").'</th><td class="nowrap">'.price(price2num($obj_facturation->prixTotalTtc(), 'MT'), '', $langs, 0, -1, -1, $conf->currency)."\n"; ?></td>
<th class="nowrap"><?php echo ''.$langs->trans("TotalTTC").'</th><td class="nowrap">'.price(price2num($obj_facturation->amountWithTax(), 'MT'), '', $langs, 0, -1, -1, $conf->currency)."\n"; ?></td>
</tr>
</table>

View File

@ -35,16 +35,16 @@ $langs->loadLangs(array("main", "bills", "banks"));
<table class="table_resume">
<tr><td class="resume_label"><?php echo $langs->trans("Invoice"); ?></td><td><?php echo $obj_facturation->numInvoice(); ?></td></tr>
<tr><td class="resume_label"><?php echo $langs->trans("TotalHT"); ?></td><td><?php echo price(price2num($obj_facturation->prixTotalHt(), 'MT'), 0, $langs, 0, 0, -1, $conf->currency); ?></td></tr>
<tr><td class="resume_label"><?php echo $langs->trans("TotalHT"); ?></td><td><?php echo price(price2num($obj_facturation->amountWithoutTax(), 'MT'), 0, $langs, 0, 0, -1, $conf->currency); ?></td></tr>
<?php
// Affichage de la tva par taux
if ($obj_facturation->montantTva()) {
echo ('<tr><td class="resume_label">'.$langs->trans("VAT").'</td><td>'.price(price2num($obj_facturation->montantTva(), 'MT'), 0, $langs, 0, 0, -1, $conf->currency).'</td></tr>');
if ($obj_facturation->amountVat()) {
echo ('<tr><td class="resume_label">'.$langs->trans("VAT").'</td><td>'.price(price2num($obj_facturation->amountVat(), 'MT'), 0, $langs, 0, 0, -1, $conf->currency).'</td></tr>');
} else {
echo ('<tr><td class="resume_label">'.$langs->trans("VAT").'</td><td>'.$langs->trans("NoVAT").'</td></tr>');
}
?>
<tr><td class="resume_label"><?php echo $langs->trans("TotalTTC"); ?> </td><td><?php echo price(price2num($obj_facturation->prixTotalTtc(), 'MT'), 0, $langs, 0, 0, -1, $conf->currency); ?></td></tr>
<tr><td class="resume_label"><?php echo $langs->trans("TotalTTC"); ?> </td><td><?php echo price(price2num($obj_facturation->amountWithTax(), 'MT'), 0, $langs, 0, 0, -1, $conf->currency); ?></td></tr>
<tr><td class="resume_label"><?php echo $langs->trans("PaymentMode"); ?> </td><td>
<?php
switch ($obj_facturation->getSetPaymentMode())
@ -85,12 +85,12 @@ if ($obj_facturation->montantTva()) {
if ($obj_facturation->getsetPaymentMode() == 'DIF') {
echo ('<tr><td class="resume_label">'.$langs->trans("DateDue").'</td><td>'.$obj_facturation->paiementLe().'</td></tr>');
} else {
echo ('<tr><td class="resume_label">'.$langs->trans("Received").'</td><td>'.price(price2num($obj_facturation->montantEncaisse(), 'MT'), 0, $langs, 0, 0, -1, $conf->currency).'</td></tr>');
echo ('<tr><td class="resume_label">'.$langs->trans("Received").'</td><td>'.price(price2num($obj_facturation->amountCollected(), 'MT'), 0, $langs, 0, 0, -1, $conf->currency).'</td></tr>');
}
// Affichage du montant rendu (reglement en especes)
if ($obj_facturation->montantRendu()) {
echo ('<tr><td class="resume_label">'.$langs->trans("Change").'</td><td>'.price(price2num($obj_facturation->montantRendu(), 'MT'), 0, $langs, 0, 0, -1, $conf->currency).'</td></tr>');
if ($obj_facturation->amountReturned()) {
echo ('<tr><td class="resume_label">'.$langs->trans("Change").'</td><td>'.price(price2num($obj_facturation->amountReturned(), 'MT'), 0, $langs, 0, 0, -1, $conf->currency).'</td></tr>');
}
?>

View File

@ -83,19 +83,19 @@ switch ($action)
// Si paiement autre qu'en especes, montant encaisse = prix total
$mode_reglement = $obj_facturation->getSetPaymentMode();
if ($mode_reglement != 'ESP') {
$montant = $obj_facturation->prixTotalTtc();
$montant = $obj_facturation->amountWithTax();
} else {
$montant = $_POST['txtEncaisse'];
}
if ($mode_reglement != 'DIF') {
$obj_facturation->montantEncaisse($montant);
$obj_facturation->amountCollected($montant);
//Determination de la somme rendue
$total = $obj_facturation->prixTotalTtc();
$encaisse = $obj_facturation->montantEncaisse();
$total = $obj_facturation->amountWithTax();
$encaisse = $obj_facturation->amountCollected();
$obj_facturation->montantRendu($encaisse - $total);
$obj_facturation->amountReturned($encaisse - $total);
} else {
//$txtDatePaiement=$_POST['txtDatePaiement'];
$datePaiement = dol_mktime(0, 0, 0, $_POST['txtDatePaiementmonth'], $_POST['txtDatePaiementday'], $_POST['txtDatePaiementyear']);
@ -137,8 +137,8 @@ switch ($action)
$mode_reglement_id = dol_getIdFromCode($db, 'LIQ', 'c_paiement', 'code', 'id', 1);
$cond_reglement_id = 0;
$note .= $langs->trans("Cash")."\n";
$note .= $langs->trans("Received").' : '.$obj_facturation->montantEncaisse()." ".$conf->currency."\n";
$note .= $langs->trans("Rendu").' : '.$obj_facturation->montantRendu()." ".$conf->currency."\n";
$note .= $langs->trans("Received").' : '.$obj_facturation->amountCollected()." ".$conf->currency."\n";
$note .= $langs->trans("Rendu").' : '.$obj_facturation->amountReturned()." ".$conf->currency."\n";
$note .= "\n";
$note .= '--------------------------------------'."\n\n";
break;
@ -207,9 +207,9 @@ switch ($action)
$invoice->date_creation = $now;
$invoice->date = $now;
$invoice->date_lim_reglement = 0;
$invoice->total_ht = $obj_facturation->prixTotalHt();
$invoice->total_tva = $obj_facturation->montantTva();
$invoice->total_ttc = $obj_facturation->prixTotalTtc();
$invoice->total_ht = $obj_facturation->amountWithoutTax();
$invoice->total_tva = $obj_facturation->amountVat();
$invoice->total_ttc = $obj_facturation->amountWithTax();
$invoice->note_private = $note;
$invoice->cond_reglement_id = $cond_reglement_id;
$invoice->mode_reglement_id = $mode_reglement_id;
@ -295,7 +295,7 @@ switch ($action)
$payment = new Paiement($db);
$payment->datepaye = $now;
$payment->bank_account = $conf_fkaccount;
$payment->amounts[$invoice->id] = $obj_facturation->prixTotalTtc();
$payment->amounts[$invoice->id] = $obj_facturation->amountWithTax();
$payment->note = $langs->trans("Payment").' '.$langs->trans("Invoice").' '.$obj_facturation->numInvoice();
$payment->paiementid = $invoice->mode_reglement_id;
$payment->num_paiement = '';
@ -316,7 +316,7 @@ switch ($action)
if (!$error)
{
if ($invoice->total_ttc == $obj_facturation->prixTotalTtc()
if ($invoice->total_ttc == $obj_facturation->amountWithTax()
&& $obj_facturation->getSetPaymentMode() != 'DIFF')
{
// We set status to payed

View File

@ -84,7 +84,7 @@ class box_accountancy_last_manual_entries extends ModeleBoxes
$sql = "SELECT DISTINCT b.piece_num";
$sql .= ", b.doc_date as date_movement";
$sql .= ", b.label_operation";
$sql .= ", b.montant";
$sql .= ", b.montant as amount";
$sql .= ", b.code_journal";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b";
$sql .= " WHERE b.fk_doc = 0";
@ -103,7 +103,7 @@ class box_accountancy_last_manual_entries extends ModeleBoxes
$date = $this->db->jdate($objp->date_movement);
$journal = $objp->code_journal;
$label = $objp->label_operation;
$amount = $objp->montant;
$amount = $objp->amount;
$bookkeepingstatic->id = $objp->id;
$bookkeepingstatic->piece_num = $objp->piece_num;

View File

@ -223,7 +223,7 @@ class pdf_standard extends ModelePDFSuppliersPayments
}
}
$total = $object->montant;
$total = $object->amount;
// Definition of $dir and $file
if ($object->specimen)
@ -534,12 +534,12 @@ class pdf_standard extends ModelePDFSuppliersPayments
// Total payments
$pdf->SetXY($this->page_largeur - $this->marge_droite - 50, $posy);
$pdf->MultiCell(50, 4, price($object->montant), 0, 'R', 1);
$pdf->MultiCell(50, 4, price($object->amount), 0, 'R', 1);
$posy += 20;
// translate amount
$currency = $conf->currency;
$translateinletter = strtoupper(dol_convertToWord($object->montant, $outputlangs, $currency));
$translateinletter = strtoupper(dol_convertToWord($object->amount, $outputlangs, $currency));
$pdf->SetXY($this->marge_gauche + 50, $posy);
$pdf->MultiCell(90, 8, $translateinletter, 0, 'L', 1);
$posy += 8;
@ -549,7 +549,7 @@ class pdf_standard extends ModelePDFSuppliersPayments
$pdf->MultiCell(150, 4, $object->thirdparty->nom, 0, 'L', 1);
$pdf->SetXY($this->page_largeur - $this->marge_droite - 30, $posy);
$pdf->MultiCell(35, 4, str_pad(price($object->montant).' '.$currency, 18, '*', STR_PAD_LEFT), 0, 'R', 1);
$pdf->MultiCell(35, 4, str_pad(price($object->amount).' '.$currency, 18, '*', STR_PAD_LEFT), 0, 'R', 1);
$posy += 10;

View File

@ -123,7 +123,7 @@ class PaiementFourn extends Paiement
$this->bank_account = $obj->fk_account;
$this->fk_account = $obj->fk_account;
$this->bank_line = $obj->fk_bank;
$this->montant = $obj->amount;
$this->montant = $obj->amount; // deprecated
$this->amount = $obj->amount;
$this->note = $obj->note;
$this->note_private = $obj->note;

View File

@ -189,7 +189,7 @@ if ($result > 0)
// Payment mode
$labeltype = $langs->trans("PaymentType".$object->type_code) != ("PaymentType".$object->type_code) ? $langs->trans("PaymentType".$object->type_code) : $object->type_label;
print '<tr><td colspan="2">'.$langs->trans('PaymentMode').'</td><td colspan="3">'.$labeltype;
print $object->num_paiement ? ' - '.$object->num_paiement : '';
print $object->num_payment ? ' - '.$object->num_payment : '';
print '</td></tr>';
// Payment numero
@ -200,7 +200,7 @@ if ($result > 0)
*/
// Amount
print '<tr><td colspan="2">'.$langs->trans('Amount').'</td><td colspan="3">'.price($object->montant, '', $langs, 0, 0, -1, $conf->currency).'</td></tr>';
print '<tr><td colspan="2">'.$langs->trans('Amount').'</td><td colspan="3">'.price($object->amount, '', $langs, 0, 0, -1, $conf->currency).'</td></tr>';
if (!empty($conf->global->BILL_ADD_PAYMENT_VALIDATION))
{