Initial commit

This commit is contained in:
2026-07-05 21:52:31 +02:00
commit 93259f5b6d
35 changed files with 2389 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
<?php
namespace OCA\MoneyPlanner\Db;
use JsonSerializable;
use OCP\AppFramework\Db\Entity;
class Account extends Entity implements JsonSerializable {
protected $name;
protected $userId;
public function jsonSerialize() {
return [
'id' => $this->id,
'userId' => $this->userId,
'name' => $this->name
];
}
}
?>
+40
View File
@@ -0,0 +1,40 @@
<?php
namespace OCA\MoneyPlanner\Db;
use OCP\IDbConnection;
use OCP\AppFramework\Db\QBMapper;
class AccountMapper extends QBMapper {
public function __construct(IDbConnection $db) {
parent::__construct($db, 'moneyplanner_accounts', Account::class);
}
public function find(int $id, string $userId) {
$qb = $this->db->getQueryBuilder();
$qb->select('*')
->from($this->getTableName())
->where(
$qb->expr()->eq('id', $qb->createNamedParameter($id))
)->andWhere(
$qb->expr()->eq('user_id', $qb->createNamedParameter($userId))
);
return $this->findEntity($qb);
}
public function findAll(string $userId) {
$qb = $this->db->getQueryBuilder();
$qb->select('*')
->from($this->getTableName())
->where(
$qb->expr()->eq('user_id', $qb->createNamedParameter($userId))
);
return $this->findEntities($qb);
}
}
?>
+34
View File
@@ -0,0 +1,34 @@
<?php
namespace OCA\MoneyPlanner\Db;
use JsonSerializable;
use OCP\AppFramework\Db\Entity;
class Transaction extends Entity implements JsonSerializable {
protected $userId;
protected $accountFrom;
protected $accountTo;
protected $group;
protected $category;
protected $balance;
protected $date;
protected $freqNum;
protected $freqType;
public function jsonSerialize() {
return [
'id' => $this->id,
'userId' => $this->userId,
'accountFrom' => $this->accountFrom,
'accountTo' => $this->accountTo,
'group' => $this->group,
'category' => $this->category,
'balance' => $this->balance,
'date' => $this->date,
'freqNum' => $this->freqNum,
'freqType' => $this->freqType
];
}
}
+40
View File
@@ -0,0 +1,40 @@
<?php
namespace OCA\MoneyPlanner\Db;
use OCP\IDbConnection;
use OCP\AppFramework\Db\QBMapper;
class TransactionMapper extends QBMapper {
public function __construct(IDbConnection $db) {
parent::__construct($db, 'moneyplanner_transactions', Transaction::class);
}
public function find(int $id, string $userId) {
$qb = $this->db->getQueryBuilder();
$qb->select('*')
->from($this->getTableName())
->where(
$qb->expr()->eq('id', $qb->createNamedParameter($id))
)->andWhere(
$qb->expr()->eq('user_id', $qb->createNamedParameter($userId))
);
return $this->findEntity($qb);
}
public function findAll(string $userId) {
$qb = $this->db->getQueryBuilder();
$qb->select('*')
->from($this->getTableName())
->where(
$qb->expr()->eq('user_id', $qb->createNamedParameter($userId))
);
return $this->findEntities($qb);
}
}
?>