FIX sign of amount of invoice lines for credit note with multicurrency
FIX Add INVOICE_POSITIVE_CREDIT_NOTE_SCREEN to solve PT requirement
This commit is contained in:
parent
cb5afc1842
commit
7a28972c8a
@ -2335,10 +2335,10 @@ if (empty($reshook))
|
||||
}
|
||||
}
|
||||
|
||||
$result = $object->updateline(GETPOST('lineid'), $description, $pu_ht, $qty, GETPOST('remise_percent'),
|
||||
$result = $object->updateline(GETPOST('lineid', 'int'), $description, $pu_ht, $qty, price2num(GETPOST('remise_percent', 'alpha')),
|
||||
$date_start, $date_end, $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $info_bits, $type,
|
||||
GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, $special_code, $array_options, GETPOST('progress'),
|
||||
$_POST['units'], $pu_ht_devise);
|
||||
GETPOST('fk_parent_line', 'int'), 0, $fournprice, $buyingprice, $label, $special_code, $array_options, price2num(GETPOST('progress', 'alpha')),
|
||||
GETPOST('units', 'alpha'), $pu_ht_devise);
|
||||
|
||||
if ($result >= 0) {
|
||||
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
|
||||
@ -4420,44 +4420,50 @@ if ($action == 'create')
|
||||
print '<div class="fichehalfright">';
|
||||
print '<div class="ficheaddleft">';
|
||||
|
||||
print '<!-- amounts -->'."\n";
|
||||
print '<table class="border bordertop tableforfield centpercent">';
|
||||
|
||||
$sign = 1;
|
||||
if (!empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE_SCREEN) && $object->type == $object::TYPE_CREDIT_NOTE) {
|
||||
$sign = -1; // We invert sign for output
|
||||
}
|
||||
|
||||
if (!empty($conf->multicurrency->enabled) && ($object->multicurrency_code != $conf->currency))
|
||||
{
|
||||
// Multicurrency Amount HT
|
||||
print '<tr><td class="titlefieldmiddle">'.$form->editfieldkey('MulticurrencyAmountHT', 'multicurrency_total_ht', '', $object, 0).'</td>';
|
||||
print '<td class="nowrap amountcard">'.price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'</td>';
|
||||
print '<td class="nowrap amountcard">'.price($sign * $object->multicurrency_total_ht, '', $langs, 0, -1, -1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Multicurrency Amount VAT
|
||||
print '<tr><td>'.$form->editfieldkey('MulticurrencyAmountVAT', 'multicurrency_total_tva', '', $object, 0).'</td>';
|
||||
print '<td class="nowrap amountcard">'.price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'</td>';
|
||||
print '<td class="nowrap amountcard">'.price($sign * $object->multicurrency_total_tva, '', $langs, 0, -1, -1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Multicurrency Amount TTC
|
||||
print '<tr><td>'.$form->editfieldkey('MulticurrencyAmountTTC', 'multicurrency_total_ttc', '', $object, 0).'</td>';
|
||||
print '<td class="nowrap amountcard">'.price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'</td>';
|
||||
print '<td class="nowrap amountcard">'.price($sign * $object->multicurrency_total_ttc, '', $langs, 0, -1, -1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
// Amount
|
||||
print '<tr><td class="titlefieldmiddle">'.$langs->trans('AmountHT').'</td>';
|
||||
print '<td class="nowrap amountcard">'.price($object->total_ht, 1, '', 1, - 1, - 1, $conf->currency).'</td></tr>';
|
||||
print '<td class="nowrap amountcard">'.price($sign * $object->total_ht, 1, '', 1, - 1, - 1, $conf->currency).'</td></tr>';
|
||||
|
||||
// Vat
|
||||
print '<tr><td>'.$langs->trans('AmountVAT').'</td><td colspan="3" class="nowrap amountcard">'.price($object->total_tva, 1, '', 1, - 1, - 1, $conf->currency).'</td></tr>';
|
||||
print '<tr><td>'.$langs->trans('AmountVAT').'</td><td colspan="3" class="nowrap amountcard">'.price($sign * $object->total_tva, 1, '', 1, - 1, - 1, $conf->currency).'</td></tr>';
|
||||
print '</tr>';
|
||||
|
||||
// Amount Local Taxes
|
||||
if (($mysoc->localtax1_assuj == "1" && $mysoc->useLocalTax(1)) || $object->total_localtax1 != 0) // Localtax1
|
||||
{
|
||||
print '<tr><td>'.$langs->transcountry("AmountLT1", $mysoc->country_code).'</td>';
|
||||
print '<td class="nowrap amountcard">'.price($object->total_localtax1, 1, '', 1, - 1, - 1, $conf->currency).'</td></tr>';
|
||||
print '<td class="nowrap amountcard">'.price($sign * $object->total_localtax1, 1, '', 1, - 1, - 1, $conf->currency).'</td></tr>';
|
||||
}
|
||||
if (($mysoc->localtax2_assuj == "1" && $mysoc->useLocalTax(2)) || $object->total_localtax2 != 0) // Localtax2
|
||||
{
|
||||
print '<tr><td>'.$langs->transcountry("AmountLT2", $mysoc->country_code).'</td>';
|
||||
print '<td class=nowrap amountcard">'.price($object->total_localtax2, 1, '', 1, - 1, - 1, $conf->currency).'</td></tr>';
|
||||
print '<td class=nowrap amountcard">'.price($sign * $object->total_localtax2, 1, '', 1, - 1, - 1, $conf->currency).'</td></tr>';
|
||||
}
|
||||
|
||||
// Revenue stamp
|
||||
@ -4515,13 +4521,11 @@ if ($action == 'create')
|
||||
}
|
||||
|
||||
// Total with tax
|
||||
print '<tr><td>'.$langs->trans('AmountTTC').'</td><td class="nowrap amountcard">'.price($object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency).'</td></tr>';
|
||||
print '<tr><td>'.$langs->trans('AmountTTC').'</td><td class="nowrap amountcard">'.price($sign * $object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency).'</td></tr>';
|
||||
|
||||
print '</table>';
|
||||
|
||||
|
||||
$sign = 1;
|
||||
if ($object->type == Facture::TYPE_CREDIT_NOTE) $sign = - 1;
|
||||
$nbrows = 8;
|
||||
$nbcols = 3;
|
||||
if (!empty($conf->projet->enabled))
|
||||
@ -4664,6 +4668,8 @@ if ($action == 'create')
|
||||
print '</table>';
|
||||
}
|
||||
|
||||
$sign = 1;
|
||||
if ($object->type == $object::TYPE_CREDIT_NOTE) $sign = -1;
|
||||
|
||||
// List of payments already done
|
||||
|
||||
|
||||
@ -3351,7 +3351,7 @@ class Facture extends CommonInvoice
|
||||
$this->line->localtax2_type = $localtaxes_type[2];
|
||||
|
||||
$this->line->remise_percent = $remise_percent;
|
||||
$this->line->subprice = ($this->type == 2 ?-abs($pu_ht) : $pu_ht); // For credit note, unit price always negative, always positive otherwise
|
||||
$this->line->subprice = ($this->type == self::TYPE_CREDIT_NOTE ?-abs($pu_ht) : $pu_ht); // For credit note, unit price always negative, always positive otherwise
|
||||
$this->line->date_start = $date_start;
|
||||
$this->line->date_end = $date_end;
|
||||
$this->line->total_ht = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($total_ht) : $total_ht); // For credit note and if qty is negative, total is negative
|
||||
@ -3371,10 +3371,10 @@ class Facture extends CommonInvoice
|
||||
$this->line->pa_ht = $pa_ht;
|
||||
|
||||
// Multicurrency
|
||||
$this->line->multicurrency_subprice = $pu_ht_devise;
|
||||
$this->line->multicurrency_total_ht = $multicurrency_total_ht;
|
||||
$this->line->multicurrency_total_tva = $multicurrency_total_tva;
|
||||
$this->line->multicurrency_total_ttc = $multicurrency_total_ttc;
|
||||
$this->line->multicurrency_subprice = ($this->type == self::TYPE_CREDIT_NOTE ?-abs($pu_ht_devise) : $pu_ht_devise); // For credit note, unit price always negative, always positive otherwise
|
||||
$this->line->multicurrency_total_ht = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($multicurrency_total_ht) : $multicurrency_total_ht); // For credit note and if qty is negative, total is negative
|
||||
$this->line->multicurrency_total_tva = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($multicurrency_total_tva) : $multicurrency_total_tva);
|
||||
$this->line->multicurrency_total_ttc = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($multicurrency_total_ttc) : $multicurrency_total_ttc);
|
||||
|
||||
if (is_array($array_options) && count($array_options) > 0) {
|
||||
// We replace values in this->line->array_options only for entries defined into $array_options
|
||||
|
||||
@ -63,8 +63,13 @@ $domData .= ' data-id="'.$line->id.'"';
|
||||
$domData .= ' data-qty="'.$line->qty.'"';
|
||||
$domData .= ' data-product_type="'.$line->product_type.'"';
|
||||
|
||||
$sign = 1;
|
||||
if (!empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE_SCREEN) && $object->type == $object::TYPE_CREDIT_NOTE) {
|
||||
$sign = -1;
|
||||
}
|
||||
|
||||
$coldisplay = 0; ?>
|
||||
$coldisplay = 0;
|
||||
?>
|
||||
<!-- BEGIN PHP TEMPLATE objectline_view.tpl.php -->
|
||||
<tr id="row-<?php print $line->id?>" class="drag drop oddeven" <?php print $domData; ?> >
|
||||
<?php if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { ?>
|
||||
@ -197,14 +202,14 @@ print vatrate($positiverates.($line->vat_src_code ? ' ('.$line->vat_src_code.')'
|
||||
//print vatrate($line->tva_tx.($line->vat_src_code?(' ('.$line->vat_src_code.')'):''), '%', $line->info_bits);
|
||||
?></td>
|
||||
|
||||
<td class="linecoluht nowrap right"><?php $coldisplay++; ?><?php print price($line->subprice); ?></td>
|
||||
<td class="linecoluht nowrap right"><?php $coldisplay++; ?><?php print price($sign * $line->subprice); ?></td>
|
||||
|
||||
<?php if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) { ?>
|
||||
<td class="linecoluht_currency nowrap right"><?php $coldisplay++; ?><?php print price($line->multicurrency_subprice); ?></td>
|
||||
<td class="linecoluht_currency nowrap right"><?php $coldisplay++; ?><?php print price($sign * $line->multicurrency_subprice); ?></td>
|
||||
<?php }
|
||||
|
||||
if ($inputalsopricewithtax) { ?>
|
||||
<td class="linecoluttc nowrap right"><?php $coldisplay++; ?><?php print (isset($line->pu_ttc) ?price($line->pu_ttc) : price($line->subprice)); ?></td>
|
||||
<td class="linecoluttc nowrap right"><?php $coldisplay++; ?><?php print (isset($line->pu_ttc) ? price($sign * $line->pu_ttc) : price($sign * $line->subprice)); ?></td>
|
||||
<?php } ?>
|
||||
|
||||
<td class="linecolqty nowrap right"><?php $coldisplay++; ?>
|
||||
@ -247,7 +252,7 @@ if ($this->situation_cycle_ref)
|
||||
$coldisplay++;
|
||||
$locataxes_array = getLocalTaxesFromRate($line->tva.($line->vat_src_code ? ' ('.$line->vat_src_code.')' : ''), 0, ($senderissupplier ? $mysoc : $object->thirdparty), ($senderissupplier ? $object->thirdparty : $mysoc));
|
||||
$tmp = calcul_price_total($line->qty, $line->pu, $line->remise_percent, $line->txtva, -1, -1, 0, 'HT', $line->info_bits, $line->type, ($senderissupplier ? $object->thirdparty : $mysoc), $locataxes_array, 100, $object->multicurrency_tx, $line->multicurrency_subprice);
|
||||
print '<td align="right" class="linecolcycleref2 nowrap">'.price($tmp[0]).'</td>';
|
||||
print '<td align="right" class="linecolcycleref2 nowrap">'.price($sign * $tmp[0]).'</td>';
|
||||
}
|
||||
|
||||
if ($usemargins && !empty($conf->margin->enabled) && empty($user->socid))
|
||||
@ -262,6 +267,7 @@ if ($usemargins && !empty($conf->margin->enabled) && empty($user->socid))
|
||||
<td class="linecolmargin2 nowrap margininfos right"><?php $coldisplay++; ?><?php print price(price2num($line->marque_tx, 'MT')).'%'; ?></td>
|
||||
<?php }
|
||||
}
|
||||
// Price total without tax
|
||||
if ($line->special_code == 3) { ?>
|
||||
<td class="linecoloption nowrap right"><?php $coldisplay++; ?><?php print $langs->trans('Option'); ?></td>
|
||||
<?php } else {
|
||||
@ -291,19 +297,19 @@ if ($line->special_code == 3) { ?>
|
||||
|
||||
print '<span class="classfortooltip" title="'.dol_escape_htmltag($tooltiponprice).'">';
|
||||
}
|
||||
print price($line->total_ht);
|
||||
print price($sign * $line->total_ht);
|
||||
if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
|
||||
{
|
||||
print '</span>';
|
||||
}
|
||||
print '</td>';
|
||||
if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) {
|
||||
print '<td class="linecolutotalht_currency nowrap right">'.price($line->multicurrency_total_ht).'</td>';
|
||||
print '<td class="linecolutotalht_currency nowrap right">'.price($sign * $line->multicurrency_total_ht).'</td>';
|
||||
$coldisplay++;
|
||||
}
|
||||
}
|
||||
if ($outputalsopricetotalwithtax) {
|
||||
print '<td class="linecolht nowrap right">'.price($line->total_ttc).'</td>';
|
||||
print '<td class="linecolht nowrap right">'.price($sign * $line->total_ttc).'</td>';
|
||||
$coldisplay++;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user