Fehler im Modul Multicurrency (Mehrere Währungen)

Wir nutzen als Hauptwährung CHF und als Fremdwährung EUR. Seit dem Update von Version 21.0.2 auf 21.0.3 haben wir das Problem, dass Dolibarr bei Angebot und Rechnung die Währungen mischt.

Beispiel:
Rechnung Position 1 = 190 CHF = 200 EUR
Rechnung Position 2 = 190 CHF = 200 EUR
Rabatt = -95 CHF = -100 EUR

Erwartetes Ergebnis:
Netto vor Rabatt = 400 EUR
Rabatt = 100 EUR
Netto = 300 EUR

Dolibarr rechnet aber:
Netto vor Rabatt = 395 EUR
Rabatt = 95 EUR
Netto = 300 EUR

Dolibarr nimmt also den korrekten EUR-Nettowert und addiert den CHF-Rabatt um den Nettowert vor Rabatt zu berechnen.

Können wir hier irgendetwas tun um den Fehler zu beheben? Weiß da jemand etwas?

MERCI

Dolibarr 21.0.3
PHP 8.1.33
10.6.22-MariaDB-log

GitHub-Beitrag: https://github.com/Dolibarr/dolibarr/issues/35208

Wir haben kürzlich ein ähnliches Problem in der Vorlage für Lieferantenrechnungen behoben: Fix #34891 - Skonto/Escompte calculation involving foreign currency by priojk · Pull Request #34892 · Dolibarr/dolibarr · GitHub

Vielen Dank @priojk, ich hab nun die pdf_cyan geändert und auch die weiteren Templates angepasst und es funktioniert. Ich hoffe, dass die Entwickler den Fix in die neue Version aufnehmen.



		// Total remise
		$total_line_remise = 0;
		foreach ($object->lines as $i => $line) {
			$resdiscount = pdfGetLineTotalDiscountAmount($object, $i, $outputlangs, 2);
			$total_line_remise += (is_numeric($resdiscount) ? $resdiscount : 0);
			// Gestion remise sous forme de ligne négative
			if ($line->total_ht < 0) {
				$total_line_remise += -$line->total_ht;
			}
		
		// --- Multicurrency-safe discount printing ---   //   new
		$usemc = (isModEnabled("multicurrency") && $object->multicurrency_tx != 1);
		$total_line_remise_print = $total_line_remise;
		if ($usemc) {
			$ratio = (!empty($object->total_ht) ? (float) $object->multicurrency_total_ht / (float) $object->total_ht : 0);
			if (!empty($ratio)) $total_line_remise_print = price2num($total_line_remise * $ratio, 'MT');
		}
		// --- End Multicurrency-safe discount printing ---
}
		if ($total_line_remise > 0) {
			$pdf->SetFillColor(255, 255, 255);
			$pdf->SetXY($col1x, $tab2_top + $tab2_hl);
			$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalDiscount").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("TotalDiscount") : ''), 0, 'L', 1);
			$pdf->SetXY($col2x, $tab2_top + $tab2_hl);
// 		$pdf->MultiCell($largcol2, $tab2_hl, price($total_line_remise, 0, $outputlangs), 0, 'R', 1);   // old
			$pdf->MultiCell($largcol2, $tab2_hl, price($total_line_remise_print, 0, $outputlangs), 0, 'R', 1);   //new

			$index++;

			// Show total NET before discount
			$pdf->SetFillColor(255, 255, 255);
			$pdf->SetXY($col1x, $tab2_top);
			$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHTBeforeDiscount").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("TotalHTBeforeDiscount") : ''), 0, 'L', 1);
			$pdf->SetXY($col2x, $tab2_top);
//		$pdf->MultiCell($largcol2, $tab2_hl, price($total_line_remise + $total_ht, 0, $outputlangs), 0, 'R', 1);   // old
			$pdf->MultiCell($largcol2, $tab2_hl, price($total_line_remise_print + $total_ht, 0, $outputlangs), 0, 'R', 1);   // new

			$index++;
		}