fix billing process

This commit is contained in:
Dennis Eichhorn 2023-04-08 04:36:25 +02:00
parent dd6f194beb
commit d6b13086b3
5 changed files with 58 additions and 38 deletions

View File

@ -8,9 +8,11 @@ assignees: ''
--- ---
# Bug Description # Bug Description
A clear and concise description of what the bug is. A clear and concise description of what the bug is.
# How to Reproduce # How to Reproduce
Steps to reproduce the behavior: Steps to reproduce the behavior:
1. Go to '...' 1. Go to '...'
@ -19,16 +21,20 @@ Steps to reproduce the behavior:
4. See error 4. See error
# Expected Behavior # Expected Behavior
A clear and concise description of what you expected to happen. A clear and concise description of what you expected to happen.
# Screenshots # Screenshots
If applicable, add screenshots to help explain your problem. If applicable, add screenshots to help explain your problem.
# System Information # System Information
- System: [e.g. PC or iPhone11, ...]
- OS: [e.g. iOS] - System: [e.g. PC or iPhone11, ...]
- Browser [e.g. chrome, safari] - OS: [e.g. iOS]
- KarakaVersion [e.g. 22] - Browser [e.g. chrome, safari]
- KarakaVersion [e.g. 22]
# Additional Information # Additional Information
Add any other context about the problem here. Add any other context about the problem here.

View File

