Skip to content
Code-Schnipsel Gruppen Projekte
Bestätigt Commit 27c3e760 erstellt von Henning Leutz's avatar Henning Leutz :martial_arts_uniform:
Dateien durchsuchen

fix: #128

Übergeordneter f4a8fefe
No related branches found
No related tags found
Keine zugehörigen Merge Requests gefunden
......@@ -235,18 +235,18 @@ public function getView(): InvoiceView
*/
public function getArticles(): ArticleListUnique
{
try {
$Currency = $this->getCurrency();
} catch (QUI\Exception $Exception) {
$Currency = QUI\ERP\Defaults::getCurrency();
}
$articles = $this->getAttribute('articles');
if (\is_string($articles)) {
$articles = \json_decode($articles, true);
}
try {
$articles['calculations']['currencyData'] = $this->getCurrency()->toArray();
} catch (QUI\Exception $Exception) {
QUI\System\Log::writeDebugException($Exception);
}
$List = new ArticleListUnique($articles, $this->getCustomer());
$List->setLocale($this->getCustomer()->getLocale());
......
......@@ -121,10 +121,10 @@ public function __construct($id, Handler $Handler)
$data = $Handler->getTemporaryInvoiceData($id);
$this->prefix = Settings::getInstance()->getTemporaryInvoicePrefix();
$this->id = (int)\str_replace($this->prefix, '', $id);
$this->id = (int)\str_replace($this->prefix, '', $id);
$this->Articles = new ArticleList();
$this->History = new QUI\ERP\Comments();
$this->History = new QUI\ERP\Comments();
$this->Comments = new QUI\ERP\Comments();
if (!empty($data['delivery_address'])) {
......@@ -279,7 +279,7 @@ public function __construct($id, Handler $Handler)
*/
public function getId(): string
{
return $this->prefix.$this->id;
return $this->prefix . $this->id;
}
/**
......@@ -419,7 +419,8 @@ public function setCurrency($currency)
}
$this->setAttribute('currency_data', $currency->toArray());
$this->Currency = null;
$this->Articles->setCurrency($this->Currency);
$this->Currency = $this->getCurrency();
}
/**
......@@ -471,7 +472,7 @@ public function getEditor(): ?QUI\Interfaces\Users\User
if ($this->getAttribute('editor_id')) {
try {
$Editor = QUI::getUsers()->get($this->getAttribute('editor_id'));
$Editor = QUI::getUsers()->get($this->getAttribute('editor_id'));
$isInGroup = $Editor->isInGroup($Employees->getEmployeeGroup()->getId());
if ($isInGroup) {
......@@ -630,7 +631,7 @@ public function setInvoiceType($type, $PermissionUser = null)
}
$this->type = $type;
$typeTitle = QUI::getLocale()->get('quiqqer/invoice', 'invoice.type.'.$type);
$typeTitle = QUI::getLocale()->get('quiqqer/invoice', 'invoice.type.' . $type);
$this->addHistory(
QUI::getLocale()->get(
......@@ -689,9 +690,9 @@ public function update($PermissionUser = null)
);
// attributes
$projectName = '';
$projectName = '';
$timeForPayment = null;
$date = '';
$date = '';
$isBrutto = QUI\ERP\Defaults::getBruttoNettoStatus();
......@@ -741,7 +742,7 @@ public function update($PermissionUser = null)
$invoiceAddressId = $Address->getId();
} catch (QUI\Exception $Exception) {
$invoiceAddress = $this->getAttribute('invoice_address');
$invoiceAddress = $this->getAttribute('invoice_address');
$invoiceAddressCheck = false;
if (\is_string($invoiceAddress)) {
......@@ -765,7 +766,7 @@ public function update($PermissionUser = null)
try {
if ($this->getAttribute('payment_method')) {
$Payments = QUI\ERP\Accounting\Payments\Payments::getInstance();
$Payment = $Payments->getPayment($this->getAttribute('payment_method'));
$Payment = $Payments->getPayment($this->getAttribute('payment_method'));
$paymentMethod = $Payment->getId();
}
......@@ -796,50 +797,50 @@ public function update($PermissionUser = null)
}
// Editor
$Editor = $this->getEditor();
$editorId = 0;
$Editor = $this->getEditor();
$editorId = 0;
$editorName = '';
// use default advisor as editor
if ($Editor) {
$editorId = $Editor->getId();
$editorId = $Editor->getId();
$editorName = $Editor->getName();
}
// Ordered By
$OrderedBy = $this->getOrderedByUser();
$orderedBy = (int)$this->getAttribute('customer_id');
$OrderedBy = $this->getOrderedByUser();
$orderedBy = (int)$this->getAttribute('customer_id');
$orderedByName = '';
if ($OrderedBy) {
$orderedBy = $OrderedBy->getId();
$orderedBy = $OrderedBy->getId();
$orderedByName = $OrderedBy->getName();
} elseif ($orderedBy) {
try {
$User = QUI::getUsers()->get($orderedBy);
$orderedBy = $User->getId();
$User = QUI::getUsers()->get($orderedBy);
$orderedBy = $User->getId();
$orderedByName = $User->getName();
} catch (QUI\Exception $Exception) {
}
}
// shipping
$shippingId = null;
$shippingId = null;
$shippingData = null;
if ($this->getShipping()) {
$shippingId = $this->getShipping()->getId();
$shippingId = $this->getShipping()->getId();
$shippingData = $this->getShipping()->toJSON();
}
// delivery address
$deliveryAddress = '';
$deliveryAddress = '';
$deliveryAddressId = null;
$DeliveryAddress = $this->getDeliveryAddress();
$DeliveryAddress = $this->getDeliveryAddress();
// Save delivery address separately only if it differs from invoice address
if ($DeliveryAddress && ($invoiceAddressId && $DeliveryAddress->getId() !== $invoiceAddressId)) {
$deliveryAddress = $DeliveryAddress->toJSON();
$deliveryAddress = $DeliveryAddress->toJSON();
$deliveryAddressId = $DeliveryAddress->getId();
if (empty($deliveryAddressId)) {
......@@ -1010,7 +1011,7 @@ public function copy($PermissionUser = null): InvoiceTemporary
$Handler = Handler::getInstance();
$Factory = Factory::getInstance();
$New = $Factory->createInvoice($PermissionUser);
$New = $Factory->createInvoice($PermissionUser);
$currentData = QUI::getDataBase()->fetch([
'from' => $Handler->temporaryInvoiceTable(),
......@@ -1020,7 +1021,7 @@ public function copy($PermissionUser = null): InvoiceTemporary
'limit' => 1
]);
$currentData = $currentData[0];
$currentData = $currentData[0];
$currentData['hash'] = QUI\Utils\Uuid::get();
unset($currentData['id']);
......@@ -1080,11 +1081,11 @@ public function post($PermissionUser = null): Invoice
$this->validate();
// data
$User = QUI::getUserBySession();
$date = \date('Y-m-d H:i:s'); // invoice date, to today
$User = QUI::getUserBySession();
$date = \date('Y-m-d H:i:s'); // invoice date, to today
$isBrutto = QUI\ERP\Defaults::getBruttoNettoStatus();
$Customer = $this->getCustomer();
$Handler = Handler::getInstance();
$Handler = Handler::getInstance();
if (QUI\Permissions\Permission::hasPermission('quiqqer.invoice.changeDate')) {
if ($this->getAttribute('date')
......@@ -1116,37 +1117,37 @@ public function post($PermissionUser = null): Invoice
// customerData
$ErpCustomer = QUI\ERP\User::convertUserToErpUser($Customer);
$customerData = $ErpCustomer->getAttributes();
$customerData = $ErpCustomer->getAttributes();
$customerData['erp.isNettoUser'] = $Customer->getAttribute('quiqqer.erp.isNettoUser');
$customerData['erp.euVatId'] = $Customer->getAttribute('quiqqer.erp.euVatId');
$customerData['erp.taxId'] = $Customer->getAttribute('quiqqer.erp.taxId');
$customerData['erp.euVatId'] = $Customer->getAttribute('quiqqer.erp.euVatId');
$customerData['erp.taxId'] = $Customer->getAttribute('quiqqer.erp.taxId');
// Editor
$Editor = $this->getEditor();
$editorId = 0;
$Editor = $this->getEditor();
$editorId = 0;
$editorName = '';
// use default advisor as editor
if ($Editor) {
$editorId = $Editor->getId();
$editorId = $Editor->getId();
$editorName = $Editor->getName();
}
// Ordered By
$OrderedBy = $this->getOrderedByUser();
$orderedBy = (int)$this->getAttribute('customer_id');
$OrderedBy = $this->getOrderedByUser();
$orderedBy = (int)$this->getAttribute('customer_id');
$orderedByName = '';
// use default advisor as editor
if ($OrderedBy) {
$orderedBy = $OrderedBy->getId();
$orderedBy = $OrderedBy->getId();
$orderedByName = $OrderedBy->getName();
} elseif ($orderedBy) {
try {
$User = QUI::getUsers()->get($orderedBy);
$orderedBy = $User->getId();
$User = QUI::getUsers()->get($orderedBy);
$orderedBy = $User->getId();
$orderedByName = $User->getName();
} catch (QUI\Exception $Exception) {
}
......@@ -1159,16 +1160,16 @@ public function post($PermissionUser = null): Invoice
// payment stuff
$Payments = QUI\ERP\Accounting\Payments\Payments::getInstance();
$Payment = $Payments->getPayment($this->getAttribute('payment_method'));
$Payment = $Payments->getPayment($this->getAttribute('payment_method'));
$paymentMethodData = $this->parsePaymentForPaymentData($Payment);
$paymentTime = (int)$this->getAttribute('time_for_payment');
$paymentTime = (int)$this->getAttribute('time_for_payment');
if ($paymentTime < 0) {
$paymentTime = 0;
}
$timeForPayment = \strtotime(\date('Y-m-d').' 00:00 + '.$paymentTime.' days');
$timeForPayment = \strtotime(\date('Y-m-d') . ' 00:00 + ' . $paymentTime . ' days');
$timeForPayment = \date('Y-m-d', $timeForPayment);
$timeForPayment .= ' 23:59:59';
......@@ -1191,18 +1192,18 @@ public function post($PermissionUser = null): Invoice
$this->Articles->calc();
$listCalculations = $this->Articles->getCalculations();
$uniqueList = $this->Articles->toUniqueList()->toArray();
$uniqueList = $this->Articles->toUniqueList()->toArray();
$uniqueList['calculations']['sum'] = InvoiceUtils::roundInvoiceSum($uniqueList['calculations']['sum']);
$uniqueList['calculations']['sum'] = InvoiceUtils::roundInvoiceSum($uniqueList['calculations']['sum']);
$uniqueList['calculations']['subSum'] = InvoiceUtils::roundInvoiceSum($uniqueList['calculations']['subSum']);
$uniqueList = \json_encode($uniqueList);
$uniqueList = \json_encode($uniqueList);
//shipping
$shippingId = null;
$shippingId = null;
$shippingData = null;
if ($this->getShipping()) {
$shippingId = $this->getShipping()->getId();
$shippingId = $this->getShipping()->getId();
$shippingData = $this->getShipping()->toJSON();
}
......@@ -1232,7 +1233,7 @@ public function post($PermissionUser = null): Invoice
// payment custom data
try {
$InvoicePayment = new Payment($paymentMethodData);
$InvoicePayment = new Payment($paymentMethodData);
$this->customData['InvoiceInformationText'] = $InvoicePayment->getInvoiceInformationText($this);
} catch (\Exception $Exception) {
}
......@@ -1262,9 +1263,9 @@ public function post($PermissionUser = null): Invoice
// if invoice hash exist, we need a new hash
$this->setAttribute('hash', QUI\Utils\Uuid::get());
$this->getComments()->addComment(
'A new hash has been created. The hash already existed.'.
'Old Hash: '.$oldHash.
'New Hash: '.$this->getAttribute('hash')
'A new hash has been created. The hash already existed.' .
'Old Hash: ' . $oldHash .
'New Hash: ' . $this->getAttribute('hash')
);
} catch (QUI\Exception $Exception) {
QUI\System\Log::writeDebugException($Exception);
......@@ -1361,7 +1362,7 @@ public function post($PermissionUser = null): Invoice
$this->delete(QUI::getUsers()->getSystemUser());
// invoice payment calculation
$Invoice = $Handler->getInvoice($newId);
$Invoice = $Handler->getInvoice($newId);
$calculation = QUI\ERP\Accounting\Calc::calculatePayments($Invoice);
if (empty($calculation)) {
......@@ -1407,7 +1408,6 @@ public function post($PermissionUser = null): Invoice
}
} catch (\Exception $Exception) {
QUI\System\Log::writeException($Exception);
// @todo history info das mail nicht raus ging
}
......@@ -1453,8 +1453,8 @@ public function toArray(): array
{
$attributes = $this->getAttributes();
$attributes['id'] = $this->getId();
$attributes['type'] = $this->getInvoiceType();
$attributes['id'] = $this->getId();
$attributes['type'] = $this->getInvoiceType();
$attributes['articles'] = $this->Articles->toArray();
$attributes['globalProcessId'] = $this->getGlobalProcessId();
......@@ -1730,20 +1730,20 @@ public function getData(string $key)
*/
protected function parsePaymentForPaymentData(QUI\ERP\Accounting\Payments\Types\PaymentInterface $Payment): array
{
$data = $Payment->toArray();
$Locale = new QUI\Locale();
$data = $Payment->toArray();
$Locale = new QUI\Locale();
$languages = QUI\Translator::getAvailableLanguages();
$data['title'] = [];
$data['title'] = [];
$data['workingTitle'] = [];
$data['description'] = [];
$data['description'] = [];
foreach ($languages as $language) {
$Locale->setCurrent($language);
$data['title'][$language] = $Payment->getTitle($Locale);
$data['title'][$language] = $Payment->getTitle($Locale);
$data['workingTitle'][$language] = $Payment->getWorkingTitle($Locale);
$data['description'][$language] = $Payment->getDescription($Locale);
$data['description'][$language] = $Payment->getDescription($Locale);
}
return $data;
......@@ -1793,7 +1793,7 @@ public function getPaymentData(string $key)
public function lock()
{
$Package = QUI::getPackage('quiqqer/invoice');
$key = 'temporary-invoice-'.$this->getId();
$key = 'temporary-invoice-' . $this->getId();
QUI\Lock\Locker::lock($Package, $key);
}
......@@ -1808,7 +1808,7 @@ public function lock()
public function unlock()
{
$Package = QUI::getPackage('quiqqer/invoice');
$key = 'temporary-invoice-'.$this->getId();
$key = 'temporary-invoice-' . $this->getId();
QUI\Lock\Locker::unlock($Package, $key);
}
......@@ -1823,7 +1823,7 @@ public function unlock()
public function isLocked(): bool
{
$Package = QUI::getPackage('quiqqer/invoice');
$key = 'temporary-invoice-'.$this->getId();
$key = 'temporary-invoice-' . $this->getId();
return QUI\Lock\Locker::isLocked($Package, $key);
}
......@@ -1837,7 +1837,7 @@ public function isLocked(): bool
public function checkLocked()
{
$Package = QUI::getPackage('quiqqer/invoice');
$key = 'temporary-invoice-'.$this->getId();
$key = 'temporary-invoice-' . $this->getId();
QUI\Lock\Locker::checkLocked($Package, $key);
}
......@@ -1943,7 +1943,7 @@ public function getDeliveryAddress(): ?QUI\ERP\Address
);
if ($Address) {
$addressData = $Address->getAttributes();
$addressData = $Address->getAttributes();
$addressData['id'] = $Address->getId();
return new QUI\ERP\Address($addressData, $this->getCustomer());
......@@ -2072,7 +2072,7 @@ public function addCustomerFile(string $fileHash, array $options = [])
'options' => $options
];
$customerFiles = $this->getCustomerFiles();
$customerFiles = $this->getCustomerFiles();
$customerFiles[] = $fileEntry;
$this->setData('customer_files', $customerFiles);
......
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