mirror of
https://github.com/Karaka-Management/oms-Billing.git
synced 2026-01-11 15:18:42 +00:00
started with template fixes
This commit is contained in:
parent
e75a9fb9dc
commit
36fcbadbdd
|
|
@ -23,4 +23,18 @@ return [
|
|||
'pattern' => '',
|
||||
'module' => ApiController::NAME,
|
||||
],
|
||||
[
|
||||
'type' => 'setting',
|
||||
'name' => SettingsEnum::BILLING_DOCUMENT_SPACER_COLOR,
|
||||
'content' => '15613766',
|
||||
'pattern' => '\d',
|
||||
'module' => ApiController::NAME,
|
||||
],
|
||||
[
|
||||
'type' => 'setting',
|
||||
'name' => SettingsEnum::BILLING_DOCUMENT_SPACER_TOLERANCE,
|
||||
'content' => '175',
|
||||
'pattern' => '\d',
|
||||
'module' => ApiController::NAME,
|
||||
],
|
||||
];
|
||||
|
|
|
|||
|
|
@ -337,5 +337,51 @@
|
|||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 1005103001,
|
||||
"pid": "/",
|
||||
"type": 2,
|
||||
"subtype": 1,
|
||||
"name": "TaxCombinations",
|
||||
"uri": "{/base}/finance/tax/combination/list?{?}",
|
||||
"target": "self",
|
||||
"icon": null,
|
||||
"order": 2,
|
||||
"from": "Billing",
|
||||
"permission": { "permission": 2, "category": null, "element": null },
|
||||
"parent": 1008101001,
|
||||
"children": [
|
||||
{
|
||||
"id": 1005103002,
|
||||
"pid": "/finance/tax/combination",
|
||||
"type": 3,
|
||||
"subtype": 1,
|
||||
"name": "List",
|
||||
"uri": "{/base}/finance/tax/combination/list?{?}",
|
||||
"target": "self",
|
||||
"icon": null,
|
||||
"order": 1,
|
||||
"from": "Billing",
|
||||
"permission": { "permission": 2, "category": null, "element": null },
|
||||
"parent": 1005103001,
|
||||
"children": []
|
||||
},
|
||||
{
|
||||
"id": 1005103003,
|
||||
"pid": "/finance/tax/combination",
|
||||
"type": 3,
|
||||
"subtype": 1,
|
||||
"name": "Create",
|
||||
"uri": "{/base}/finance/tax/combination/create?{?}",
|
||||
"target": "self",
|
||||
"icon": null,
|
||||
"order": 5,
|
||||
"from": "Billing",
|
||||
"permission": { "permission": 2, "category": null, "element": null },
|
||||
"parent": 1005103001,
|
||||
"children": []
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -1,4 +1,11 @@
|
|||
[
|
||||
{
|
||||
"type": 1,
|
||||
"item_code": "GENERAL",
|
||||
"account_code": "EU_S",
|
||||
"tax_code": "EU_S0",
|
||||
"account": "8400"
|
||||
},
|
||||
{
|
||||
"type": 1,
|
||||
"item_code": "GENERAL",
|
||||
|
|
@ -83,14 +90,14 @@
|
|||
{
|
||||
"type": 1,
|
||||
"item_code": "GENERAL",
|
||||
"account_code": "DE_0",
|
||||
"account_code": "DE_S",
|
||||
"tax_code": "SBIZ_0",
|
||||
"account": "8195"
|
||||
},
|
||||
{
|
||||
"type": 2,
|
||||
"item_code": "GENERAL",
|
||||
"account_code": "DE_0",
|
||||
"account_code": "DE_S",
|
||||
"tax_code": "SBIZ_0",
|
||||
"account": "3349"
|
||||
},
|
||||
|
|
@ -202,6 +209,12 @@
|
|||
"account_code": "INT",
|
||||
"tax_code": "S0"
|
||||
},
|
||||
{
|
||||
"type": 1,
|
||||
"item_code": "SOFTWARE",
|
||||
"account_code": "EU_S",
|
||||
"tax_code": "EU_S0"
|
||||
},
|
||||
{
|
||||
"type": 1,
|
||||
"item_code": "SOFTWARE",
|
||||
|
|
@ -285,14 +298,14 @@
|
|||
{
|
||||
"type": 1,
|
||||
"item_code": "SOFTWARE",
|
||||
"account_code": "DE_0",
|
||||
"account_code": "DE_S",
|
||||
"tax_code": "SBIZ_0",
|
||||
"account": "8195"
|
||||
},
|
||||
{
|
||||
"type": 2,
|
||||
"item_code": "SOFTWARE",
|
||||
"account_code": "DE_0",
|
||||
"account_code": "DE_S",
|
||||
"tax_code": "SBIZ_0",
|
||||
"account": "3349"
|
||||
},
|
||||
|
|
@ -404,6 +417,12 @@
|
|||
"account_code": "INT",
|
||||
"tax_code": "S0"
|
||||
},
|
||||
{
|
||||
"type": 1,
|
||||
"item_code": "SERVICE",
|
||||
"account_code": "EU_S",
|
||||
"tax_code": "EU_S0"
|
||||
},
|
||||
{
|
||||
"type": 1,
|
||||
"item_code": "SERVICE",
|
||||
|
|
@ -487,14 +506,14 @@
|
|||
{
|
||||
"type": 1,
|
||||
"item_code": "SERVICE",
|
||||
"account_code": "DE_0",
|
||||
"account_code": "DE_S",
|
||||
"tax_code": "SBIZ_0",
|
||||
"account": "8195"
|
||||
},
|
||||
{
|
||||
"type": 2,
|
||||
"item_code": "SERVICE",
|
||||
"account_code": "DE_0",
|
||||
"account_code": "DE_S",
|
||||
"tax_code": "SBIZ_0",
|
||||
"account": "3349"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ return [
|
|||
[
|
||||
'dest' => '\Modules\Billing\Controller\ApiBillController:apiMediaRender',
|
||||
'verb' => RouteVerb::GET,
|
||||
'csrf' => true,
|
||||
'permission' => [
|
||||
'module' => BackendController::NAME,
|
||||
'type' => PermissionType::CREATE,
|
||||
|
|
@ -33,6 +34,7 @@ return [
|
|||
[
|
||||
'dest' => '\Modules\Billing\Controller\ApiBillController:apiPreviewRender',
|
||||
'verb' => RouteVerb::GET,
|
||||
'csrf' => true,
|
||||
'permission' => [
|
||||
'module' => BackendController::NAME,
|
||||
'type' => PermissionType::CREATE,
|
||||
|
|
@ -44,6 +46,7 @@ return [
|
|||
[
|
||||
'dest' => '\Modules\Billing\Controller\ApiPriceController:apiPriceCreate',
|
||||
'verb' => RouteVerb::GET,
|
||||
'csrf' => true,
|
||||
'permission' => [
|
||||
'module' => BackendController::NAME,
|
||||
'type' => PermissionType::CREATE,
|
||||
|
|
@ -55,6 +58,7 @@ return [
|
|||
[
|
||||
'dest' => '\Modules\Billing\Controller\ApiPurchaseController:apiInvoiceParse',
|
||||
'verb' => RouteVerb::SET,
|
||||
'csrf' => true,
|
||||
'permission' => [
|
||||
'module' => BackendController::NAME,
|
||||
'type' => PermissionType::MODIFY,
|
||||
|
|
|
|||
|
|
@ -275,4 +275,27 @@ return [
|
|||
],
|
||||
],
|
||||
],
|
||||
|
||||
'^.*/finance/tax/combination/list(\?.*$|$)' => [
|
||||
[
|
||||
'dest' => '\Modules\Billing\Controller\BackendController:viewTaxCombinationList',
|
||||
'verb' => RouteVerb::GET,
|
||||
'permission' => [
|
||||
'module' => BackendController::NAME,
|
||||
'type' => PermissionType::CREATE,
|
||||
'state' => PermissionCategory::TAX,
|
||||
],
|
||||
],
|
||||
],
|
||||
'^.*/finance/tax/combination/create(\?.*$|$)' => [
|
||||
[
|
||||
'dest' => '\Modules\Billing\Controller\BackendController:viewTaxCombinationCreate',
|
||||
'verb' => RouteVerb::GET,
|
||||
'permission' => [
|
||||
'module' => BackendController::NAME,
|
||||
'type' => PermissionType::CREATE,
|
||||
'state' => PermissionCategory::TAX,
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
|
|
|
|||
|
|
@ -440,7 +440,7 @@ final class ApiBillController extends Controller
|
|||
|
||||
// @todo use bill and shipping address instead of main address if available
|
||||
// https://github.com/Karaka-Management/oms-Billing/issues/45
|
||||
$bill->billTo = $request->getDataString('billto') ?? $account->account->name1;
|
||||
$bill->billTo = $request->getDataString('billto') ?? $account->account->name1 . ' ' . $account->account->name2;
|
||||
$bill->billAddress = $request->getDataString('billaddress') ?? $account->mainAddress->address;
|
||||
$bill->billCity = $request->getDataString('billtocity') ?? $account->mainAddress->city;
|
||||
$bill->billZip = $request->getDataString('billtopostal') ?? $account->mainAddress->postal;
|
||||
|
|
@ -481,7 +481,7 @@ final class ApiBillController extends Controller
|
|||
$settings = $this->app->appSettings->get(null,
|
||||
SettingsEnum::VALID_BILL_LANGUAGES,
|
||||
unit: $this->app->unitId,
|
||||
module: 'Admin'
|
||||
module: self::NAME
|
||||
);
|
||||
|
||||
if (empty($settings)) {
|
||||
|
|
@ -489,7 +489,7 @@ final class ApiBillController extends Controller
|
|||
$settings = $this->app->appSettings->get(null,
|
||||
SettingsEnum::VALID_BILL_LANGUAGES,
|
||||
unit: null,
|
||||
module: 'Admin'
|
||||
module: self::NAME
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -111,7 +111,39 @@ final class ApiPurchaseController extends Controller
|
|||
$bills = [];
|
||||
|
||||
$files = \array_merge($request->files, $request->getDataJson('media'));
|
||||
|
||||
/** @var \Model\Setting[] $settings */
|
||||
$settings = $this->app->appSettings->get(null,
|
||||
[SettingsEnum::BILLING_DOCUMENT_SPACER_COLOR, SettingsEnum::BILLING_DOCUMENT_SPACER_TOLERANCE],
|
||||
unit: $this->app->unitId,
|
||||
module: self::NAME
|
||||
);
|
||||
|
||||
if (empty($settings)) {
|
||||
/** @var \Model\Setting[] $settings */
|
||||
$settings = $this->app->appSettings->get(null,
|
||||
[SettingsEnum::BILLING_DOCUMENT_SPACER_COLOR, SettingsEnum::BILLING_DOCUMENT_SPACER_TOLERANCE],
|
||||
unit: null,
|
||||
module: self::NAME
|
||||
);
|
||||
}
|
||||
|
||||
foreach ($files as $file) {
|
||||
// 1. convert to image pdftoppm
|
||||
// 2. search for color pages by using averageColorRandom (tolerance < 175 = color match)
|
||||
// 3. split pdf document if necessary
|
||||
// sudo apt-get --yes install pdftk
|
||||
// pdftk foo-bar.pdf cat 1-12 output foo.pdf
|
||||
// pdftk foo-bar.pdf cat 13-end output bar.pdf
|
||||
// alternatively, pdfseparate -f 1 -l 5 input.pdf output-page%d.pdf
|
||||
// alternatively, pdfjam <input-file> <page-ranges> -o <output-file>
|
||||
// alternatively, pdfly cat in.pdf 2:4 -o out.pdf
|
||||
// 4. add to documents array
|
||||
}
|
||||
|
||||
$documents = $files;
|
||||
|
||||
foreach ($documents as $file) {
|
||||
// Create default bill
|
||||
$billRequest = new HttpRequest();
|
||||
$billRequest->header->account = $request->header->account;
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ use Modules\Billing\Models\SettingsEnum;
|
|||
use Modules\Billing\Models\ShippingTermL11nMapper;
|
||||
use Modules\Billing\Models\ShippingTermMapper;
|
||||
use Modules\Billing\Models\StockBillMapper;
|
||||
use Modules\Billing\Models\Tax\TaxCombinationMapper;
|
||||
use phpOMS\Account\PermissionType;
|
||||
use phpOMS\Contract\RenderableInterface;
|
||||
use phpOMS\DataStorage\Database\Query\OrderType;
|
||||
|
|
@ -725,4 +726,57 @@ final class BackendController extends Controller
|
|||
|
||||
return $view;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method which shows the sales dashboard
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param array $data Generic data
|
||||
*
|
||||
* @return RenderableInterface Response can be rendered
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function viewTaxCombinationList(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface
|
||||
{
|
||||
$view = new View($this->app->l11nManager, $request, $response);
|
||||
$view->setTemplate('/Modules/Billing/Theme/Backend/finance-taxcombination-list');
|
||||
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1005103001, $request, $response);
|
||||
|
||||
$view->data['taxcombination'] = TaxCombinationMapper::getAll()
|
||||
->with('clientCode')
|
||||
->with('supplierCode')
|
||||
->with('itemCode')
|
||||
->with('taxCode')
|
||||
->executeGetArray();
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method which shows the sales dashboard
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param array $data Generic data
|
||||
*
|
||||
* @return RenderableInterface Response can be rendered
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function viewTaxCombinationView(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface
|
||||
{
|
||||
$view = new View($this->app->l11nManager, $request, $response);
|
||||
$view->setTemplate('/Modules/Billing/Theme/Backend/finance-taxcombination-view');
|
||||
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1005103001, $request, $response);
|
||||
|
||||
$view->data['taxcombination'] = TaxCombinationMapper::getAll()
|
||||
->with('clientCode')
|
||||
->with('supplierCode')
|
||||
->with('itemCode')
|
||||
->executeGetArray();
|
||||
|
||||
return $view;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ declare(strict_types=1);
|
|||
namespace Modules\Billing\Models;
|
||||
|
||||
use Modules\Billing\Models\Tax\TaxCombination;
|
||||
use Modules\Finance\Models\TaxCode;
|
||||
use Modules\ItemManagement\Models\Container;
|
||||
use Modules\ItemManagement\Models\Item;
|
||||
use Modules\ItemManagement\Models\NullItem;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ use Modules\Admin\Models\AccountMapper;
|
|||
use Modules\Billing\Models\Attribute\BillAttributeMapper;
|
||||
use Modules\ClientManagement\Models\ClientMapper;
|
||||
use Modules\Editor\Models\EditorDocMapper;
|
||||
use Modules\Media\Models\CollectionMapper;
|
||||
use Modules\Media\Models\MediaMapper;
|
||||
use Modules\SupplierManagement\Models\SupplierMapper;
|
||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||
|
|
|
|||
|
|
@ -45,4 +45,6 @@ abstract class PermissionCategory extends Enum
|
|||
public const SHIPPING_TERM = 10;
|
||||
|
||||
public const BILL_LOG = 101;
|
||||
|
||||
public const TAX = 201;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ namespace Modules\Billing\Models;
|
|||
|
||||
use Modules\ClientManagement\Models\ClientMapper;
|
||||
use phpOMS\DataStorage\Database\Query\Builder;
|
||||
use phpOMS\Localization\Defaults\CountryMapper;
|
||||
use phpOMS\DataStorage\Database\Query\OrderType;
|
||||
use phpOMS\Stdlib\Base\FloatInt;
|
||||
|
||||
/**
|
||||
|
|
@ -257,13 +257,16 @@ final class SalesBillMapper extends BillMapper
|
|||
{
|
||||
$query = new Builder(self::$db);
|
||||
$query->selectAs(ClientMapper::TABLE . '.clientmgmt_client_id', 'client')
|
||||
->selectAs('SUM(' . BillElementMapper::TABLE . '.billing_bill_element_total_netsalesprice)', 'net_sales')
|
||||
->selectAs('SUM(' . BillElementMapper::TABLE . '.billing_bill_element_total_netsalesprice * billing_type_transfer_sign)', 'net_sales')
|
||||
->from(ClientMapper::TABLE)
|
||||
->leftJoin(self::TABLE)
|
||||
->on(ClientMapper::TABLE . '.clientmgmt_client_id', '=', self::TABLE . '.billing_bill_client')
|
||||
->leftJoin(BillElementMapper::TABLE)
|
||||
->on(self::TABLE . '.billing_bill_id', '=', BillElementMapper::TABLE . '.billing_bill_element_bill')
|
||||
->leftJoin(BillTypeMapper::TABLE)
|
||||
->on(self::TABLE . '.billing_bill_type', '=', BillTypeMapper::TABLE . '.billing_type_id')
|
||||
->where(BillElementMapper::TABLE . '.billing_bill_element_item', '=', $id)
|
||||
->andWhere(BillTypeMapper::TABLE . '.billing_type_accounting', '=', true)
|
||||
->andWhere(self::TABLE . '.billing_bill_performance_date', '>=', $start)
|
||||
->andWhere(self::TABLE . '.billing_bill_performance_date', '<=', $end)
|
||||
->orderBy('net_sales', 'DESC')
|
||||
|
|
@ -294,28 +297,27 @@ final class SalesBillMapper extends BillMapper
|
|||
* Placeholder
|
||||
* @todo Implement
|
||||
*/
|
||||
public static function getItemBills(int $id, \DateTime $start, \DateTime $end) : array
|
||||
public static function getItemBills(int $id, \DateTime $start, \DateTime $end, int $limit = 10000) : array
|
||||
{
|
||||
$query = self::reader()
|
||||
->with('type')
|
||||
->with('type/l11n')
|
||||
->where('type/l11n/language', 'en')
|
||||
->where('createdAt', $start, '>=')
|
||||
->where('createdAt', $end, '<=')
|
||||
->sort('id', OrderType::DESC)
|
||||
->limit($limit)
|
||||
->getQuery();
|
||||
|
||||
$query->leftJoin(BillElementMapper::TABLE, BillElementMapper::TABLE . '_d1')
|
||||
->on(self::TABLE . '_d1.billing_bill_id', '=', BillElementMapper::TABLE . '_d1.billing_bill_element_bill')
|
||||
->where(BillElementMapper::TABLE . '_d1.billing_bill_element_item', '=', $id);
|
||||
|
||||
/** @phpstan-ignore-next-line */
|
||||
if (!empty(self::CREATED_AT)) {
|
||||
$query->orderBy(self::TABLE . '_d1.' . self::COLUMNS[self::CREATED_AT]['name'], 'DESC');
|
||||
} else {
|
||||
$query->orderBy(self::TABLE . '_d1.' . self::COLUMNS[self::PRIMARYFIELD]['name'], 'DESC');
|
||||
}
|
||||
|
||||
return self::getAll()
|
||||
->with('type')
|
||||
->with('type/l11n')
|
||||
->sort('id', OrderType::DESC)
|
||||
->limit($limit)
|
||||
->execute($query);
|
||||
}
|
||||
|
||||
|
|
@ -353,26 +355,43 @@ final class SalesBillMapper extends BillMapper
|
|||
* Placeholder
|
||||
* @todo Implement
|
||||
*/
|
||||
public static function getItemCountrySales(int $id, \DateTime $start, \DateTime $end, int $limit = 10) : array
|
||||
public static function getItemCountrySales(int $item, \DateTime $start, \DateTime $end, int $limit = 10) : array
|
||||
{
|
||||
$query = new Builder(self::$db);
|
||||
$result = $query->select(CountryMapper::TABLE . '.country_code2')
|
||||
->selectAs('SUM(billing_bill_element_total_netsalesprice)', 'net_sales')
|
||||
->from(self::TABLE)
|
||||
->leftJoin(BillElementMapper::TABLE)
|
||||
->on(self::TABLE . '.billing_bill_id', '=', BillElementMapper::TABLE . '.billing_bill_element_bill')
|
||||
->leftJoin(CountryMapper::TABLE)
|
||||
->on(self::TABLE . '.billing_bill_billCountry', '=', CountryMapper::TABLE . '.country_code2')
|
||||
->where(BillElementMapper::TABLE . '.billing_bill_element_item', '=', $id)
|
||||
->andWhere(self::TABLE . '.billing_bill_performance_date', '>=', $start)
|
||||
->andWhere(self::TABLE . '.billing_bill_performance_date', '<=', $end)
|
||||
->groupBy(CountryMapper::TABLE . '.country_code2')
|
||||
->orderBy('net_sales', 'DESC')
|
||||
->limit($limit)
|
||||
->execute()
|
||||
?->fetchAll(\PDO::FETCH_KEY_PAIR);
|
||||
$sql = <<<SQL
|
||||
SELECT
|
||||
billing_bill_billCountry as country,
|
||||
SUM(billing_bill_element_total_netlistprice * billing_type_transfer_sign) as net_sales
|
||||
FROM billing_bill
|
||||
LEFT JOIN billing_type
|
||||
ON billing_bill_type = billing_type_id
|
||||
LEFT JOIN billing_bill_element
|
||||
ON billing_bill_id = billing_bill_element_bill
|
||||
WHERE
|
||||
billing_bill_element_item = {$item}
|
||||
AND billing_type_accounting = 1
|
||||
AND billing_bill_performance_date >= '{$start->format('Y-m-d H:i:s')}'
|
||||
AND billing_bill_performance_date <= '{$end->format('Y-m-d H:i:s')}'
|
||||
GROUP BY
|
||||
billing_bill_billCountry
|
||||
LIMIT {$limit};
|
||||
SQL;
|
||||
|
||||
return $result ?? [];
|
||||
$query = new Builder(self::$db);
|
||||
$results = $query->raw($sql)->execute()?->fetchAll(\PDO::FETCH_ASSOC) ?? [];
|
||||
|
||||
if ($results === false) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$hasData = false;
|
||||
foreach ($results as $result) {
|
||||
if ($result !== "0" || $result > 0) {
|
||||
$hasData = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $hasData ? $results : [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -390,14 +409,16 @@ final class SalesBillMapper extends BillMapper
|
|||
$sql = <<<SQL
|
||||
SELECT
|
||||
billing_bill_element_item,
|
||||
SUM(billing_bill_element_total_netsalesprice) as net_sales,
|
||||
SUM(billing_bill_element_total_netpurchaseprice) as net_costs,
|
||||
SUM(billing_bill_element_total_netsalesprice * billing_type_transfer_sign) as net_sales,
|
||||
SUM(billing_bill_element_total_netpurchaseprice * billing_type_transfer_sign) as net_costs,
|
||||
YEAR(billing_bill_performance_date) as year,
|
||||
MONTH(billing_bill_performance_date) as month
|
||||
FROM billing_bill_element
|
||||
JOIN billing_bill ON billing_bill_element.billing_bill_element_bill = billing_bill.billing_bill_id
|
||||
LEFT JOIN billing_type ON billing_bill_type = billing_type_id
|
||||
WHERE
|
||||
billing_bill_element_item IN ({$item})
|
||||
AND billing_type_accounting = 1
|
||||
AND billing_bill_performance_date >= '{$start->format('Y-m-d H:i:s')}'
|
||||
AND billing_bill_performance_date <= '{$end->format('Y-m-d H:i:s')}'
|
||||
GROUP BY billing_bill_element_item, year, month
|
||||
|
|
@ -405,9 +426,23 @@ final class SalesBillMapper extends BillMapper
|
|||
SQL;
|
||||
|
||||
$query = new Builder(self::$db);
|
||||
$result = $query->raw($sql)->execute()?->fetchAll(\PDO::FETCH_ASSOC) ?? [];
|
||||
$results = $query->raw($sql)->execute()?->fetchAll(\PDO::FETCH_ASSOC) ?? [];
|
||||
|
||||
return $result ?? [];
|
||||
if ($results === false) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$hasData = false;
|
||||
foreach ($results as $result) {
|
||||
if ($result['net_sales'] !== "0" || $result['net_sales'] > 0
|
||||
|| $result['net_costs'] !== "0" || $result['net_costs'] > 0
|
||||
) {
|
||||
$hasData = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $hasData ? $results : [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -452,13 +487,15 @@ final class SalesBillMapper extends BillMapper
|
|||
{
|
||||
$sql = <<<SQL
|
||||
SELECT
|
||||
SUM(billing_bill_netsales) as net_sales,
|
||||
SUM(billing_bill_netcosts) as net_costs,
|
||||
SUM(billing_bill_netsales * billing_type_transfer_sign) as net_sales,
|
||||
SUM(billing_bill_netcosts * billing_type_transfer_sign) as net_costs,
|
||||
YEAR(billing_bill_performance_date) as year,
|
||||
MONTH(billing_bill_performance_date) as month
|
||||
FROM billing_bill
|
||||
LEFT JOIN billing_type ON billing_bill_type = billing_type_id
|
||||
WHERE
|
||||
billing_bill_client = {$client}
|
||||
AND billing_type_accounting = 1
|
||||
AND billing_bill_performance_date >= '{$start->format('Y-m-d H:i:s')}'
|
||||
AND billing_bill_performance_date <= '{$end->format('Y-m-d H:i:s')}'
|
||||
GROUP BY year, month
|
||||
|
|
@ -493,6 +530,55 @@ final class SalesBillMapper extends BillMapper
|
|||
return new FloatInt((int) ($result[0]['net_sales'] ?? 0));
|
||||
}
|
||||
|
||||
/**
|
||||
* Placeholder
|
||||
* @todo Implement
|
||||
*/
|
||||
public static function getClientAttributeNetSales(
|
||||
int $client,
|
||||
string $attribute,
|
||||
string $language,
|
||||
\DateTime $start,
|
||||
\DateTime $end
|
||||
) : array
|
||||
{
|
||||
$sql = <<<SQL
|
||||
SELECT
|
||||
itemmgmt_attr_value_l11n_title as title,
|
||||
SUM(billing_bill_element_total_netlistprice * billing_type_transfer_sign) as net_sales
|
||||
FROM billing_bill
|
||||
LEFT JOIN billing_type
|
||||
ON billing_bill_type = billing_type_id
|
||||
LEFT JOIN billing_bill_element
|
||||
ON billing_bill_id = billing_bill_element_bill
|
||||
LEFT JOIN itemmgmt_item
|
||||
ON itemmgmt_item_id = billing_bill_element_item
|
||||
LEFT JOIN itemmgmt_item_attr
|
||||
ON itemmgmt_item_id = itemmgmt_item_attr_item
|
||||
LEFT JOIN itemmgmt_attr_type
|
||||
ON itemmgmt_item_attr_type = itemmgmt_attr_type_id
|
||||
LEFT JOIN itemmgmt_attr_type_l11n
|
||||
ON itemmgmt_attr_type_id = itemmgmt_attr_type_l11n_type AND itemmgmt_attr_type_l11n_lang = '{$language}'
|
||||
LEFT JOIN itemmgmt_attr_value
|
||||
ON itemmgmt_item_attr_value = itemmgmt_attr_value_id
|
||||
LEFT JOIN itemmgmt_attr_value_l11n
|
||||
ON itemmgmt_attr_value_id = itemmgmt_attr_value_l11n_value AND itemmgmt_attr_value_l11n_lang = '{$language}'
|
||||
WHERE
|
||||
billing_bill_client = {$client}
|
||||
AND billing_type_accounting = 1
|
||||
AND billing_bill_performance_date >= '{$start->format('Y-m-d H:i:s')}'
|
||||
AND billing_bill_performance_date <= '{$end->format('Y-m-d H:i:s')}'
|
||||
AND itemmgmt_attr_type_name = '{$attribute}'
|
||||
GROUP BY
|
||||
itemmgmt_attr_value_l11n_title;
|
||||
SQL;
|
||||
|
||||
$query = new Builder(self::$db);
|
||||
$result = $query->raw($sql)->execute()?->fetchAll(\PDO::FETCH_ASSOC) ?? [];
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Placeholder
|
||||
* @todo Implement
|
||||
|
|
|
|||
|
|
@ -37,4 +37,7 @@ abstract class SettingsEnum extends Enum
|
|||
public const BILLING_CUSTOMER_EMAIL_TEMPLATE = '1005100004'; // Email template for customer billing
|
||||
|
||||
public const BILLING_SUPPLIER_EMAIL_TEMPLATE = '1005100005'; // Email template for supplier billing
|
||||
|
||||
public const BILLING_DOCUMENT_SPACER_COLOR = '1005100101';
|
||||
public const BILLING_DOCUMENT_SPACER_TOLERANCE = '1005100102';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -81,6 +81,9 @@ return ['Billing' => [
|
|||
'Upload' => 'Hochladen',
|
||||
'Zip' => 'Zip',
|
||||
'Files' => 'Files',
|
||||
'TaxCode' => 'Steuerkz.',
|
||||
'PL' => 'GuV',
|
||||
'TaxCombinations' => 'Steuerkomb.',
|
||||
'PaymentTerms' => 'Zahlungsbedingungen',
|
||||
'ShippingTerms' => 'Lieferbedingungen',
|
||||
'PaymentTerm' => 'Zahlungsbedingung',
|
||||
|
|
|
|||
|
|
@ -81,6 +81,9 @@ return ['Billing' => [
|
|||
'Upload' => 'Upload',
|
||||
'Zip' => 'Zip',
|
||||
'Files' => 'Files',
|
||||
'TaxCode' => 'Tax Code',
|
||||
'PL' => 'PL',
|
||||
'TaxCombinations' => 'Tax Combinations',
|
||||
'PaymentTerms' => 'Payment Terms',
|
||||
'ShippingTerms' => 'Shipping Terms',
|
||||
'PaymentTerm' => 'Payment Term',
|
||||
|
|
|
|||
72
Theme/Backend/finance-taxcombination-list.tpl.php
Normal file
72
Theme/Backend/finance-taxcombination-list.tpl.php
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
<?php
|
||||
/**
|
||||
* Jingga
|
||||
*
|
||||
* PHP Version 8.2
|
||||
*
|
||||
* @package Modules\Accounting
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use phpOMS\Uri\UriFactory;
|
||||
|
||||
/**
|
||||
* @var \phpOMS\Views\View $this
|
||||
* @var \Modules\Tag\Models\CostCenter[] $taxcombination
|
||||
*/
|
||||
$taxcombination = $this->data['taxcombination'];
|
||||
|
||||
$previous = empty($taxcombination) ? '{/base}/finance/tax/combination/list' : '{/base}/finance/tax/combination/list?{?}&id=' . \reset($taxcombination)->id . '&ptype=p';
|
||||
$next = empty($taxcombination) ? '{/base}/finance/tax/combination/list' : '{/base}/finance/tax/combination/list?{?}&id=' . \end($taxcombination)->id . '&ptype=n';
|
||||
|
||||
echo $this->data['nav']->render(); ?>
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<div class="portlet">
|
||||
<div class="portlet-head"><?= $this->getHtml('TaxCombinations'); ?><i class="g-icon download btn end-xs">download</i></div>
|
||||
<table class="default sticky">
|
||||
<thead>
|
||||
<tr>
|
||||
<td><?= $this->getHtml('ID', '0', '0'); ?>
|
||||
<td><?= $this->getHtml('Client'); ?>
|
||||
<td><?= $this->getHtml('Supplier'); ?>
|
||||
<td class="wf-100"><?= $this->getHtml('Item'); ?>
|
||||
<td><?= $this->getHtml('TaxCode'); ?>
|
||||
<td><?= $this->getHtml('Tax'); ?>
|
||||
<td><?= $this->getHtml('PL'); ?>
|
||||
<tbody>
|
||||
<?php $count = 0;
|
||||
foreach ($taxcombination as $key => $value) : ++$count;
|
||||
$url = UriFactory::build('{/base}/finance/tax/combination/view?{?}&id=' . $value->id); ?>
|
||||
<tr tabindex="0" data-href="<?= $url; ?>">
|
||||
<td><a href="<?= $url; ?>">
|
||||
<?= $value->id; ?></a>
|
||||
<td><a href="<?= $url; ?>">
|
||||
<?= $this->printHtml($value->clientCode->getValue()); ?></a>
|
||||
<td><a href="<?= $url; ?>">
|
||||
<?= $this->printHtml($value->supplierCode->getValue()); ?></a>
|
||||
<td><a href="<?= $url; ?>">
|
||||
<?= $this->printHtml($value->itemCode->getValue()); ?></a>
|
||||
<td><a href="<?= $url; ?>">
|
||||
<?= $this->printHtml($value->taxCode->abbr); ?></a>
|
||||
<td><a href="<?= $url; ?>">
|
||||
<?= $value->taxCode->percentageInvoice / 10000; ?> %</a>
|
||||
<td><a href="<?= $url; ?>">
|
||||
<?= $this->printHtml($value->account); ?></a>
|
||||
<?php endforeach; ?>
|
||||
<?php if ($count === 0) : ?>
|
||||
<tr><td colspan="7" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?>
|
||||
<?php endif; ?>
|
||||
</table>
|
||||
<!--
|
||||
<div class="portlet-foot">
|
||||
<a tabindex="0" class="button" href="<?= UriFactory::build($previous); ?>"><?= $this->getHtml('Previous', '0', '0'); ?></a>
|
||||
<a tabindex="0" class="button" href="<?= UriFactory::build($next); ?>"><?= $this->getHtml('Next', '0', '0'); ?></a>
|
||||
</div>
|
||||
-->
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -22,7 +22,7 @@ echo $this->data['nav']->render(); ?>
|
|||
<div class="row">
|
||||
<div class="col-xs-12 col-md-6">
|
||||
<div class="portlet">
|
||||
<form id="paymentForm" method="POST" action="<?= UriFactory::build('{/api}bill/payment'); ?>"
|
||||
<form id="paymentForm" method="POST" action="<?= UriFactory::build('{/api}bill/payment?csrf={$CSRF}'); ?>"
|
||||
data-ui-container="#paymentTable tbody"
|
||||
data-add-form="paymentForm"
|
||||
data-add-tpl="#paymentTable tbody .oms-add-tpl-payment">
|
||||
|
|
@ -30,7 +30,7 @@ echo $this->data['nav']->render(); ?>
|
|||
<div class="portlet-body">
|
||||
<div class="form-group">
|
||||
<label for="iName"><?= $this->getHtml('Name'); ?></label>
|
||||
<input type="text" name="code" id="iName" placeholder="" value="<?= $this->printHtml($type->title); ?>">
|
||||
<input type="text" name="code" id="iName" value="<?= $this->printHtml($type->title); ?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
@ -47,7 +47,7 @@ echo $this->data['nav']->render(); ?>
|
|||
<?= $this->data['l11nView']->render(
|
||||
$this->data['l11nValues'],
|
||||
[],
|
||||
'{/api}bill/payment/l11n'
|
||||
'{/api}bill/payment/l11n?csrf={$CSRF}'
|
||||
);
|
||||
?>
|
||||
</div>
|
||||
|
|
@ -438,7 +438,7 @@ echo $this->data['nav']->render(); ?>
|
|||
<div>
|
||||
<div class="col-xs-12 col-sm-3 box">
|
||||
<form id="iInvoiceRecognition"
|
||||
action="<?= UriFactory::build('{/api}bill/parse?id=' . $bill->id . '&async=0'); ?>"
|
||||
action="<?= UriFactory::build('{/api}bill/parse?id=' . $bill->id . '&async=0&csrf={$CSRF}'); ?>"
|
||||
method="post"
|
||||
data-redirect="<?= UriFactory::build('{%}'); ?>">
|
||||
<input type="submit" value="<?= $this->getHtml('Parse'); ?>">
|
||||
|
|
@ -453,7 +453,7 @@ echo $this->data['nav']->render(); ?>
|
|||
<div class="portlet-body col-simple">
|
||||
<iframe id="iBillArchive"
|
||||
class="col-simple"
|
||||
src="<?= UriFactory::build('{/api}media/export') . '?id=' . $archive->id; ?>"
|
||||
src="<?= UriFactory::build('{/api}media/export?csrf={$CSRF}') . '?id=' . $archive->id; ?>"
|
||||
loading="lazy" allowfullscreen></iframe>
|
||||
</div>
|
||||
</section>
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ echo $this->data['nav']->render(); ?>
|
|||
<div class="row">
|
||||
<div class="col-xs-12 col-md-6">
|
||||
<div class="portlet">
|
||||
<form id="shippingForm" method="POST" action="<?= UriFactory::build('{/api}bill/shipping'); ?>"
|
||||
<form id="shippingForm" method="POST" action="<?= UriFactory::build('{/api}bill/shipping?csrf={$CSRF}'); ?>"
|
||||
data-ui-container="#shippingTable tbody"
|
||||
data-add-form="shippingForm"
|
||||
data-add-tpl="#shippingTable tbody .oms-add-tpl-shipping">
|
||||
|
|
@ -30,7 +30,7 @@ echo $this->data['nav']->render(); ?>
|
|||
<div class="portlet-body">
|
||||
<div class="form-group">
|
||||
<label for="iName"><?= $this->getHtml('Name'); ?></label>
|
||||
<input type="text" name="code" id="iName" placeholder="" value="<?= $this->printHtml($type->title); ?>">
|
||||
<input type="text" name="code" id="iName" value="<?= $this->printHtml($type->title); ?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
@ -47,7 +47,7 @@ echo $this->data['nav']->render(); ?>
|
|||
<?= $this->data['l11nView']->render(
|
||||
$this->data['l11nValues'],
|
||||
[],
|
||||
'{/api}bill/shipping/l11n'
|
||||
'{/api}bill/shipping/l11n?csrf={$CSRF}'
|
||||
);
|
||||
?>
|
||||
</div>
|
||||
Loading…
Reference in New Issue
Block a user