Fix category creation & updating

Signed-off-by: William Brawner <me@wbrawner.com>
This commit is contained in:
William Brawner 2020-03-17 21:49:39 -06:00
parent 02947db565
commit ba1ffd5cc6
3 changed files with 10 additions and 3 deletions

View file

@ -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);

View file

@ -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,
];
}
}
}

View file

@ -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,
]);