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 (9)
......@@ -22,7 +22,7 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/Journal', [
'text!package/quiqqer/invoice/bin/backend/controls/panels/Journal.Total.html',
'css!package/quiqqer/invoice/bin/backend/controls/panels/Journal.css',
'css!package/quiqqer/erp/bin/backend/payment-status.css'
], function(
], function (
QUI,
QUIPanel,
QUIButton,
......@@ -68,11 +68,12 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/Journal', [
'$onClickOpenInvoice',
'$onClickCreateCredit',
'$onClickReversal',
'$onClickDownload',
'$onSearchKeyUp',
'linkTransaction'
],
initialize: function(options) {
initialize: function (options) {
this.setAttributes({
icon: 'fa fa-money',
title: QUILocale.get(lg, 'erp.panel.invoice.text')
......@@ -109,7 +110,7 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/Journal', [
/**
* Refresh the grid
*/
refresh: function() {
refresh: function () {
this.Loader.show();
if (!this.$Grid) {
......@@ -150,10 +151,10 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/Journal', [
paid_status: [status],
search: this.$currentSearch,
currency: this.$Currency.getAttribute('value')
}).then(function(result) {
}).then(function (result) {
let gridData = result.grid;
gridData.data = gridData.data.map(function(entry) {
gridData.data = gridData.data.map(function (entry) {
const Icon = new Element('span');
switch (parseInt(entry.type)) {
......@@ -212,7 +213,7 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/Journal', [
this.$Total.set('html', Mustache.render(templateTotal, result.total));
this.Loader.hide();
}.bind(this)).catch(function(err) {
}.bind(this)).catch(function (err) {
console.error(err);
this.Loader.hide();
}.bind(this));
......@@ -222,22 +223,22 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/Journal', [
* refresh the button status
* disabled or enabled
*/
$refreshButtonStatus: function() {
$refreshButtonStatus: function () {
if (!this.$Grid) {
return;
}
const selected = this.$Grid.getSelectedData(), buttons = this.$Grid.getButtons();
const Actions = buttons.filter(function(Button) {
const Actions = buttons.filter(function (Button) {
return Button.getAttribute('name') === 'actions';
})[0];
const Payment = Actions.getChildren().filter(function(Button) {
const Payment = Actions.getChildren().filter(function (Button) {
return Button.getAttribute('name') === 'addPayment';
})[0];
const CreditNote = Actions.getChildren().filter(function(Button) {
const CreditNote = Actions.getChildren().filter(function (Button) {
return Button.getAttribute('name') === 'createCreditNote';
})[0];
......@@ -269,7 +270,7 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/Journal', [
/**
* event : on create
*/
$onCreate: function() {
$onCreate: function () {
// Buttons
this.addButton({
name: 'total',
......@@ -286,7 +287,7 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/Journal', [
disabled: true,
showIcons: false,
events: {
onChange: function(Menu, Item) {
onChange: function (Menu, Item) {
self.$Currency.setAttribute('value', Item.getAttribute('value'));
self.$Currency.setAttribute('text', Item.getAttribute('value'));
self.refresh();
......@@ -335,10 +336,10 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/Journal', [
},
events: {
onChange: this.refresh,
onPeriodSelectClose: function(Filter) {
onPeriodSelectClose: function (Filter) {
self.$periodFilter = Filter.getValue();
},
onPeriodSelectOpen: function(Filter) {
onPeriodSelectOpen: function (Filter) {
if (self.$periodFilter) {
Filter.setAttribute('from', self.$periodFilter.from);
Filter.setAttribute('to', self.$periodFilter.to);
......@@ -438,6 +439,15 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/Journal', [
}
});
Actions.appendChild({
icon: 'fa fa-download',
text: QUILocale.get(lg, 'dialog.invoice.download.button'),
events: {
onClick: this.$onClickDownload
}
});
this.fireEvent('actionButtonCreate', [
this,
Actions
......@@ -715,7 +725,7 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/Journal', [
/**
* event : on resize
*/
$onResize: function() {
$onResize: function () {
if (!this.$Grid) {
return;
}
......@@ -740,7 +750,7 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/Journal', [
/**
* event: on inject
*/
$onInject: function() {
$onInject: function () {
const self = this,
value = this.$Status.getValue();
......@@ -753,7 +763,7 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/Journal', [
QUIAjax.get([
'package_quiqqer_currency_ajax_getAllowedCurrencies',
'package_quiqqer_currency_ajax_getDefault'
], function(currencies, currency) {
], function (currencies, currency) {
let i, len, entry, text;
if (!currencies.length || currencies.length === 1) {
......@@ -781,7 +791,7 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/Journal', [
'package': 'quiqqer/currency'
});
this.$Currency.getContextMenu(function(ContextMenu) {
this.$Currency.getContextMenu(function (ContextMenu) {
ContextMenu.setAttribute('showIcons', false);
});
},
......@@ -789,7 +799,7 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/Journal', [
/**
* event: on panel destroy
*/
$onDestroy: function() {
$onDestroy: function () {
Invoices.removeEvents({
onPostInvoice: this.$onInvoicesChange
});
......@@ -798,7 +808,7 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/Journal', [
/**
* event: on show
*/
$onShow: function() {
$onShow: function () {
if (this.$Search.value !== '') {
return;
}
......@@ -809,18 +819,18 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/Journal', [
/**
* event: invoices changed something
*/
$onInvoicesChange: function() {
$onInvoicesChange: function () {
this.refresh();
},
//region Buttons events
$onClickCreateInvoice: function() {
return Invoices.createInvoice().then(function(invoiceId) {
$onClickCreateInvoice: function () {
return Invoices.createInvoice().then(function (invoiceId) {
require([
'package/quiqqer/invoice/bin/backend/controls/panels/TemporaryInvoice',
'utils/Panels'
], function(TemporaryInvoice, PanelUtils) {
], function (TemporaryInvoice, PanelUtils) {
const Panel = new TemporaryInvoice({
invoiceId: invoiceId,
'#id': invoiceId
......@@ -828,8 +838,8 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/Journal', [
PanelUtils.openPanelInTasks(Panel);
});
}.bind(this)).catch(function(Exception) {
QUI.getMessageHandler().then(function(MH) {
}.bind(this)).catch(function (Exception) {
QUI.getMessageHandler().then(function (MH) {
if (typeof Exception.getMessage !== 'undefined') {
MH.addError(Exception.getMessage());
return;
......@@ -843,7 +853,7 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/Journal', [
/**
* event : on PDF Export button click
*/
$onPDFExportButtonClick: function(Button) {
$onPDFExportButtonClick: function (Button) {
const selectedData = this.$Grid.getSelectedData();
if (!selectedData.length) {
......@@ -867,8 +877,8 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/Journal', [
entityType = 'Invoice';
}
return new Promise(function(resolve) {
require(['package/quiqqer/invoice/bin/backend/utils/Dialogs'], function(Dialogs) {
return new Promise(function (resolve) {
require(['package/quiqqer/invoice/bin/backend/utils/Dialogs'], function (Dialogs) {
Dialogs.openPrintDialog(Entry.hash, entityType).catch((err) => {
QUI.getMessageHandler().then((MH) => {
MH.addError(err.getMessage());
......@@ -883,7 +893,7 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/Journal', [
/**
* event : on payment add button click
*/
$onAddPaymentButtonClick: function(Button) {
$onAddPaymentButtonClick: function (Button) {
const self = this, selectedData = this.$Grid.getSelectedData();
if (!selectedData.length) {
......@@ -896,26 +906,26 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/Journal', [
require([
'package/quiqqer/payment-transactions/bin/backend/controls/IncomingPayments/AddPaymentWindow'
], function(AddPaymentWindow) {
], function (AddPaymentWindow) {
new AddPaymentWindow({
entityId: hash,
entityType: 'Invoice',
events: {
onSubmit: function(Win, data) {
self.addPayment(hash, data.amount, data.payment_method, data.date).then(function() {
onSubmit: function (Win, data) {
self.addPayment(hash, data.amount, data.payment_method, data.date).then(function () {
Button.setAttribute('textimage', 'fa fa-money');
self.refresh();
});
},
onSubmitExisting: (txId) => {
self.linkTransaction(hash, txId).then(function() {
self.linkTransaction(hash, txId).then(function () {
Button.setAttribute('textimage', 'fa fa-money');
self.refresh();
});
},
onClose: function() {
onClose: function () {
Button.setAttribute('textimage', 'fa fa-money');
}
}
......@@ -928,7 +938,7 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/Journal', [
*
* @return {Promise}
*/
$onClickCopyInvoice: function() {
$onClickCopyInvoice: function () {
const selected = this.$Grid.getSelectedData();
if (!selected.length) {
......@@ -937,7 +947,7 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/Journal', [
const hash = selected[0].hash;
return new Promise(function(resolve) {
return new Promise(function (resolve) {
require([
'package/quiqqer/erp/bin/backend/controls/dialogs/CopyErpEntityDialog'
], (CopyErpEntityDialog) => {
......@@ -957,13 +967,13 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/Journal', [
*
* @param {Object} data
*/
$onClickInvoiceDetails: function(data) {
$onClickInvoiceDetails: function (data) {
const row = data.row, ParentNode = data.parent;
ParentNode.setStyle('padding', 10);
ParentNode.set('html', '<div class="fa fa-spinner fa-spin"></div>');
Invoices.getArticleHtml(this.$Grid.getDataByRow(row).hash).then(function(result) {
Invoices.getArticleHtml(this.$Grid.getDataByRow(row).hash).then(function (result) {
ParentNode.set('html', '');
new Element('div', {
......@@ -979,7 +989,7 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/Journal', [
* @param {object} data - cell data
* @return {Promise}
*/
$onClickOpenInvoice: function(data) {
$onClickOpenInvoice: function (data) {
if (typeof data !== 'undefined'
&& typeof data.cell !== 'undefined'
&& (
......@@ -991,14 +1001,14 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/Journal', [
const self = this, Cell = data.cell, position = Cell.getPosition(),
rowData = this.$Grid.getDataByRow(data.row);
return new Promise(function(resolve) {
return new Promise(function (resolve) {
require([
'qui/controls/contextmenu/Menu',
'qui/controls/contextmenu/Item'
], function(QUIMenu, QUIMenuItem) {
], function (QUIMenu, QUIMenuItem) {
const Menu = new QUIMenu({
events: {
onBlur: function() {
onBlur: function () {
Menu.hide();
Menu.destroy();
}
......@@ -1009,7 +1019,7 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/Journal', [
icon: rowData.display_type.className,
text: QUILocale.get(lg, 'journal.contextMenu.open.invoice'),
events: {
onClick: function() {
onClick: function () {
self.openInvoice(rowData.hash);
}
}
......@@ -1019,10 +1029,10 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/Journal', [
icon: 'fa fa-user-o',
text: QUILocale.get(lg, 'journal.contextMenu.open.user'),
events: {
onClick: function() {
onClick: function () {
require(
['package/quiqqer/customer/bin/backend/Handler'],
function(CustomerHandler) {
function (CustomerHandler) {
CustomerHandler.openCustomer(rowData.customer_id);
}
);
......@@ -1035,14 +1045,14 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/Journal', [
icon: 'fa fa-check',
text: QUILocale.get(lg, 'journal.contextMenu.change.status'),
events: {
onClick: function() {
onClick: function () {
require([
'package/quiqqer/invoice/bin/backend/controls/panels/status/StatusWindow'
], function(StatusWindow) {
], function (StatusWindow) {
new StatusWindow({
hash: rowData.hash,
events: {
statusChanged: function() {
statusChanged: function () {
self.refresh();
}
}
......@@ -1070,7 +1080,7 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/Journal', [
if (rowData.globalProcessId && rowData.globalProcessId !== '') {
require([
'package/quiqqer/erp/bin/backend/controls/process/ProcessWindow'
], function(ProcessWindow) {
], function (ProcessWindow) {
new ProcessWindow({
globalProcessId: rowData.globalProcessId
}).open();
......@@ -1094,7 +1104,7 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/Journal', [
*
* @return {Promise}
*/
$onClickCreateCredit: function() {
$onClickCreateCredit: function () {
const selected = this.$Grid.getSelectedData();
if (!selected.length) {
......@@ -1103,11 +1113,11 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/Journal', [
const self = this, invoiceId = selected[0].hash;
return new Promise(function(resolve) {
return new Promise(function (resolve) {
require([
'package/quiqqer/invoice/bin/backend/utils/Dialogs'
], function(Dialogs) {
Dialogs.openCreateCreditNoteDialog(invoiceId).then(function(newId) {
], function (Dialogs) {
Dialogs.openCreateCreditNoteDialog(invoiceId).then(function (newId) {
if (!newId) {
return;
}
......@@ -1125,7 +1135,7 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/Journal', [
*
* @return {Promise}
*/
$onClickReversal: function() {
$onClickReversal: function () {
const selected = this.$Grid.getSelectedData();
if (!selected.length) {
......@@ -1134,15 +1144,15 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/Journal', [
const self = this, invoiceId = selected[0].hash;
return new Promise(function(resolve) {
return new Promise(function (resolve) {
require([
'package/quiqqer/invoice/bin/backend/utils/Dialogs'
], function(Dialogs) {
Dialogs.openReversalDialog(invoiceId).then(function(result) {
], function (Dialogs) {
Dialogs.openReversalDialog(invoiceId).then(function (result) {
Dialogs.openPrintDialog(result.reversalHash, 'Canceled');
return self.refresh();
}).then(resolve).catch(function(Exception) {
QUI.getMessageHandler().then(function(MH) {
}).then(resolve).catch(function (Exception) {
QUI.getMessageHandler().then(function (MH) {
console.error(Exception);
if (typeof Exception.getMessage !== 'undefined') {
......@@ -1159,6 +1169,20 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/Journal', [
});
},
$onClickDownload: function () {
const selected = this.$Grid.getSelectedData();
if (!selected.length) {
return Promise.resolve();
}
const hash = selected[0].hash;
require(['package/quiqqer/invoice/bin/backend/utils/Dialogs'], (Dialogs) => {
Dialogs.openDownloadDialog(hash);
});
},
//endregion
/**
......@@ -1166,8 +1190,8 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/Journal', [
*
* @param {Number|String} invoiceId
*/
downloadPdf: function(invoiceId) {
return new Promise(function(resolve) {
downloadPdf: function (invoiceId) {
return new Promise(function (resolve) {
const id = 'download-invoice-' + invoiceId;
new Element('iframe', {
......@@ -1184,25 +1208,26 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/Journal', [
}
}).inject(document.body);
(function() {
(function () {
// document.getElements('#' + id).destroy();
resolve();
}).delay(1000, this);
});
},
/**
* Open an invoice panel
*
* @param {Number|String} hash - ID or hash of the invoice
* @return {Promise}
*/
openInvoice: function(hash) {
return new Promise(function(resolve) {
openInvoice: function (hash) {
return new Promise(function (resolve) {
require([
'package/quiqqer/invoice/bin/backend/controls/panels/Invoice',
'utils/Panels'
], function(InvoicePanel, PanelUtils) {
], function (InvoicePanel, PanelUtils) {
const Panel = new InvoicePanel({
hash: hash,
'#id': hash
......@@ -1224,16 +1249,16 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/Journal', [
*
* @return {Promise}
*/
addPayment: function(hash, amount, paymentMethod, date) {
addPayment: function (hash, amount, paymentMethod, date) {
const self = this;
this.Loader.show();
return Invoices.addPaymentToInvoice(hash, amount, paymentMethod, date).then(function() {
return Invoices.addPaymentToInvoice(hash, amount, paymentMethod, date).then(function () {
return self.refresh();
}).then(function() {
}).then(function () {
self.Loader.hide();
}).catch(function(err) {
}).catch(function (err) {
console.error(err);
});
},
......@@ -1246,14 +1271,14 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/Journal', [
*
* @return {Promise<void>}
*/
linkTransaction: function(invoiceHash, txId) {
linkTransaction: function (invoiceHash, txId) {
this.Loader.show();
return Invoices.linkTransaction(invoiceHash, txId).then(() => {
return this.refresh();
}).then(() => {
this.Loader.hide();
}).catch(function(err) {
}).catch(function (err) {
console.error(err);
});
},
......@@ -1264,11 +1289,11 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/Journal', [
* @param {String|Number} invoiceId
* @return {Promise}
*/
openTemporaryInvoice: function(invoiceId) {
return new Promise(function(resolve) {
openTemporaryInvoice: function (invoiceId) {
return new Promise(function (resolve) {
require([
'package/quiqqer/invoice/bin/backend/utils/Panels'
], function(PanelUtils) {
], function (PanelUtils) {
PanelUtils.openTemporaryInvoice(invoiceId).then(resolve);
});
});
......@@ -1279,7 +1304,7 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/Journal', [
*
* @return {Promise}
*/
toggleTotal: function() {
toggleTotal: function () {
if (parseInt(this.$Total.getStyle('opacity')) === 1) {
return this.hideTotal();
}
......@@ -1292,14 +1317,14 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/Journal', [
*
* @return {Promise}
*/
showTotal: function() {
showTotal: function () {
this.getButtons('total').setActive();
this.getContent().setStyle('overflow', 'hidden');
this.$totalsOpen = true;
this.refresh();
return new Promise(function(resolve) {
return new Promise(function (resolve) {
this.$Total.setStyles({
display: 'inline-block',
opacity: 0
......@@ -1322,14 +1347,14 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/Journal', [
*
* @return {Promise}
*/
hideTotal: function() {
hideTotal: function () {
const self = this;
this.$totalsOpen = false;
this.getButtons('total').setNormal();
return new Promise(function(resolve) {
return new Promise(function (resolve) {
self.$Grid.setHeight(self.getContent().getSize().y - 20);
moofx(self.$Total).animate({
......@@ -1337,7 +1362,7 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/Journal', [
opacity: 0
}, {
duration: 200,
callback: function() {
callback: function () {
self.$Total.setStyles({
display: 'none'
});
......@@ -1351,7 +1376,7 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/Journal', [
/**
* Disable the filter
*/
disableFilter: function() {
disableFilter: function () {
this.$TimeFilter.disable();
this.$Status.disable();
},
......@@ -1359,12 +1384,12 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/Journal', [
/**
* Enable the filter
*/
enableFilter: function() {
enableFilter: function () {
this.$TimeFilter.enable();
this.$Status.enable();
},
search: function() {
search: function () {
this.hideTotal().then(() => {
this.refresh();
});
......@@ -1375,7 +1400,7 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/Journal', [
*
* @param {DOMEvent} event
*/
$onSearchKeyUp: function(event) {
$onSearchKeyUp: function (event) {
if (event.key === 'up' || event.key === 'down' || event.key === 'left' || event.key === 'right') {
return;
}
......@@ -1388,7 +1413,7 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/Journal', [
// workaround, cancel needs time to clear
(() => {
if (this.$currentSearch !== this.$Search.value) {
this.$searchDelay = (function() {
this.$searchDelay = (function () {
this.search();
}).delay(250, this);
}
......@@ -1400,7 +1425,7 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/Journal', [
}
if (event.key === 'enter') {
this.$searchDelay = (function() {
this.$searchDelay = (function () {
this.search();
}).delay(250, this);
}
......
......@@ -35,6 +35,10 @@
fire="\QUI\ERP\Accounting\Invoice\EventHandler::onQuiqqerErpOutputSendMail"
/>
<event on="onQuiqqerHtmlToPDFCreated"
fire="\QUI\ERP\Accounting\Invoice\EventHandler::onQuiqqerHtmlToPDFCreated"
/>
<event on="onQuiqqerMigrationV2"
fire="\QUI\ERP\Accounting\Invoice\EventHandler::onQuiqqerMigrationV2"
/>
......
......@@ -325,7 +325,7 @@ public static function onQuiqqerErpOutputSendMailBefore(
// extend pdf with e-invoice
$Config = QUI::getPackage('quiqqer/invoice')->getConfig();
if ($Config->getValue('invoice', 'xInvoiceAttachment')) {
if (file_exists($mailFile) && $Config->getValue('invoice', 'xInvoiceAttachment')) {
$xmlFile = str_replace('.pdf', '.xml', $mailFile);
$document = QUI\ERP\Accounting\Invoice\Utils\Invoice::getElectronicInvoice(
$Invoice,
......@@ -336,15 +336,6 @@ public static function onQuiqqerErpOutputSendMailBefore(
$Mailer->addAttachment($xmlFile);
}
if (file_exists($mailFile) && $Config->getValue('invoice', 'zugferdInvoiceAttachment')) {
$document = QUI\ERP\Accounting\Invoice\Utils\Invoice::getElectronicInvoice(
$Invoice,
$Config->getValue('invoice', 'xInvoiceAttachmentType')
);
$pdfBuilder = new ZugferdDocumentPdfBuilder($document, $mailFile);
$pdfBuilder->generateDocument()->saveDocument($mailFile);
}
// @todo
$customerFiles = $Invoice->getCustomerFiles();
......@@ -365,6 +356,27 @@ public static function onQuiqqerErpOutputSendMailBefore(
}
}
public static function onQuiqqerHtmlToPDFCreated(QUI\HtmlToPdf\Document $Document, $filename): void
{
$Entity = $Document->getAttribute('Entity');
if (!($Entity instanceof Invoice)) {
return;
}
// extend pdf with e-invoice
$Config = QUI::getPackage('quiqqer/invoice')->getConfig();
if (file_exists($filename) && $Config->getValue('invoice', 'zugferdInvoiceAttachment')) {
$document = QUI\ERP\Accounting\Invoice\Utils\Invoice::getElectronicInvoice(
$Entity,
$Config->getValue('invoice', 'xInvoiceAttachmentType')
);
$pdfBuilder = new ZugferdDocumentPdfBuilder($document, $filename);
$pdfBuilder->generateDocument()->saveDocument($filename);
}
}
/**
* quiqqer/erp: onQuiqqerErpOutputSendMail
*
......
......@@ -17,6 +17,14 @@
use IntlDateFormatter;
use horstoeko\zugferd\ZugferdDocumentBuilder;
use horstoeko\zugferd\ZugferdProfiles;
use horstoeko\zugferd\codelists\ZugferdCountryCodes;
use horstoeko\zugferd\codelists\ZugferdCurrencyCodes;
use horstoeko\zugferd\codelists\ZugferdElectronicAddressScheme;
use horstoeko\zugferd\codelists\ZugferdInvoiceType;
use horstoeko\zugferd\codelists\ZugferdReferenceCodeQualifiers;
use horstoeko\zugferd\codelists\ZugferdUnitCodes;
use horstoeko\zugferd\codelists\ZugferdVatCategoryCodes;
use horstoeko\zugferd\codelists\ZugferdVatTypeCodes;
use function array_map;
use function array_merge;
......@@ -450,7 +458,7 @@ protected static function verificateField(
*/
public static function getInvoiceFilename(
QUI\ERP\Accounting\Invoice\Invoice|InvoiceTemporary $Invoice,
QUI\Locale $Locale = null
?QUI\Locale $Locale = null
): string {
if (
!($Invoice instanceof QUI\ERP\Accounting\Invoice\Invoice) &&
......@@ -517,7 +525,7 @@ public static function getInvoiceFilename(
*/
public static function roundInvoiceSum(
float|int $amount,
QUI\ERP\Currency\Currency $Currency = null
?QUI\ERP\Currency\Currency $Currency = null
): float|int {
if ($Currency === null) {
$Currency = QUI\ERP\Defaults::getCurrency();
......@@ -679,42 +687,95 @@ public static function getElectronicInvoice(
$Invoice->getCurrency()->getCode()
);
// ids
$taxId = Defaults::conf('company', 'taxId');
$taxNumber = Defaults::conf('company', 'taxNumber');
// seller / owner
$document
->setDocumentSeller(Defaults::conf('company', 'name'))
->addDocumentSellerGlobalId("4000001123452", "0088")
->addDocumentSellerTaxRegistration("FC", "201/113/40209")
->addDocumentSellerTaxRegistration("VA", "DE123456789")
->setDocumentSellerAddress(
Defaults::conf('company', 'street'),
"",
"",
Defaults::conf('company', 'zip'),
Defaults::conf('company', 'city'),
Defaults::conf('company', 'country') // @todo country ->code<-
)
->setDocumentSellerCommunication(
'EM',
Defaults::conf('company', 'email')
)
->setDocumentSellerContact(
Defaults::conf('company', 'owner'), // @todo contact person
'', // @todo contact department
Defaults::conf('company', 'phone'), // @todo contact phone
Defaults::conf('company', 'fax'), // @todo contact fax
Defaults::conf('company', 'email') // @todo contact email
);
$document->setDocumentSeller(Defaults::conf('company', 'name'));
// @todo global seller id
// ->addDocumentSellerGlobalId("4000001123452", "0088");
if (!empty($taxNumber)) {
$document->addDocumentSellerTaxRegistration("FC", $taxNumber);
}
if (!empty($taxId)) {
$document->addDocumentSellerTaxRegistration("VA", $taxId);
}
// address
$country = Defaults::conf('company', 'country');
if (strlen($country) !== 2) {
$DefaultLocale = QUI::getSystemLocale();
foreach (QUI\Countries\Manager::getCompleteList() as $Country) {
if ($Country->getName($DefaultLocale) === $country) {
$country = $Country->getCode();
break;
}
}
}
if (strlen($country) !== 2) {
$country = '';
}
$document->setDocumentSellerAddress(
Defaults::conf('company', 'street'),
"",
"",
Defaults::conf('company', 'zipCode'),
Defaults::conf('company', 'city'),
$country
);
$document->setDocumentSellerCommunication(
'EM',
Defaults::conf('company', 'email')
);
$document->setDocumentSellerContact(
Defaults::conf('company', 'owner'), // @todo contact person
'', // @todo contact department
Defaults::conf('company', 'phone'), // @todo contact phone
Defaults::conf('company', 'fax'), // @todo contact fax
Defaults::conf('company', 'email') // @todo contact email
);
// bank stuff
$bankAccount = QUI\ERP\BankAccounts\Handler::getCompanyBankAccount();
if (!empty($bankAccount)) {
/* lastschrift
$document->addDocumentPaymentMeanToDirectDebit(
$bankAccount['iban'],
$Invoice->getPrefixedNumber()
// @todo mandats nummer
);
*/
$document->addDocumentPaymentMean(
'42', // TypeCode für Überweisung
$bankAccount['iban'] ?? '',
$bankAccount['bic'] ?? ''
);
} else {
$document->addDocumentPaymentMean(
'42', // TypeCode für Überweisung
'',
''
);
}
$document->addDocumentPaymentMean(
'42', // TypeCode für Überweisung
$bankAccount['iban'] ?? '',
$bankAccount['bic'] ?? ''
);
// customer
$Customer = $Invoice->getCustomer();
......@@ -730,9 +791,22 @@ public static function getElectronicInvoice(
$Customer->getAddress()->getAttribute('zip'),
$Customer->getAddress()->getAttribute('city'),
$Customer->getAddress()->getCountry()->getCode()
)
->setDocumentBuyerCommunication('EM', $Customer->getAddress()->getAttribute('email'))
->setDocumentBuyerReference($Customer->getUUID());
)->setDocumentBuyerReference($Customer->getUUID());
if ($Customer->getAddress()->getAttribute('email')) {
$document->setDocumentBuyerCommunication('EM', $Customer->getAddress()->getAttribute('email'));
} else {
try {
$User = QUI::getUsers()->get($Customer->getUUID());
$document->setDocumentBuyerCommunication('EM', $User->getAttribute('email'));
} catch (QUI\Exception) {
// requirement -> workaround -> placeholder
$document->setDocumentBuyerCommunication('EM', 'unknown@example.com');
}
}
//->setDocumentBuyerOrderReferencedDocument($Invoice->getUUID());
// total
$priceCalculation = $Invoice->getPriceCalculation();
......@@ -742,7 +816,7 @@ public static function getElectronicInvoice(
$document->addDocumentTax(
"S",
"VAT",
$priceCalculation->getSum()->value(),
$priceCalculation->getNettoSum()->value(),
$vat->value(),
$vat->getVat()
);
......@@ -753,13 +827,13 @@ public static function getElectronicInvoice(
$document->setDocumentSummation(
$priceCalculation->getSum()->value(),
$priceCalculation->getSum()->value(),
$priceCalculation->getSum()->value(),
0.0,
0.0,
$priceCalculation->getSum()->value(),
$vatTotal,
null,
0.0
$priceCalculation->getNettoSum()->value(),
0.0, // zuschläge
0.0, // rabatte
$priceCalculation->getNettoSum()->value(), // Steuerbarer Betrag (BT-109)
$vatTotal, // Steuerbetrag
null, // Rundungsbetrag
0.0 // Vorauszahlungen
);
// products
......@@ -783,6 +857,25 @@ public static function getElectronicInvoice(
->setDocumentPositionLineSummation($article['sum']);
}
// payment stuff
$PaymentDate = null;
try {
$timeForPayment = $Invoice->getAttribute('time_for_payment');
$timeForPayment = strtotime($timeForPayment);
if ($timeForPayment) {
$PaymentDate = new DateTime();
$PaymentDate->setTimestamp($timeForPayment);
}
} catch (\Exception) {
}
$document->addDocumentPaymentTerm(
$Invoice->getAttribute('additional_invoice_text'),
$PaymentDate
);
return $document;
}
}