mirror of
https://github.com/Karaka-Management/oms-Billing.git
synced 2026-02-17 08:48:40 +00:00
phpstan and phpcs fixes
This commit is contained in:
parent
b148909011
commit
3ccdcade6e
|
|
@ -43,7 +43,7 @@ class Media
|
||||||
{
|
{
|
||||||
$media = \Modules\Media\Admin\Installer::installExternal($app, ['path' => __DIR__ . '/Media.install.json']);
|
$media = \Modules\Media\Admin\Installer::installExternal($app, ['path' => __DIR__ . '/Media.install.json']);
|
||||||
|
|
||||||
$preivewType = (int) \reset($media['type'][0]);
|
$preivewType = (int) \reset($media['type'][0]);
|
||||||
$originalType = (int) \reset($media['type'][1]);
|
$originalType = (int) \reset($media['type'][1]);
|
||||||
|
|
||||||
$setting = new Setting();
|
$setting = new Setting();
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
"icon": null,
|
"icon": null,
|
||||||
"order": 5,
|
"order": 5,
|
||||||
"from": "Billing",
|
"from": "Billing",
|
||||||
"permission": { "permission": 2, "type": null, "element": null },
|
"permission": { "permission": 2, "category": null, "element": null },
|
||||||
"parent": 1001601001,
|
"parent": 1001601001,
|
||||||
"children": [
|
"children": [
|
||||||
{
|
{
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
"icon": null,
|
"icon": null,
|
||||||
"order": 1,
|
"order": 1,
|
||||||
"from": "Billing",
|
"from": "Billing",
|
||||||
"permission": { "permission": 2, "type": null, "element": null },
|
"permission": { "permission": 2, "category": null, "element": null },
|
||||||
"parent": 1005104001,
|
"parent": 1005104001,
|
||||||
"children": []
|
"children": []
|
||||||
},
|
},
|
||||||
|
|
@ -39,7 +39,7 @@
|
||||||
"icon": null,
|
"icon": null,
|
||||||
"order": 5,
|
"order": 5,
|
||||||
"from": "Billing",
|
"from": "Billing",
|
||||||
"permission": { "permission": 2, "type": null, "element": null },
|
"permission": { "permission": 2, "category": null, "element": null },
|
||||||
"parent": 1005104001,
|
"parent": 1005104001,
|
||||||
"children": []
|
"children": []
|
||||||
},
|
},
|
||||||
|
|
@ -54,7 +54,7 @@
|
||||||
"icon": null,
|
"icon": null,
|
||||||
"order": 10,
|
"order": 10,
|
||||||
"from": "Billing",
|
"from": "Billing",
|
||||||
"permission": { "permission": 4, "type": null, "element": null },
|
"permission": { "permission": 4, "category": null, "element": null },
|
||||||
"parent": 1005104001,
|
"parent": 1005104001,
|
||||||
"children": []
|
"children": []
|
||||||
}
|
}
|
||||||
|
|
@ -71,7 +71,7 @@
|
||||||
"icon": null,
|
"icon": null,
|
||||||
"order": 5,
|
"order": 5,
|
||||||
"from": "Billing",
|
"from": "Billing",
|
||||||
"permission": { "permission": 2, "type": null, "element": null },
|
"permission": { "permission": 2, "category": null, "element": null },
|
||||||
"parent": 1002101001,
|
"parent": 1002101001,
|
||||||
"children": [
|
"children": [
|
||||||
{
|
{
|
||||||
|
|
@ -85,7 +85,7 @@
|
||||||
"icon": null,
|
"icon": null,
|
||||||
"order": 1,
|
"order": 1,
|
||||||
"from": "Billing",
|
"from": "Billing",
|
||||||
"permission": { "permission": 2, "type": null, "element": null },
|
"permission": { "permission": 2, "category": null, "element": null },
|
||||||
"parent": 1005105001,
|
"parent": 1005105001,
|
||||||
"children": []
|
"children": []
|
||||||
},
|
},
|
||||||
|
|
@ -100,7 +100,7 @@
|
||||||
"icon": null,
|
"icon": null,
|
||||||
"order": 5,
|
"order": 5,
|
||||||
"from": "Billing",
|
"from": "Billing",
|
||||||
"permission": { "permission": 2, "type": null, "element": null },
|
"permission": { "permission": 2, "category": null, "element": null },
|
||||||
"parent": 1005105001,
|
"parent": 1005105001,
|
||||||
"children": []
|
"children": []
|
||||||
},
|
},
|
||||||
|
|
@ -115,7 +115,7 @@
|
||||||
"icon": null,
|
"icon": null,
|
||||||
"order": 10,
|
"order": 10,
|
||||||
"from": "Billing",
|
"from": "Billing",
|
||||||
"permission": { "permission": 4, "type": null, "element": null },
|
"permission": { "permission": 4, "category": null, "element": null },
|
||||||
"parent": 1005105001,
|
"parent": 1005105001,
|
||||||
"children": []
|
"children": []
|
||||||
},
|
},
|
||||||
|
|
@ -130,7 +130,7 @@
|
||||||
"icon": null,
|
"icon": null,
|
||||||
"order": 15,
|
"order": 15,
|
||||||
"from": "Billing",
|
"from": "Billing",
|
||||||
"permission": { "permission": 4, "type": null, "element": null },
|
"permission": { "permission": 4, "category": null, "element": null },
|
||||||
"parent": 1005105001,
|
"parent": 1005105001,
|
||||||
"children": []
|
"children": []
|
||||||
}
|
}
|
||||||
|
|
@ -147,7 +147,7 @@
|
||||||
"icon": null,
|
"icon": null,
|
||||||
"order": 5,
|
"order": 5,
|
||||||
"from": "Billing",
|
"from": "Billing",
|
||||||
"permission": { "permission": 2, "type": null, "element": null },
|
"permission": { "permission": 2, "category": null, "element": null },
|
||||||
"parent": 1001301001,
|
"parent": 1001301001,
|
||||||
"children": [
|
"children": [
|
||||||
{
|
{
|
||||||
|
|
@ -161,7 +161,7 @@
|
||||||
"icon": null,
|
"icon": null,
|
||||||
"order": 1,
|
"order": 1,
|
||||||
"from": "Billing",
|
"from": "Billing",
|
||||||
"permission": { "permission": 2, "type": null, "element": null },
|
"permission": { "permission": 2, "category": null, "element": null },
|
||||||
"parent": 1005106001,
|
"parent": 1005106001,
|
||||||
"children": []
|
"children": []
|
||||||
},
|
},
|
||||||
|
|
@ -176,7 +176,7 @@
|
||||||
"icon": null,
|
"icon": null,
|
||||||
"order": 1,
|
"order": 1,
|
||||||
"from": "Billing",
|
"from": "Billing",
|
||||||
"permission": { "permission": 2, "type": null, "element": null },
|
"permission": { "permission": 2, "category": null, "element": null },
|
||||||
"parent": 1005106001,
|
"parent": 1005106001,
|
||||||
"children": []
|
"children": []
|
||||||
},
|
},
|
||||||
|
|
@ -191,7 +191,7 @@
|
||||||
"icon": null,
|
"icon": null,
|
||||||
"order": 5,
|
"order": 5,
|
||||||
"from": "Billing",
|
"from": "Billing",
|
||||||
"permission": { "permission": 4, "type": null, "element": null },
|
"permission": { "permission": 4, "category": null, "element": null },
|
||||||
"parent": 1005106001,
|
"parent": 1005106001,
|
||||||
"children": []
|
"children": []
|
||||||
}
|
}
|
||||||
|
|
@ -208,7 +208,7 @@
|
||||||
"icon": null,
|
"icon": null,
|
||||||
"order": 15,
|
"order": 15,
|
||||||
"from": "Billing",
|
"from": "Billing",
|
||||||
"permission": { "permission": 2, "type": null, "element": null },
|
"permission": { "permission": 2, "category": null, "element": null },
|
||||||
"parent": 1001602001,
|
"parent": 1001602001,
|
||||||
"children": []
|
"children": []
|
||||||
},
|
},
|
||||||
|
|
@ -223,7 +223,7 @@
|
||||||
"icon": null,
|
"icon": null,
|
||||||
"order": 15,
|
"order": 15,
|
||||||
"from": "Billing",
|
"from": "Billing",
|
||||||
"permission": { "permission": 2, "type": null, "element": null },
|
"permission": { "permission": 2, "category": null, "element": null },
|
||||||
"parent": 1001602001,
|
"parent": 1001602001,
|
||||||
"children": []
|
"children": []
|
||||||
},
|
},
|
||||||
|
|
@ -238,7 +238,7 @@
|
||||||
"icon": null,
|
"icon": null,
|
||||||
"order": 5,
|
"order": 5,
|
||||||
"from": "Billing",
|
"from": "Billing",
|
||||||
"permission": { "permission": 2, "type": null, "element": null },
|
"permission": { "permission": 2, "category": null, "element": null },
|
||||||
"parent": 1003401001,
|
"parent": 1003401001,
|
||||||
"children": [
|
"children": [
|
||||||
{
|
{
|
||||||
|
|
@ -252,7 +252,7 @@
|
||||||
"icon": null,
|
"icon": null,
|
||||||
"order": 1,
|
"order": 1,
|
||||||
"from": "Billing",
|
"from": "Billing",
|
||||||
"permission": { "permission": 2, "type": null, "element": null },
|
"permission": { "permission": 2, "category": null, "element": null },
|
||||||
"parent": 1005109001,
|
"parent": 1005109001,
|
||||||
"children": [
|
"children": [
|
||||||
]
|
]
|
||||||
|
|
@ -268,7 +268,7 @@
|
||||||
"icon": null,
|
"icon": null,
|
||||||
"order": 5,
|
"order": 5,
|
||||||
"from": "Billing",
|
"from": "Billing",
|
||||||
"permission": { "permission": 2, "type": null, "element": null },
|
"permission": { "permission": 2, "category": null, "element": null },
|
||||||
"parent": 1005109001,
|
"parent": 1005109001,
|
||||||
"children": [
|
"children": [
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -194,10 +194,9 @@ final class ApiController extends Controller
|
||||||
$bill = new Bill();
|
$bill = new Bill();
|
||||||
$bill->createdBy = new NullAccount($request->header->account);
|
$bill->createdBy = new NullAccount($request->header->account);
|
||||||
$bill->type = $billType;
|
$bill->type = $billType;
|
||||||
$bill->setStatus((int) ($request->getData('status') ?? BillStatus::ACTIVE));
|
|
||||||
$bill->numberFormat = $billType->numberFormat;
|
$bill->numberFormat = $billType->numberFormat;
|
||||||
$bill->billTo = $request->getData('billto')
|
$bill->billTo = $request->getData('billto')
|
||||||
?? ($account->profile->account->name1 . (!empty($account->profile->account->name2) ? ', ' . $account->profile->account->name2 : '')); // @todo: use defaultInvoiceAddress or mainAddress. also consider to use billto1, billto2, billto3 (for multiple lines e.g. name2, fao etc.)
|
?? ($account->profile->account->name1 . (!empty($account->profile->account->name2) ? ', ' . $account->profile->account->name2 : '')); // @todo: use defaultInvoiceAddress or mainAddress. also consider to use billto1, billto2, billto3 (for multiple lines e.g. name2, fao etc.)
|
||||||
$bill->billAddress = $request->getData('billaddress') ?? $account->mainAddress->address;
|
$bill->billAddress = $request->getData('billaddress') ?? $account->mainAddress->address;
|
||||||
$bill->billZip = $request->getData('billtopostal') ?? $account->mainAddress->postal;
|
$bill->billZip = $request->getData('billtopostal') ?? $account->mainAddress->postal;
|
||||||
$bill->billCity = $request->getData('billtocity') ?? $account->mainAddress->city;
|
$bill->billCity = $request->getData('billtocity') ?? $account->mainAddress->city;
|
||||||
|
|
@ -205,6 +204,7 @@ final class ApiController extends Controller
|
||||||
$bill->client = $request->getData('client') === null ? null : $account;
|
$bill->client = $request->getData('client') === null ? null : $account;
|
||||||
$bill->supplier = $request->getData('supplier') === null ? null : $account;
|
$bill->supplier = $request->getData('supplier') === null ? null : $account;
|
||||||
$bill->performanceDate = new \DateTime($request->getData('performancedate') ?? 'now');
|
$bill->performanceDate = new \DateTime($request->getData('performancedate') ?? 'now');
|
||||||
|
$bill->setStatus((int) ($request->getData('status') ?? BillStatus::ACTIVE));
|
||||||
|
|
||||||
return $bill;
|
return $bill;
|
||||||
}
|
}
|
||||||
|
|
@ -286,7 +286,6 @@ final class ApiController extends Controller
|
||||||
|
|
||||||
if ($collection instanceof NullCollection) {
|
if ($collection instanceof NullCollection) {
|
||||||
$collection = $this->app->moduleManager->get('Media')->createRecursiveMediaCollection(
|
$collection = $this->app->moduleManager->get('Media')->createRecursiveMediaCollection(
|
||||||
'/Modules/Media/Files',
|
|
||||||
$path,
|
$path,
|
||||||
$request->header->account,
|
$request->header->account,
|
||||||
__DIR__ . '/../../../Modules/Media/Files' . $path,
|
__DIR__ . '/../../../Modules/Media/Files' . $path,
|
||||||
|
|
@ -318,6 +317,15 @@ final class ApiController extends Controller
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create media directory path
|
||||||
|
*
|
||||||
|
* @param Bill $bill Bill
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
private function createBillDir(Bill $bill): string
|
private function createBillDir(Bill $bill): string
|
||||||
{
|
{
|
||||||
return '/Modules/Billing/Bills/'
|
return '/Modules/Billing/Bills/'
|
||||||
|
|
@ -495,7 +503,7 @@ final class ApiController extends Controller
|
||||||
|
|
||||||
$template = $bill->type->template;
|
$template = $bill->type->template;
|
||||||
|
|
||||||
$path = $this->createBillDir($bill);;
|
$path = $this->createBillDir($bill);
|
||||||
$pdfDir = __DIR__ . '/../../../Modules/Media/Files' . $path;
|
$pdfDir = __DIR__ . '/../../../Modules/Media/Files' . $path;
|
||||||
|
|
||||||
$status = !\is_dir($pdfDir) ? \mkdir($pdfDir, 0755, true) : true;
|
$status = !\is_dir($pdfDir) ? \mkdir($pdfDir, 0755, true) : true;
|
||||||
|
|
@ -648,14 +656,14 @@ final class ApiController extends Controller
|
||||||
$files = $request->getFiles();
|
$files = $request->getFiles();
|
||||||
foreach ($files as $file) {
|
foreach ($files as $file) {
|
||||||
// Create default bill
|
// Create default bill
|
||||||
$billRequest = new HttpRequest(new HttpUri(''));
|
$billRequest = new HttpRequest(new HttpUri(''));
|
||||||
$billRequest->header->account = $request->header->account;
|
$billRequest->header->account = $request->header->account;
|
||||||
$billRequest->header->l11n = $request->header->l11n;
|
$billRequest->header->l11n = $request->header->l11n;
|
||||||
$billRequest->setData('supplier', 0);
|
$billRequest->setData('supplier', 0);
|
||||||
$billRequest->setData('status', BillStatus::UNPARSED);
|
$billRequest->setData('status', BillStatus::UNPARSED);
|
||||||
$billRequest->setData('type', $purchaseTransferType->getId());
|
$billRequest->setData('type', $purchaseTransferType->getId());
|
||||||
|
|
||||||
$billResponse = new HttpResponse();
|
$billResponse = new HttpResponse();
|
||||||
$billResponse->header->l11n = $response->header->l11n;
|
$billResponse->header->l11n = $response->header->l11n;
|
||||||
|
|
||||||
$this->apiBillCreate($billRequest, $billResponse, $data);
|
$this->apiBillCreate($billRequest, $billResponse, $data);
|
||||||
|
|
@ -663,12 +671,12 @@ final class ApiController extends Controller
|
||||||
$billId = $billResponse->get('')['response']->getId();
|
$billId = $billResponse->get('')['response']->getId();
|
||||||
|
|
||||||
// Upload and assign document to bill
|
// Upload and assign document to bill
|
||||||
$mediaRequest = new HttpRequest();
|
$mediaRequest = new HttpRequest();
|
||||||
$mediaRequest->header->account = $request->header->account;
|
$mediaRequest->header->account = $request->header->account;
|
||||||
$mediaRequest->header->l11n = $request->header->l11n;
|
$mediaRequest->header->l11n = $request->header->l11n;
|
||||||
$mediaRequest->addFile($file);
|
$mediaRequest->addFile($file);
|
||||||
|
|
||||||
$mediaResponse = new HttpResponse();
|
$mediaResponse = new HttpResponse();
|
||||||
$mediaResponse->header->l11n = $response->header->l11n;
|
$mediaResponse->header->l11n = $response->header->l11n;
|
||||||
|
|
||||||
$mediaRequest->setData('bill', $billId);
|
$mediaRequest->setData('bill', $billId);
|
||||||
|
|
@ -676,7 +684,7 @@ final class ApiController extends Controller
|
||||||
$this->apiMediaAddToBill($mediaRequest, $mediaResponse, $data);
|
$this->apiMediaAddToBill($mediaRequest, $mediaResponse, $data);
|
||||||
|
|
||||||
$uploaded = $mediaResponse->get('')['response']['upload'];
|
$uploaded = $mediaResponse->get('')['response']['upload'];
|
||||||
$in = \reset($uploaded)->getAbsolutePath(); // pdf is parsed in $in->content
|
$in = \reset($uploaded)->getAbsolutePath(); // pdf is parsed in $in->content
|
||||||
|
|
||||||
if (!\is_file($in)) {
|
if (!\is_file($in)) {
|
||||||
throw new \Exception();
|
throw new \Exception();
|
||||||
|
|
@ -685,14 +693,14 @@ final class ApiController extends Controller
|
||||||
// @todo: Parse text and analyze text structure
|
// @todo: Parse text and analyze text structure
|
||||||
|
|
||||||
// Update bill with parsed text
|
// Update bill with parsed text
|
||||||
$billRequest = new HttpRequest();
|
$billRequest = new HttpRequest();
|
||||||
$billRequest->header->account = $request->header->account;
|
$billRequest->header->account = $request->header->account;
|
||||||
$billRequest->header->l11n = $request->header->l11n;
|
$billRequest->header->l11n = $request->header->l11n;
|
||||||
|
|
||||||
$billRequest->setData('bill', $billId);
|
$billRequest->setData('bill', $billId);
|
||||||
$billRequest->setData('supplier', 1);
|
$billRequest->setData('supplier', 1);
|
||||||
|
|
||||||
$billResponse = new HttpResponse();
|
$billResponse = new HttpResponse();
|
||||||
$billResponse->header->l11n = $response->header->l11n;
|
$billResponse->header->l11n = $response->header->l11n;
|
||||||
|
|
||||||
$this->apiBillUpdate($billRequest, $billResponse, $data);
|
$this->apiBillUpdate($billRequest, $billResponse, $data);
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ class BillType
|
||||||
*/
|
*/
|
||||||
public function __construct(string $name = '')
|
public function __construct(string $name = '')
|
||||||
{
|
{
|
||||||
$this->media = new NullCollection();
|
$this->template = new NullCollection();
|
||||||
$this->setL11n($name);
|
$this->setL11n($name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,5 +35,4 @@ abstract class PermissionCategory extends Enum
|
||||||
public const PRIVATE_DASHBOARD = 5;
|
public const PRIVATE_DASHBOARD = 5;
|
||||||
|
|
||||||
public const PRIVATE_BILL_UPLOAD = 6;
|
public const PRIVATE_BILL_UPLOAD = 6;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,4 @@ abstract class SettingsEnum extends Enum
|
||||||
public const PREVIEW_MEDIA_TYPE = '1005100001_1'; // internally generated preview
|
public const PREVIEW_MEDIA_TYPE = '1005100001_1'; // internally generated preview
|
||||||
|
|
||||||
public const ORIGINAL_MEDIA_TYPE = '1005100001_2'; // original document (mostly supplier invoice/delivery note)
|
public const ORIGINAL_MEDIA_TYPE = '1005100001_2'; // original document (mostly supplier invoice/delivery note)
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user