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

refactor: development

Übergeordneter 7dd4bce5
Keine zugehörigen Branchen gefunden
Keine zugehörigen Tags gefunden
Keine zugehörigen Merge Requests gefunden
......@@ -12,11 +12,11 @@
QUI::$Ajax->registerFunction(
'package_quiqqer_invoice_ajax_invoices_create',
function () {
$Invoices = QUI\ERP\Accounting\Invoice\Handler::getInstance();
$Invoice = $Invoices->create();
$Factory = QUI\ERP\Accounting\Invoice\Factory::getInstance();
$Invoice = $Factory->createInvoice();
return $Invoice->getId();
},
array(),
false,
'Permission::checkAdminUser'
);
......@@ -157,6 +157,10 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/TemporaryInvoice.Use
}
return this.$getUser().then(function (User) {
if (!User) {
return [];
}
return User.getAddressList();
}).then(function (addresses) {
......
......@@ -58,7 +58,7 @@
<field type="INT NOT NULL">customer_id</field>
<field type="INT NOT NULL">address_id</field>
<field type="INT NULL">order_id</field>
<field type="VARCHAR(250) NOT NULL">hash</field>
<field type="VARCHAR(40) NOT NULL">hash</field>
<field type="VARCHAR(200) NOT NULL">payment_method</field>
<field type="TEXT NULL">payment_data</field> <!-- muss verschlüsselt sein -->
......
......@@ -11,45 +11,32 @@
*
* @package QUI\ERP\Accounting\Invoice
*/
class Factory
class Factory extends QUI\Utils\Singleton
{
/**
* @var null
*/
protected static $Instance = null;
/**
* @return null|Factory
*/
public static function getInstance()
{
if (self::$Instance === null) {
self::$Instance = new self();
}
return self::$Instance;
}
/**
* Create a non posted invoice
* Creates a new temporary invoice
*
* @param QUI\Interfaces\Users\User|null $User
* @return TemporaryInvoice
*/
public function createInvoice()
public function createInvoice($User = null)
{
$Handler = Handler::getInstance();
$Database = QUI::getDataBase();
$Hash = Uuid::uuid1();
if ($User === null) {
$User = QUI::getUserBySession();
}
QUI\Permissions\Permission::checkPermission('quiqqer.invoice.create', $User);
$Database->insert(
$Handler->temporaryInvoiceTable(),
QUI::getDataBase()->insert(
Handler::getInstance()->temporaryInvoiceTable(),
array(
'hash' => $Hash->toString()
'c_user' => $User->getId(),
'hash' => Uuid::uuid1()->toString()
)
);
$newId = $Database->getPDO()->lastInsertId();
$newId = QUI::getDataBase()->getPDO()->lastInsertId();
return $Handler->getTemporaryInvoice($newId);
return Handler::getInstance()->getTemporaryInvoice($newId);
}
}
......@@ -52,32 +52,6 @@ public function temporaryInvoiceTable()
return QUI::getDBTableName(self::TABLE_TEMPORARY_INVOICE);
}
/**
* Creates a new temporary invoice
*
* @param QUI\Interfaces\Users\User|null $User
* @return TemporaryInvoice
*/
public function create($User = null)
{
if ($User === null) {
$User = QUI::getUserBySession();
}
QUI\Permissions\Permission::checkPermission('quiqqer.invoice.create', $User);
QUI::getDataBase()->insert(
$this->temporaryInvoiceTable(),
array(
'c_user' => $User->getId()
)
);
$newId = QUI::getDataBase()->getPDO()->lastInsertId();
return $this->getTemporaryInvoice($newId);
}
/**
* Delete a temporary invoice
*
......
......@@ -123,7 +123,6 @@ public function save($User = null)
'sum' => '',
'vat_data' => '',
'processing_status' => ''
),
array(
'id' => $this->getCleanId()
......@@ -159,7 +158,8 @@ public function delete($User = null)
public function copy($User = null)
{
$Handler = Handler::getInstance();
$New = $Handler->create($User);
$Factory = Factory::getInstance();
$New = $Factory->createInvoice($User);
$currentData = QUI::getDataBase()->fetch(array(
'from' => $Handler->temporaryInvoiceTable(),
......
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