mirror of
https://github.com/Karaka-Management/oms-Billing.git
synced 2026-02-08 12:38: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']);
|
||||
|
||||
$preivewType = (int) \reset($media['type'][0]);
|
||||
$preivewType = (int) \reset($media['type'][0]);
|
||||
$originalType = (int) \reset($media['type'][1]);
|
||||
|
||||
$setting = new Setting();
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
"icon": null,
|
||||
"order": 5,
|
||||
"from": "Billing",
|
||||
"permission": { "permission": 2, "type": null, "element": null },
|
||||
"permission": { "permission": 2, "category": null, "element": null },
|
||||
"parent": 1001601001,
|
||||
"children": [
|
||||
{
|
||||
|
|
@ -24,7 +24,7 @@
|
|||
"icon": null,
|
||||
"order": 1,
|
||||
"from": "Billing",
|
||||
"permission": { "permission": 2, "type": null, "element": null },
|
||||
"permission": { "permission": 2, "category": null, "element": null },
|
||||
"parent": 1005104001,
|
||||
"children": []
|
||||
},
|
||||
|
|
@ -39,7 +39,7 @@
|
|||
"icon": null,
|
||||
"order": 5,
|
||||
"from": "Billing",
|
||||
"permission": { "permission": 2, "type": null, "element": null },
|
||||
"permission": { "permission": 2, "category": null, "element": null },
|
||||
"parent": 1005104001,
|
||||
"children": []
|
||||
},
|
||||
|
|
@ -54,7 +54,7 @@
|
|||
"icon": null,
|
||||
"order": 10,
|
||||
"from": "Billing",
|
||||
"permission": { "permission": 4, "type": null, "element": null },
|
||||
"permission": { "permission": 4, "category": null, "element": null },
|
||||
"parent": 1005104001,
|
||||
"children": []
|
||||
}
|
||||
|
|
@ -71,7 +71,7 @@
|
|||
"icon": null,
|
||||
"order": 5,
|
||||
"from": "Billing",
|
||||
"permission": { "permission": 2, "type": null, "element": null },
|
||||
"permission": { "permission": 2, "category": null, "element": null },
|
||||
"parent": 1002101001,
|
||||
"children": [
|
||||
{
|
||||
|
|
@ -85,7 +85,7 @@
|
|||
"icon": null,
|
||||
"order": 1,
|
||||
"from": "Billing",
|
||||
"permission": { "permission": 2, "type": null, "element": null },
|
||||
"permission": { "permission": 2, "category": null, "element": null },
|
||||
"parent": 1005105001,
|
||||
"children": []
|
||||
},
|
||||
|
|
@ -100,7 +100,7 @@
|
|||
"icon": null,
|
||||
"order": 5,
|
||||
"from": "Billing",
|
||||
"permission": { "permission": 2, "type": null, "element": null },
|
||||
"permission": { "permission": 2, "category": null, "element": null },
|
||||
"parent": 1005105001,
|
||||
"children": []
|
||||
},
|
||||
|
|
@ -115,7 +115,7 @@
|
|||
"icon": null,
|
||||
"order": 10,
|
||||
"from": "Billing",
|
||||
"permission": { "permission": 4, "type": null, "element": null },
|
||||
"permission": { "permission": 4, "category": null, "element": null },
|
||||
"parent": 1005105001,
|
||||
"children": []
|
||||
},
|
||||
|
|
@ -130,7 +130,7 @@
|
|||
"icon": null,
|
||||
"order": 15,
|
||||
"from": "Billing",
|
||||
"permission": { "permission": 4, "type": null, "element": null },
|
||||
"permission": { "permission": 4, "category": null, "element": null },
|
||||
"parent": 1005105001,
|
||||
"children": []
|
||||
}
|
||||
|
|
@ -147,7 +147,7 @@
|
|||
"icon": null,
|
||||
"order": 5,
|
||||
"from": "Billing",
|
||||
"permission": { "permission": 2, "type": null, "element": null },
|
||||
"permission": { "permission": 2, "category": null, "element": null },
|
||||
"parent": 1001301001,
|
||||
"children": [
|
||||
{
|
||||
|
|
@ -161,7 +161,7 @@
|
|||
"icon": null,
|
||||
"order": 1,
|
||||
"from": "Billing",
|
||||
"permission": { "permission": 2, "type": null, "element": null },
|
||||
"permission": { "permission": 2, "category": null, "element": null },
|
||||
"parent": 1005106001,
|
||||
"children": []
|
||||
},
|
||||
|
|
@ -176,7 +176,7 @@
|
|||
"icon": null,
|
||||
"order": 1,
|
||||
"from": "Billing",
|
||||
"permission": { "permission": 2, "type": null, "element": null },
|
||||
"permission": { "permission": 2, "category": null, "element": null },
|
||||
"parent": 1005106001,
|
||||
"children": []
|
||||
},
|
||||
|
|
@ -191,7 +191,7 @@
|
|||
"icon": null,
|
||||
"order": 5,
|
||||
"from": "Billing",
|
||||
"permission": { "permission": 4, "type": null, "element": null },
|
||||
"permission": { "permission": 4, "category": null, "element": null },
|
||||
"parent": 1005106001,
|
||||
"children": []
|
||||
}
|
||||
|
|
@ -208,7 +208,7 @@
|
|||
"icon": null,
|
||||
"order": 15,
|
||||
"from": "Billing",
|
||||
"permission": { "permission": 2, "type": null, "element": null },
|
||||
"permission": { "permission": 2, "category": null, "element": null },
|
||||
"parent": 1001602001,
|
||||
"children": []
|
||||
},
|
||||
|
|
@ -223,7 +223,7 @@
|
|||
"icon": null,
|
||||
"order": 15,
|
||||
"from": "Billing",
|
||||
"permission": { "permission": 2, "type": null, "element": null },
|
||||
"permission": { "permission": 2, "category": null, "element": null },
|
||||
"parent": 1001602001,
|
||||
"children": []
|
||||
},
|
||||
|
|
@ -238,7 +238,7 @@
|
|||
"icon": null,
|
||||
"order": 5,
|
||||
"from": "Billing",
|
||||
"permission": { "permission": 2, "type": null, "element": null },
|
||||
"permission": { "permission": 2, "category": null, "element": null },
|
||||
"parent": 1003401001,
|
||||
"children": [
|
||||
{
|
||||
|
|
@ -252,7 +252,7 @@
|
|||
"icon": null,
|
||||
"order": 1,
|
||||
"from": "Billing",
|
||||
"permission": { "permission": 2, "type": null, "element": null },
|
||||
"permission": { "permission": 2, "category": null, "element": null },
|
||||
"parent": 1005109001,
|
||||
"children": [
|
||||
]
|
||||
|
|
@ -268,7 +268,7 @@
|
|||
"icon": null,
|
||||
"order": 5,
|
||||
"from": "Billing",
|
||||
"permission": { "permission": 2, "type": null, "element": null },
|
||||
"permission": { "permission": 2, "category": null, "element": null },
|
||||
"parent": 1005109001,
|
||||
"children": [
|
||||
]
|
||||
|
|
|
|||
|
|
@ -194,10 +194,9 @@ final class ApiController extends Controller
|
|||
$bill = new Bill();
|
||||
$bill->createdBy = new NullAccount($request->header->account);
|
||||
$bill->type = $billType;
|
||||
$bill->setStatus((int) ($request->getData('status') ?? BillStatus::ACTIVE));
|
||||
$bill->numberFormat = $billType->numberFormat;
|
||||
$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->billZip = $request->getData('billtopostal') ?? $account->mainAddress->postal;
|
||||
$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->supplier = $request->getData('supplier') === null ? null : $account;
|
||||
$bill->performanceDate = new \DateTime($request->getData('performancedate') ?? 'now');
|
||||
$bill->setStatus((int) ($request->getData('status') ?? BillStatus::ACTIVE));
|
||||
|
||||
return $bill;
|
||||
}
|
||||
|
|
@ -286,7 +286,6 @@ final class ApiController extends Controller
|
|||
|
||||
if ($collection instanceof NullCollection) {
|
||||
$collection = $this->app->moduleManager->get('Media')->createRecursiveMediaCollection(
|
||||
'/Modules/Media/Files',
|
||||
$path,
|
||||
$request->header->account,
|
||||
__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
|
||||
{
|
||||
return '/Modules/Billing/Bills/'
|
||||
|
|
@ -495,7 +503,7 @@ final class ApiController extends Controller
|
|||
|
||||
$template = $bill->type->template;
|
||||
|
||||
$path = $this->createBillDir($bill);;
|
||||
$path = $this->createBillDir($bill);
|
||||
$pdfDir = __DIR__ . '/../../../Modules/Media/Files' . $path;
|
||||
|
||||
$status = !\is_dir($pdfDir) ? \mkdir($pdfDir, 0755, true) : true;
|
||||
|
|
@ -648,14 +656,14 @@ final class ApiController extends Controller
|
|||
$files = $request->getFiles();
|
||||
foreach ($files as $file) {
|
||||
// Create default bill
|
||||
$billRequest = new HttpRequest(new HttpUri(''));
|
||||
$billRequest = new HttpRequest(new HttpUri(''));
|
||||
$billRequest->header->account = $request->header->account;
|
||||
$billRequest->header->l11n = $request->header->l11n;
|
||||
$billRequest->header->l11n = $request->header->l11n;
|
||||
$billRequest->setData('supplier', 0);
|
||||
$billRequest->setData('status', BillStatus::UNPARSED);
|
||||
$billRequest->setData('type', $purchaseTransferType->getId());
|
||||
|
||||
$billResponse = new HttpResponse();
|
||||
$billResponse = new HttpResponse();
|
||||
$billResponse->header->l11n = $response->header->l11n;
|
||||
|
||||
$this->apiBillCreate($billRequest, $billResponse, $data);
|
||||
|
|
@ -663,12 +671,12 @@ final class ApiController extends Controller
|
|||
$billId = $billResponse->get('')['response']->getId();
|
||||
|
||||
// Upload and assign document to bill
|
||||
$mediaRequest = new HttpRequest();
|
||||
$mediaRequest = new HttpRequest();
|
||||
$mediaRequest->header->account = $request->header->account;
|
||||
$mediaRequest->header->l11n = $request->header->l11n;
|
||||
$mediaRequest->header->l11n = $request->header->l11n;
|
||||
$mediaRequest->addFile($file);
|
||||
|
||||
$mediaResponse = new HttpResponse();
|
||||
$mediaResponse = new HttpResponse();
|
||||
$mediaResponse->header->l11n = $response->header->l11n;
|
||||
|
||||
$mediaRequest->setData('bill', $billId);
|
||||
|
|
@ -676,7 +684,7 @@ final class ApiController extends Controller
|
|||
$this->apiMediaAddToBill($mediaRequest, $mediaResponse, $data);
|
||||
|
||||
$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)) {
|
||||
throw new \Exception();
|
||||
|
|
@ -685,14 +693,14 @@ final class ApiController extends Controller
|
|||
// @todo: Parse text and analyze text structure
|
||||
|
||||
// Update bill with parsed text
|
||||
$billRequest = new HttpRequest();
|
||||
$billRequest = new HttpRequest();
|
||||
$billRequest->header->account = $request->header->account;
|
||||
$billRequest->header->l11n = $request->header->l11n;
|
||||
$billRequest->header->l11n = $request->header->l11n;
|
||||
|
||||
$billRequest->setData('bill', $billId);
|
||||
$billRequest->setData('supplier', 1);
|
||||
|
||||
$billResponse = new HttpResponse();
|
||||
$billResponse = new HttpResponse();
|
||||
$billResponse->header->l11n = $response->header->l11n;
|
||||
|
||||
$this->apiBillUpdate($billRequest, $billResponse, $data);
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ class BillType
|
|||
*/
|
||||
public function __construct(string $name = '')
|
||||
{
|
||||
$this->media = new NullCollection();
|
||||
$this->template = new NullCollection();
|
||||
$this->setL11n($name);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,5 +35,4 @@ abstract class PermissionCategory extends Enum
|
|||
public const PRIVATE_DASHBOARD = 5;
|
||||
|
||||
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 ORIGINAL_MEDIA_TYPE = '1005100001_2'; // original document (mostly supplier invoice/delivery note)
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user