@ -65,6 +65,21 @@ use phpOMS\Utils\StringUtils;
*/ */
final class ApiController extends Controller final class ApiController extends Controller
{ {
public function findClientForAccount(int $account, int $unit = null) : ?Client
{
$clientMapper = ClientMapper::get()
->where('account', $account);
if (!empty($unit)) {
$clientMapper->where('unit', $unit);
}
/** @var \Modules\ClientManagement\Models\Client $client */
$client = $clientMapper->execute();
return $client instanceof NullAccount ? null : $client;
}
/** /**
* Api method to create news article * Api method to create news article
* *
@ -224,8 +239,8 @@ final class ApiController extends Controller
private function validateClientCreate(RequestAbstract $request) : array private function validateClientCreate(RequestAbstract $request) : array
{ {
$val = []; $val = [];
if (($val['number'] = empty($request->getData('number'))) if (($val['number'] = !$request->hasData('number'))
|| ($val['account'] = empty($request->getData('name1')) && empty($request->getData('account'))) || ($val['account'] = !$request->hasData('name1') && !$request->hasData('account'))
) { ) {
return $val; return $val;
} }
@ -297,7 +312,7 @@ final class ApiController extends Controller
private function validateMainAddressUpdate(RequestAbstract $request) : array private function validateMainAddressUpdate(RequestAbstract $request) : array
{ {
$val = []; $val = [];
if (($val['client'] = (empty($request->getData('client') && empty($request->getData('account'))))) if (($val['client'] = (!$request->hasData('client') && !$request->hasData('account')))
) { ) {
return $val; return $val;
} }
@ -308,9 +323,8 @@ final class ApiController extends Controller
/** /**
* Method to update an account from a request * Method to update an account from a request
* *
* @param RequestAbstract $request Request * @param RequestAbstract $request Request
* @param Address $address Address * @param Address $address Address
* @param bool $allowPassword Allow to change password
* *
* @return Address * @return Address
* *
@ -321,8 +335,8 @@ final class ApiController extends Controller
$address->address = $request->getDataString('address') ?? $address->address; $address->address = $request->getDataString('address') ?? $address->address;
$address->postal = $request->getDataString('postal') ?? $address->postal; $address->postal = $request->getDataString('postal') ?? $address->postal;
$address->city = $request->getDataString('city') ?? $address->city; $address->city = $request->getDataString('city') ?? $address->city;
$address->state = $request->getDataString('state') ?? $address->state;
$address->setCountry($request->getDataString('country') ?? $address->getCountry()); $address->setCountry($request->getDataString('country') ?? $address->getCountry());
$address->state = $request->getDataString('state') ?? $address->state;
return $address; return $address;
} }
@ -388,9 +402,9 @@ final class ApiController extends Controller
private function validateClientL11nCreate(RequestAbstract $request) : array private function validateClientL11nCreate(RequestAbstract $request) : array
{ {
$val = []; $val = [];
if (($val['client'] = empty($request->getData('client'))) if (($val['client'] = !$request->hasData('client'))
|| ($val['type'] = empty($request->getData('type'))) || ($val['type'] = !$request->hasData('type'))
|| ($val['description'] = empty($request->getData('description'))) || ($val['description'] = !$request->hasData('description'))
) { ) {
return $val; return $val;
} }
@ -455,7 +469,7 @@ final class ApiController extends Controller
private function validateClientL11nTypeCreate(RequestAbstract $request) : array private function validateClientL11nTypeCreate(RequestAbstract $request) : array
{ {
$val = []; $val = [];
if (($val['title'] = empty($request->getData('title')))) { if (($val['title'] = !$request->hasData('title'))) {
return $val; return $val;
} }
@ -530,9 +544,9 @@ final class ApiController extends Controller
private function validateClientAttributeCreate(RequestAbstract $request) : array private function validateClientAttributeCreate(RequestAbstract $request) : array
{ {
$val = []; $val = [];
if (($val['type'] = empty($request->getData('type'))) if (($val['type'] = !$request->hasData('type'))
|| ($val['value'] = (empty($request->getData('value')) && empty($request->getData('custom')))) || ($val['value'] = (!$request->hasData('value') && !$request->hasData('custom')))
|| ($val['client'] = empty($request->getData('client'))) || ($val['client'] = !$request->hasData('client'))
) { ) {
return $val; return $val;
} }
@ -600,8 +614,8 @@ final class ApiController extends Controller
private function validateClientAttributeTypeL11nCreate(RequestAbstract $request) : array private function validateClientAttributeTypeL11nCreate(RequestAbstract $request) : array
{ {
$val = []; $val = [];
if (($val['title'] = empty($request->getData('title'))) if (($val['title'] = !$request->hasData('title'))
|| ($val['type'] = empty($request->getData('type'))) || ($val['type'] = !$request->hasData('type'))
) { ) {
return $val; return $val;
} }
@ -671,8 +685,8 @@ final class ApiController extends Controller
private function validateClientAttributeTypeCreate(RequestAbstract $request) : array private function validateClientAttributeTypeCreate(RequestAbstract $request) : array
{ {
$val = []; $val = [];
if (($val['title'] = empty($request->getData('title'))) if (($val['title'] = !$request->hasData('title'))
|| ($val['name'] = empty($request->getData('name'))) || ($val['name'] = !$request->hasData('name'))
) { ) {
return $val; return $val;
} }
@ -756,8 +770,8 @@ final class ApiController extends Controller
private function validateClientAttributeValueCreate(RequestAbstract $request) : array private function validateClientAttributeValueCreate(RequestAbstract $request) : array
{ {
$val = []; $val = [];
if (($val['type'] = empty($request->getData('type'))) if (($val['type'] = !$request->hasData('type'))
|| ($val['value'] = empty($request->getData('value'))) || ($val['value'] = !$request->hasData('value'))
) { ) {
return $val; return $val;
} }
@ -825,8 +839,8 @@ final class ApiController extends Controller
private function validateClientAttributeValueL11nCreate(RequestAbstract $request) : array private function validateClientAttributeValueL11nCreate(RequestAbstract $request) : array
{ {
$val = []; $val = [];
if (($val['title'] = empty($request->getData('title'))) if (($val['title'] = !$request->hasData('title'))
|| ($val['value'] = empty($request->getData('value'))) || ($val['value'] = !$request->hasData('value'))
) { ) {
return $val; return $val;
} }

View File

@ -300,7 +300,7 @@ class Client
{ {
foreach ($this->attributes as $attribute) { foreach ($this->attributes as $attribute) {
if ($attribute->type->name === $attrName) { if ($attribute->type->name === $attrName) {
return $attribute->value; return $attribute;
} }
} }

View File

@ -207,7 +207,7 @@ echo $this->getData('nav')->render();
?> ?>
<tr> <tr>
<td><?= $values['month'] . '/' . \substr((string) $values['year'], -2); ?> <td><?= $values['month'] . '/' . \substr((string) $values['year'], -2); ?>
<td><?= (new Money(((int) $values['net_sales']) / 1000))->getCurrency(); ?> <td><?= (new Money(((int) $values['net_sales']) / 10000))->getCurrency(); ?>
<td><?= ((int) $values['customers']); ?> <td><?= ((int) $values['customers']); ?>
<?php endforeach; ?> <?php endforeach; ?>
<tr> <tr>
@ -327,7 +327,7 @@ echo $this->getData('nav')->render();
?> ?>
<tr> <tr>
<td><?= (string) $values['year']; ?> <td><?= (string) $values['year']; ?>
<td><?= (new Money(((int) $values['net_sales']) / 1000))->getCurrency(); ?> <td><?= (new Money(((int) $values['net_sales']) / 10000))->getCurrency(); ?>
<td><?= ((int) $values['customers']); ?> <td><?= ((int) $values['customers']); ?>
<?php endforeach; ?> <?php endforeach; ?>
</table> </table>
@ -1329,7 +1329,7 @@ echo $this->getData('nav')->render();
?> ?>
<tr> <tr>
<td><?= $values['month'] . '/' . \substr((string) $values['year'], -2); ?> <td><?= $values['month'] . '/' . \substr((string) $values['year'], -2); ?>
<td><?= (new Money(((int) $values['net_sales']) / 1000))->getCurrency(); ?> <td><?= (new Money(((int) $values['net_sales']) / 10000))->getCurrency(); ?>
<td><?= ((int) $values['customers']); ?> <td><?= ((int) $values['customers']); ?>
<?php endforeach; ?> <?php endforeach; ?>
<tr> <tr>
@ -1449,7 +1449,7 @@ echo $this->getData('nav')->render();
?> ?>
<tr> <tr>
<td><?= (string) $values['year']; ?> <td><?= (string) $values['year']; ?>
<td><?= (new Money(((int) $values['net_sales']) / 1000))->getCurrency(); ?> <td><?= (new Money(((int) $values['net_sales']) / 10000))->getCurrency(); ?>
<td><?= ((int) $values['customers']); ?> <td><?= ((int) $values['customers']); ?>
<?php endforeach; ?> <?php endforeach; ?>
</table> </table>
@ -2394,7 +2394,7 @@ echo $this->getData('nav')->render();
?> ?>
<tr> <tr>
<td><?= $values['month'] . '/' . \substr((string) $values['year'], -2); ?> <td><?= $values['month'] . '/' . \substr((string) $values['year'], -2); ?>
<td><?= (new Money(((int) $values['net_sales']) / 1000))->getCurrency(); ?> <td><?= (new Money(((int) $values['net_sales']) / 10000))->getCurrency(); ?>
<td><?= ((int) $values['customers']); ?> <td><?= ((int) $values['customers']); ?>
<?php endforeach; ?> <?php endforeach; ?>
<tr> <tr>
@ -2514,7 +2514,7 @@ echo $this->getData('nav')->render();
?> ?>
<tr> <tr>
<td><?= (string) $values['year']; ?> <td><?= (string) $values['year']; ?>
<td><?= (new Money(((int) $values['net_sales']) / 1000))->getCurrency(); ?> <td><?= (new Money(((int) $values['net_sales']) / 10000))->getCurrency(); ?>
<td><?= ((int) $values['customers']); ?> <td><?= ((int) $values['customers']); ?>
<?php endforeach; ?> <?php endforeach; ?>
</table> </table>
@ -3476,7 +3476,7 @@ echo $this->getData('nav')->render();
?> ?>
<tr> <tr>
<td><?= $values['month'] . '/' . \substr((string) $values['year'], -2); ?> <td><?= $values['month'] . '/' . \substr((string) $values['year'], -2); ?>
<td><?= (new Money(((int) $values['net_sales']) / 1000))->getCurrency(); ?> <td><?= (new Money(((int) $values['net_sales']) / 10000))->getCurrency(); ?>
<td><?= ((int) $values['customers']); ?> <td><?= ((int) $values['customers']); ?>
<td><?= ((int) $values['customers']); ?> <td><?= ((int) $values['customers']); ?>
<?php endforeach; ?> <?php endforeach; ?>
@ -3599,7 +3599,7 @@ echo $this->getData('nav')->render();
?> ?>
<tr> <tr>
<td><?= (string) $values['year']; ?> <td><?= (string) $values['year']; ?>
<td><?= (new Money(((int) $values['net_sales']) / 1000))->getCurrency(); ?> <td><?= (new Money(((int) $values['net_sales']) / 10000))->getCurrency(); ?>
<td><?= ((int) $values['customers']); ?> <td><?= ((int) $values['customers']); ?>
<td><?= ((int) $values['customers']); ?> <td><?= ((int) $values['customers']); ?>
<?php endforeach; ?> <?php endforeach; ?>
@ -4306,7 +4306,7 @@ echo $this->getData('nav')->render();
?> ?>
<tr> <tr>
<td><?= $values['month'] . '/' . \substr((string) $values['year'], -2); ?> <td><?= $values['month'] . '/' . \substr((string) $values['year'], -2); ?>
<td><?= (new Money(((int) $values['net_sales']) / 1000))->getCurrency(); ?> <td><?= (new Money(((int) $values['net_sales']) / 10000))->getCurrency(); ?>
<td><?= ((int) $values['customers']); ?> <td><?= ((int) $values['customers']); ?>
<td><?= ((int) $values['customers']); ?> <td><?= ((int) $values['customers']); ?>
<?php endforeach; ?> <?php endforeach; ?>
@ -4428,7 +4428,7 @@ echo $this->getData('nav')->render();
?> ?>
<tr> <tr>
<td><?= (string) $values['year']; ?> <td><?= (string) $values['year']; ?>
<td><?= (new Money(((int) $values['net_sales']) / 1000))->getCurrency(); ?> <td><?= (new Money(((int) $values['net_sales']) / 10000))->getCurrency(); ?>
<td><?= ((int) $values['customers']); ?> <td><?= ((int) $values['customers']); ?>
<td><?= ((int) $values['customers']); ?> <td><?= ((int) $values['customers']); ?>
<?php endforeach; ?> <?php endforeach; ?>

View File

@ -69,7 +69,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase
$permission = new AccountPermission(); $permission = new AccountPermission();
$permission->setUnit(1); $permission->setUnit(1);
$permission->setApp('backend'); $permission->setApp(2);
$permission->setPermission( $permission->setPermission(
PermissionType::READ PermissionType::READ
| PermissionType::CREATE | PermissionType::CREATE