Skip to content
Code-Schnipsel Gruppen Projekte

Revisionen vergleichen

Änderungen werden so angezeigt, als ob die Quellrevision mit der Zielrevision zusammengeführt würde. Erfahre mehr über den Vergleich von Revisionen.

Quelle

Zielprojekt auswählen
No results found

Ziel

Zielprojekt auswählen
  • quiqqer/invoice
1 Ergebnis
Änderungen anzeigen
Commits auf Quelle (2)
  • Henning Leutz's avatar
    fix: enhance invoice download and electronic invoice processing · bdd10914
    verfasst von Henning Leutz
    - Introduced a new JS script block in `download.php` which gets triggered when user session is not
    valid or on missing parameters `invoice` or `type`.
    - `Dialog.js` has been modified to change how invoices are downloaded. Instead of creating an
    invisible iframe, now it leverages fetch API and download.js to get the invoice and proceed
    downloading.
    - Corrected indentation of the text and button image in the dialog box of the invoice download.
    - `Invoice.php` updated to include a new check for net value invoices. Adds articles to the
    `ZugferdDocumentBuilder` and calculates VAT based on the detected invoice type (net or gross). This
    ensures accurate electronic invoices.
    bdd10914
  • Henning Leutz's avatar
    Merge branch 'next-2.x' into 'main' · 3a60a588
    verfasst von Henning Leutz
    fix: enhance invoice download and electronic invoice processing
    
    See merge request !95
    3a60a588
......@@ -14,15 +14,30 @@
$User = QUI::getUserBySession();
$jsClose = '
<script>
console.log(1);
if (window.parent) {
console.log(2);
window.parent.require(["qui/QUI"], function(QUI) {
console.log("fire");
QUI.fireEvent("quiqqerInvoiceDownloadDone");
});
}
</script>';
if (!$User->canUseBackend()) {
echo $jsClose;
exit;
}
if (empty($_REQUEST['invoice'])) {
echo $jsClose;
exit;
}
if (empty($_REQUEST['type'])) {
echo $jsClose;
exit;
}
......@@ -83,3 +98,6 @@
} catch (Exception $e) {
Log::writeException($e);
}
echo $jsClose;
exit;
......@@ -361,8 +361,8 @@ define('package/quiqqer/invoice/bin/backend/utils/Dialogs', [
maxWidth: 600,
autoclose: false,
ok_button: {
text: QUILocale.get(lg, 'dialog.invoice.download.button'),
textimage: 'fa fa-download'
text: QUILocale.get(lg, 'dialog.invoice.download.button'),
textimage: 'fa fa-download'
},
events: {
onOpen: function (Win) {
......@@ -390,27 +390,42 @@ define('package/quiqqer/invoice/bin/backend/utils/Dialogs', [
},
onSubmit: function (Win) {
Win.Loader.show();
const Select = Win.getElm().querySelector('select');
const id = 'download-invoice-' + hash + '-' + Select.value;
new Element('iframe', {
src: URL_OPT_DIR + 'quiqqer/invoice/bin/backend/download.php?' + Object.toQueryString({
invoice: hash,
type: Button.value
}),
id: id,
styles: {
position: 'absolute',
top: -200,
left: -200,
width: 50,
height: 50
}
}).inject(document.body);
(function () {
document.getElements('#' + id).destroy();
}).delay(10000, this);
require([
URL_OPT_DIR + 'bin/quiqqer-asset/downloadjs/downloadjs/download.js'
], function (download) {
const url = URL_OPT_DIR + 'quiqqer/invoice/bin/backend/download.php?' +
new URLSearchParams({
invoice: hash,
type: Select.value
}).toString();
fetch(url).then(response => {
if (!response.ok) {
throw new Error("Fehler beim Download: " + response.statusText);
}
let filename = "invoice.pdf"; // Fallback-Dateiname
const contentDisposition = response.headers.get("Content-Disposition");
if (contentDisposition) {
const match = contentDisposition.match(/filename="?([^"]+)"?/);
if (match) {
filename = match[1];
}
}
return response.blob().then(blob => ({blob, filename}));
}).then(({blob, filename}) => {
download(blob, filename);
Win.Loader.hide();
}).catch(error => {
Win.Loader.hide();
});
});
}
}
}).open();
......
......@@ -673,6 +673,7 @@ public static function getElectronicInvoice(
$type = ZugferdProfiles::PROFILE_EN16931
): ZugferdDocumentBuilder {
$document = ZugferdDocumentBuilder::CreateNew($type);
$Articles = $Invoice->getArticles();
$date = $Invoice->getAttribute('date');
$date = strtotime($date);
......@@ -819,6 +820,12 @@ public static function getElectronicInvoice(
$vatTotal = $vatTotal + $vat->value();
}
$isNetInvoice = false;
if ($Customer->getAttribute('isNetto') || $Articles->getCalculations()['isNetto']) {
$isNetInvoice = true;
}
$document->setDocumentSummation(
$priceCalculation->getSum()->value(),
$priceCalculation->getSum()->value(),
......@@ -826,13 +833,13 @@ public static function getElectronicInvoice(
0.0, // zuschläge
0.0, // rabatte
$priceCalculation->getNettoSum()->value(), // Steuerbarer Betrag (BT-109)
$vatTotal, // Steuerbetrag
$isNetInvoice ? $vatTotal : 0, // ausgewiesene steuer
null, // Rundungsbetrag
0.0 // Vorauszahlungen
);
// products
foreach ($Invoice->getArticles() as $Article) {
foreach ($Articles as $Article) {
$article = $Article->toArray();
$nettoPreis = $article['calculated']['nettoPrice']; // Netto-Einzelpreis
......