Skip to content
Code-Schnipsel Gruppen Projekte
Commit e14dba9a erstellt von Henning Leutz's avatar Henning Leutz :martial_arts_uniform:
Dateien durchsuchen

Merge branch 'main' into 'next-3.x'

Update 'next-3.x' with latest changes from 'main'

See merge request !94
Übergeordnete f94d69ef 3a60a588
Branches next-3.x
No related tags found
1 Merge Request!94Update 'next-3.x' with latest changes from 'main'
Pipeline #16098 bestanden mit Phase
in 3 Minuten und 13 Sekunden
......@@ -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();
......
......@@ -663,11 +663,17 @@ public static function addressRequirementThreshold(): float
return floatval($threshold);
}
/**
* @throws QUI\ERP\Exception
* @throws QUI\Exception
* @throws QUI\Users\Exception
*/
public static function getElectronicInvoice(
InvoiceTemporary | QUI\ERP\Accounting\Invoice\Invoice $Invoice,
$type = ZugferdProfiles::PROFILE_EN16931
): ZugferdDocumentBuilder {
$document = ZugferdDocumentBuilder::CreateNew($type);
$Articles = $Invoice->getArticles();
$date = $Invoice->getAttribute('date');
$date = strtotime($date);
......@@ -814,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(),
......@@ -821,16 +833,24 @@ 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) {
/* @var $Article QUI\ERP\Accounting\Article */
foreach ($Articles as $Article) {
$article = $Article->toArray();
$nettoPreis = $article['calculated']['nettoPrice']; // Netto-Einzelpreis
$vatSum = $article['calculated']['vatArray']['sum'];
$bruttoPreis = $nettoPreis;
if ($vatSum) {
$bruttoPreis = $nettoPreis + ($vatSum / $article['quantity']);
}
$document
->addNewPosition($article['position'])
->setDocumentPositionProductDetails(
......@@ -841,9 +861,10 @@ public static function getElectronicInvoice(
null,
null
)
->setDocumentPositionNetPrice($article['calculated']['nettoPrice'])
->setDocumentPositionNetPrice($article['calculated']['nettoPrice'], 1, "C62") // C62 = Stück
->setDocumentPositionGrossPrice($bruttoPreis, 1, "C62") // C62 = Stück
->setDocumentPositionQuantity($article['quantity'], "H87")
->addDocumentPositionTax('S', 'VAT', $article['vat'])
->addDocumentPositionTax('S', 'VAT', $article['vat'], $article['calculated']['vatArray']['sum'])
->setDocumentPositionLineSummation($article['sum']);
}
......
0% oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren