Fix category creation & updating
Signed-off-by: William Brawner <me@wbrawner.com>
This commit is contained in:
parent
02947db565
commit
ba1ffd5cc6
3 changed files with 10 additions and 3 deletions
|
@ -88,7 +88,7 @@ class CategoryController extends Controller
|
|||
* @param int amount
|
||||
* @param bool expense
|
||||
*/
|
||||
public function create(string $name, int $amount, int $budgetId, bool $expense)
|
||||
public function create(string $name, ?string $description, int $amount, int $budgetId, bool $expense)
|
||||
{
|
||||
try {
|
||||
$userPermission = $this->userPermissionMapper->find($budgetId, $this->userId);
|
||||
|
@ -100,6 +100,7 @@ class CategoryController extends Controller
|
|||
}
|
||||
$category = new Category();
|
||||
$category->setName($name);
|
||||
$category->setDescription($description);
|
||||
$category->setAmount($amount);
|
||||
$category->setExpense($expense);
|
||||
$category->setBudgetId($budgetId);
|
||||
|
@ -115,7 +116,7 @@ class CategoryController extends Controller
|
|||
* @param string $description
|
||||
* @param array $users
|
||||
*/
|
||||
public function update(int $id, string $name, string $description, int $amount, int $budgetId, bool $expense)
|
||||
public function update(int $id, string $name, ?string $description, int $amount, int $budgetId, bool $expense)
|
||||
{
|
||||
try {
|
||||
$category = $this->categoryMapper->find($id);
|
||||
|
|
|
@ -8,6 +8,7 @@ use OCP\AppFramework\Db\Entity;
|
|||
class Category extends Entity implements JsonSerializable {
|
||||
|
||||
protected $name;
|
||||
protected $description;
|
||||
protected $amount;
|
||||
protected $expense;
|
||||
protected $budgetId;
|
||||
|
@ -16,9 +17,10 @@ class Category extends Entity implements JsonSerializable {
|
|||
return [
|
||||
'id' => (int) $this->id,
|
||||
'name' => $this->name,
|
||||
'description' => $this->description,
|
||||
'amount' => (int) $this->amount,
|
||||
'expense' => (bool) $this->expense,
|
||||
'budgetId' => (int) $this->budgetId,
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,6 +51,10 @@ class Version000001Date20200204101200 extends SimpleMigrationStep {
|
|||
'notnull' => true,
|
||||
'length' => 200
|
||||
]);
|
||||
$table->addColumn('description', 'string', [
|
||||
'notnull' => true,
|
||||
'length' => 1000
|
||||
]);
|
||||
$table->addColumn('amount', 'integer', [
|
||||
'notnull' => true,
|
||||
]);
|
||||
|
|
Loading…
Reference in a new issue