From b6887364cf2dd1898774f8fd03051d9cd19efe27 Mon Sep 17 00:00:00 2001 From: William Brawner Date: Tue, 24 Mar 2020 20:18:07 -0700 Subject: [PATCH] Fix category & transaction creation/updating Signed-off-by: William Brawner --- appinfo/info.xml | 2 +- lib/Controller/CategoryController.php | 4 +-- lib/Controller/TransactionController.php | 6 ++-- .../Version000102Date20200324194700.php | 33 +++++++++++++++++++ 4 files changed, 39 insertions(+), 6 deletions(-) create mode 100644 lib/Migration/Version000102Date20200324194700.php diff --git a/appinfo/info.xml b/appinfo/info.xml index 5f014d1..fd4171b 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -5,7 +5,7 @@ Twigs Twigs - 0.1.1 + 0.1.2 agpl William Brawner Twigs diff --git a/lib/Controller/CategoryController.php b/lib/Controller/CategoryController.php index a223497..944056d 100644 --- a/lib/Controller/CategoryController.php +++ b/lib/Controller/CategoryController.php @@ -102,7 +102,7 @@ class CategoryController extends Controller $category->setName($name); $category->setDescription($description); $category->setAmount($amount); - $category->setExpense($expense); + $category->setExpense((int) $expense); $category->setBudgetId($budgetId); return new DataResponse($this->categoryMapper->insert($category)); } @@ -137,7 +137,7 @@ class CategoryController extends Controller $category->setAmount($amount); } if ($expense) { - $category->setExpense($expense); + $category->setExpense((int) $expense); } if ($budgetId) { try { diff --git a/lib/Controller/TransactionController.php b/lib/Controller/TransactionController.php index fd950ec..d79c91c 100644 --- a/lib/Controller/TransactionController.php +++ b/lib/Controller/TransactionController.php @@ -119,7 +119,7 @@ class TransactionController extends Controller $transaction->setName($name); $transaction->setDescription($description); $transaction->setAmount($amount); - $transaction->setExpense($expense); + $transaction->setExpense((int) $expense); $dateTime = DateTime::createFromFormat(self::DATE_FORMAT, $date); if (!$dateTime) { return new DataResponse(["message" => "Invalid date format: '$date'"], Http::STATUS_BAD_REQUEST); @@ -172,7 +172,7 @@ class TransactionController extends Controller $transaction->setName($name); $transaction->setDescription($description); $transaction->setAmount($amount); - $transaction->setExpense($expense); + $transaction->setExpense((int) $expense); $dateTime = DateTime::createFromFormat(self::DATE_FORMAT, $date); if (!$dateTime) { return new DataResponse([], Http::STATUS_BAD_REQUEST); @@ -251,7 +251,7 @@ class TransactionController extends Controller $endDateTime->setDate( $endDateTime->format('Y'), $endDateTime->format('m'), - $endDateTime->format('t'), + $endDateTime->format('t') ); $endDateTime->setTime(23, 59, 59, 999); } else { diff --git a/lib/Migration/Version000102Date20200324194700.php b/lib/Migration/Version000102Date20200324194700.php new file mode 100644 index 0000000..c1abbea --- /dev/null +++ b/lib/Migration/Version000102Date20200324194700.php @@ -0,0 +1,33 @@ +hasTable(CategoryMapper::TABLE_NAME)) { + $table = $schema->getTable(CategoryMapper::TABLE_NAME); + $table->changeColumn('description', [ + 'notnull' => false, + ]); + } + + return $schema; + } +}