Fix transaction creation

Signed-off-by: William Brawner <me@wbrawner.com>
This commit is contained in:
William Brawner 2020-03-22 21:59:02 +00:00
parent e4a3855d83
commit 3b72e1305b
3 changed files with 80 additions and 80 deletions

View file

@ -25,8 +25,8 @@ class TransactionController extends Controller
private $transactionMapper;
private $userPermissionMapper;
private $logger;
private $DATE_FORMAT = DateTime::RFC3339_EXTENDED;
private const DATE_FORMAT = "Y-m-d\TH:i:s.v\Z";
private const AMOUNT_REGEX = "/^(([\d]{1,3}[\,\.]?)?([\d]{3}([\.\,])?)+([\.\,][\d]{2})?|[\d]+)$/";
public function __construct(
$AppName,
@ -120,7 +120,7 @@ class TransactionController extends Controller
$transaction->setDescription($description);
$transaction->setAmount($amount);
$transaction->setExpense($expense);
$dateTime = DateTime::createFromFormat($this->DATE_FORMAT, $date);
$dateTime = DateTime::createFromFormat(self::DATE_FORMAT, $date);
if (!$dateTime) {
return new DataResponse(["message" => "Invalid date format: '$date'"], Http::STATUS_BAD_REQUEST);
}
@ -173,7 +173,7 @@ class TransactionController extends Controller
$transaction->setDescription($description);
$transaction->setAmount($amount);
$transaction->setExpense($expense);
$dateTime = DateTime::createFromFormat($this->DATE_FORMAT, $date);
$dateTime = DateTime::createFromFormat(self::DATE_FORMAT, $date);
if (!$dateTime) {
return new DataResponse([], Http::STATUS_BAD_REQUEST);
}
@ -240,7 +240,7 @@ class TransactionController extends Controller
);
$startDateTime->setTime(0, 0, 0, 0);
} else {
$startDateTime = DateTime::createFromFormat($this->DATE_FORMAT, $startDate);
$startDateTime = DateTime::createFromFormat(self::DATE_FORMAT, $startDate);
}
if (!$startDateTime) {
return new DataResponse([], Http::STATUS_BAD_REQUEST);
@ -255,7 +255,7 @@ class TransactionController extends Controller
);
$endDateTime->setTime(23, 59, 59, 999);
} else {
$endDateTime = DateTime::createFromFormat($this->DATE_FORMAT, $endDate);
$endDateTime = DateTime::createFromFormat(self::DATE_FORMAT, $endDate);
}
if (!$endDateTime) {
return new DataResponse([], Http::STATUS_BAD_REQUEST);

View file

@ -34,7 +34,7 @@ class Version000001Date20200204101200 extends SimpleMigrationStep {
'length' => 200
]);
$table->addColumn('description', 'string', [
'notnull' => true,
'notnull' => false,
'length' => 1000,
]);

View file

@ -65,7 +65,7 @@ export default {
},
saveTransaction() {
this.saving = true;
this.$store.dispatch("addEditTransactionSaveClicked", this.transaction);
this.$store.dispatch("transactionFormSaveClicked", this.transaction);
}
},
mounted() {