From 32c3847603532a4de2d18a41757c0d761e94924f Mon Sep 17 00:00:00 2001 From: Nafies Luthfi Date: Fri, 1 Dec 2017 23:42:55 +0800 Subject: [PATCH] Add validation on invoice item entry and update Composer update laravel v5.5.22 and luthfi/formfield 0.2.3 --- app/Http/Controllers/InvoiceDraftsController.php | 21 +- app/Services/InvoiceDraft/InvoiceDraft.php | 12 +- composer.json | 2 +- composer.lock | 443 ++++++++++++--------- resources/lang/id/invoice.php | 2 +- resources/views/invoice-drafts/index.blade.php | 2 +- .../partials/draft-item-list.blade.php | 21 +- tests/Feature/InvoiceEntryTest.php | 29 +- 8 files changed, 313 insertions(+), 219 deletions(-) diff --git a/app/Http/Controllers/InvoiceDraftsController.php b/app/Http/Controllers/InvoiceDraftsController.php index 581cec5..5818ee5 100644 --- a/app/Http/Controllers/InvoiceDraftsController.php +++ b/app/Http/Controllers/InvoiceDraftsController.php @@ -52,7 +52,12 @@ class InvoiceDraftsController extends Controller public function addDraftItem(Request $request, $draftKey) { - $item = new Item(['description' => $request->description, 'amount' => $request->amount]); + $itemData = $request->validate([ + 'new_item_description' => 'required|string|max:255', + 'new_item_amount' => 'required|numeric', + ]); + + $item = new Item(['description' => $itemData['new_item_description'], 'amount' => $itemData['new_item_amount']]); $this->draftCollection->addItemToDraft($draftKey, $item); flash(trans('invoice.item_added')); @@ -62,7 +67,19 @@ class InvoiceDraftsController extends Controller public function updateDraftItem(Request $request, $draftKey) { - $this->draftCollection->updateDraftItem($draftKey, $request->item_key, $request->only('description', 'amount')); + $itemData = $request->validate([ + 'item_key.*' => 'required|numeric', + 'description.*' => 'required|string|max:255', + 'amount.*' => 'required|numeric', + ]); + + $itemData = [ + 'item_key' => array_shift($itemData['item_key']), + 'description' => array_shift($itemData['description']), + 'amount' => array_shift($itemData['amount']), + ]; + + $this->draftCollection->updateDraftItem($draftKey, $itemData['item_key'], $itemData); return back(); } diff --git a/app/Services/InvoiceDraft/InvoiceDraft.php b/app/Services/InvoiceDraft/InvoiceDraft.php index 1018e86..328791d 100644 --- a/app/Services/InvoiceDraft/InvoiceDraft.php +++ b/app/Services/InvoiceDraft/InvoiceDraft.php @@ -62,13 +62,13 @@ class InvoiceDraft public function store() { - $invoice = new Invoice(); - $invoice->number = $invoice->generateNewNumber(); - $invoice->items = $this->getItemsArray(); + $invoice = new Invoice(); + $invoice->number = $invoice->generateNewNumber(); + $invoice->items = $this->getItemsArray(); $invoice->project_id = $this->projectId; - $invoice->amount = $this->getTotal(); - $invoice->notes = $this->notes; - $invoice->status_id = 1; + $invoice->amount = $this->getTotal(); + $invoice->notes = $this->notes; + $invoice->status_id = 1; $invoice->creator_id = auth()->id() ?: 1; $invoice->save(); diff --git a/composer.json b/composer.json index c2d2fc4..e67f90f 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ "laracasts/flash": "~2", "laracasts/presenter": "^0.2.1", "laravel/framework": "5.5.*", - "luthfi/formfield": "^0.2.0", + "luthfi/formfield": "^0.2.3", "riskihajar/terbilang": "^1.2", "spatie/laravel-fractal": "^5.0" }, diff --git a/composer.lock b/composer.lock index b6cbdaa..fba9c44 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "04aa37e7e8a32798820b57ecdee1dd40", + "content-hash": "6dbdc665baa1b50b8e237190ed93c8b9", "packages": [ { "name": "backup-manager/backup-manager", @@ -628,16 +628,16 @@ }, { "name": "laravel/framework", - "version": "v5.5.21", + "version": "v5.5.22", "source": { "type": "git", "url": "https://github.com/laravel/framework.git", - "reference": "6321069a75723d88103526903d3192f0b231544a" + "reference": "2404af887ca8272d721628a99bbc721ac3b692e7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/framework/zipball/6321069a75723d88103526903d3192f0b231544a", - "reference": "6321069a75723d88103526903d3192f0b231544a", + "url": "https://api.github.com/repos/laravel/framework/zipball/2404af887ca8272d721628a99bbc721ac3b692e7", + "reference": "2404af887ca8272d721628a99bbc721ac3b692e7", "shasum": "" }, "require": { @@ -757,7 +757,7 @@ "framework", "laravel" ], - "time": "2017-11-14T15:08:13+00:00" + "time": "2017-11-27T15:29:55+00:00" }, { "name": "laravelcollective/html", @@ -973,16 +973,16 @@ }, { "name": "luthfi/formfield", - "version": "0.2.2", + "version": "0.2.3", "source": { "type": "git", "url": "https://github.com/nafiesl/FormField.git", - "reference": "185bf67c52f4aca8227add187c72b84b945ab72f" + "reference": "3513deb4f15980564feae49ed5fe5caea7ed22eb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nafiesl/FormField/zipball/185bf67c52f4aca8227add187c72b84b945ab72f", - "reference": "185bf67c52f4aca8227add187c72b84b945ab72f", + "url": "https://api.github.com/repos/nafiesl/FormField/zipball/3513deb4f15980564feae49ed5fe5caea7ed22eb", + "reference": "3513deb4f15980564feae49ed5fe5caea7ed22eb", "shasum": "" }, "require": { @@ -1021,7 +1021,7 @@ } ], "description": "Laravel Form Field the extension of Laravelcollective Form for Laravel 5.3, 5.4 and 5.5 with Twitter Bootstrap 3", - "time": "2017-11-10T06:49:59+00:00" + "time": "2017-12-01T15:09:40+00:00" }, { "name": "monolog/monolog", @@ -1621,16 +1621,16 @@ }, { "name": "spatie/laravel-fractal", - "version": "5.2.0", + "version": "5.3.0", "source": { "type": "git", "url": "https://github.com/spatie/laravel-fractal.git", - "reference": "4aa3d4a5e5b2956eea437ee1f82201bd8b91a65e" + "reference": "f395eb645cd454b209bc628f974ed137d16e03da" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/spatie/laravel-fractal/zipball/4aa3d4a5e5b2956eea437ee1f82201bd8b91a65e", - "reference": "4aa3d4a5e5b2956eea437ee1f82201bd8b91a65e", + "url": "https://api.github.com/repos/spatie/laravel-fractal/zipball/f395eb645cd454b209bc628f974ed137d16e03da", + "reference": "f395eb645cd454b209bc628f974ed137d16e03da", "shasum": "" }, "require": { @@ -1685,7 +1685,7 @@ "spatie", "transform" ], - "time": "2017-09-15T18:57:48+00:00" + "time": "2017-11-28T16:33:26+00:00" }, { "name": "swiftmailer/swiftmailer", @@ -1744,44 +1744,45 @@ }, { "name": "symfony/console", - "version": "v3.3.13", + "version": "v3.4.0", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "63cd7960a0a522c3537f6326706d7f3b8de65805" + "reference": "9468ad3fba3a5e1f0dc12a96e50e84cddb923cf0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/63cd7960a0a522c3537f6326706d7f3b8de65805", - "reference": "63cd7960a0a522c3537f6326706d7f3b8de65805", + "url": "https://api.github.com/repos/symfony/console/zipball/9468ad3fba3a5e1f0dc12a96e50e84cddb923cf0", + "reference": "9468ad3fba3a5e1f0dc12a96e50e84cddb923cf0", "shasum": "" }, "require": { "php": "^5.5.9|>=7.0.8", - "symfony/debug": "~2.8|~3.0", + "symfony/debug": "~2.8|~3.0|~4.0", "symfony/polyfill-mbstring": "~1.0" }, "conflict": { - "symfony/dependency-injection": "<3.3" + "symfony/dependency-injection": "<3.4", + "symfony/process": "<3.3" }, "require-dev": { "psr/log": "~1.0", - "symfony/config": "~3.3", - "symfony/dependency-injection": "~3.3", - "symfony/event-dispatcher": "~2.8|~3.0", - "symfony/filesystem": "~2.8|~3.0", - "symfony/process": "~2.8|~3.0" + "symfony/config": "~3.3|~4.0", + "symfony/dependency-injection": "~3.4|~4.0", + "symfony/event-dispatcher": "~2.8|~3.0|~4.0", + "symfony/lock": "~3.4|~4.0", + "symfony/process": "~3.3|~4.0" }, "suggest": { "psr/log": "For using the console logger", "symfony/event-dispatcher": "", - "symfony/filesystem": "", + "symfony/lock": "", "symfony/process": "" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.3-dev" + "dev-master": "3.4-dev" } }, "autoload": { @@ -1808,20 +1809,20 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2017-11-16T15:24:32+00:00" + "time": "2017-11-29T13:28:14+00:00" }, { "name": "symfony/css-selector", - "version": "v3.3.13", + "version": "v3.4.0", "source": { "type": "git", "url": "https://github.com/symfony/css-selector.git", - "reference": "66e6e046032ebdf1f562c26928549f613d428bd1" + "reference": "7134b93e90ea7e7881fcb2da006d21b4c5f31908" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/css-selector/zipball/66e6e046032ebdf1f562c26928549f613d428bd1", - "reference": "66e6e046032ebdf1f562c26928549f613d428bd1", + "url": "https://api.github.com/repos/symfony/css-selector/zipball/7134b93e90ea7e7881fcb2da006d21b4c5f31908", + "reference": "7134b93e90ea7e7881fcb2da006d21b4c5f31908", "shasum": "" }, "require": { @@ -1830,7 +1831,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.3-dev" + "dev-master": "3.4-dev" } }, "autoload": { @@ -1861,20 +1862,20 @@ ], "description": "Symfony CssSelector Component", "homepage": "https://symfony.com", - "time": "2017-11-05T15:47:03+00:00" + "time": "2017-11-05T16:10:10+00:00" }, { "name": "symfony/debug", - "version": "v3.3.13", + "version": "v3.4.0", "source": { "type": "git", "url": "https://github.com/symfony/debug.git", - "reference": "74557880e2846b5c84029faa96b834da37e29810" + "reference": "fb2001e5d85f95d8b6ab94ae3be5d2672df128fd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/debug/zipball/74557880e2846b5c84029faa96b834da37e29810", - "reference": "74557880e2846b5c84029faa96b834da37e29810", + "url": "https://api.github.com/repos/symfony/debug/zipball/fb2001e5d85f95d8b6ab94ae3be5d2672df128fd", + "reference": "fb2001e5d85f95d8b6ab94ae3be5d2672df128fd", "shasum": "" }, "require": { @@ -1885,12 +1886,12 @@ "symfony/http-kernel": ">=2.3,<2.3.24|~2.4.0|>=2.5,<2.5.9|>=2.6,<2.6.2" }, "require-dev": { - "symfony/http-kernel": "~2.8|~3.0" + "symfony/http-kernel": "~2.8|~3.0|~4.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.3-dev" + "dev-master": "3.4-dev" } }, "autoload": { @@ -1917,20 +1918,20 @@ ], "description": "Symfony Debug Component", "homepage": "https://symfony.com", - "time": "2017-11-10T16:38:39+00:00" + "time": "2017-11-21T09:01:46+00:00" }, { "name": "symfony/event-dispatcher", - "version": "v3.3.13", + "version": "v3.4.0", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "271d8c27c3ec5ecee6e2ac06016232e249d638d9" + "reference": "ca20b8f9ef149f40ff656d52965f240d85f7a8e4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/271d8c27c3ec5ecee6e2ac06016232e249d638d9", - "reference": "271d8c27c3ec5ecee6e2ac06016232e249d638d9", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/ca20b8f9ef149f40ff656d52965f240d85f7a8e4", + "reference": "ca20b8f9ef149f40ff656d52965f240d85f7a8e4", "shasum": "" }, "require": { @@ -1941,10 +1942,10 @@ }, "require-dev": { "psr/log": "~1.0", - "symfony/config": "~2.8|~3.0", - "symfony/dependency-injection": "~3.3", - "symfony/expression-language": "~2.8|~3.0", - "symfony/stopwatch": "~2.8|~3.0" + "symfony/config": "~2.8|~3.0|~4.0", + "symfony/dependency-injection": "~3.3|~4.0", + "symfony/expression-language": "~2.8|~3.0|~4.0", + "symfony/stopwatch": "~2.8|~3.0|~4.0" }, "suggest": { "symfony/dependency-injection": "", @@ -1953,7 +1954,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.3-dev" + "dev-master": "3.4-dev" } }, "autoload": { @@ -1980,20 +1981,20 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "https://symfony.com", - "time": "2017-11-05T15:47:03+00:00" + "time": "2017-11-09T14:14:31+00:00" }, { "name": "symfony/finder", - "version": "v3.3.13", + "version": "v3.4.0", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "138af5ec075d4b1d1bd19de08c38a34bb2d7d880" + "reference": "dac8d7db537bac7ad8143eb11360a8c2231f251a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/138af5ec075d4b1d1bd19de08c38a34bb2d7d880", - "reference": "138af5ec075d4b1d1bd19de08c38a34bb2d7d880", + "url": "https://api.github.com/repos/symfony/finder/zipball/dac8d7db537bac7ad8143eb11360a8c2231f251a", + "reference": "dac8d7db537bac7ad8143eb11360a8c2231f251a", "shasum": "" }, "require": { @@ -2002,7 +2003,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.3-dev" + "dev-master": "3.4-dev" } }, "autoload": { @@ -2029,33 +2030,34 @@ ], "description": "Symfony Finder Component", "homepage": "https://symfony.com", - "time": "2017-11-05T15:47:03+00:00" + "time": "2017-11-05T16:10:10+00:00" }, { "name": "symfony/http-foundation", - "version": "v3.3.13", + "version": "v3.4.0", "source": { "type": "git", "url": "https://github.com/symfony/http-foundation.git", - "reference": "5943f0f19817a7e05992d20a90729b0dc93faf36" + "reference": "d9625c8abb907e0ca2d7506afd7a719a572c766f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-foundation/zipball/5943f0f19817a7e05992d20a90729b0dc93faf36", - "reference": "5943f0f19817a7e05992d20a90729b0dc93faf36", + "url": "https://api.github.com/repos/symfony/http-foundation/zipball/d9625c8abb907e0ca2d7506afd7a719a572c766f", + "reference": "d9625c8abb907e0ca2d7506afd7a719a572c766f", "shasum": "" }, "require": { "php": "^5.5.9|>=7.0.8", - "symfony/polyfill-mbstring": "~1.1" + "symfony/polyfill-mbstring": "~1.1", + "symfony/polyfill-php70": "~1.6" }, "require-dev": { - "symfony/expression-language": "~2.8|~3.0" + "symfony/expression-language": "~2.8|~3.0|~4.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.3-dev" + "dev-master": "3.4-dev" } }, "autoload": { @@ -2082,56 +2084,58 @@ ], "description": "Symfony HttpFoundation Component", "homepage": "https://symfony.com", - "time": "2017-11-13T18:13:16+00:00" + "time": "2017-11-30T14:56:21+00:00" }, { "name": "symfony/http-kernel", - "version": "v3.3.13", + "version": "v3.4.0", "source": { "type": "git", "url": "https://github.com/symfony/http-kernel.git", - "reference": "a2a942172b742217ab2ccd9399494af2aa17c766" + "reference": "2df856c9dd8a1e1f11439b12e58c474afc1aac0d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-kernel/zipball/a2a942172b742217ab2ccd9399494af2aa17c766", - "reference": "a2a942172b742217ab2ccd9399494af2aa17c766", + "url": "https://api.github.com/repos/symfony/http-kernel/zipball/2df856c9dd8a1e1f11439b12e58c474afc1aac0d", + "reference": "2df856c9dd8a1e1f11439b12e58c474afc1aac0d", "shasum": "" }, "require": { "php": "^5.5.9|>=7.0.8", "psr/log": "~1.0", - "symfony/debug": "~2.8|~3.0", - "symfony/event-dispatcher": "~2.8|~3.0", - "symfony/http-foundation": "^3.3.11" + "symfony/debug": "~2.8|~3.0|~4.0", + "symfony/event-dispatcher": "~2.8|~3.0|~4.0", + "symfony/http-foundation": "^3.3.11|~4.0" }, "conflict": { "symfony/config": "<2.8", - "symfony/dependency-injection": "<3.3", + "symfony/dependency-injection": "<3.4", "symfony/var-dumper": "<3.3", "twig/twig": "<1.34|<2.4,>=2" }, + "provide": { + "psr/log-implementation": "1.0" + }, "require-dev": { "psr/cache": "~1.0", - "symfony/browser-kit": "~2.8|~3.0", + "symfony/browser-kit": "~2.8|~3.0|~4.0", "symfony/class-loader": "~2.8|~3.0", - "symfony/config": "~2.8|~3.0", - "symfony/console": "~2.8|~3.0", - "symfony/css-selector": "~2.8|~3.0", - "symfony/dependency-injection": "~3.3", - "symfony/dom-crawler": "~2.8|~3.0", - "symfony/expression-language": "~2.8|~3.0", - "symfony/finder": "~2.8|~3.0", - "symfony/process": "~2.8|~3.0", - "symfony/routing": "~2.8|~3.0", - "symfony/stopwatch": "~2.8|~3.0", - "symfony/templating": "~2.8|~3.0", - "symfony/translation": "~2.8|~3.0", - "symfony/var-dumper": "~3.3" + "symfony/config": "~2.8|~3.0|~4.0", + "symfony/console": "~2.8|~3.0|~4.0", + "symfony/css-selector": "~2.8|~3.0|~4.0", + "symfony/dependency-injection": "~3.4|~4.0", + "symfony/dom-crawler": "~2.8|~3.0|~4.0", + "symfony/expression-language": "~2.8|~3.0|~4.0", + "symfony/finder": "~2.8|~3.0|~4.0", + "symfony/process": "~2.8|~3.0|~4.0", + "symfony/routing": "~3.4|~4.0", + "symfony/stopwatch": "~2.8|~3.0|~4.0", + "symfony/templating": "~2.8|~3.0|~4.0", + "symfony/translation": "~2.8|~3.0|~4.0", + "symfony/var-dumper": "~3.3|~4.0" }, "suggest": { "symfony/browser-kit": "", - "symfony/class-loader": "", "symfony/config": "", "symfony/console": "", "symfony/dependency-injection": "", @@ -2141,7 +2145,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.3-dev" + "dev-master": "3.4-dev" } }, "autoload": { @@ -2168,7 +2172,7 @@ ], "description": "Symfony HttpKernel Component", "homepage": "https://symfony.com", - "time": "2017-11-16T18:14:43+00:00" + "time": "2017-11-30T16:56:05+00:00" }, { "name": "symfony/polyfill-mbstring", @@ -2230,17 +2234,76 @@ "time": "2017-10-11T12:05:26+00:00" }, { + "name": "symfony/polyfill-php70", + "version": "v1.6.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php70.git", + "reference": "0442b9c0596610bd24ae7b5f0a6cdbbc16d9fcff" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php70/zipball/0442b9c0596610bd24ae7b5f0a6cdbbc16d9fcff", + "reference": "0442b9c0596610bd24ae7b5f0a6cdbbc16d9fcff", + "shasum": "" + }, + "require": { + "paragonie/random_compat": "~1.0|~2.0", + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.6-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Php70\\": "" + }, + "files": [ + "bootstrap.php" + ], + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 7.0+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "time": "2017-10-11T12:05:26+00:00" + }, + { "name": "symfony/process", - "version": "v3.3.13", + "version": "v3.4.0", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "a56a3989fb762d7b19a0cf8e7693ee99a6ffb78d" + "reference": "db25e810fd5e124085e3777257d0cf4ae533d0ea" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/a56a3989fb762d7b19a0cf8e7693ee99a6ffb78d", - "reference": "a56a3989fb762d7b19a0cf8e7693ee99a6ffb78d", + "url": "https://api.github.com/repos/symfony/process/zipball/db25e810fd5e124085e3777257d0cf4ae533d0ea", + "reference": "db25e810fd5e124085e3777257d0cf4ae533d0ea", "shasum": "" }, "require": { @@ -2249,7 +2312,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.3-dev" + "dev-master": "3.4-dev" } }, "autoload": { @@ -2276,20 +2339,20 @@ ], "description": "Symfony Process Component", "homepage": "https://symfony.com", - "time": "2017-11-13T15:31:11+00:00" + "time": "2017-11-22T12:18:49+00:00" }, { "name": "symfony/routing", - "version": "v3.3.13", + "version": "v3.4.0", "source": { "type": "git", "url": "https://github.com/symfony/routing.git", - "reference": "cf7fa1dfcfee2c96969bfa1c0341e5627ecb1e95" + "reference": "d768aa5b25d98188bae3fe4ce3eb2924c97aafac" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/routing/zipball/cf7fa1dfcfee2c96969bfa1c0341e5627ecb1e95", - "reference": "cf7fa1dfcfee2c96969bfa1c0341e5627ecb1e95", + "url": "https://api.github.com/repos/symfony/routing/zipball/d768aa5b25d98188bae3fe4ce3eb2924c97aafac", + "reference": "d768aa5b25d98188bae3fe4ce3eb2924c97aafac", "shasum": "" }, "require": { @@ -2298,17 +2361,17 @@ "conflict": { "symfony/config": "<2.8", "symfony/dependency-injection": "<3.3", - "symfony/yaml": "<3.3" + "symfony/yaml": "<3.4" }, "require-dev": { "doctrine/annotations": "~1.0", "doctrine/common": "~2.2", "psr/log": "~1.0", - "symfony/config": "~2.8|~3.0", - "symfony/dependency-injection": "~3.3", - "symfony/expression-language": "~2.8|~3.0", - "symfony/http-foundation": "~2.8|~3.0", - "symfony/yaml": "~3.3" + "symfony/config": "~2.8|~3.0|~4.0", + "symfony/dependency-injection": "~3.3|~4.0", + "symfony/expression-language": "~2.8|~3.0|~4.0", + "symfony/http-foundation": "~2.8|~3.0|~4.0", + "symfony/yaml": "~3.4|~4.0" }, "suggest": { "doctrine/annotations": "For using the annotation loader", @@ -2321,7 +2384,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.3-dev" + "dev-master": "3.4-dev" } }, "autoload": { @@ -2354,20 +2417,20 @@ "uri", "url" ], - "time": "2017-11-07T14:16:22+00:00" + "time": "2017-11-24T14:13:49+00:00" }, { "name": "symfony/translation", - "version": "v3.3.13", + "version": "v3.4.0", "source": { "type": "git", "url": "https://github.com/symfony/translation.git", - "reference": "373e553477e55cd08f8b86b74db766c75b987fdb" + "reference": "e05b0a5996ad7a35ba3a19ffad8b72c9daa64dfa" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/translation/zipball/373e553477e55cd08f8b86b74db766c75b987fdb", - "reference": "373e553477e55cd08f8b86b74db766c75b987fdb", + "url": "https://api.github.com/repos/symfony/translation/zipball/e05b0a5996ad7a35ba3a19ffad8b72c9daa64dfa", + "reference": "e05b0a5996ad7a35ba3a19ffad8b72c9daa64dfa", "shasum": "" }, "require": { @@ -2376,13 +2439,16 @@ }, "conflict": { "symfony/config": "<2.8", - "symfony/yaml": "<3.3" + "symfony/dependency-injection": "<3.4", + "symfony/yaml": "<3.4" }, "require-dev": { "psr/log": "~1.0", - "symfony/config": "~2.8|~3.0", - "symfony/intl": "^2.8.18|^3.2.5", - "symfony/yaml": "~3.3" + "symfony/config": "~2.8|~3.0|~4.0", + "symfony/dependency-injection": "~3.4|~4.0", + "symfony/finder": "~2.8|~3.0|~4.0", + "symfony/intl": "^2.8.18|^3.2.5|~4.0", + "symfony/yaml": "~3.4|~4.0" }, "suggest": { "psr/log": "To use logging capability in translator", @@ -2392,7 +2458,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.3-dev" + "dev-master": "3.4-dev" } }, "autoload": { @@ -2419,20 +2485,20 @@ ], "description": "Symfony Translation Component", "homepage": "https://symfony.com", - "time": "2017-11-07T14:12:55+00:00" + "time": "2017-11-27T14:23:00+00:00" }, { "name": "symfony/var-dumper", - "version": "v3.3.13", + "version": "v3.4.0", "source": { "type": "git", "url": "https://github.com/symfony/var-dumper.git", - "reference": "805de6bd6869073e60610df1b14ab7d969c61b01" + "reference": "ec650a975a8e04e0c114d35eab732981243db3a2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-dumper/zipball/805de6bd6869073e60610df1b14ab7d969c61b01", - "reference": "805de6bd6869073e60610df1b14ab7d969c61b01", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/ec650a975a8e04e0c114d35eab732981243db3a2", + "reference": "ec650a975a8e04e0c114d35eab732981243db3a2", "shasum": "" }, "require": { @@ -2448,12 +2514,13 @@ }, "suggest": { "ext-iconv": "To convert non-UTF-8 strings to UTF-8 (or symfony/polyfill-iconv in case ext-iconv cannot be used).", + "ext-intl": "To show region name in time zone dump", "ext-symfony_debug": "" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.3-dev" + "dev-master": "3.4-dev" } }, "autoload": { @@ -2487,7 +2554,7 @@ "debug", "dump" ], - "time": "2017-11-07T14:16:22+00:00" + "time": "2017-11-30T14:59:23+00:00" }, { "name": "tijsverkoyen/css-to-inline-styles", @@ -2792,12 +2859,12 @@ "source": { "type": "git", "url": "https://github.com/johnkary/phpunit-speedtrap.git", - "reference": "cbd785f67116c581f71705342cb316631e5a2be9" + "reference": "0c16841c6830bbc11446a774d05e33e84237cdc4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/johnkary/phpunit-speedtrap/zipball/cbd785f67116c581f71705342cb316631e5a2be9", - "reference": "cbd785f67116c581f71705342cb316631e5a2be9", + "url": "https://api.github.com/repos/johnkary/phpunit-speedtrap/zipball/0c16841c6830bbc11446a774d05e33e84237cdc4", + "reference": "0c16841c6830bbc11446a774d05e33e84237cdc4", "shasum": "" }, "require": { @@ -2832,7 +2899,7 @@ "profile", "slow" ], - "time": "2017-03-17T12:23:15+00:00" + "time": "2017-11-29T15:26:42+00:00" }, { "name": "laravel/browser-kit-testing", @@ -3260,29 +3327,35 @@ }, { "name": "phpdocumentor/reflection-docblock", - "version": "4.1.1", + "version": "4.2.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "2d3d238c433cf69caeb4842e97a3223a116f94b2" + "reference": "66465776cfc249844bde6d117abff1d22e06c2da" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/2d3d238c433cf69caeb4842e97a3223a116f94b2", - "reference": "2d3d238c433cf69caeb4842e97a3223a116f94b2", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/66465776cfc249844bde6d117abff1d22e06c2da", + "reference": "66465776cfc249844bde6d117abff1d22e06c2da", "shasum": "" }, "require": { "php": "^7.0", - "phpdocumentor/reflection-common": "^1.0@dev", + "phpdocumentor/reflection-common": "^1.0.0", "phpdocumentor/type-resolver": "^0.4.0", "webmozart/assert": "^1.0" }, "require-dev": { - "mockery/mockery": "^0.9.4", - "phpunit/phpunit": "^4.4" + "doctrine/instantiator": "~1.0.5", + "mockery/mockery": "^1.0", + "phpunit/phpunit": "^6.4" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.x-dev" + } + }, "autoload": { "psr-4": { "phpDocumentor\\Reflection\\": [ @@ -3301,7 +3374,7 @@ } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "time": "2017-08-30T18:51:59+00:00" + "time": "2017-11-27T17:38:31+00:00" }, { "name": "phpdocumentor/type-resolver", @@ -3352,16 +3425,16 @@ }, { "name": "phpspec/prophecy", - "version": "v1.7.2", + "version": "1.7.3", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "c9b8c6088acd19d769d4cc0ffa60a9fe34344bd6" + "reference": "e4ed002c67da8eceb0eb8ddb8b3847bb53c5c2bf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/c9b8c6088acd19d769d4cc0ffa60a9fe34344bd6", - "reference": "c9b8c6088acd19d769d4cc0ffa60a9fe34344bd6", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/e4ed002c67da8eceb0eb8ddb8b3847bb53c5c2bf", + "reference": "e4ed002c67da8eceb0eb8ddb8b3847bb53c5c2bf", "shasum": "" }, "require": { @@ -3373,7 +3446,7 @@ }, "require-dev": { "phpspec/phpspec": "^2.5|^3.2", - "phpunit/phpunit": "^4.8 || ^5.6.5" + "phpunit/phpunit": "^4.8.35 || ^5.7" }, "type": "library", "extra": { @@ -3411,20 +3484,20 @@ "spy", "stub" ], - "time": "2017-09-04T11:05:03+00:00" + "time": "2017-11-24T13:59:53+00:00" }, { "name": "phpunit/php-code-coverage", - "version": "5.2.3", + "version": "5.2.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "8e1d2397d8adf59a3f12b2878a3aaa66d1ab189d" + "reference": "033ec97498cf530cc1be4199264cad568b19be26" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/8e1d2397d8adf59a3f12b2878a3aaa66d1ab189d", - "reference": "8e1d2397d8adf59a3f12b2878a3aaa66d1ab189d", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/033ec97498cf530cc1be4199264cad568b19be26", + "reference": "033ec97498cf530cc1be4199264cad568b19be26", "shasum": "" }, "require": { @@ -3433,7 +3506,7 @@ "php": "^7.0", "phpunit/php-file-iterator": "^1.4.2", "phpunit/php-text-template": "^1.2.1", - "phpunit/php-token-stream": "^2.0", + "phpunit/php-token-stream": "^2.0.1", "sebastian/code-unit-reverse-lookup": "^1.0.1", "sebastian/environment": "^3.0", "sebastian/version": "^2.0.1", @@ -3475,20 +3548,20 @@ "testing", "xunit" ], - "time": "2017-11-03T13:47:33+00:00" + "time": "2017-11-27T09:00:30+00:00" }, { "name": "phpunit/php-file-iterator", - "version": "1.4.2", + "version": "1.4.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "3cc8f69b3028d0f96a9078e6295d86e9bf019be5" + "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/3cc8f69b3028d0f96a9078e6295d86e9bf019be5", - "reference": "3cc8f69b3028d0f96a9078e6295d86e9bf019be5", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/730b01bc3e867237eaac355e06a36b85dd93a8b4", + "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4", "shasum": "" }, "require": { @@ -3522,7 +3595,7 @@ "filesystem", "iterator" ], - "time": "2016-10-03T07:40:28+00:00" + "time": "2017-11-27T13:52:08+00:00" }, { "name": "phpunit/php-text-template", @@ -3616,16 +3689,16 @@ }, { "name": "phpunit/php-token-stream", - "version": "2.0.1", + "version": "2.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "9a02332089ac48e704c70f6cefed30c224e3c0b0" + "reference": "791198a2c6254db10131eecfe8c06670700904db" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/9a02332089ac48e704c70f6cefed30c224e3c0b0", - "reference": "9a02332089ac48e704c70f6cefed30c224e3c0b0", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/791198a2c6254db10131eecfe8c06670700904db", + "reference": "791198a2c6254db10131eecfe8c06670700904db", "shasum": "" }, "require": { @@ -3661,20 +3734,20 @@ "keywords": [ "tokenizer" ], - "time": "2017-08-20T05:47:52+00:00" + "time": "2017-11-27T05:48:46+00:00" }, { "name": "phpunit/phpunit", - "version": "6.4.4", + "version": "6.5.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "562f7dc75d46510a4ed5d16189ae57fbe45a9932" + "reference": "8eea3cfbfe3c8363f8111e24569bdb6ead71ea6e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/562f7dc75d46510a4ed5d16189ae57fbe45a9932", - "reference": "562f7dc75d46510a4ed5d16189ae57fbe45a9932", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/8eea3cfbfe3c8363f8111e24569bdb6ead71ea6e", + "reference": "8eea3cfbfe3c8363f8111e24569bdb6ead71ea6e", "shasum": "" }, "require": { @@ -3688,12 +3761,12 @@ "phar-io/version": "^1.0", "php": "^7.0", "phpspec/prophecy": "^1.7", - "phpunit/php-code-coverage": "^5.2.2", - "phpunit/php-file-iterator": "^1.4.2", + "phpunit/php-code-coverage": "^5.2.3", + "phpunit/php-file-iterator": "^1.4.3", "phpunit/php-text-template": "^1.2.1", "phpunit/php-timer": "^1.0.9", - "phpunit/phpunit-mock-objects": "^4.0.3", - "sebastian/comparator": "^2.0.2", + "phpunit/phpunit-mock-objects": "^5.0", + "sebastian/comparator": "^2.1", "sebastian/diff": "^2.0", "sebastian/environment": "^3.1", "sebastian/exporter": "^3.1", @@ -3719,7 +3792,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "6.4.x-dev" + "dev-master": "6.5.x-dev" } }, "autoload": { @@ -3745,20 +3818,20 @@ "testing", "xunit" ], - "time": "2017-11-08T11:26:09+00:00" + "time": "2017-12-01T09:57:23+00:00" }, { "name": "phpunit/phpunit-mock-objects", - "version": "4.0.4", + "version": "5.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "2f789b59ab89669015ad984afa350c4ec577ade0" + "reference": "b09519fb0786d369c0ae6b00c9caf25f7292b393" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/2f789b59ab89669015ad984afa350c4ec577ade0", - "reference": "2f789b59ab89669015ad984afa350c4ec577ade0", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/b09519fb0786d369c0ae6b00c9caf25f7292b393", + "reference": "b09519fb0786d369c0ae6b00c9caf25f7292b393", "shasum": "" }, "require": { @@ -3771,7 +3844,7 @@ "phpunit/phpunit": "<6.0" }, "require-dev": { - "phpunit/phpunit": "^6.0" + "phpunit/phpunit": "^6.5" }, "suggest": { "ext-soap": "*" @@ -3779,7 +3852,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.0.x-dev" + "dev-master": "5.0.x-dev" } }, "autoload": { @@ -3794,7 +3867,7 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", + "email": "sebastian@phpunit.de", "role": "lead" } ], @@ -3804,7 +3877,7 @@ "mock", "xunit" ], - "time": "2017-08-03T14:08:16+00:00" + "time": "2017-12-01T09:50:16+00:00" }, { "name": "sebastian/code-unit-reverse-lookup", @@ -4367,16 +4440,16 @@ }, { "name": "symfony/dom-crawler", - "version": "v3.3.13", + "version": "v3.4.0", "source": { "type": "git", "url": "https://github.com/symfony/dom-crawler.git", - "reference": "cebe3c068867956e012d9135282ba6a05d8a259e" + "reference": "7bf68716e400997a291ad42c9f9fe7972e6656d2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/cebe3c068867956e012d9135282ba6a05d8a259e", - "reference": "cebe3c068867956e012d9135282ba6a05d8a259e", + "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/7bf68716e400997a291ad42c9f9fe7972e6656d2", + "reference": "7bf68716e400997a291ad42c9f9fe7972e6656d2", "shasum": "" }, "require": { @@ -4384,7 +4457,7 @@ "symfony/polyfill-mbstring": "~1.0" }, "require-dev": { - "symfony/css-selector": "~2.8|~3.0" + "symfony/css-selector": "~2.8|~3.0|~4.0" }, "suggest": { "symfony/css-selector": "" @@ -4392,7 +4465,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.3-dev" + "dev-master": "3.4-dev" } }, "autoload": { @@ -4419,7 +4492,7 @@ ], "description": "Symfony DomCrawler Component", "homepage": "https://symfony.com", - "time": "2017-11-05T15:47:03+00:00" + "time": "2017-11-05T16:10:10+00:00" }, { "name": "theseer/tokenizer", diff --git a/resources/lang/id/invoice.php b/resources/lang/id/invoice.php index e12297d..c653988 100644 --- a/resources/lang/id/invoice.php +++ b/resources/lang/id/invoice.php @@ -29,7 +29,7 @@ return [ 'undeleted' => 'Data Invoice gagal dihapus.', 'undeleteable' => 'Data Invoice tidak dapat dihapus.', 'print' => 'Cetak Invoice', - 'add-item' => 'Tambah Item', + 'add_item' => 'Tambah Item', 'item_added' => 'Item berhasil ditambahkan.', 'confirm_instruction' => 'Silakan periksa rincian di bawah ini, jika belum sesuai, silakan klik kembali.', diff --git a/resources/views/invoice-drafts/index.blade.php b/resources/views/invoice-drafts/index.blade.php index d9118e0..b0ea8cb 100644 --- a/resources/views/invoice-drafts/index.blade.php +++ b/resources/views/invoice-drafts/index.blade.php @@ -1,6 +1,6 @@ @extends('layouts.app') -@section('title', 'Entry Invoice') +@section('title', trans('invoice.create')) @section('content')

diff --git a/resources/views/invoice-drafts/partials/draft-item-list.blade.php b/resources/views/invoice-drafts/partials/draft-item-list.blade.php index 7bf45fd..522d09b 100644 --- a/resources/views/invoice-drafts/partials/draft-item-list.blade.php +++ b/resources/views/invoice-drafts/partials/draft-item-list.blade.php @@ -21,16 +21,16 @@ {{ $no }} {{ Form::open(['route' => ['invoice-drafts.update-draft-item', $draft->draftKey], 'method' => 'patch']) }} - {{ Form::hidden('item_key', $key) }} + {{ Form::hidden('item_key['.$key.']', $key) }} {!! FormField::textarea( - 'description', + 'description['.$key.']', ['id' => 'description-'.$key, 'value' => $item->description, 'label' => false] ) !!} {!! FormField::price( - 'amount', + 'amount['.$key.']', ['id' => 'amount-'.$key, 'value' => $item->amount, 'label' => false] ) !!} {{ Form::submit('Update', ['id' => 'update-item-'.$key, 'class' => 'btn btn-success btn-xs pull-right']) }} @@ -49,21 +49,20 @@ Tambah Item Invoice -   {{ Form::open(['route' => ['invoice-drafts.add-draft-item', $draft->draftKey]]) }} - + {!! FormField::textarea( - 'description', - ['id' => 'description', 'label' => false, 'placeholder' => 'Deskripsi Item'] + 'new_item_description', + ['id' => 'new_item_description', 'label' => false, 'placeholder' => trans('invoice.item_description')] ) !!} - + {!! FormField::price( - 'amount', - ['id' => 'amount', 'label' => false, 'placeholder' => 'Biaya Item'] + 'new_item_amount', + ['id' => 'new_item_amount', 'label' => false, 'placeholder' => trans('invoice.item_amount')] ) !!} + {{ Form::submit(trans('invoice.add_item'), ['class' => 'btn btn-primary btn-block']) }} - {{ Form::submit('add-item', ['class' => 'btn btn-primary']) }} {{ Form::close() }} diff --git a/tests/Feature/InvoiceEntryTest.php b/tests/Feature/InvoiceEntryTest.php index 150ffbe..e7f2e76 100644 --- a/tests/Feature/InvoiceEntryTest.php +++ b/tests/Feature/InvoiceEntryTest.php @@ -9,6 +9,11 @@ use App\Services\InvoiceDrafts\InvoiceDraftCollection; use App\Services\InvoiceDrafts\Item; use Tests\TestCase; +/** + * Invoice Entry Feature Test + * + * @author Nafies Luthfi + */ class InvoiceEntryTest extends TestCase { /** @test */ @@ -48,15 +53,15 @@ class InvoiceEntryTest extends TestCase $this->visit(route('invoice-drafts.show', $draft->draftKey)); - $this->type('Testing deskripsi invoice item', 'description'); - $this->type(2000, 'amount'); - $this->press('add-item'); + $this->type('Testing deskripsi invoice item', 'new_item_description'); + $this->type(2000, 'new_item_amount'); + $this->press(trans('invoice.add_item')); $this->see(trans('invoice.item_added')); - $this->type('Testing deskripsi invoice item', 'description'); - $this->type(3000, 'amount'); - $this->press('add-item'); + $this->type('Testing deskripsi invoice item', 'new_item_description'); + $this->type(3000, 'new_item_amount'); + $this->press(trans('invoice.add_item')); $this->seePageIs(route('invoice-drafts.show', $draft->draftKey)); $this->assertEquals(5000, $draft->getTotal()); @@ -97,15 +102,15 @@ class InvoiceEntryTest extends TestCase $this->visit(route('invoice-drafts.show', $draft->draftKey)); $this->submitForm('update-item-0', [ - 'item_key' => 0, - 'description' => 'Testing deskripsi Update', - 'amount' => 100, + 'item_key[0]' => 0, + 'description[0]' => 'Testing deskripsi Update', + 'amount[0]' => 100, ]); $this->submitForm('update-item-1', [ - 'item_key' => 1, - 'description' => 'Testing deskripsi Update', - 'amount' => 100, + 'item_key[1]' => 1, + 'description[1]' => 'Testing deskripsi Update', + 'amount[1]' => 100, ]); $this->assertEquals(200, $draft->getTotal());