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

fix: #44

Übergeordneter 24b56703
Keine zugehörigen Branchen gefunden
Keine zugehörigen Tags gefunden
Keine zugehörigen Merge Requests gefunden
......@@ -159,7 +159,10 @@ function ($params, $filter) {
$data[$key]['display_subsum'] = $Currency->format($data[$key]['subsum']);
}
return $Grid->parseResult($data, $Invoices->countTemporaryInvoices());
return $Grid->parseResult(
$data,
$Invoices->countTemporaryInvoices($query)
);
},
['params', 'filter'],
'Permission::checkAdminUser'
......
......@@ -19,7 +19,16 @@ function ($productId, $attributes, $user) {
$Locale = QUI::getLocale();
if (!empty($user)) {
$User = QUI\ERP\User::convertUserDataToErpUser($user);
try {
$User = QUI\ERP\User::convertUserDataToErpUser($user);
} catch (QUI\Exception $Exception) {
if (!isset($user['uid'])) {
throw $Exception;
}
$User = QUI::getUsers()->get($user['uid']);
}
$Locale = $User->getLocale();
}
......
......@@ -34,6 +34,7 @@ function ($article) {
$Calc = QUI\ERP\Accounting\Calc::getInstance($Brutto);
$Article = new QUI\ERP\Accounting\Article($article);
//$Article->setCurrency();
$Article->setUser($Brutto);
$Article->calc($Calc);
......
......@@ -42,6 +42,10 @@ define('package/quiqqer/invoice/bin/backend/controls/InvoiceArticleList', [
'$onInject'
],
options: {
currency: false // bool || string -> EUR, USD ...
},
initialize: function (options) {
this.parent(options);
......@@ -226,6 +230,11 @@ define('package/quiqqer/invoice/bin/backend/controls/InvoiceArticleList', [
return;
}
if (this.getAttribute('currency')) {
Child.setCurrency(this.getAttribute('currency'));
}
this.$articles.push(Child);
Child.setUser(this.$user);
......
......@@ -30,6 +30,7 @@ define('package/quiqqer/invoice/bin/backend/controls/articles/Article', [
'qui/utils/Elements',
'package/quiqqer/erp/bin/backend/utils/Discount',
'package/quiqqer/erp/bin/backend/utils/Money',
'package/quiqqer/currency/bin/Currency',
'Mustache',
'Locale',
'Ajax',
......@@ -38,7 +39,7 @@ define('package/quiqqer/invoice/bin/backend/controls/articles/Article', [
'text!package/quiqqer/invoice/bin/backend/controls/articles/Article.html',
'css!package/quiqqer/invoice/bin/backend/controls/articles/Article.css'
], function (QUI, QUIControl, QUIButton, QUIConfirm, QUIElements, DiscountUtils, MoneyUtils, Mustache, QUILocale, QUIAjax, Editors, template) {
], function (QUI, QUIControl, QUIButton, QUIConfirm, QUIElements, DiscountUtils, MoneyUtils, Currency, Mustache, QUILocale, QUIAjax, Editors, template) {
"use strict";
var lg = 'quiqqer/invoice';
......@@ -74,7 +75,8 @@ define('package/quiqqer/invoice/bin/backend/controls/articles/Article', [
unitPrice : 0,
vat : '',
'class' : 'QUI\\ERP\\Accounting\\Invoice\\Articles\\Article',
params : false // mixed value for API Articles
params : false, // mixed value for API Articles
currency : false
},
initialize: function (options) {
......@@ -108,12 +110,6 @@ define('package/quiqqer/invoice/bin/backend/controls/articles/Article', [
)
);
}
// admin format
this.$Formatter = QUILocale.getNumberFormatter({
style : 'currency',
currency: 'EUR'
});
},
/**
......@@ -292,41 +288,59 @@ define('package/quiqqer/invoice/bin/backend/controls/articles/Article', [
this.showLoader();
return new Promise(function (resolve, reject) {
QUIAjax.get('package_quiqqer_invoice_ajax_invoices_temporary_product_calc', function (product) {
var unitPrice = self.$Formatter.format(product.unitPrice);
var price = self.$Formatter.format(product.calculated.nettoSubSum);
var total = self.$Formatter.format(product.calculated.nettoSum);
return this.getCurrencyFormatter().then(function (Formatter) {
return Promise.all([
self.$calc(),
Formatter
]);
}).then(function (result) {
var product = result[0];
var Formatter = result[1];
self.$calculations = product;
var unitPrice = Formatter.format(product.unitPrice);
var price = Formatter.format(product.calculated.nettoSubSum);
var total = Formatter.format(product.calculated.nettoSum);
var setElement = function (Node, text) {
var isInEditMode = Node.getElement('input');
self.$calculations = product;
if (isInEditMode) {
Node.set({
title: text
});
return;
}
var setElement = function (Node, text) {
var isInEditMode = Node.getElement('input');
if (isInEditMode) {
Node.set({
html : text,
title: text
});
};
return;
}
Node.set({
html : text,
title: text
});
};
setElement(self.$Total, total);
setElement(self.$UnitPrice, unitPrice);
setElement(self.$Price, price);
setElement(self.$VAT, product.vat + '%');
setElement(self.$Total, total);
setElement(self.$UnitPrice, unitPrice);
setElement(self.$Price, price);
setElement(self.$VAT, product.vat + '%');
self.hideLoader();
self.hideLoader();
self.fireEvent('calc', [self]);
resolve(product);
return product;
});
},
self.fireEvent('calc', [self]);
}, {
/**
* Calculate the current article
*
* @return {Promise}
*/
$calc: function () {
var self = this;
return new Promise(function (resolve, reject) {
QUIAjax.get('package_quiqqer_invoice_ajax_invoices_temporary_product_calc', resolve, {
'package': 'quiqqer/invoice',
onError : reject,
params : JSON.encode(self.getAttributes()),
......@@ -344,6 +358,55 @@ define('package/quiqqer/invoice/bin/backend/controls/articles/Article', [
return this.$calculations;
},
/**
* Return the article currency
*
* @return {Promise|*}
*/
getCurrencyFormatter: function () {
if (this.$Formatter) {
return Promise.resolve(this.$Formatter);
}
// admin format
if (this.getAttribute('currency')) {
this.$Formatter = QUILocale.getNumberFormatter({
style : 'currency',
currency: this.getAttribute('currency')
});
return Promise.resolve(this.$Formatter);
}
var self = this;
return new Promise(function (resolve) {
Currency.getCurrency().then(function (currency) {
self.$Formatter = QUILocale.getNumberFormatter({
style : 'currency',
currency: currency.code
});
resolve(self.$Formatter);
});
});
},
/**
* Set the currency to the article
*
* @param {String} currency
*/
setCurrency: function (currency) {
if (this.getAttribute('currency') === currency) {
return;
}
this.setAttribute('currency', currency);
this.$Formatter = null;
},
/**
* Set the product title
*
......
......@@ -24,8 +24,9 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/TemporaryInvoice.Sum
Type : 'package/quiqqer/invoice/bin/backend/controls/panels/TemporaryInvoice.Summary',
options: {
List : null,
styles: false
List : null,
styles : false,
currency: 'EUR'
},
Binds: [
......@@ -41,7 +42,7 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/TemporaryInvoice.Sum
this.$Formatter = QUILocale.getNumberFormatter({
style : 'currency',
currency : 'EUR',
currency : this.getAttribute('currency'),
minimumFractionDigits: 2
});
......@@ -103,16 +104,9 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/TemporaryInvoice.Sum
List.addEvent('onCalc', function (List) {
var data = List.getCalculation();
self.$Formatter = QUILocale.getNumberFormatter({
style : 'currency',
currency : data.currencyData.code,
minimumFractionDigits: 2
});
self.$NettoSum.set('html', self.$Formatter.format(data.nettoSum));
self.$BruttoSum.set('html', self.$Formatter.format(data.sum));
if (typeOf(data.vatArray) === 'array' && !data.vatArray.length) {
self.$VAT.set('html', '---');
return;
......
......@@ -462,10 +462,11 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/TemporaryInvoice', [
'package/quiqqer/invoice/bin/backend/controls/panels/TemporaryInvoice.Summary'
], function (List, Summary) {
self.$ArticleList = new List({
events: {
currency: self.getAttribute('currency'),
events : {
onArticleReplaceClick: self.$onArticleReplaceClick
},
styles: {
styles : {
height: 'calc(100% - 120px)'
}
}).inject(Container);
......@@ -473,8 +474,9 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/TemporaryInvoice', [
Container.setStyle('height', '100%');
self.$ArticleListSummary = new Summary({
List : self.$ArticleList,
styles: {
currency: self.getAttribute('currency'),
List : self.$ArticleList,
styles : {
bottom : -20,
left : 0,
opacity : 0,
......
......@@ -681,6 +681,7 @@ public function createCreditNote($PermissionUser = null, $globalProcessId = fals
// change all prices
$ArticleList = $Copy->getArticles();
$ArticleList->clear();
$ArticleList->setCurrency($this->getCurrency());
foreach ($articles as $Article) {
/* @var $Article QUI\ERP\Accounting\Article */
......@@ -738,6 +739,7 @@ public function createCreditNote($PermissionUser = null, $globalProcessId = fals
$Copy->setData('originalId', $this->getCleanId());
$Copy->setAttribute('date', \date('Y-m-d H:i:s'));
$Copy->setAttribute('additional_invoice_text', $additionalText);
$Copy->setAttribute('currency_data', $this->getAttribute('currency_data'));
$Copy->setInvoiceType(Handler::TYPE_INVOICE_CREDIT_NOTE);
$Copy->save(QUI::getUsers()->getSystemUser());
......
......@@ -1226,10 +1226,16 @@ public function importArticles($articles = [])
$Article = new QUI\ERP\Accounting\Article($article);
$this->addArticle($Article);
} catch (QUI\Exception $Exception) {
} catch (\Exception $Exception) {
QUI\System\Log::writeException($Exception);
}
}
try {
$this->Articles->setCurrency($this->getCurrency());
} catch (QUI\Exception $Exception) {
QUI\System\Log::writeDebugException($Exception);
}
}
//endregion
......
0% Lade oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren