Fix category & transaction creation/updating
Signed-off-by: William Brawner <me@wbrawner.com>
This commit is contained in:
parent
d241fbf1ea
commit
b6887364cf
4 changed files with 39 additions and 6 deletions
|
@ -5,7 +5,7 @@
|
|||
<name>Twigs</name>
|
||||
<summary>Twigs</summary>
|
||||
<description><![CDATA[Twigs is meant to help you get your finances on track by helping you establish budgets and register expenses. You can also share your budgets with other users.]]></description>
|
||||
<version>0.1.1</version>
|
||||
<version>0.1.2</version>
|
||||
<licence>agpl</licence>
|
||||
<author mail="william@wbrawner.com" homepage="https://wbrawner.com">William Brawner</author>
|
||||
<namespace>Twigs</namespace>
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
33
lib/Migration/Version000102Date20200324194700.php
Normal file
33
lib/Migration/Version000102Date20200324194700.php
Normal file
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
namespace OCA\Twigs\Migration;
|
||||
|
||||
use Closure;
|
||||
use OCP\DB\ISchemaWrapper;
|
||||
use OCP\Migration\SimpleMigrationStep;
|
||||
use OCP\Migration\IOutput;
|
||||
use OCA\Twigs\Db\CategoryMapper;
|
||||
use OCA\Twigs\Db\TransactionMapper;
|
||||
|
||||
class Version000102Date20200324194700 extends SimpleMigrationStep {
|
||||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param array $options
|
||||
* @return null|ISchemaWrapper
|
||||
*/
|
||||
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
|
||||
/** @var ISchemaWrapper $schema */
|
||||
$schema = $schemaClosure();
|
||||
|
||||
if ($schema->hasTable(CategoryMapper::TABLE_NAME)) {
|
||||
$table = $schema->getTable(CategoryMapper::TABLE_NAME);
|
||||
$table->changeColumn('description', [
|
||||
'notnull' => false,
|
||||
]);
|
||||
}
|
||||
|
||||
return $schema;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue