Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
This commit is contained in:
Julien Veyssier
2024-09-21 01:43:06 +02:00
parent 43b961f94d
commit d8450635be
33 changed files with 287 additions and 281 deletions

View File

@@ -155,7 +155,7 @@ class ActivityManager {
break;
case self::SUBJECT_PROJECT_SHARE:
case self::SUBJECT_PROJECT_UNSHARE:
$subjectParams = $this->findDetailsForProject((string) $entity->getId());
$subjectParams = $this->findDetailsForProject((string)$entity->getId());
$objectName = $object->getId();
break;
default:
@@ -167,7 +167,7 @@ class ActivityManager {
$event->setApp('cospend')
->setType($eventType)
->setAuthor($author === null ? $this->userId ?? '' : $author)
->setObject($objectType, (int)$object->getId(), (string) $objectName)
->setObject($objectType, (int)$object->getId(), (string)$objectName)
->setSubject($subject, array_merge($subjectParams, $additionalParams))
->setTimestamp(time());
@@ -214,7 +214,7 @@ class ActivityManager {
$objectId = $entity->getId();
break;
default:
throw new InvalidArgumentException('No entity relation present for '. $className . ' to ' . $objectType);
throw new InvalidArgumentException('No entity relation present for ' . $className . ' to ' . $objectType);
}
return $this->billMapper->find($objectId);
}
@@ -224,15 +224,15 @@ class ActivityManager {
$objectId = $entity->getId();
break;
default:
throw new InvalidArgumentException('No entity relation present for '. $className . ' to ' . $objectType);
throw new InvalidArgumentException('No entity relation present for ' . $className . ' to ' . $objectType);
}
$dbProject = $this->projectMapper->find($objectId);
if ($dbProject === null) {
throw new InvalidArgumentException('No entity relation present for '. $className . ' to ' . $objectType);
throw new InvalidArgumentException('No entity relation present for ' . $className . ' to ' . $objectType);
}
return $dbProject;
}
throw new InvalidArgumentException('No entity relation present for '. $className . ' to ' . $objectType);
throw new InvalidArgumentException('No entity relation present for ' . $className . ' to ' . $objectType);
}
/**

View File

@@ -48,7 +48,7 @@ class CospendProvider implements IProvider {
private IAppManager $appManager,
private IL10N $l10n,
private LocalProjectService $projectService,
private ?string $userId
private ?string $userId,
) {
$this->projectNames = [];
if (!is_null($userId)) {
@@ -221,8 +221,8 @@ class CospendProvider implements IProvider {
$params[$paramName] = [
'type' => 'highlight',
'id' => $subjectParams[$paramName]['id'],
'name' => $subjectParams[$paramName]['name'].' ('.$subjectParams[$paramName]['amount'].')',
'link' => $this->cospendUrl('?project=' . $subjectParams['project']['id']) . '&bill='.$subjectParams[$paramName]['id'],
'name' => $subjectParams[$paramName]['name'] . ' (' . $subjectParams[$paramName]['amount'] . ')',
'link' => $this->cospendUrl('?project=' . $subjectParams['project']['id']) . '&bill=' . $subjectParams[$paramName]['id'],
];
}
return $params;

View File

@@ -53,8 +53,8 @@ class Filter implements IFilter {
/**
* @return int whether the filter should be rather on the top or bottom of
* the admin section. The filters are arranged in ascending order of the
* priority values. It is required to return a value between 0 and 100.
* the admin section. The filters are arranged in ascending order of the
* priority values. It is required to return a value between 0 and 100.
* @since 11.0.0
*/
public function getPriority(): int {

View File

@@ -28,7 +28,9 @@ use OCP\IL10N;
class Setting implements ISetting {
public function __construct(protected IL10N $l) {
public function __construct(
protected IL10N $l,
) {
}
/**
@@ -49,8 +51,8 @@ class Setting implements ISetting {
/**
* @return int whether the filter should be rather on the top or bottom of
* the admin section. The filters are arranged in ascending order of the
* priority values. It is required to return a value between 0 and 100.
* the admin section. The filters are arranged in ascending order of the
* priority values. It is required to return a value between 0 and 100.
* @since 11.0.0
*/
public function getPriority(): int {

View File

@@ -19,7 +19,7 @@ class CospendPublicAuth {
* and if this shared access has at least the minimum level permission
*/
public function __construct(
protected int $minimumLevel
protected int $minimumLevel,
) {
}

View File

@@ -15,7 +15,7 @@ class CospendUserPermissions {
* if the project is local
*/
public function __construct(
protected int $minimumLevel
protected int $minimumLevel,
) {
}

View File

@@ -11,7 +11,7 @@ use OCP\Capabilities\IPublicCapability;
class Capabilities implements IPublicCapability {
public function __construct(
private IAppManager $appManager
private IAppManager $appManager,
) {
}

View File

@@ -22,7 +22,9 @@ use Symfony\Component\Console\Output\OutputInterface;
class DeleteBills extends Base {
public function __construct(private BillMapper $billMapper) {
public function __construct(
private BillMapper $billMapper,
) {
parent::__construct();
}
@@ -58,7 +60,7 @@ class DeleteBills extends Base {
$projectId = $input->getArgument('project_id');
$what = $input->getOption('what');
$minTs = $input->getOption('min_timestamp');
$minTs = $minTs === null ? null : (int) $minTs;
$minTs = $minTs === null ? null : (int)$minTs;
if ($input->getOption('simulate')) {
$output->writeln('This is just a simulation');

View File

@@ -55,14 +55,14 @@ class ExportProject extends Base {
$result = $this->cospendService->exportCsvProject($projectId, $dbProject->getUserId(), $projectInfo, $bills, $name);
if (array_key_exists('path', $result)) {
$output->writeln(
'Project "'.$projectId.'" exported in "'.$result['path'].
'" of user "'.$dbProject->getUserId().'" storage'
'Project "' . $projectId . '" exported in "' . $result['path'] .
'" of user "' . $dbProject->getUserId() . '" storage'
);
} else {
$output->writeln('Error: '.$result['message']);
$output->writeln('Error: ' . $result['message']);
}
} else {
$output->writeln('Project '.$projectId.' not found');
$output->writeln('Project ' . $projectId . ' not found');
}
return 0;
}

View File

@@ -34,8 +34,8 @@ class RepeatBills extends Base {
$repeated = $this->localProjectService->cronRepeatBills();
foreach ($repeated as $r) {
$output->writeln(
'[Project "'.$r['project_name'].'"] Bill "'.$r['what'].
'" ('.$r['date_orig'].') repeated on ('.$r['date_repeat'].')'
'[Project "' . $r['project_name'] . '"] Bill "' . $r['what'] .
'" (' . $r['date_orig'] . ') repeated on (' . $r['date_repeat'] . ')'
);
}
return 0;

View File

@@ -215,7 +215,7 @@ class ApiController extends OCSController {
public function editProject(
string $projectId, ?string $name = null,
?string $autoExport = null, ?string $currencyName = null, ?bool $deletionDisabled = null,
?string $categorySort = null, ?string $paymentModeSort = null, ?int $archivedTs = null
?string $categorySort = null, ?string $paymentModeSort = null, ?int $archivedTs = null,
): DataResponse {
try {
$this->projectService->editProject(
@@ -277,7 +277,7 @@ class ApiController extends OCSController {
public function getProjectStatistics(
string $projectId, ?int $tsMin = null, ?int $tsMax = null, ?int $paymentModeId = null,
?int $categoryId = null, ?float $amountMin = null, ?float $amountMax = null,
string $showDisabled = '1', ?int $currencyId = null, ?int $payerId = null
string $showDisabled = '1', ?int $currencyId = null, ?int $payerId = null,
): DataResponse {
try {
$result = $this->projectService->getStatistics(
@@ -406,7 +406,7 @@ class ApiController extends OCSController {
#[SupportFederatedProject]
public function editMember(
string $projectId, int $memberId, ?string $name = null, ?float $weight = null, $activated = null,
?string $color = null, ?string $userId = null
?string $color = null, ?string $userId = null,
): DataResponse {
if ($activated === 'true') {
$activated = true;
@@ -441,7 +441,7 @@ class ApiController extends OCSController {
#[SupportFederatedProject]
public function createMember(
string $projectId, string $name, ?string $userId = null, float $weight = 1,
int $active = 1, ?string $color = null
int $active = 1, ?string $color = null,
): DataResponse {
try {
$member = $this->projectService->createMember($projectId, $name, $weight, $active !== 0, $color, $userId);
@@ -487,7 +487,7 @@ class ApiController extends OCSController {
?int $payer = null, ?string $payedFor = null, ?float $amount = null, ?string $repeat = null,
?string $paymentMode = null, ?int $paymentModeId = null,
?int $categoryId = null, ?int $repeatAllActive = null, ?string $repeatUntil = null,
?int $timestamp = null, ?string $comment = null, ?int $repeatFreq = null, ?int $deleted = null
?int $timestamp = null, ?string $comment = null, ?int $repeatFreq = null, ?int $deleted = null,
): DataResponse {
try {
$this->projectService->editBill(
@@ -536,7 +536,7 @@ class ApiController extends OCSController {
?float $amount = null, ?string $repeat = null,
?string $paymentMode = null, ?int $paymentModeId = null,
?int $repeatAllActive = null, ?string $repeatUntil = null, ?int $timestamp = null,
?string $comment = null, ?int $repeatFreq = null, ?int $deleted = null
?string $comment = null, ?int $repeatFreq = null, ?int $deleted = null,
): DataResponse {
try {
$this->projectService->editBills(
@@ -657,7 +657,7 @@ class ApiController extends OCSController {
string $projectId, ?string $date = null, ?string $what = null, ?int $payer = null, ?string $payedFor = null,
?float $amount = null, ?string $repeat = null, ?string $paymentMode = null, ?int $paymentModeId = null,
?int $categoryId = null, int $repeatAllActive = 0, ?string $repeatUntil = null, ?int $timestamp = null,
?string $comment = null, ?int $repeatFreq = null
?string $comment = null, ?int $repeatFreq = null,
): DataResponse {
try {
$newBillId = $this->projectService->createBill(
@@ -776,7 +776,7 @@ class ApiController extends OCSController {
public function getBills(
string $projectId, ?int $lastChanged = null, ?int $offset = 0, ?int $limit = null, bool $reverse = false,
?int $payerId = null, ?int $categoryId = null, ?int $paymentModeId = null, ?int $includeBillId = null,
?string $searchTerm = null, ?int $deleted = 0
?string $searchTerm = null, ?int $deleted = 0,
): DataResponse {
try {
return new DataResponse(
@@ -933,7 +933,7 @@ class ApiController extends OCSController {
#[OpenAPI(scope: OpenAPI::SCOPE_DEFAULT, tags: ['Payment-modes'])]
#[SupportFederatedProject]
public function editPaymentMode(
string $projectId, int $pmId, ?string $name = null, ?string $icon = null, ?string $color = null
string $projectId, int $pmId, ?string $name = null, ?string $icon = null, ?string $color = null,
): DataResponse {
try {
$pm = $this->projectService->editPaymentMode($projectId, $pmId, $name, $icon, $color);
@@ -1045,7 +1045,7 @@ class ApiController extends OCSController {
#[OpenAPI(scope: OpenAPI::SCOPE_DEFAULT, tags: ['Categories'])]
#[SupportFederatedProject]
public function editCategory(
string $projectId, int $categoryId, ?string $name = null, ?string $icon = null, ?string $color = null
string $projectId, int $categoryId, ?string $name = null, ?string $icon = null, ?string $color = null,
): DataResponse {
try {
$category = $this->projectService->editCategory($projectId, $categoryId, $name, $icon, $color);
@@ -1172,7 +1172,7 @@ class ApiController extends OCSController {
* @param int $currencyId
* @return DataResponse<Http::STATUS_OK, '', array{}>|DataResponse<Http::STATUS_BAD_REQUEST|Http::STATUS_FAILED_DEPENDENCY, array<string, string>, array{}>
* @throws Exception
* * @throws MultipleObjectsReturnedException
* * @throws MultipleObjectsReturnedException
*
* 200: The currency was successfully deleted
* 400: Failed to delete the currency
@@ -1212,7 +1212,7 @@ class ApiController extends OCSController {
#[OpenAPI(scope: OpenAPI::SCOPE_DEFAULT, tags: ['Sharing'])]
public function createFederatedShare(
string $projectId, string $userCloudId, int $accessLevel = 2,
bool $manuallyAdded = true
bool $manuallyAdded = true,
): DataResponse {
try {
$share = $this->localProjectService->createFederatedShare($projectId, $userCloudId, $this->userId, $accessLevel, $manuallyAdded);
@@ -1277,7 +1277,7 @@ class ApiController extends OCSController {
#[OpenAPI(scope: OpenAPI::SCOPE_DEFAULT, tags: ['Sharing'])]
public function createUserShare(
string $projectId, string $userId, int $accessLevel = 2,
bool $manuallyAdded = true
bool $manuallyAdded = true,
): DataResponse {
$result = $this->localProjectService->createUserShare($projectId, $userId, $this->userId, $accessLevel, $manuallyAdded);
if (!isset($result['message'])) {
@@ -1338,7 +1338,7 @@ class ApiController extends OCSController {
#[CospendUserPermissions(minimumLevel: Application::ACCESS_LEVEL_PARTICIPANT)]
#[OpenAPI(scope: OpenAPI::SCOPE_DEFAULT, tags: ['Sharing'])]
public function createPublicShare(
string $projectId, ?string $label = null, ?string $password = null, int $accessLevel = 2
string $projectId, ?string $label = null, ?string $password = null, int $accessLevel = 2,
): DataResponse {
$result = $this->localProjectService->createPublicShare($projectId, $label, $password, $accessLevel);
return new DataResponse($result);
@@ -1524,7 +1524,7 @@ class ApiController extends OCSController {
$shares = $this->shareManager->getSharesBy($this->userId,
IShare::TYPE_LINK, $file, false, 1, 0);
if (count($shares) > 0) {
foreach($shares as $share) {
foreach ($shares as $share) {
if ($share->getPassword() === null) {
$token = $share->getToken();
break;
@@ -1601,7 +1601,7 @@ class ApiController extends OCSController {
string $projectId, ?int $tsMin = null, ?int $tsMax = null,
?int $paymentModeId = null, ?int $category = null,
?float $amountMin = null, ?float $amountMax = null,
int $showDisabled = 1, ?int $currencyId = null
int $showDisabled = 1, ?int $currencyId = null,
): DataResponse {
$statistics = $this->projectService->getStatistics($projectId, $tsMin, $tsMax, $paymentModeId, $category, $amountMin, $amountMax, $showDisabled !== 0, $currencyId);
$result = $this->cospendService->exportCsvStatistics($projectId, $this->userId, $statistics);

View File

@@ -239,7 +239,7 @@ class OldApiController extends ApiController {
public function apiv3GetBills(
string $token, ?int $lastchanged = null, ?int $offset = 0, ?int $limit = null, bool $reverse = false,
?int $payerId = null, ?int $categoryId = null, ?int $paymentModeId = null, ?int $includeBillId = null,
?string $searchTerm = null, ?int $deleted = 0
?string $searchTerm = null, ?int $deleted = 0,
): DataResponse {
$publicShareInfo = $this->localProjectService->getLinkShareInfoFromShareToken($token);
if ($limit) {
@@ -453,7 +453,7 @@ class OldApiController extends ApiController {
?string $paymentmode = null, ?int $paymentmodeid = null,
?int $categoryid = null, ?int $repeatallactive = null,
?string $repeatuntil = null, ?int $timestamp = null, ?string $comment = null,
?int $repeatfreq = null, ?int $deleted = null
?int $repeatfreq = null, ?int $deleted = null,
): DataResponse {
$publicShareInfo = $this->localProjectService->getLinkShareInfoFromShareToken($token);
try {
@@ -497,7 +497,7 @@ class OldApiController extends ApiController {
?string $repeat = 'n', ?string $paymentmode = null, ?int $paymentmodeid = null,
?int $repeatallactive = null,
?string $repeatuntil = null, ?int $timestamp = null, ?string $comment = null,
?int $repeatfreq = null, ?int $deleted = null
?int $repeatfreq = null, ?int $deleted = null,
): DataResponse {
$publicShareInfo = $this->localProjectService->getLinkShareInfoFromShareToken($token);
if (is_null($publicShareInfo)) {
@@ -540,7 +540,7 @@ class OldApiController extends ApiController {
?string $paymentmode = null, ?int $paymentmodeid = null,
?int $categoryid = null, ?int $repeatallactive = null,
?string $repeatuntil = null, ?int $timestamp = null, ?string $comment = null,
?int $repeatfreq = null, ?int $deleted = null
?int $repeatfreq = null, ?int $deleted = null,
): DataResponse {
try {
$this->localProjectService->editBill(
@@ -574,7 +574,7 @@ class OldApiController extends ApiController {
try {
$this->billMapper->deleteDeletedBills($publicShareInfo['projectid']);
return new DataResponse('');
} catch (\Exception | \Throwable $e) {
} catch (\Exception|\Throwable $e) {
return new DataResponse('', Http::STATUS_BAD_REQUEST);
}
}
@@ -661,7 +661,7 @@ class OldApiController extends ApiController {
try {
$this->billMapper->deleteDeletedBills($projectId);
return new DataResponse('');
} catch (\Exception | \Throwable $e) {
} catch (\Exception|\Throwable $e) {
return new DataResponse('', Http::STATUS_NOT_FOUND);
}
}

View File

@@ -53,7 +53,7 @@ class PageController extends Controller {
private IAppManager $appManager,
private IEventDispatcher $eventDispatcher,
private IConfig $config,
private ?string $userId
private ?string $userId,
) {
parent::__construct($appName, $request);
}

View File

@@ -99,7 +99,7 @@ class PublicApiController extends OCSController {
try {
$this->billMapper->deleteDeletedBills($this->projectId);
return new DataResponse('');
} catch (\Exception | \Throwable $e) {
} catch (\Exception|\Throwable $e) {
return new DataResponse('', Http::STATUS_BAD_REQUEST);
}
}
@@ -259,7 +259,7 @@ class PublicApiController extends OCSController {
string $token, ?int $tsMin = null, ?int $tsMax = null,
?int $paymentModeId = null, ?int $categoryId = null,
?float $amountMin = null, ?float $amountMax = null,
string $showDisabled = '1', ?int $currencyId = null, ?int $payerId = null
string $showDisabled = '1', ?int $currencyId = null, ?int $payerId = null,
): DataResponse {
$result = $this->localProjectService->getStatistics(
$this->projectId, $tsMin, $tsMax,
@@ -306,7 +306,7 @@ class PublicApiController extends OCSController {
#[BruteForceProtection(action: 'CospendPublicAutoSettlement')]
#[OpenAPI(scope: OpenAPI::SCOPE_DEFAULT, tags: ['Public-API_Projects'])]
public function publicAutoSettlement(
string $token, ?int $centeredOn = null, int $precision = 2, ?int $maxTimestamp = null
string $token, ?int $centeredOn = null, int $precision = 2, ?int $maxTimestamp = null,
): DataResponse {
try {
$this->localProjectService->autoSettlement(
@@ -355,7 +355,7 @@ class PublicApiController extends OCSController {
?string $paymentMode = null, ?int $paymentModeId = null,
?int $categoryId = null, ?int $repeatAllActive = null,
?string $repeatUntil = null, ?int $timestamp = null, ?string $comment = null,
?int $repeatFreq = null, ?int $deleted = null
?int $repeatFreq = null, ?int $deleted = null,
): DataResponse {
$share = $this->shareMapper->getLinkOrFederatedShareByToken($token);
try {
@@ -421,7 +421,7 @@ class PublicApiController extends OCSController {
?string $what = null, ?int $payer = null, ?string $payedFor = null, ?float $amount = null,
?string $repeat = 'n', ?string $paymentMode = null, ?int $paymentModeId = null,
?int $repeatAllActive = null, ?string $repeatUntil = null, ?int $timestamp = null,
?string $comment = null, ?int $repeatFreq = null, ?int $deleted = null
?string $comment = null, ?int $repeatFreq = null, ?int $deleted = null,
): DataResponse {
$share = $this->shareMapper->getLinkOrFederatedShareByToken($token);
if ($share->getLabel()) {
@@ -494,7 +494,7 @@ class PublicApiController extends OCSController {
public function publicEditProject(
string $token, ?string $name = null,
?string $autoExport = null, ?string $currencyName = null, ?bool $deletionDisabled = null,
?string $categorySort = null, ?string $paymentModeSort = null, ?int $archivedTs = null
?string $categorySort = null, ?string $paymentModeSort = null, ?int $archivedTs = null,
): DataResponse {
try {
$this->localProjectService->editProject(
@@ -541,7 +541,7 @@ class PublicApiController extends OCSController {
?string $payedFor = null, ?float $amount = null, string $repeat = 'n',
?string $paymentMode = null, ?int $paymentModeId = null,
?int $categoryId = null, int $repeatAllActive = 0, ?string $repeatUntil = null, ?int $timestamp = null,
?string $comment = null, ?int $repeatFreq = null
?string $comment = null, ?int $repeatFreq = null,
): DataResponse {
$share = $this->shareMapper->getLinkOrFederatedShareByToken($token);
try {
@@ -594,7 +594,7 @@ class PublicApiController extends OCSController {
public function publicGetBills(
string $token, ?int $lastChanged = null, ?int $offset = 0, ?int $limit = null, bool $reverse = false,
?int $payerId = null, ?int $categoryId = null, ?int $paymentModeId = null, ?int $includeBillId = null,
?string $searchTerm = null, ?int $deleted = 0
?string $searchTerm = null, ?int $deleted = 0,
): DataResponse {
if ($limit) {
$bills = $this->billMapper->getBillsWithLimit(
@@ -704,7 +704,7 @@ class PublicApiController extends OCSController {
#[OpenAPI(scope: OpenAPI::SCOPE_DEFAULT, tags: ['Public-API_Members'])]
public function publicEditMember(
string $token, int $memberId, ?string $name = null, ?float $weight = null,
$activated = null, ?string $color = null, ?string $userId = null
$activated = null, ?string $color = null, ?string $userId = null,
): DataResponse {
if ($activated === 'true') {
$activated = true;
@@ -743,7 +743,7 @@ class PublicApiController extends OCSController {
#[OpenAPI(scope: OpenAPI::SCOPE_DEFAULT, tags: ['Public-API_Members'])]
public function publicCreateMember(
string $token, string $name, float $weight = 1, int $active = 1,
?string $color = null, ?string $userId = null
?string $color = null, ?string $userId = null,
): DataResponse {
try {
$member = $this->localProjectService->createMember(
@@ -796,7 +796,7 @@ class PublicApiController extends OCSController {
#[BruteForceProtection(action: 'CospendPublicEditPaymentMode')]
#[OpenAPI(scope: OpenAPI::SCOPE_DEFAULT, tags: ['Public-API_Payment-modes'])]
public function publicEditPaymentMode(
string $token, int $pmId, ?string $name = null, ?string $icon = null, ?string $color = null
string $token, int $pmId, ?string $name = null, ?string $icon = null, ?string $color = null,
): DataResponse {
try {
$pm = $this->localProjectService->editPaymentMode(
@@ -895,7 +895,7 @@ class PublicApiController extends OCSController {
#[OpenAPI(scope: OpenAPI::SCOPE_DEFAULT, tags: ['Public-API_Categories'])]
public function publicEditCategory(
string $token, int $categoryId,
?string $name = null, ?string $icon = null, ?string $color = null
?string $name = null, ?string $icon = null, ?string $color = null,
): DataResponse {
try {
$category = $this->localProjectService->editCategory(

View File

@@ -17,7 +17,7 @@ class AutoExport extends TimedJob {
public function __construct(
ITimeFactory $time,
private CospendService $cospendService
private CospendService $cospendService,
) {
parent::__construct($time);
// Run each day

View File

@@ -17,7 +17,7 @@ class RepeatBills extends TimedJob {
public function __construct(
ITimeFactory $time,
private LocalProjectService $localProjectService
private LocalProjectService $localProjectService,
) {
parent::__construct($time);
// Run each day

View File

@@ -34,7 +34,7 @@ class CospendWidget implements IWidget {
public function __construct(
private IL10N $l10n,
private IURLGenerator $url
private IURLGenerator $url,
) {
}

View File

@@ -235,7 +235,7 @@ class BillMapper extends QBMapper {
try {
return $this->findEntity($qb);
} catch (DoesNotExistException | MultipleObjectsReturnedException | \OCP\DB\Exception $e) {
} catch (DoesNotExistException|MultipleObjectsReturnedException|\OCP\DB\Exception $e) {
return null;
}
}
@@ -267,10 +267,10 @@ class BillMapper extends QBMapper {
$req = $qb->executeQuery();
while ($row = $req->fetch()) {
$dbWeight = (float) $row['weight'];
$dbWeight = (float)$row['weight'];
$dbName = $row['name'];
$dbActivated = (((int) $row['activated']) === 1);
$dbOwerId = (int) $row['memberid'];
$dbActivated = (((int)$row['activated']) === 1);
$dbOwerId = (int)$row['memberid'];
$billOwers[] = [
'id' => $dbOwerId,
'weight' => $dbWeight,
@@ -337,7 +337,7 @@ class BillMapper extends QBMapper {
?string $paymentMode = null, ?int $paymentModeId = null,
?int $category = null, ?float $amountMin = null, ?float $amountMax = null,
?int $lastchanged = null, ?int $limit = null,
bool $reverse = false, ?int $payerId = null, ?int $deleted = 0
bool $reverse = false, ?int $payerId = null, ?int $deleted = 0,
): array {
$qb = $this->db->getQueryBuilder();
$qb->select('bi.id', 'what', 'comment', 'timestamp', 'amount', 'payer_id', 'repeat',
@@ -421,7 +421,7 @@ class BillMapper extends QBMapper {
// ordered list of bill ids
$orderedBillIds = [];
while ($row = $req->fetch()) {
$dbBillId = (int) $row['id'];
$dbBillId = (int)$row['id'];
// if first time we see the bill : add it to bill list
if (!isset($billDict[$dbBillId])) {
$billDict[$dbBillId] = $this->getBillFromRow($row);
@@ -429,10 +429,10 @@ class BillMapper extends QBMapper {
$orderedBillIds[] = $dbBillId;
}
// anyway add an ower
$dbWeight = (float) $row['weight'];
$dbWeight = (float)$row['weight'];
$dbName = $row['name'];
$dbActivated = ((int) $row['activated']) === 1;
$dbOwerId = (int) $row['memberid'];
$dbActivated = ((int)$row['activated']) === 1;
$dbOwerId = (int)$row['memberid'];
$billDict[$dbBillId]['owers'][] = [
'id' => $dbOwerId,
'weight' => $dbWeight,
@@ -479,7 +479,7 @@ class BillMapper extends QBMapper {
?int $category = null, ?float $amountMin = null, ?float $amountMax = null,
?int $lastchanged = null, ?int $limit = null,
bool $reverse = false, ?int $offset = 0, ?int $payerId = null,
?int $includeBillId = null, ?string $searchTerm = null, ?int $deleted = 0
?int $includeBillId = null, ?string $searchTerm = null, ?int $deleted = 0,
): array {
$qb = $this->db->getQueryBuilder();
$qb->select('*')
@@ -611,10 +611,10 @@ class BillMapper extends QBMapper {
$qb->setFirstResult(0);
$req = $qb->executeQuery();
while ($row = $req->fetch()) {
$dbWeight = (float) $row['weight'];
$dbWeight = (float)$row['weight'];
$dbName = $row['name'];
$dbActivated = ((int) $row['activated']) === 1;
$dbOwerId = (int) $row['memberid'];
$dbActivated = ((int)$row['activated']) === 1;
$dbOwerId = (int)$row['memberid'];
$billOwers[] = [
'id' => $dbOwerId,
'weight' => $dbWeight,
@@ -633,22 +633,22 @@ class BillMapper extends QBMapper {
}
private function getBillFromRow(array $row): array {
$dbBillId = (int) $row['id'];
$dbAmount = (float) $row['amount'];
$dbBillId = (int)$row['id'];
$dbAmount = (float)$row['amount'];
$dbWhat = $row['what'];
$dbComment = $row['comment'];
$dbTimestamp = (int) $row['timestamp'];
$dbTimestamp = (int)$row['timestamp'];
$dbDate = DateTime::createFromFormat('U', $row['timestamp']);
$dbRepeat = $row['repeat'];
$dbPayerId = (int) $row['payer_id'];
$dbPayerId = (int)$row['payer_id'];
$dbPaymentMode = $row['payment_mode'];
$dbPaymentModeId = (int) $row['payment_mode_id'];
$dbCategoryId = (int) $row['category_id'];
$dbLastchanged = (int) $row['last_changed'];
$dbRepeatAllActive = (int) $row['repeat_all_active'];
$dbPaymentModeId = (int)$row['payment_mode_id'];
$dbCategoryId = (int)$row['category_id'];
$dbLastchanged = (int)$row['last_changed'];
$dbRepeatAllActive = (int)$row['repeat_all_active'];
$dbRepeatUntil = $row['repeat_until'];
$dbRepeatFreq = (int) $row['repeat_frequency'];
$dbDeleted = (int) $row['deleted'];
$dbRepeatFreq = (int)$row['repeat_frequency'];
$dbDeleted = (int)$row['deleted'];
return [
'id' => $dbBillId,
'amount' => $dbAmount,
@@ -683,7 +683,7 @@ class BillMapper extends QBMapper {
// search amount
$noCommaTerm = str_replace(',', '.', $term);
if (is_numeric($noCommaTerm)) {
$amount = (float) $noCommaTerm;
$amount = (float)$noCommaTerm;
$amountMin = $amount - 1.0;
$amountMax = $amount + 1.0;
$andExpr = $qb->expr()->andX();
@@ -731,14 +731,14 @@ class BillMapper extends QBMapper {
// bills by id
$bills = [];
while ($row = $req->fetch()) {
$dbBillId = (int) $row['id'];
$dbAmount = (float) $row['amount'];
$dbBillId = (int)$row['id'];
$dbAmount = (float)$row['amount'];
$dbWhat = $row['what'];
$dbTimestamp = (int) $row['timestamp'];
$dbTimestamp = (int)$row['timestamp'];
$dbComment = $row['comment'];
$dbPaymentMode = $row['payment_mode'];
$dbPaymentModeId = (int) $row['payment_mode_id'];
$dbCategoryId = (int) $row['category_id'];
$dbPaymentModeId = (int)$row['payment_mode_id'];
$dbCategoryId = (int)$row['category_id'];
$dbProjectCurrencyName = $row['currency_name'];
$dbPayerName = $row['name'];
$dbPayerUserId = $row['userid'];
@@ -802,7 +802,7 @@ class BillMapper extends QBMapper {
}
$req = $qb->executeQuery();
while ($row = $req->fetch()) {
return (int) $row['count_bills'];
return (int)$row['count_bills'];
}
return 0;
}
@@ -831,7 +831,7 @@ class BillMapper extends QBMapper {
$req = $qb->executeQuery();
while ($row = $req->fetch()) {
$billIds[] = (int) $row['id'];
$billIds[] = (int)$row['id'];
}
$req->closeCursor();

View File

@@ -49,7 +49,7 @@ class MemberMapper extends QBMapper {
try {
return $this->findEntity($qb);
} catch (DoesNotExistException | MultipleObjectsReturnedException | Exception $e) {
} catch (DoesNotExistException|MultipleObjectsReturnedException|Exception $e) {
return null;
}
}
@@ -72,7 +72,7 @@ class MemberMapper extends QBMapper {
try {
return $this->findEntity($qb);
} catch (DoesNotExistException | MultipleObjectsReturnedException | Exception $e) {
} catch (DoesNotExistException|MultipleObjectsReturnedException|Exception $e) {
return null;
}
}
@@ -95,7 +95,7 @@ class MemberMapper extends QBMapper {
try {
return $this->findEntity($qb);
} catch (DoesNotExistException | MultipleObjectsReturnedException | Exception $e) {
} catch (DoesNotExistException|MultipleObjectsReturnedException|Exception $e) {
return null;
}
}

View File

@@ -70,7 +70,7 @@ class ProjectMapper extends QBMapper {
try {
return $this->findEntity($qb);
} catch (DoesNotExistException | MultipleObjectsReturnedException |Exception $e) {
} catch (DoesNotExistException|MultipleObjectsReturnedException|Exception $e) {
return null;
}
}
@@ -90,7 +90,7 @@ class ProjectMapper extends QBMapper {
*/
public function createProject(
string $name, string $id, ?string $contact_email, array $defaultCategories, array $defaultPaymentModes,
string $userid = '', bool $createDefaultCategories = true, bool $createDefaultPaymentModes = true
string $userid = '', bool $createDefaultCategories = true, bool $createDefaultPaymentModes = true,
): Project {
// check if id is valid
if (str_contains($id, '/')) {

View File

@@ -67,10 +67,10 @@ class Version000303Date20200201171814 extends SimpleMigrationStep {
public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
$qb = $this->connection->getQueryBuilder();
$qb->update('cospend_shares')
->set('type', $qb->createNamedParameter('g', IQueryBuilder::PARAM_STR))
->where(
$qb->expr()->eq('isgroupshare', $qb->createNamedParameter(1, IQueryBuilder::PARAM_INT))
);
->set('type', $qb->createNamedParameter('g', IQueryBuilder::PARAM_STR))
->where(
$qb->expr()->eq('isgroupshare', $qb->createNamedParameter(1, IQueryBuilder::PARAM_INT))
);
$qb->executeStatement();
}
}

View File

@@ -68,13 +68,13 @@ class Version000304Date20200313092247 extends SimpleMigrationStep {
$qb = $this->connection->getQueryBuilder();
$timestamps = [];
$qb->select('id', 'date')
->from('cospend_bills', 'b');
->from('cospend_bills', 'b');
$req = $qb->executeQuery();
while ($row = $req->fetch()) {
$id = $row['id'];
$date = $row['date'];
$timestamp = strtotime($date.' 12:00:00');
$timestamp = strtotime($date . ' 12:00:00');
$timestamps[$id] = $timestamp;
}
$req->closeCursor();
@@ -82,10 +82,10 @@ class Version000304Date20200313092247 extends SimpleMigrationStep {
foreach ($timestamps as $bid => $ts) {
$qb->update('cospend_bills')
->set('timestamp', $qb->createNamedParameter($ts, IQueryBuilder::PARAM_INT))
->where(
$qb->expr()->eq('id', $qb->createNamedParameter($bid, IQueryBuilder::PARAM_INT))
);
->set('timestamp', $qb->createNamedParameter($ts, IQueryBuilder::PARAM_INT))
->where(
$qb->expr()->eq('id', $qb->createNamedParameter($bid, IQueryBuilder::PARAM_INT))
);
$qb->executeStatement();
$qb = $this->connection->getQueryBuilder();
}

View File

@@ -80,35 +80,35 @@ class Version000403Date20200231152118 extends SimpleMigrationStep {
// permissions were c e d => v p m a for viewer participant maintener admin
// user share permissions
$qb->update('cospend_shares')
->set('accesslevel', $qb->createNamedParameter(2, IQueryBuilder::PARAM_INT))
->where(
$qb->expr()->neq('permissions', $qb->createNamedParameter('', IQueryBuilder::PARAM_STR))
);
->set('accesslevel', $qb->createNamedParameter(2, IQueryBuilder::PARAM_INT))
->where(
$qb->expr()->neq('permissions', $qb->createNamedParameter('', IQueryBuilder::PARAM_STR))
);
$qb->executeStatement();
$qb = $this->connection->getQueryBuilder();
$qb->update('cospend_shares')
->set('accesslevel', $qb->createNamedParameter(1, IQueryBuilder::PARAM_INT))
->where(
$qb->expr()->eq('permissions', $qb->createNamedParameter('', IQueryBuilder::PARAM_STR))
);
->set('accesslevel', $qb->createNamedParameter(1, IQueryBuilder::PARAM_INT))
->where(
$qb->expr()->eq('permissions', $qb->createNamedParameter('', IQueryBuilder::PARAM_STR))
);
$qb->executeStatement();
$qb = $this->connection->getQueryBuilder();
// guest permissions
$qb->update('cospend_projects')
->set('guestaccesslevel', $qb->createNamedParameter(2, IQueryBuilder::PARAM_INT))
->where(
$qb->expr()->neq('guestpermissions', $qb->createNamedParameter('', IQueryBuilder::PARAM_STR))
);
->set('guestaccesslevel', $qb->createNamedParameter(2, IQueryBuilder::PARAM_INT))
->where(
$qb->expr()->neq('guestpermissions', $qb->createNamedParameter('', IQueryBuilder::PARAM_STR))
);
$qb->executeStatement();
$qb = $this->connection->getQueryBuilder();
$qb->update('cospend_projects')
->set('guestaccesslevel', $qb->createNamedParameter(1, IQueryBuilder::PARAM_INT))
->where(
$qb->expr()->eq('guestpermissions', $qb->createNamedParameter('', IQueryBuilder::PARAM_STR))
);
->set('guestaccesslevel', $qb->createNamedParameter(1, IQueryBuilder::PARAM_INT))
->where(
$qb->expr()->eq('guestpermissions', $qb->createNamedParameter('', IQueryBuilder::PARAM_STR))
);
$qb->executeStatement();
}
}

View File

@@ -72,7 +72,7 @@ class Version000406Date20200426154317 extends SimpleMigrationStep {
// first, copy icon -> encoded_icon
$categoryIconDict = [];
$qb->select('c.id', 'c.icon')
->from('cospend_categories', 'c');
->from('cospend_categories', 'c');
$req = $qb->executeQuery();
while ($row = $req->fetch()) {
@@ -142,7 +142,7 @@ class Version000406Date20200426154317 extends SimpleMigrationStep {
// get project ids
$projectIdList = [];
$qb->select('p.id')
->from('cospend_projects', 'p');
->from('cospend_projects', 'p');
$req = $qb->executeQuery();
while ($row = $req->fetch()) {
@@ -155,10 +155,10 @@ class Version000406Date20200426154317 extends SimpleMigrationStep {
// is there at least one default category already?
$oneDefaultFound = false;
$qb->select('c.name')
->from('cospend_categories', 'c')
->where(
$qb->expr()->eq('projectid', $qb->createNamedParameter($projectId, IQueryBuilder::PARAM_STR))
);
->from('cospend_categories', 'c')
->where(
$qb->expr()->eq('projectid', $qb->createNamedParameter($projectId, IQueryBuilder::PARAM_STR))
);
$req = $qb->executeQuery();
while ($row = $req->fetch()) {
@@ -195,7 +195,7 @@ class Version000406Date20200426154317 extends SimpleMigrationStep {
$qb->expr()->eq('projectid', $qb->createNamedParameter($projectId, IQueryBuilder::PARAM_STR))
)
->andWhere(
$qb->expr()->eq('categoryid', $qb->createNamedParameter((int) $strId, IQueryBuilder::PARAM_INT))
$qb->expr()->eq('categoryid', $qb->createNamedParameter((int)$strId, IQueryBuilder::PARAM_INT))
);
$qb->executeStatement();
$qb = $this->connection->getQueryBuilder();

View File

@@ -15,7 +15,9 @@ use OCP\Migration\SimpleMigrationStep;
class Version010514Date20231203164157 extends SimpleMigrationStep {
public function __construct(private IDBConnection $connection) {
public function __construct(
private IDBConnection $connection,
) {
}
/**

View File

@@ -27,7 +27,7 @@ class Notifier implements INotifier {
private IConfig $config,
private IUserManager $userManager,
private IURLGenerator $url,
private ?string $userId
private ?string $userId,
) {
}

View File

@@ -88,7 +88,7 @@ class CospendSearchProvider implements IProvider {
$limit = $query->getLimit();
$term = $query->getTerm();
$offset = $query->getCursor();
$offset = $offset ? (int) $offset : 0;
$offset = $offset ? (int)$offset : 0;
$resultBills = [];
@@ -164,7 +164,7 @@ class CospendSearchProvider implements IProvider {
}
}
$amount = number_format($bill['amount'], 2);
return $what. ' ('. $amount . $currency . ') ' . $catPmChars;
return $what . ' (' . $amount . $currency . ') ' . $catPmChars;
}
/**

View File

@@ -197,7 +197,7 @@ class CospendService {
fclose($handle);
return ['message' => $this->l10n->t('Error when adding category %1$s', [$categoryname])];
}
$categoryid = (int) $data[$columns['categoryid']];
$categoryid = (int)$data[$columns['categoryid']];
$categories[] = [
'icon' => $icon,
'color' => $color,
@@ -216,7 +216,7 @@ class CospendService {
return ['message' => $this->l10n->t('Error when adding payment mode %1$s', [$paymentmodename])];
}
$color = $data[$columns['color']];
$paymentmodeid = (int) $data[$columns['paymentmodeid']];
$paymentmodeid = (int)$data[$columns['paymentmodeid']];
$paymentModes[] = [
'icon' => $icon,
'color' => $color,
@@ -229,7 +229,7 @@ class CospendService {
fclose($handle);
return ['message' => $this->l10n->t('Error when adding currency %1$s', [$name])];
}
$exchange_rate = (float) $data[$columns['exchange_rate']];
$exchange_rate = (float)$data[$columns['exchange_rate']];
if (($exchange_rate) === 1.0) {
$mainCurrencyName = $name;
} else {
@@ -244,8 +244,8 @@ class CospendService {
fclose($handle);
return ['message' => $this->l10n->t('Error when adding member %1$s', [$name])];
}
$weight = (float) $data[$columns['weight']];
$active = (int) $data[$columns['active']];
$weight = (float)$data[$columns['weight']];
$active = (int)$data[$columns['active']];
$color = $data[$columns['color']];
if (strlen($name) > 0
&& preg_match('/^#[0-9A-Fa-f]+$/', $color) !== false
@@ -265,11 +265,11 @@ class CospendService {
fclose($handle);
return ['message' => $this->l10n->t('Malformed CSV, invalid amount on line %1$s', [$row + 1])];
}
$amount = (float) $data[$columns['amount']];
$amount = (float)$data[$columns['amount']];
$timestamp = null;
// priority to timestamp
if (array_key_exists('timestamp', $columns)) {
$timestamp = (int) $data[$columns['timestamp']];
$timestamp = (int)$data[$columns['timestamp']];
} elseif (array_key_exists('date', $columns)) {
$date = $data[$columns['date']];
$datetime = DateTime::createFromFormat('Y-m-d', $date);
@@ -286,24 +286,24 @@ class CospendService {
$owers = $data[$columns['owers']];
$payer_active = array_key_exists('payer_active', $columns) ? $data[$columns['payer_active']] : 1;
$repeat = array_key_exists('repeat', $columns) ? $data[$columns['repeat']] : Application::FREQUENCY_NO;
$categoryid = array_key_exists('categoryid', $columns) ? (int) $data[$columns['categoryid']] : null;
$categoryid = array_key_exists('categoryid', $columns) ? (int)$data[$columns['categoryid']] : null;
$paymentmode = array_key_exists('paymentmode', $columns) ? $data[$columns['paymentmode']] : null;
$paymentmodeid = array_key_exists('paymentmodeid', $columns) ? (int) $data[$columns['paymentmodeid']] : null;
$repeatallactive = array_key_exists('repeatallactive', $columns) ? (int) $data[$columns['repeatallactive']] : 0;
$paymentmodeid = array_key_exists('paymentmodeid', $columns) ? (int)$data[$columns['paymentmodeid']] : null;
$repeatallactive = array_key_exists('repeatallactive', $columns) ? (int)$data[$columns['repeatallactive']] : 0;
$repeatuntil = array_key_exists('repeatuntil', $columns) ? $data[$columns['repeatuntil']] : null;
$repeatfreq = array_key_exists('repeatfreq', $columns) ? (int) $data[$columns['repeatfreq']] : 1;
$repeatfreq = array_key_exists('repeatfreq', $columns) ? (int)$data[$columns['repeatfreq']] : 1;
$comment = array_key_exists('comment', $columns) ? urldecode($data[$columns['comment']] ?? '') : null;
$deleted = array_key_exists('deleted', $columns) ? (int) $data[$columns['deleted']] : 0;
$deleted = array_key_exists('deleted', $columns) ? (int)$data[$columns['deleted']] : 0;
// manage members
if (!isset($membersByName[$payer_name])) {
$membersByName[$payer_name] = [
'active' => ((int) $payer_active) !== 0,
'active' => ((int)$payer_active) !== 0,
'weight' => 1.0,
'color' => null,
];
if (is_numeric($payer_weight)) {
$membersByName[$payer_name]['weight'] = (float) $payer_weight;
$membersByName[$payer_name]['weight'] = (float)$payer_weight;
} else {
fclose($handle);
return ['message' => $this->l10n->t('Malformed CSV, invalid payer weight on line %1$s', [$row + 1])];
@@ -531,7 +531,7 @@ class CospendService {
fclose($handle);
return ['message' => $this->l10n->t('Malformed CSV, bad amount on line %1$s', [$row])];
}
$amount = (float) $data[$c];
$amount = (float)$data[$c];
if ($amount < 0) {
$negativeCols[] = $c;
}
@@ -541,7 +541,7 @@ class CospendService {
}, $negativeCols);
// each positive one: bill with member-specific amount (not the full amount), owers are the negative ones
for ($c = 5; $c < $nbCol; $c++) {
$amount = (float) $data[$c];
$amount = (float)$data[$c];
if ($amount > 0) {
$payer_name = $owersArray[$c - 5];
if (empty($payer_name)) {
@@ -665,43 +665,43 @@ class CospendService {
$minDayTimestamp = $maxDayTimestamp - (24 * 60 * 60);
$dateMaxDay->modify('-1 day');
$dailySuffix = '_'.$this->l10n->t('daily').'_'.$dateMaxDay->format('Y-m-d');
$dailySuffix = '_' . $this->l10n->t('daily') . '_' . $dateMaxDay->format('Y-m-d');
// last week
$now = new DateTime();
while (((int) $now->format('N')) !== 1) {
while (((int)$now->format('N')) !== 1) {
$now->modify('-1 day');
}
$y = $now->format('Y');
$m = $now->format('m');
$d = $now->format('d');
$dateWeekMax = new DateTime($y.'-'.$m.'-'.$d);
$dateWeekMax = new DateTime($y . '-' . $m . '-' . $d);
$maxWeekTimestamp = $dateWeekMax->getTimestamp();
$minWeekTimestamp = $maxWeekTimestamp - (7 * 24 * 60 * 60);
$dateWeekMin = new DateTime($y.'-'.$m.'-'.$d);
$dateWeekMin = new DateTime($y . '-' . $m . '-' . $d);
$dateWeekMin->modify('-7 day');
$weeklySuffix = '_'.$this->l10n->t('weekly').'_'.$dateWeekMin->format('Y-m-d');
$weeklySuffix = '_' . $this->l10n->t('weekly') . '_' . $dateWeekMin->format('Y-m-d');
// last month
$now = new DateTime();
while (((int) $now->format('d')) !== 1) {
while (((int)$now->format('d')) !== 1) {
$now->modify('-1 day');
}
$y = $now->format('Y');
$m = $now->format('m');
$d = $now->format('d');
$dateMonthMax = new DateTime($y.'-'.$m.'-'.$d);
$dateMonthMax = new DateTime($y . '-' . $m . '-' . $d);
$maxMonthTimestamp = $dateMonthMax->getTimestamp();
$now->modify('-1 day');
while (((int) $now->format('d')) !== 1) {
while (((int)$now->format('d')) !== 1) {
$now->modify('-1 day');
}
$y = (int) $now->format('Y');
$m = (int) $now->format('m');
$d = (int) $now->format('d');
$dateMonthMin = new DateTime($y.'-'.$m.'-'.$d);
$y = (int)$now->format('Y');
$m = (int)$now->format('m');
$d = (int)$now->format('d');
$dateMonthMin = new DateTime($y . '-' . $m . '-' . $d);
$minMonthTimestamp = $dateMonthMin->getTimestamp();
$monthlySuffix = '_'.$this->l10n->t('monthly').'_'.$dateMonthMin->format('Y-m');
$monthlySuffix = '_' . $this->l10n->t('monthly') . '_' . $dateMonthMin->format('Y-m');
// $weekFilterArray = [];
// $weekFilterArray['tsmin'] = $minWeekTimestamp;
@@ -813,10 +813,10 @@ class CospendService {
}
// create file
if ($folder->nodeExists($projectId.'-settlement.csv')) {
$folder->get($projectId.'-settlement.csv')->delete();
if ($folder->nodeExists($projectId . '-settlement.csv')) {
$folder->get($projectId . '-settlement.csv')->delete();
}
$file = $folder->newFile($projectId.'-settlement.csv');
$file = $folder->newFile($projectId . '-settlement.csv');
$handler = $file->fopen('w');
fwrite(
$handler,
@@ -837,7 +837,7 @@ class CospendService {
$handler,
'"' . $memberIdToName[$transaction['from']]
. '","' . $memberIdToName[$transaction['to']]
. '",' . (float) $transaction['amount']
. '",' . (float)$transaction['amount']
. "\n"
);
}
@@ -862,7 +862,7 @@ class CospendService {
* @throws NotPermittedException
*/
public function exportCsvStatistics(
string $projectId, string $userId, array $statistics
string $projectId, string $userId, array $statistics,
): array {
// create export directory if needed
$outPath = $this->config->getUserValue($userId, 'cospend', 'outputDirectory', '/Cospend');
@@ -877,10 +877,10 @@ class CospendService {
}
// create file
if ($folder->nodeExists($projectId.'-stats.csv')) {
$folder->get($projectId.'-stats.csv')->delete();
if ($folder->nodeExists($projectId . '-stats.csv')) {
$folder->get($projectId . '-stats.csv')->delete();
}
$file = $folder->newFile($projectId.'-stats.csv');
$file = $folder->newFile($projectId . '-stats.csv');
$handler = $file->fopen('w');
fwrite(
$handler,
@@ -896,9 +896,9 @@ class CospendService {
fwrite(
$handler,
'"' . $stat['member']['name']
. '",' . (float) $stat['paid']
. ',' . (float) $stat['spent']
. ',' . (float) $stat['balance']
. '",' . (float)$stat['paid']
. ',' . (float)$stat['spent']
. ',' . (float)$stat['balance']
. "\n"
);
}
@@ -937,7 +937,7 @@ class CospendService {
}
// create file
$filename = $projectId.'.csv';
$filename = $projectId . '.csv';
if ($name !== null) {
$filename = $name;
if (!str_ends_with($filename, '.csv')) {
@@ -973,12 +973,12 @@ class CospendService {
foreach ($members as $member) {
$memberIdToName[$member['id']] = $member['name'];
$memberIdToWeight[$member['id']] = $member['weight'];
$memberIdToActive[$member['id']] = (int) $member['activated'];
$memberIdToActive[$member['id']] = (int)$member['activated'];
$c = $member['color'];
yield '"' . $member['name'] . '",'
. (float) $member['weight'] . ','
. (int) $member['activated'] . ',"'
. sprintf("#%02x%02x%02x", $c['r'] ?? 0, $c['g'] ?? 0, $c['b'] ?? 0) . '"'
. (float)$member['weight'] . ','
. (int)$member['activated'] . ',"'
. sprintf('#%02x%02x%02x', $c['r'] ?? 0, $c['g'] ?? 0, $c['b'] ?? 0) . '"'
. "\n";
}
// bills
@@ -997,16 +997,16 @@ class CospendService {
$dateTime = DateTime::createFromFormat('U', $bill['timestamp']);
$oldDateStr = $dateTime->format('Y-m-d');
yield '"' . $bill['what'] . '",'
. (float) $bill['amount'] . ','
. (float)$bill['amount'] . ','
. $oldDateStr . ','
. $bill['timestamp'] . ',"'
. $payer_name . '",'
. (float) $payer_weight . ','
. (float)$payer_weight . ','
. $payer_active . ',"'
. $owersTxt . '",'
. $bill['repeat'] . ','
. $bill['repeatfreq'] . ','
. $bill['repeatallactive'] .','
. $bill['repeatallactive'] . ','
. $bill['repeatuntil'] . ','
. $bill['categoryid'] . ','
. $bill['paymentmode'] . ','
@@ -1022,7 +1022,7 @@ class CospendService {
yield "\ncategoryname,categoryid,icon,color\n";
foreach ($categories as $id => $cat) {
yield '"' . $cat['name'] . '",' .
(int) $id . ',"' .
(int)$id . ',"' .
$cat['icon'] . '","' .
$cat['color'] . '"' .
"\n";
@@ -1035,7 +1035,7 @@ class CospendService {
yield "\npaymentmodename,paymentmodeid,icon,color\n";
foreach ($paymentModes as $id => $pm) {
yield '"' . $pm['name'] . '",' .
(int) $id . ',"' .
(int)$id . ',"' .
$pm['icon'] . '","' .
$pm['color'] . '"' .
"\n";
@@ -1050,7 +1050,7 @@ class CospendService {
yield '"' . $projectInfo['currencyname'] . '",1' . "\n";
foreach ($currencies as $cur) {
yield '"' . $cur['name']
. '",' . (float) $cur['exchange_rate']
. '",' . (float)$cur['exchange_rate']
. "\n";
}
}

View File

@@ -128,7 +128,7 @@ class FederatedProjectService implements IProjectService {
public function getBills(
string $projectId, ?int $lastChanged = null, ?int $offset = 0, ?int $limit = null, bool $reverse = false,
?int $payerId = null, ?int $categoryId = null, ?int $paymentModeId = null, ?int $includeBillId = null,
?string $searchTerm = null, ?int $deleted = 0
?string $searchTerm = null, ?int $deleted = 0,
): array {
$params = [
'lastChanged' => $lastChanged,
@@ -154,7 +154,7 @@ class FederatedProjectService implements IProjectService {
?float $amount, ?string $repeat, ?string $paymentMode = null, ?int $paymentModeId = null,
?int $categoryId = null, int $repeatAllActive = 0, ?string $repeatUntil = null,
?int $timestamp = null, ?string $comment = null, ?int $repeatFreq = null,
int $deleted = 0, bool $produceActivity = false
int $deleted = 0, bool $produceActivity = false,
): int {
$params = [
'date' => $date,
@@ -197,7 +197,7 @@ class FederatedProjectService implements IProjectService {
?float $amount, ?string $repeat, ?string $paymentMode = null, ?int $paymentModeId = null,
?int $categoryId = null, ?int $repeatAllActive = null, ?string $repeatUntil = null,
?int $timestamp = null, ?string $comment = null, ?int $repeatFreq = null,
?int $deleted = null, bool $produceActivity = false
?int $deleted = null, bool $produceActivity = false,
): void {
$params = [
'date' => $date,
@@ -226,7 +226,7 @@ class FederatedProjectService implements IProjectService {
?string $paymentMode = null, ?int $paymentModeId = null,
?int $categoryId = null,
?int $repeatAllActive = null, ?string $repeatUntil = null, ?int $timestamp = null,
?string $comment = null, ?int $repeatFreq = null, ?int $deleted = null, bool $produceActivity = false
?string $comment = null, ?int $repeatFreq = null, ?int $deleted = null, bool $produceActivity = false,
): void {
$params = [
'billIds' => $billIds,
@@ -260,7 +260,7 @@ class FederatedProjectService implements IProjectService {
public function getStatistics(
string $projectId, ?int $tsMin = null, ?int $tsMax = null,
?int $paymentModeId = null, ?int $categoryId = null, ?float $amountMin = null, ?float $amountMax = null,
bool $showDisabled = true, ?int $currencyId = null, ?int $payerId = null
bool $showDisabled = true, ?int $currencyId = null, ?int $payerId = null,
): array {
$params = [
'tsMin' => $tsMin,
@@ -296,7 +296,7 @@ class FederatedProjectService implements IProjectService {
public function editProject(
string $projectId, ?string $name = null, ?string $contact_email = null,
?string $autoExport = null, ?string $currencyName = null, ?bool $deletionDisabled = null,
?string $categorySort = null, ?string $paymentModeSort = null, ?int $archivedTs = null
?string $categorySort = null, ?string $paymentModeSort = null, ?int $archivedTs = null,
): void {
$params = [
'name' => $name,
@@ -313,7 +313,7 @@ class FederatedProjectService implements IProjectService {
public function createMember(
string $projectId, string $name, ?float $weight = 1.0, bool $active = true,
?string $color = null, ?string $userId = null
?string $color = null, ?string $userId = null,
): array {
$params = [
'name' => $name,
@@ -338,7 +338,7 @@ class FederatedProjectService implements IProjectService {
public function editMember(
string $projectId, int $memberId, ?string $name = null, ?string $userId = null,
?float $weight = null, ?bool $activated = null, ?string $color = null
?float $weight = null, ?bool $activated = null, ?string $color = null,
): ?array {
$params = [
'name' => $name,
@@ -403,7 +403,7 @@ class FederatedProjectService implements IProjectService {
}
public function editCategory(
string $projectId, int $categoryId, ?string $name = null, ?string $icon = null, ?string $color = null
string $projectId, int $categoryId, ?string $name = null, ?string $icon = null, ?string $color = null,
): array {
$params = [
'name' => $name,

View File

@@ -53,7 +53,7 @@ interface IProjectService {
public function getStatistics(
string $projectId, ?int $tsMin = null, ?int $tsMax = null,
?int $paymentModeId = null, ?int $categoryId = null, ?float $amountMin = null, ?float $amountMax = null,
bool $showDisabled = true, ?int $currencyId = null, ?int $payerId = null
bool $showDisabled = true, ?int $currencyId = null, ?int $payerId = null,
): array;
/**
@@ -91,7 +91,7 @@ interface IProjectService {
*/
public function editMember(
string $projectId, int $memberId, ?string $name = null, ?string $userId = null,
?float $weight = null, ?bool $activated = null, ?string $color = null
?float $weight = null, ?bool $activated = null, ?string $color = null,
): ?array;
@@ -112,7 +112,7 @@ interface IProjectService {
public function editProject(
string $projectId, ?string $name = null, ?string $contact_email = null,
?string $autoExport = null, ?string $currencyName = null, ?bool $deletionDisabled = null,
?string $categorySort = null, ?string $paymentModeSort = null, ?int $archivedTs = null
?string $categorySort = null, ?string $paymentModeSort = null, ?int $archivedTs = null,
): void;
/**
@@ -128,7 +128,7 @@ interface IProjectService {
*/
public function createMember(
string $projectId, string $name, ?float $weight = 1.0, bool $active = true,
?string $color = null, ?string $userId = null
?string $color = null, ?string $userId = null,
): array;
/**
@@ -169,7 +169,7 @@ interface IProjectService {
public function getBills(
string $projectId, ?int $lastChanged = null, ?int $offset = 0, ?int $limit = null, bool $reverse = false,
?int $payerId = null, ?int $categoryId = null, ?int $paymentModeId = null, ?int $includeBillId = null,
?string $searchTerm = null, ?int $deleted = 0
?string $searchTerm = null, ?int $deleted = 0,
): array;
/**
@@ -206,7 +206,7 @@ interface IProjectService {
?float $amount, ?string $repeat, ?string $paymentMode = null, ?int $paymentModeId = null,
?int $categoryId = null, int $repeatAllActive = 0, ?string $repeatUntil = null,
?int $timestamp = null, ?string $comment = null, ?int $repeatFreq = null,
int $deleted = 0, bool $produceActivity = false
int $deleted = 0, bool $produceActivity = false,
): int;
/**
@@ -220,7 +220,7 @@ interface IProjectService {
* @return void
*/
public function deleteBill(
string $projectId, int $billId, bool $force = false, bool $moveToTrash = true, bool $produceActivity = false
string $projectId, int $billId, bool $force = false, bool $moveToTrash = true, bool $produceActivity = false,
): void;
/**
@@ -259,7 +259,7 @@ interface IProjectService {
?float $amount, ?string $repeat, ?string $paymentMode = null, ?int $paymentModeId = null,
?int $categoryId = null, ?int $repeatAllActive = null, ?string $repeatUntil = null,
?int $timestamp = null, ?string $comment = null, ?int $repeatFreq = null,
?int $deleted = null, bool $produceActivity = false
?int $deleted = null, bool $produceActivity = false,
): void;
/**
@@ -290,7 +290,7 @@ interface IProjectService {
?string $paymentMode = null, ?int $paymentModeId = null,
?int $categoryId = null,
?int $repeatAllActive = null, ?string $repeatUntil = null, ?int $timestamp = null,
?string $comment = null, ?int $repeatFreq = null, ?int $deleted = null, bool $produceActivity = false
?string $comment = null, ?int $repeatFreq = null, ?int $deleted = null, bool $produceActivity = false,
): void;
/**
@@ -339,7 +339,7 @@ interface IProjectService {
* @return array
*/
public function editPaymentMode(
string $projectId, int $pmId, ?string $name = null, ?string $icon = null, ?string $color = null
string $projectId, int $pmId, ?string $name = null, ?string $icon = null, ?string $color = null,
): array;
/**
@@ -383,7 +383,7 @@ interface IProjectService {
* @return array
*/
public function editCategory(
string $projectId, int $categoryId, ?string $name = null, ?string $icon = null, ?string $color = null
string $projectId, int $categoryId, ?string $name = null, ?string $icon = null, ?string $color = null,
): array;
/**

View File

@@ -275,7 +275,7 @@ class LocalProjectService implements IProjectService {
*/
public function createProject(
string $name, string $id, ?string $contact_email, string $userId = '',
bool $createDefaultCategories = true, bool $createDefaultPaymentModes = true
bool $createDefaultCategories = true, bool $createDefaultPaymentModes = true,
): array {
$newProject = $this->projectMapper->createProject(
$name, $id, $contact_email, $this->defaultCategories, $this->defaultPaymentModes,
@@ -408,7 +408,7 @@ class LocalProjectService implements IProjectService {
);
$req = $qb->executeQuery();
while ($row = $req->fetch()) {
$totalSpent = (float) $row['sum_amount'];
$totalSpent = (float)$row['sum_amount'];
}
return [
@@ -437,7 +437,7 @@ class LocalProjectService implements IProjectService {
public function getStatistics(
string $projectId, ?int $tsMin = null, ?int $tsMax = null,
?int $paymentModeId = null, ?int $categoryId = null, ?float $amountMin = null, ?float $amountMax = null,
bool $showDisabled = true, ?int $currencyId = null, ?int $payerId = null
bool $showDisabled = true, ?int $currencyId = null, ?int $payerId = null,
): array {
$timeZone = $this->dateTimeZone->getTimeZone();
$membersWeight = [];
@@ -486,7 +486,7 @@ class LocalProjectService implements IProjectService {
$memberId = $member['id'];
$allMembersIds[] = $memberId;
// only take enabled members or those with non-zero balance
$mBalance = (float) $membersBalance[$memberId];
$mBalance = (float)$membersBalance[$memberId];
if ($showDisabled || $member['activated'] || $mBalance >= 0.01 || $mBalance <= -0.01) {
$membersToDisplay[$memberId] = $member;
}
@@ -843,7 +843,7 @@ class LocalProjectService implements IProjectService {
public function getBills(
string $projectId, ?int $lastChanged = null, ?int $offset = 0, ?int $limit = null, bool $reverse = false,
?int $payerId = null, ?int $categoryId = null, ?int $paymentModeId = null, ?int $includeBillId = null,
?string $searchTerm = null, ?int $deleted = 0
?string $searchTerm = null, ?int $deleted = 0,
): array {
if ($limit) {
$bills = $this->billMapper->getBillsWithLimit(
@@ -901,7 +901,7 @@ class LocalProjectService implements IProjectService {
?float $amount, ?string $repeat, ?string $paymentMode = null, ?int $paymentModeId = null,
?int $categoryId = null, int $repeatAllActive = 0, ?string $repeatUntil = null,
?int $timestamp = null, ?string $comment = null, ?int $repeatFreq = null,
int $deleted = 0, bool $produceActivity = false
int $deleted = 0, bool $produceActivity = false,
): int {
// if we don't have the payment modes, get them now
if ($this->paymentModes === null) {
@@ -951,7 +951,7 @@ class LocalProjectService implements IProjectService {
if (!is_numeric($owerId)) {
throw new CospendBasicException('payed_for is not valid', Http::STATUS_BAD_REQUEST);
}
if ($this->getMemberById($projectId, (int) $owerId) === null) {
if ($this->getMemberById($projectId, (int)$owerId) === null) {
throw new CospendBasicException('payed_for is not valid', Http::STATUS_BAD_REQUEST);
}
}
@@ -1036,7 +1036,7 @@ class LocalProjectService implements IProjectService {
* @throws \OCP\DB\Exception
*/
public function deleteBill(
string $projectId, int $billId, bool $force = false, bool $moveToTrash = true, bool $produceActivity = false
string $projectId, int $billId, bool $force = false, bool $moveToTrash = true, bool $produceActivity = false,
): void {
if ($force === false) {
$project = $this->getProjectInfo($projectId);
@@ -1132,8 +1132,8 @@ class LocalProjectService implements IProjectService {
foreach ($transactions as $transaction) {
$fromId = $transaction['from'];
$toId = $transaction['to'];
$amount = round((float) $transaction['amount'], $precision);
$billTitle = $memberIdToName[$fromId].' → '.$memberIdToName[$toId];
$amount = round((float)$transaction['amount'], $precision);
$billTitle = $memberIdToName[$fromId] . ' → ' . $memberIdToName[$toId];
try {
$this->createBill(
$projectId, null, $billTitle, $fromId, $toId, $amount,
@@ -1330,7 +1330,7 @@ class LocalProjectService implements IProjectService {
*/
public function editMember(
string $projectId, int $memberId, ?string $name = null, ?string $userId = null,
?float $weight = null, ?bool $activated = null, ?string $color = null
?float $weight = null, ?bool $activated = null, ?string $color = null,
): ?array {
$dbMember = $this->memberMapper->getMemberById($projectId, $memberId);
if ($dbMember === null) {
@@ -1404,7 +1404,7 @@ class LocalProjectService implements IProjectService {
public function editProject(
string $projectId, ?string $name = null, ?string $contact_email = null,
?string $autoExport = null, ?string $currencyName = null, ?bool $deletionDisabled = null,
?string $categorySort = null, ?string $paymentModeSort = null, ?int $archivedTs = null
?string $categorySort = null, ?string $paymentModeSort = null, ?int $archivedTs = null,
): void {
$dbProject = $this->projectMapper->find($projectId);
if ($dbProject === null) {
@@ -1471,7 +1471,7 @@ class LocalProjectService implements IProjectService {
*/
public function createMember(
string $projectId, string $name, ?float $weight = 1.0, bool $active = true,
?string $color = null, ?string $userId = null
?string $color = null, ?string $userId = null,
): array {
if ($name === '') {
throw new CospendBasicException('', Http::STATUS_BAD_REQUEST, ['error' => $this->l10n->t('Name field is required')]);
@@ -1844,7 +1844,7 @@ class LocalProjectService implements IProjectService {
$req = $qb->executeQuery();
$order = 0;
while ($row = $req->fetch()) {
$dbId = (int) $row['id'];
$dbId = (int)$row['id'];
$mostUsedOrder[$dbId] = $order++;
}
$req->closeCursor();
@@ -1870,7 +1870,7 @@ class LocalProjectService implements IProjectService {
$req = $qb->executeQuery();
$order = 0;
while ($row = $req->fetch()) {
$dbId = (int) $row['id'];
$dbId = (int)$row['id'];
$mostUsedOrder[$dbId] = $order++;
}
$req->closeCursor();
@@ -2119,7 +2119,7 @@ class LocalProjectService implements IProjectService {
?float $amount, ?string $repeat, ?string $paymentMode = null, ?int $paymentModeId = null,
?int $categoryId = null, ?int $repeatAllActive = null, ?string $repeatUntil = null,
?int $timestamp = null, ?string $comment = null, ?int $repeatFreq = null,
?int $deleted = null, bool $produceActivity = false
?int $deleted = null, bool $produceActivity = false,
): void {
// if we don't have the payment modes, get them now
if ($this->paymentModes === null) {
@@ -2166,7 +2166,7 @@ class LocalProjectService implements IProjectService {
if (!is_numeric($owerId)) {
throw new CospendBasicException('', Http::STATUS_BAD_REQUEST, ['payed_for' => $this->l10n->t('Invalid value')]);
}
if ($this->getMemberById($projectId, (int) $owerId) === null) {
if ($this->getMemberById($projectId, (int)$owerId) === null) {
throw new CospendBasicException('', Http::STATUS_BAD_REQUEST, ['payed_for' => $this->l10n->t('Not a valid choice')]);
}
}
@@ -2300,7 +2300,7 @@ class LocalProjectService implements IProjectService {
?string $paymentMode = null, ?int $paymentModeId = null,
?int $categoryId = null,
?int $repeatAllActive = null, ?string $repeatUntil = null, ?int $timestamp = null,
?string $comment = null, ?int $repeatFreq = null, ?int $deleted = null, bool $produceActivity = false
?string $comment = null, ?int $repeatFreq = null, ?int $deleted = null, bool $produceActivity = false,
): void {
foreach ($billIds as $billId) {
$this->editBill(
@@ -2550,7 +2550,7 @@ class LocalProjectService implements IProjectService {
$bill = $this->billMapper->getBill($projectId, $billId);
$owerIds = [];
if (((int) $bill['repeatallactive']) === 1) {
if (((int)$bill['repeatallactive']) === 1) {
$pInfo = $this->getProjectInfo($projectId);
foreach ($pInfo['active_members'] as $am) {
$owerIds[] = $am['id'];
@@ -2643,9 +2643,9 @@ class LocalProjectService implements IProjectService {
break;
case Application::FREQUENCY_SEMI_MONTHLY:
$day = (int) $billDate->format('d');
$month = (int) $billDate->format('m');
$year = (int) $billDate->format('Y');
$day = (int)$billDate->format('d');
$month = (int)$billDate->format('m');
$year = (int)$billDate->format('Y');
// first of next month
if ($day >= 15) {
@@ -2665,15 +2665,15 @@ class LocalProjectService implements IProjectService {
case Application::FREQUENCY_MONTHLY:
$freq = ($bill['repeatfreq'] < 2) ? 1 : $bill['repeatfreq'];
$billMonth = (int) $billDate->format('m');
$billMonth = (int)$billDate->format('m');
$yearDelta = intdiv($billMonth + $freq - 1, 12);
$nextYear = ((int) $billDate->format('Y')) + $yearDelta;
$nextYear = ((int)$billDate->format('Y')) + $yearDelta;
$nextMonth = (($billMonth + $freq - 1) % 12) + 1;
// same day of month if possible, otherwise at end of month
$firstOfNextMonth = $billDate->setDate($nextYear, $nextMonth, 1);
$billDay = (int) $billDate->format('d');
$nbDaysInTargetMonth = (int) $firstOfNextMonth->format('t');
$billDay = (int)$billDate->format('d');
$nbDaysInTargetMonth = (int)$firstOfNextMonth->format('t');
if ($billDay > $nbDaysInTargetMonth) {
return $billDate->setDate($nextYear, $nextMonth, $nbDaysInTargetMonth);
} else {
@@ -2683,14 +2683,14 @@ class LocalProjectService implements IProjectService {
case Application::FREQUENCY_YEARLY:
$freq = ($bill['repeatfreq'] < 2) ? 1 : $bill['repeatfreq'];
$billYear = (int) $billDate->format('Y');
$billMonth = (int) $billDate->format('m');
$billDay = (int) $billDate->format('d');
$billYear = (int)$billDate->format('Y');
$billMonth = (int)$billDate->format('m');
$billDay = (int)$billDate->format('d');
$nextYear = $billYear + $freq;
// same day of month if possible, otherwise at end of month + same month
$firstDayOfTargetMonth = $billDate->setDate($nextYear, $billMonth, 1);
$nbDaysInTargetMonth = (int) $firstDayOfTargetMonth->format('t');
$nbDaysInTargetMonth = (int)$firstDayOfTargetMonth->format('t');
if ($billDay > $nbDaysInTargetMonth) {
return $billDate->setDate($nextYear, $billMonth, $nbDaysInTargetMonth);
} else {
@@ -2784,7 +2784,7 @@ class LocalProjectService implements IProjectService {
* @throws \OCP\DB\Exception
*/
public function editPaymentMode(
string $projectId, int $pmId, ?string $name = null, ?string $icon = null, ?string $color = null
string $projectId, int $pmId, ?string $name = null, ?string $icon = null, ?string $color = null,
): array {
if ($name === null || $name === '') {
throw new CospendBasicException('', Http::STATUS_BAD_REQUEST, ['message' => $this->l10n->t('Incorrect field values')]);
@@ -2889,7 +2889,7 @@ class LocalProjectService implements IProjectService {
* @throws \OCP\DB\Exception
*/
public function editCategory(
string $projectId, int $categoryId, ?string $name = null, ?string $icon = null, ?string $color = null
string $projectId, int $categoryId, ?string $name = null, ?string $icon = null, ?string $color = null,
): array {
if ($name === null || $name === '') {
throw new CospendBasicException('', Http::STATUS_BAD_REQUEST, ['message' => $this->l10n->t('Incorrect field values')]);
@@ -2982,7 +2982,7 @@ class LocalProjectService implements IProjectService {
*/
public function createFederatedShare(
string $projectId, string $userCloudId, string $fromUserId, int $accessLevel = Application::ACCESS_LEVEL_PARTICIPANT,
bool $manually_added = true
bool $manually_added = true,
): Share {
try {
$this->shareMapper->getFederatedShareByProjectIdAndUserCloudId($projectId, $userCloudId);
@@ -3071,7 +3071,7 @@ class LocalProjectService implements IProjectService {
*/
public function createUserShare(
string $projectId, string $userId, string $fromUserId, int $accesslevel = Application::ACCESS_LEVEL_PARTICIPANT,
bool $manually_added = true
bool $manually_added = true,
): array {
$user = $this->userManager->get($userId);
if ($user === null || $userId === $fromUserId) {
@@ -3149,7 +3149,7 @@ class LocalProjectService implements IProjectService {
* @throws \OCP\DB\Exception
*/
public function createPublicShare(
string $projectId, ?string $label = null, ?string $password = null, int $accesslevel = Application::ACCESS_LEVEL_PARTICIPANT
string $projectId, ?string $label = null, ?string $password = null, int $accesslevel = Application::ACCESS_LEVEL_PARTICIPANT,
): array {
$shareToken = $this->secureRandom->generate(
FederationManager::TOKEN_LENGTH,
@@ -3374,7 +3374,7 @@ class LocalProjectService implements IProjectService {
* @throws \OCP\DB\Exception
*/
public function createGroupShare(
string $projectId, string $groupId, ?string $fromUserId = null, int $accessLevel = Application::ACCESS_LEVEL_PARTICIPANT
string $projectId, string $groupId, ?string $fromUserId = null, int $accessLevel = Application::ACCESS_LEVEL_PARTICIPANT,
): array {
if (!$this->groupManager->groupExists($groupId)) {
return ['message' => $this->l10n->t('No such group')];
@@ -3445,7 +3445,7 @@ class LocalProjectService implements IProjectService {
* @throws \OCP\DB\Exception
*/
public function createCircleShare(
string $projectId, string $circleId, ?string $fromUserId = null, int $accesslevel = Application::ACCESS_LEVEL_PARTICIPANT
string $projectId, string $circleId, ?string $fromUserId = null, int $accesslevel = Application::ACCESS_LEVEL_PARTICIPANT,
): array {
// check if circleId exists
$circlesEnabled = $this->appManager->isEnabledForUser('circles');

View File

@@ -24,7 +24,7 @@ class UserService {
public function __construct(
private ProjectMapper $projectMapper,
private IGroupManager $groupManager,
private IDBConnection $dbconnection
private IDBConnection $dbconnection,
) {
}
@@ -66,7 +66,7 @@ class UserService {
/** @var string[] $groupIds */
$groupIds = [];
while ($row = $req->fetch()) {
$groupIds[] = (string) $row['userid'];
$groupIds[] = (string)$row['userid'];
}
$req->closeCursor();
// get users of groups

View File

@@ -444,7 +444,7 @@ class LocalProjectServiceTest extends TestCase {
// create bills
$resp = $this->apiController->createBill(
'superproj', '2019-01-22', 'boomerang', $idMember1,
$idMember1.','.$idMember2, 22.5, Application::FREQUENCY_NO, null, $idPm1, $idCat1,
$idMember1 . ',' . $idMember2, 22.5, Application::FREQUENCY_NO, null, $idPm1, $idCat1,
0, '2049-01-01'
);
$status = $resp->getStatus();
@@ -509,7 +509,7 @@ class LocalProjectServiceTest extends TestCase {
// add a bill with this payment mode
$resp = $this->apiController->createBill(
'superproj', '2019-01-22', 'boomerang', $idMember1,
$idMember1.','.$idMember2, 22.5, Application::FREQUENCY_NO, null, $oneDefPm['id'], $idCat1,
$idMember1 . ',' . $idMember2, 22.5, Application::FREQUENCY_NO, null, $oneDefPm['id'], $idCat1,
0, '2049-01-01'
);
$status = $resp->getStatus();
@@ -535,7 +535,7 @@ class LocalProjectServiceTest extends TestCase {
// edit a bill with this payment mode
$resp = $this->apiController->editBill(
'superproj', $idBillPm, '2019-01-22', 'boomerang', $idMember1,
$idMember1.','.$idMember2, 22.5, Application::FREQUENCY_NO, null, $otherDefPm['id'], $idCat1,
$idMember1 . ',' . $idMember2, 22.5, Application::FREQUENCY_NO, null, $otherDefPm['id'], $idCat1,
0, '2049-01-01'
);
$status = $resp->getStatus();
@@ -550,7 +550,7 @@ class LocalProjectServiceTest extends TestCase {
$resp = $this->apiController->editBill(
'superproj', $idBillPm, '2019-01-22', 'boomerang', $idMember1,
$idMember1.','.$idMember2, 22.5, Application::FREQUENCY_NO, $oneDefPm['old_id'], null, $idCat1,
$idMember1 . ',' . $idMember2, 22.5, Application::FREQUENCY_NO, $oneDefPm['old_id'], null, $idCat1,
0, '2049-01-01'
);
$status = $resp->getStatus();
@@ -566,7 +566,7 @@ class LocalProjectServiceTest extends TestCase {
// add bill with old pm id, it should affect the matching default pm
$resp = $this->apiController->createBill(
'superproj', '2019-01-22', 'boomerang', $idMember1,
$idMember1.','.$idMember2, 22.5, Application::FREQUENCY_NO,
$idMember1 . ',' . $idMember2, 22.5, Application::FREQUENCY_NO,
'c', null, $idCat1,
0, '2049-01-01'
);
@@ -652,7 +652,7 @@ class LocalProjectServiceTest extends TestCase {
$this->assertTrue(isset($data['error'], $data['error']['message']));
$this->assertFalse(isset($data['inserted_id']));
$resp = $this->apiController->createBill('superproj', '2019-01-20', 'lala', $idMember2, $idMember1.',aa', 12.3, 'n');
$resp = $this->apiController->createBill('superproj', '2019-01-20', 'lala', $idMember2, $idMember1 . ',aa', 12.3, 'n');
$status = $resp->getStatus();
$this->assertEquals(Http::STATUS_BAD_REQUEST, $status);
$data = $resp->getData();
@@ -666,7 +666,7 @@ class LocalProjectServiceTest extends TestCase {
// edit bill
$resp = $this->apiController->editBill(
'superproj', $idBill1, '2039-02-02', 'kangaroo', $idMember2,
$idMember1.','.$idMember2, 99, Application::FREQUENCY_MONTHLY, null,
$idMember1 . ',' . $idMember2, 99, Application::FREQUENCY_MONTHLY, null,
$idPm2, $idCat2, 1, '2021-09-10',
null, 'newcom', 2
);
@@ -725,7 +725,7 @@ class LocalProjectServiceTest extends TestCase {
$resp = $this->apiController->editBill(
'superproj', $idBill1, null, 'boomerang', $idMember2,
$idMember1.','.$idMember2, 99, Application::FREQUENCY_MONTHLY, null,
$idMember1 . ',' . $idMember2, 99, Application::FREQUENCY_MONTHLY, null,
null, null, 1, '',
123456789, 'newcom', 2
);
@@ -740,37 +740,37 @@ class LocalProjectServiceTest extends TestCase {
// $status = $resp->getStatus();
// $this->assertEquals(Http::STATUS_UNAUTHORIZED, $status);
$resp = $this->apiController->editBill('superproj', -1, '2019-01-20', 'boomerang', $idMember1, $idMember1.','.$idMember2, 99, 'n');
$resp = $this->apiController->editBill('superproj', -1, '2019-01-20', 'boomerang', $idMember1, $idMember1 . ',' . $idMember2, 99, 'n');
$status = $resp->getStatus();
$this->assertEquals(Http::STATUS_BAD_REQUEST, $status);
$resp = $this->apiController->editBill(
'superproj', $idBill1, '2019-01-20', 'boomerang', $idMember1,
$idMember1.','.$idMember2, 99, Application::FREQUENCY_MONTHLY . 'wrong_value', null,
$idMember1 . ',' . $idMember2, 99, Application::FREQUENCY_MONTHLY . 'wrong_value', null,
null, null, null, null,
null, 'newcom', 2
);
$status = $resp->getStatus();
$this->assertEquals(Http::STATUS_BAD_REQUEST, $status);
$resp = $this->apiController->editBill('superproj', $idBill1, '2019-01-20', '', $idMember1, $idMember1.','.$idMember2, 99, 'n');
$resp = $this->apiController->editBill('superproj', $idBill1, '2019-01-20', '', $idMember1, $idMember1 . ',' . $idMember2, 99, 'n');
$status = $resp->getStatus();
$this->assertEquals(Http::STATUS_OK, $status);
$resp = $this->apiController->editBill('superproj', $idBill1, '2019-01-20', 'boomerang', $idMember1, $idMember1.','.$idMember2, 99, '');
$resp = $this->apiController->editBill('superproj', $idBill1, '2019-01-20', 'boomerang', $idMember1, $idMember1 . ',' . $idMember2, 99, '');
$status = $resp->getStatus();
$this->assertEquals(Http::STATUS_OK, $status);
// invalid date
$resp = $this->apiController->editBill('superproj', $idBill1, 'aaa', 'boomerang', $idMember1, $idMember1.','.$idMember2, 99, '');
$resp = $this->apiController->editBill('superproj', $idBill1, 'aaa', 'boomerang', $idMember1, $idMember1 . ',' . $idMember2, 99, '');
$status = $resp->getStatus();
$this->assertEquals(Http::STATUS_BAD_REQUEST, $status);
$resp = $this->apiController->editBill('superproj', $idBill1, '2019-01-20', 'boomerang', 0, $idMember1.','.$idMember2, 99, 'n');
$resp = $this->apiController->editBill('superproj', $idBill1, '2019-01-20', 'boomerang', 0, $idMember1 . ',' . $idMember2, 99, 'n');
$status = $resp->getStatus();
$this->assertEquals(Http::STATUS_BAD_REQUEST, $status);
$resp = $this->apiController->editBill('superproj', $idBill1, '2019-01-20', 'boomerang', $idMember1, '0,'.$idMember2, 99, 'n');
$resp = $this->apiController->editBill('superproj', $idBill1, '2019-01-20', 'boomerang', $idMember1, '0,' . $idMember2, 99, 'n');
$status = $resp->getStatus();
$this->assertEquals(Http::STATUS_BAD_REQUEST, $status);
@@ -1072,7 +1072,7 @@ class LocalProjectServiceTest extends TestCase {
// bill with no enabled owers
$resp = $this->apiController->editBill(
'superproj', $idBill2, '2019-02-02', 'kangaroo', $idMember2,
$idMember1.','.$idMember2, 99, Application::FREQUENCY_YEARLY, null,
$idMember1 . ',' . $idMember2, 99, Application::FREQUENCY_YEARLY, null,
$idPm2, $idCat2, 0, '2021-03-10',
null, 'newcom', 1
);
@@ -1111,7 +1111,7 @@ class LocalProjectServiceTest extends TestCase {
// yearly
$resp = $this->apiController->editBill(
'superproj', $idBill2, '2019-02-02', 'kangaroo', $idMember2,
$idMember1.','.$idMember2, 99, Application::FREQUENCY_YEARLY, null,
$idMember1 . ',' . $idMember2, 99, Application::FREQUENCY_YEARLY, null,
$idPm2, $idCat2, 0, '2021-03-10',
null, 'newcom', 1
);
@@ -1144,7 +1144,7 @@ class LocalProjectServiceTest extends TestCase {
// yearly freq 2
$resp = $this->apiController->editBill(
'superproj', $idBill2, '2019-02-02', 'kangaroo', $idMember2,
$idMember1.','.$idMember2, 99, Application::FREQUENCY_YEARLY, null,
$idMember1 . ',' . $idMember2, 99, Application::FREQUENCY_YEARLY, null,
$idPm2, $idCat2, 1, '2021-03-10',
null, 'newcom', 2
);
@@ -1173,7 +1173,7 @@ class LocalProjectServiceTest extends TestCase {
// monthly
$resp = $this->apiController->editBill(
'superproj', $idBill2, '2019-02-02', 'kangaroo', $idMember2,
$idMember1.','.$idMember2, 99, Application::FREQUENCY_MONTHLY, null,
$idMember1 . ',' . $idMember2, 99, Application::FREQUENCY_MONTHLY, null,
$idPm2, $idCat2, 1, '2019-05-10',
null, 'newcom', 1
);
@@ -1202,7 +1202,7 @@ class LocalProjectServiceTest extends TestCase {
// monthly freq 2
$resp = $this->apiController->editBill(
'superproj', $idBill2, '2019-02-02', 'kangaroo', $idMember2,
$idMember1.','.$idMember2, 99, Application::FREQUENCY_MONTHLY, null,
$idMember1 . ',' . $idMember2, 99, Application::FREQUENCY_MONTHLY, null,
$idPm2, $idCat2, 1, '2019-06-10',
null, 'newcom', 2
);
@@ -1231,7 +1231,7 @@ class LocalProjectServiceTest extends TestCase {
// daily
$resp = $this->apiController->editBill(
'superproj', $idBill2, '2019-02-02', 'kangaroo', $idMember2,
$idMember1.','.$idMember2, 99, Application::FREQUENCY_DAILY, null,
$idMember1 . ',' . $idMember2, 99, Application::FREQUENCY_DAILY, null,
$idPm2, $idCat2, 1, '2019-02-12',
null, 'newcom', 1
);
@@ -1260,7 +1260,7 @@ class LocalProjectServiceTest extends TestCase {
// daily freq 2
$resp = $this->apiController->editBill(
'superproj', $idBill2, '2019-02-02', 'kangaroo', $idMember2,
$idMember1.','.$idMember2, 99, Application::FREQUENCY_DAILY, null,
$idMember1 . ',' . $idMember2, 99, Application::FREQUENCY_DAILY, null,
$idPm2, $idCat2, 1, '2019-02-12',
null, 'newcom', 2
);
@@ -1289,7 +1289,7 @@ class LocalProjectServiceTest extends TestCase {
// weekly
$resp = $this->apiController->editBill(
'superproj', $idBill2, '2019-03-02', 'kangaroo', $idMember2,
$idMember1.','.$idMember2, 99, Application::FREQUENCY_WEEKLY, null,
$idMember1 . ',' . $idMember2, 99, Application::FREQUENCY_WEEKLY, null,
$idPm2, $idCat2, 1, '2019-03-18',
null, 'newcom', 1
);
@@ -1318,7 +1318,7 @@ class LocalProjectServiceTest extends TestCase {
// weekly freq 2
$resp = $this->apiController->editBill(
'superproj', $idBill2, '2019-03-02', 'kangaroo', $idMember2,
$idMember1.','.$idMember2, 99, Application::FREQUENCY_WEEKLY, null,
$idMember1 . ',' . $idMember2, 99, Application::FREQUENCY_WEEKLY, null,
$idPm2, $idCat2, 1, '2019-03-18',
null, 'newcom', 2
);
@@ -1347,7 +1347,7 @@ class LocalProjectServiceTest extends TestCase {
// bi weekly
$resp = $this->apiController->editBill(
'superproj', $idBill2, '2019-03-02', 'kangaroo', $idMember2,
$idMember1.','.$idMember2, 99, Application::FREQUENCY_BI_WEEKLY, null,
$idMember1 . ',' . $idMember2, 99, Application::FREQUENCY_BI_WEEKLY, null,
$idPm2, $idCat2, 1, '2019-04-03',
null, 'newcom', 1
);
@@ -1376,7 +1376,7 @@ class LocalProjectServiceTest extends TestCase {
// semi monthly
$resp = $this->apiController->editBill(
'superproj', $idBill2, '2019-03-02', 'kangaroo', $idMember2,
$idMember1.','.$idMember2, 99, Application::FREQUENCY_SEMI_MONTHLY, null,
$idMember1 . ',' . $idMember2, 99, Application::FREQUENCY_SEMI_MONTHLY, null,
$idPm2, $idCat2, 1, '2019-04-14',
null, 'newcom', 1
);
@@ -1559,7 +1559,7 @@ class LocalProjectServiceTest extends TestCase {
// search bills
$resp = $this->apiController->createBill(
'superprojS', '2019-01-22', 'one', $idMember1,
$idMember1.','.$idMember2, 22.5, Application::FREQUENCY_NO, null, null, null,
$idMember1 . ',' . $idMember2, 22.5, Application::FREQUENCY_NO, null, null, null,
0, '2049-01-01', null, 'super comment 1'
);
$status = $resp->getStatus();
@@ -1568,7 +1568,7 @@ class LocalProjectServiceTest extends TestCase {
// $idBillSearch1 = $data;
$resp = $this->apiController->createBill(
'superprojS', '2019-01-22', 'two', $idMember1,
$idMember1.','.$idMember2, 22.5, Application::FREQUENCY_NO, null, null, null,
$idMember1 . ',' . $idMember2, 22.5, Application::FREQUENCY_NO, null, null, null,
0, '2049-01-01', null, 'ultra comment 2'
);
$status = $resp->getStatus();
@@ -1577,7 +1577,7 @@ class LocalProjectServiceTest extends TestCase {
$idBillSearch2 = $data;
$resp = $this->apiController->createBill(
'superprojS', '2019-01-22', 'three', $idMember1,
$idMember1.','.$idMember2, 22.5, Application::FREQUENCY_NO, null, null, null,
$idMember1 . ',' . $idMember2, 22.5, Application::FREQUENCY_NO, null, null, null,
0, '2049-01-01', null, 'mega comment 3'
);
$status = $resp->getStatus();
@@ -1625,7 +1625,7 @@ class LocalProjectServiceTest extends TestCase {
// search bills
$resp = $this->apiController->createBill(
'superprojS', '2019-01-22', 'one', $idMember1,
$idMember1.','.$idMember2, 22.5, Application::FREQUENCY_NO, null, $idPm1, $idCat1,
$idMember1 . ',' . $idMember2, 22.5, Application::FREQUENCY_NO, null, $idPm1, $idCat1,
0, '2049-01-01', null, 'super comment 1'
);
$status = $resp->getStatus();
@@ -1634,7 +1634,7 @@ class LocalProjectServiceTest extends TestCase {
// $idBill1 = $data;
$resp = $this->apiController->createBill(
'superprojS', '2019-01-22', 'two', $idMember2,
$idMember1.','.$idMember2, 22.5, Application::FREQUENCY_NO, null, null, $idCat1,
$idMember1 . ',' . $idMember2, 22.5, Application::FREQUENCY_NO, null, null, $idCat1,
0, '2049-01-01', null, 'ultra comment 2'
);
$status = $resp->getStatus();
@@ -1643,7 +1643,7 @@ class LocalProjectServiceTest extends TestCase {
// $idBill2 = $data;
$resp = $this->apiController->createBill(
'superprojS', '2019-01-22', 'three', $idMember1,
$idMember1.','.$idMember2, 22.5, Application::FREQUENCY_NO, null, null, null,
$idMember1 . ',' . $idMember2, 22.5, Application::FREQUENCY_NO, null, null, null,
0, '2049-01-01', null, 'mega comment 3'
);
$status = $resp->getStatus();
@@ -1703,7 +1703,7 @@ class LocalProjectServiceTest extends TestCase {
// search bills
$resp = $this->apiController->createBill(
$projectId, '2019-01-22', 'one', $idMember1,
$idMember1.','.$idMember2, 22.5, Application::FREQUENCY_NO, null, $idPm1, $idCat1,
$idMember1 . ',' . $idMember2, 22.5, Application::FREQUENCY_NO, null, $idPm1, $idCat1,
0, '2049-01-01', null, 'super comment 1'
);
$status = $resp->getStatus();
@@ -1712,7 +1712,7 @@ class LocalProjectServiceTest extends TestCase {
// $idBill1 = $data;
$resp = $this->apiController->createBill(
$projectId, '2019-01-22', 'two', $idMember2,
$idMember1.','.$idMember3, 22.5, Application::FREQUENCY_NO, null, null, $idCat1,
$idMember1 . ',' . $idMember3, 22.5, Application::FREQUENCY_NO, null, null, $idCat1,
0, '2049-01-01', null, 'ultra comment 2'
);
$status = $resp->getStatus();
@@ -1721,7 +1721,7 @@ class LocalProjectServiceTest extends TestCase {
// $idBill2 = $data;
$resp = $this->apiController->createBill(
$projectId, '2019-01-22', 'three', $idMember1,
$idMember1.','.$idMember2, 22.5, Application::FREQUENCY_NO, null, null, null,
$idMember1 . ',' . $idMember2, 22.5, Application::FREQUENCY_NO, null, null, null,
0, '2049-01-01', null, 'mega comment 3'
);
$status = $resp->getStatus();