- invoice fixes

- optimization for new invoicing module
This commit is contained in:
Peter Papp
2021-05-24 16:47:21 +02:00
parent 26636dffab
commit 8a2af11f6a
9 changed files with 224 additions and 88 deletions
+1 -1
View File
@@ -12,9 +12,9 @@ use Kyslik\ColumnSortable\Sortable;
use App\Notifications\ResetPassword; use App\Notifications\ResetPassword;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
use Illuminate\Notifications\Notifiable; use Illuminate\Notifications\Notifiable;
use Makingcg\Invoice\Http\Traits\Invoiceable;
use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Foundation\Auth\User as Authenticatable;
use Makingcg\Invoice\App\Traits\Invoiceable;
class User extends Authenticatable class User extends Authenticatable
{ {
Generated
+168 -26
View File
@@ -712,16 +712,16 @@
}, },
{ {
"name": "composer/package-versions-deprecated", "name": "composer/package-versions-deprecated",
"version": "1.11.99.1", "version": "1.11.99.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/composer/package-versions-deprecated.git", "url": "https://github.com/composer/package-versions-deprecated.git",
"reference": "7413f0b55a051e89485c5cb9f765fe24bb02a7b6" "reference": "c6522afe5540d5fc46675043d3ed5a45a740b27c"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/composer/package-versions-deprecated/zipball/7413f0b55a051e89485c5cb9f765fe24bb02a7b6", "url": "https://api.github.com/repos/composer/package-versions-deprecated/zipball/c6522afe5540d5fc46675043d3ed5a45a740b27c",
"reference": "7413f0b55a051e89485c5cb9f765fe24bb02a7b6", "reference": "c6522afe5540d5fc46675043d3ed5a45a740b27c",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -765,7 +765,7 @@
"description": "Composer plugin that provides efficient querying for installed package versions (no runtime IO)", "description": "Composer plugin that provides efficient querying for installed package versions (no runtime IO)",
"support": { "support": {
"issues": "https://github.com/composer/package-versions-deprecated/issues", "issues": "https://github.com/composer/package-versions-deprecated/issues",
"source": "https://github.com/composer/package-versions-deprecated/tree/1.11.99.1" "source": "https://github.com/composer/package-versions-deprecated/tree/1.11.99.2"
}, },
"funding": [ "funding": [
{ {
@@ -781,7 +781,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2020-11-11T10:22:58+00:00" "time": "2021-05-24T07:46:03+00:00"
}, },
{ {
"name": "composer/semver", "name": "composer/semver",
@@ -3754,7 +3754,7 @@
"dist": { "dist": {
"type": "path", "type": "path",
"url": "../vuefilemanager-invoicing", "url": "../vuefilemanager-invoicing",
"reference": "397ccf463f15abaef111501681fa69d5785c4d73" "reference": "51dc6322d98cd7fc487eb2bd4b5582442c1f7c4f"
}, },
"require": { "require": {
"barryvdh/laravel-snappy": "^0.4.8", "barryvdh/laravel-snappy": "^0.4.8",
@@ -3765,14 +3765,16 @@
"laravel/cashier": "^12.13", "laravel/cashier": "^12.13",
"laravel/sanctum": "^2.11", "laravel/sanctum": "^2.11",
"php": "^8.0", "php": "^8.0",
"spatie/data-transfer-object": "^3.1",
"spatie/laravel-package-tools": "^1.4.3", "spatie/laravel-package-tools": "^1.4.3",
"spatie/laravel-query-builder": "^3.4.0",
"spatie/laravel-queueable-action": "^2.11", "spatie/laravel-queueable-action": "^2.11",
"teamtnt/laravel-scout-tntsearch-driver": "^11.3" "teamtnt/laravel-scout-tntsearch-driver": "^11.3"
}, },
"require-dev": { "require-dev": {
"brianium/paratest": "^6.2", "brianium/paratest": "^6.2",
"ext-json": "*", "ext-json": "*",
"friendsofphp/php-cs-fixer": "^2.19", "friendsofphp/php-cs-fixer": "^3.0",
"nunomaduro/collision": "^5.3", "nunomaduro/collision": "^5.3",
"orchestra/testbench": "^6.15", "orchestra/testbench": "^6.15",
"phpunit/phpunit": "^9.3", "phpunit/phpunit": "^9.3",
@@ -3784,11 +3786,12 @@
"laravel": { "laravel": {
"providers": [ "providers": [
"Makingcg\\Invoice\\InvoiceServiceProvider", "Makingcg\\Invoice\\InvoiceServiceProvider",
"Kyslik\\ColumnSortable\\ColumnSortableServiceProvider" "Kyslik\\ColumnSortable\\ColumnSortableServiceProvider",
"Spatie\\QueryBuilder\\QueryBuilderServiceProvider"
], ],
"aliases": { "aliases": {
"Invoice": "Makingcg\\Invoice\\InvoiceFacade", "PDF": "Barryvdh\\Snappy\\Facades\\SnappyPdf",
"PDF": "Barryvdh\\Snappy\\Facades\\SnappyPdf" "QueryBuilder": "Spatie\\QueryBuilder\\QueryBuilder"
} }
} }
}, },
@@ -3803,7 +3806,10 @@
}, },
"autoload-dev": { "autoload-dev": {
"psr-4": { "psr-4": {
"Makingcg\\Invoice\\Tests\\": "tests" "App\\": "src/App/",
"Domain\\": "src/Domain/",
"Support\\": "src/Support/",
"Tests\\": "tests/"
} }
}, },
"scripts": { "scripts": {
@@ -7213,6 +7219,72 @@
], ],
"time": "2020-09-28T06:39:44+00:00" "time": "2020-09-28T06:39:44+00:00"
}, },
{
"name": "spatie/data-transfer-object",
"version": "3.1.1",
"source": {
"type": "git",
"url": "https://github.com/spatie/data-transfer-object.git",
"reference": "a16ed4916f13c916107f692bd9a5d52d2c9daaa6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/spatie/data-transfer-object/zipball/a16ed4916f13c916107f692bd9a5d52d2c9daaa6",
"reference": "a16ed4916f13c916107f692bd9a5d52d2c9daaa6",
"shasum": ""
},
"require": {
"php": "^8.0"
},
"require-dev": {
"illuminate/collections": "^8.36",
"jetbrains/phpstorm-attributes": "^1.0",
"larapack/dd": "^1.1",
"phpunit/phpunit": "^9.0"
},
"suggest": {
"phpstan/phpstan": "Take advantage of checkUninitializedProperties with \\Spatie\\DataTransferObject\\PHPstan\\PropertiesAreAlwaysInitializedExtension"
},
"type": "library",
"autoload": {
"psr-4": {
"Spatie\\DataTransferObject\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Brent Roose",
"email": "brent@spatie.be",
"homepage": "https://spatie.be",
"role": "Developer"
}
],
"description": "Data transfer objects with batteries included",
"homepage": "https://github.com/spatie/data-transfer-object",
"keywords": [
"data-transfer-object",
"spatie"
],
"support": {
"issues": "https://github.com/spatie/data-transfer-object/issues",
"source": "https://github.com/spatie/data-transfer-object/tree/3.1.1"
},
"funding": [
{
"url": "https://spatie.be/open-source/support-us",
"type": "custom"
},
{
"url": "https://github.com/spatie",
"type": "github"
}
],
"time": "2021-04-26T03:32:41+00:00"
},
{ {
"name": "spatie/db-dumper", "name": "spatie/db-dumper",
"version": "2.21.1", "version": "2.21.1",
@@ -7365,16 +7437,16 @@
}, },
{ {
"name": "spatie/laravel-package-tools", "name": "spatie/laravel-package-tools",
"version": "1.7.0", "version": "1.9.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/spatie/laravel-package-tools.git", "url": "https://github.com/spatie/laravel-package-tools.git",
"reference": "a28108b61dac8a83de6c97f09a5a1e98f4d75522" "reference": "cf4c4cec220575e2864c6082842d76822421f1b1"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/spatie/laravel-package-tools/zipball/a28108b61dac8a83de6c97f09a5a1e98f4d75522", "url": "https://api.github.com/repos/spatie/laravel-package-tools/zipball/cf4c4cec220575e2864c6082842d76822421f1b1",
"reference": "a28108b61dac8a83de6c97f09a5a1e98f4d75522", "reference": "cf4c4cec220575e2864c6082842d76822421f1b1",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -7413,7 +7485,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/spatie/laravel-package-tools/issues", "issues": "https://github.com/spatie/laravel-package-tools/issues",
"source": "https://github.com/spatie/laravel-package-tools/tree/1.7.0" "source": "https://github.com/spatie/laravel-package-tools/tree/1.9.0"
}, },
"funding": [ "funding": [
{ {
@@ -7421,7 +7493,77 @@
"type": "github" "type": "github"
} }
], ],
"time": "2021-05-06T21:49:32+00:00" "time": "2021-05-23T15:12:33+00:00"
},
{
"name": "spatie/laravel-query-builder",
"version": "3.4.0",
"source": {
"type": "git",
"url": "https://github.com/spatie/laravel-query-builder.git",
"reference": "1bd3682c3640b905de4868c413e7eda44ed21e9b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/spatie/laravel-query-builder/zipball/1bd3682c3640b905de4868c413e7eda44ed21e9b",
"reference": "1bd3682c3640b905de4868c413e7eda44ed21e9b",
"shasum": ""
},
"require": {
"illuminate/database": "^6.0|^7.0|^8.0",
"illuminate/http": "^6.0|^7.0|^8.0",
"illuminate/support": "^6.0|^7.0|^8.0",
"php": "^7.3|^8.0"
},
"require-dev": {
"ext-json": "*",
"laravel/legacy-factories": "^1.0.4",
"mockery/mockery": "^1.4",
"orchestra/testbench": "^4.9|^5.8|^6.3",
"phpunit/phpunit": "^9.0"
},
"type": "library",
"extra": {
"laravel": {
"providers": [
"Spatie\\QueryBuilder\\QueryBuilderServiceProvider"
]
}
},
"autoload": {
"psr-4": {
"Spatie\\QueryBuilder\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Alex Vanderbist",
"email": "alex@spatie.be",
"homepage": "https://spatie.be",
"role": "Developer"
}
],
"description": "Easily build Eloquent queries from API requests",
"homepage": "https://github.com/spatie/laravel-query-builder",
"keywords": [
"laravel-query-builder",
"spatie"
],
"support": {
"issues": "https://github.com/spatie/laravel-query-builder/issues",
"source": "https://github.com/spatie/laravel-query-builder"
},
"funding": [
{
"url": "https://spatie.be/open-source/support-us",
"type": "custom"
}
],
"time": "2021-05-20T09:15:38+00:00"
}, },
{ {
"name": "spatie/laravel-queueable-action", "name": "spatie/laravel-queueable-action",
@@ -10336,16 +10478,16 @@
}, },
{ {
"name": "vimeo/psalm", "name": "vimeo/psalm",
"version": "4.7.2", "version": "4.7.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/vimeo/psalm.git", "url": "https://github.com/vimeo/psalm.git",
"reference": "83a0325c0a95c0ab531d6b90c877068b464377b5" "reference": "38c452ae584467e939d55377aaf83b5a26f19dd1"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/vimeo/psalm/zipball/83a0325c0a95c0ab531d6b90c877068b464377b5", "url": "https://api.github.com/repos/vimeo/psalm/zipball/38c452ae584467e939d55377aaf83b5a26f19dd1",
"reference": "83a0325c0a95c0ab531d6b90c877068b464377b5", "reference": "38c452ae584467e939d55377aaf83b5a26f19dd1",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -10364,7 +10506,7 @@
"felixfbecker/advanced-json-rpc": "^3.0.3", "felixfbecker/advanced-json-rpc": "^3.0.3",
"felixfbecker/language-server-protocol": "^1.5", "felixfbecker/language-server-protocol": "^1.5",
"netresearch/jsonmapper": "^1.0 || ^2.0 || ^3.0 || ^4.0", "netresearch/jsonmapper": "^1.0 || ^2.0 || ^3.0 || ^4.0",
"nikic/php-parser": "^4.10.1", "nikic/php-parser": "^4.10.5",
"openlss/lib-array2xml": "^1.0", "openlss/lib-array2xml": "^1.0",
"php": "^7.1|^8", "php": "^7.1|^8",
"sebastian/diff": "^3.0 || ^4.0", "sebastian/diff": "^3.0 || ^4.0",
@@ -10384,7 +10526,7 @@
"phpspec/prophecy": ">=1.9.0", "phpspec/prophecy": ">=1.9.0",
"phpunit/phpunit": "^9.0", "phpunit/phpunit": "^9.0",
"psalm/plugin-phpunit": "^0.13", "psalm/plugin-phpunit": "^0.13",
"slevomat/coding-standard": "^6.3.11", "slevomat/coding-standard": "^7.0",
"squizlabs/php_codesniffer": "^3.5", "squizlabs/php_codesniffer": "^3.5",
"symfony/process": "^4.3", "symfony/process": "^4.3",
"weirdan/phpunit-appveyor-reporter": "^1.0.0", "weirdan/phpunit-appveyor-reporter": "^1.0.0",
@@ -10435,9 +10577,9 @@
], ],
"support": { "support": {
"issues": "https://github.com/vimeo/psalm/issues", "issues": "https://github.com/vimeo/psalm/issues",
"source": "https://github.com/vimeo/psalm/tree/4.7.2" "source": "https://github.com/vimeo/psalm/tree/4.7.3"
}, },
"time": "2021-05-01T20:56:25+00:00" "time": "2021-05-24T04:09:51+00:00"
}, },
{ {
"name": "vlucas/phpdotenv", "name": "vlucas/phpdotenv",
+14 -4
View File
@@ -50,13 +50,13 @@
"/chunks/invoices.js": "/chunks/invoices.js?id=44cc3fb563e6711fcf9f", "/chunks/invoices.js": "/chunks/invoices.js?id=44cc3fb563e6711fcf9f",
"/chunks/not-found-shared.js": "/chunks/not-found-shared.js?id=4ead3393f11e9d24a662", "/chunks/not-found-shared.js": "/chunks/not-found-shared.js?id=4ead3393f11e9d24a662",
"/chunks/oasis/homepage.js": "/chunks/oasis/homepage.js?id=98041261853208c9d48e", "/chunks/oasis/homepage.js": "/chunks/oasis/homepage.js?id=98041261853208c9d48e",
"/chunks/oasis/invoices.js": "/chunks/oasis/invoices.js?id=52cbf342ca2600db8b22", "/chunks/oasis/invoices.js": "/chunks/oasis/invoices.js?id=073e1755e4cd5f89a325",
"/chunks/oasis/invoices/client.js": "/chunks/oasis/invoices/client.js?id=5f6d3da1b11ef17294eb", "/chunks/oasis/invoices/client.js": "/chunks/oasis/invoices/client.js?id=5f6d3da1b11ef17294eb",
"/chunks/oasis/invoices/client-detail.js": "/chunks/oasis/invoices/client-detail.js?id=2acbe292c3671f3dbf55", "/chunks/oasis/invoices/client-detail.js": "/chunks/oasis/invoices/client-detail.js?id=2acbe292c3671f3dbf55",
"/chunks/oasis/invoices/client-invoices.js": "/chunks/oasis/invoices/client-invoices.js?id=d393bc04694023a2591b", "/chunks/oasis/invoices/client-invoices.js": "/chunks/oasis/invoices/client-invoices.js?id=d393bc04694023a2591b",
"/chunks/oasis/invoices/create-client.js": "/chunks/oasis/invoices/create-client.js?id=c4d22f8f40db80976b36", "/chunks/oasis/invoices/create-client.js": "/chunks/oasis/invoices/create-client.js?id=c4d22f8f40db80976b36",
"/chunks/oasis/invoices/create-invoice.js": "/chunks/oasis/invoices/create-invoice.js?id=050e749f6070fdc2b7ff", "/chunks/oasis/invoices/create-invoice.js": "/chunks/oasis/invoices/create-invoice.js?id=55fb19d18359f4ff8e08",
"/chunks/oasis/invoices/edit-invoice.js": "/chunks/oasis/invoices/edit-invoice.js?id=88f4d717ca4817c4a153", "/chunks/oasis/invoices/edit-invoice.js": "/chunks/oasis/invoices/edit-invoice.js?id=3f25967c0e5edd323773",
"/chunks/oasis/invoices/list.js": "/chunks/oasis/invoices/list.js?id=b138f14c38c3a9f7d75a", "/chunks/oasis/invoices/list.js": "/chunks/oasis/invoices/list.js?id=b138f14c38c3a9f7d75a",
"/chunks/oasis/invoices/profile.js": "/chunks/oasis/invoices/profile.js?id=c552dc38756ae53a6f23", "/chunks/oasis/invoices/profile.js": "/chunks/oasis/invoices/profile.js?id=c552dc38756ae53a6f23",
"/chunks/oasis/invoices~chunks/platform~chunks/shared.js": "/chunks/oasis/invoices~chunks/platform~chunks/shared.js?id=4f78c954ea35727cfa9f", "/chunks/oasis/invoices~chunks/platform~chunks/shared.js": "/chunks/oasis/invoices~chunks/platform~chunks/shared.js?id=4f78c954ea35727cfa9f",
@@ -110,5 +110,15 @@
"/vendors~chunks/admin~chunks/admin-account~chunks/app-appearance~chunks/app-billings~chunks/app-email~4509a016.js": "/vendors~chunks/admin~chunks/admin-account~chunks/app-appearance~chunks/app-billings~chunks/app-email~4509a016.js?id=c708d0d8324c04a73bff", "/vendors~chunks/admin~chunks/admin-account~chunks/app-appearance~chunks/app-billings~chunks/app-email~4509a016.js": "/vendors~chunks/admin~chunks/admin-account~chunks/app-appearance~chunks/app-billings~chunks/app-email~4509a016.js?id=c708d0d8324c04a73bff",
"/vendors~chunks/admin~chunks/admin-account~chunks/app-appearance~chunks/app-billings~chunks/app-email~66c4fa45.js": "/vendors~chunks/admin~chunks/admin-account~chunks/app-appearance~chunks/app-billings~chunks/app-email~66c4fa45.js?id=a90d02375626aeb98cba", "/vendors~chunks/admin~chunks/admin-account~chunks/app-appearance~chunks/app-billings~chunks/app-email~66c4fa45.js": "/vendors~chunks/admin~chunks/admin-account~chunks/app-appearance~chunks/app-billings~chunks/app-email~66c4fa45.js?id=a90d02375626aeb98cba",
"/vendors~chunks/files~chunks/oasis/invoices~chunks/platform~chunks/shared~chunks/shared/file-browser~~b42d96c6.js": "/vendors~chunks/files~chunks/oasis/invoices~chunks/platform~chunks/shared~chunks/shared/file-browser~~b42d96c6.js?id=052d693d0460936fcf73", "/vendors~chunks/files~chunks/oasis/invoices~chunks/platform~chunks/shared~chunks/shared/file-browser~~b42d96c6.js": "/vendors~chunks/files~chunks/oasis/invoices~chunks/platform~chunks/shared~chunks/shared/file-browser~~b42d96c6.js?id=052d693d0460936fcf73",
"/vendors~chunks/oasis/invoices~chunks/platform~chunks/shared.js": "/vendors~chunks/oasis/invoices~chunks/platform~chunks/shared.js?id=9b089a73923448db1f5f" "/vendors~chunks/oasis/invoices~chunks/platform~chunks/shared.js": "/vendors~chunks/oasis/invoices~chunks/platform~chunks/shared.js?id=9b089a73923448db1f5f",
"/js/main.821cf80c969286659107.hot-update.js": "/js/main.821cf80c969286659107.hot-update.js",
"/js/main.d2fca26c80514a127d5a.hot-update.js": "/js/main.d2fca26c80514a127d5a.hot-update.js",
"/js/main.256658b9180c80ca1834.hot-update.js": "/js/main.256658b9180c80ca1834.hot-update.js",
"/js/main.87c79141d92781dff75d.hot-update.js": "/js/main.87c79141d92781dff75d.hot-update.js",
"/chunks/oasis/invoices.0ccc93a12deb31c9ac4a.hot-update.js": "/chunks/oasis/invoices.0ccc93a12deb31c9ac4a.hot-update.js",
"/js/main.9585915d6bb4684979d1.hot-update.js": "/js/main.9585915d6bb4684979d1.hot-update.js",
"/chunks/oasis/invoices.a075ea28bf5dbd958f9c.hot-update.js": "/chunks/oasis/invoices.a075ea28bf5dbd958f9c.hot-update.js",
"/js/main.be296ea68969b4bd8724.hot-update.js": "/js/main.be296ea68969b4bd8724.hot-update.js",
"/chunks/oasis/invoices.be296ea68969b4bd8724.hot-update.js": "/chunks/oasis/invoices.be296ea68969b4bd8724.hot-update.js",
"/chunks/oasis/invoices.2a5f508b0e15ad857bcc.hot-update.js": "/chunks/oasis/invoices.2a5f508b0e15ad857bcc.hot-update.js"
} }
+5 -12
View File
@@ -117,29 +117,22 @@
methods: { methods: {
goTo(location) { goTo(location) {
let routes = { let routes = {
'regular-invoice': 'getRegularInvoices', 'regular-invoice': ['getInvoices', 'regular-invoice'],
'advance-invoice': 'getAdvanceInvoices', 'advance-invoice': ['getInvoices', 'advance-invoice'],
'clients': 'getClients', 'clients': ['getClients'],
} }
if (this.$route.name !== 'InvoicesList') { if (this.$route.name !== 'InvoicesList') {
this.$router.push({name: 'InvoicesList'}) this.$router.push({name: 'InvoicesList'})
} }
this.$store.dispatch(routes[location]) this.$store.dispatch(...routes[location])
}, },
}, },
mounted() { mounted() {
if (! this.currentFolder) { if (! this.currentFolder) {
this.$store.dispatch('getInvoices', 'regular-invoice')
this.$store.commit('STORE_CURRENT_FOLDER', {
name: this.$t('in.nav.invoices'),
id: undefined,
location: 'regular-invoice',
})
this.$store.dispatch('getRegularInvoices')
} }
events.$on('mobile-menu:show', () => this.isScaledDown = true) events.$on('mobile-menu:show', () => this.isScaledDown = true)
@@ -516,6 +516,12 @@
}, },
'invoice.client_ico': function (val) { 'invoice.client_ico': function (val) {
this.getCompanyDetails(val) this.getCompanyDetails(val)
},
'isDiscount': function (val) {
if (!val) {
this.invoice.discount_type = undefined
this.invoice.discount_rate = undefined
}
} }
}, },
data() { data() {
@@ -636,10 +642,7 @@
}) })
// Reload invoices and go to invoice page // Reload invoices and go to invoice page
this.$store.dispatch({ this.$store.dispatch('getInvoices', this.invoice.invoice_type)
'regular-invoice': 'getRegularInvoices',
'advance-invoice': 'getAdvanceInvoices',
}[this.invoice.invoice_type])
this.$router.push({name: 'InvoicesList'}) this.$router.push({name: 'InvoicesList'})
}) })
@@ -416,6 +416,14 @@
return total return total
} }
}, },
watch: {
'isDiscount': function (val) {
if (!val) {
this.invoice.discount_type = undefined
this.invoice.discount_rate = undefined
}
}
},
data() { data() {
return { return {
fullDetails: undefined, fullDetails: undefined,
@@ -498,10 +506,7 @@
.put(`/api/v1/invoicing/invoices/${this.$route.params.id}`, this.invoice) .put(`/api/v1/invoicing/invoices/${this.$route.params.id}`, this.invoice)
.then(() => { .then(() => {
this.$store.dispatch({ this.$store.dispatch('getInvoices', this.invoice.invoice_type)
'regular-invoice': 'getRegularInvoices',
'advance-invoice': 'getAdvanceInvoices',
}[this.invoice.invoice_type])
this.$router.push({name: 'InvoicesList'}) this.$router.push({name: 'InvoicesList'})
@@ -35,11 +35,11 @@ export default {
methods: { methods: {
showLocation(location) { showLocation(location) {
let routes = { let routes = {
'regular-invoice': 'getRegularInvoices', 'regular-invoice': ['getInvoices', 'regular-invoice'],
'advance-invoice': 'getAdvanceInvoices', 'advance-invoice': ['getInvoices', 'advance-invoice'],
'clients': 'getClients', 'clients': ['getClients'],
} }
this.$store.dispatch(routes[location]) this.$store.dispatch(...routes[location])
} }
} }
} }
+9 -9
View File
@@ -22,7 +22,7 @@ const OasisHelpers = {
location: 'regular-invoice', location: 'regular-invoice',
}) })
store.dispatch('getRegularInvoices') store.dispatch('getInvoices', 'regular-invoice')
} }
Vue.prototype.$getInvoiceDataByLocation = function () { Vue.prototype.$getInvoiceDataByLocation = function () {
@@ -32,12 +32,12 @@ const OasisHelpers = {
: undefined : undefined
let actions = { let actions = {
'regular-invoice': 'getRegularInvoices', 'regular-invoice': ['getInvoices', 'regular-invoice'],
'advance-invoice': 'getAdvanceInvoices', 'advance-invoice': ['getInvoices', 'advance-invoice'],
'clients': 'getClients', 'clients': ['getClients'],
} }
store.dispatch(actions[currentLocation]) store.dispatch(...actions[currentLocation])
} }
Vue.prototype.$shareInvoice = function (entry) { Vue.prototype.$shareInvoice = function (entry) {
@@ -98,12 +98,12 @@ const OasisHelpers = {
} else if (typeof value !== 'undefined') { } else if (typeof value !== 'undefined') {
let locations = { let locations = {
'regular-invoice': 'getRegularInvoices', 'regular-invoice': ['getInvoices', 'regular-invoice'],
'advance-invoice': 'getAdvanceInvoices', 'advance-invoice': ['getInvoices', 'advance-invoice'],
'clients': 'getClients', 'clients': ['getClients'],
} }
store.dispatch(locations[store.getters.currentFolder.location]) store.dispatch(...locations[store.getters.currentFolder.location])
store.commit('CHANGE_SEARCHING_STATE', false) store.commit('CHANGE_SEARCHING_STATE', false)
} }
+7 -24
View File
@@ -10,38 +10,19 @@ const defaultState = {
} }
const actions = { const actions = {
getRegularInvoices: ({commit, getters}) => { getInvoices: ({commit, getters}, type) => {
commit('LOADING_STATE', {loading: true, data: []}) commit('LOADING_STATE', {loading: true, data: []})
commit('STORE_CURRENT_FOLDER', { commit('STORE_CURRENT_FOLDER', {
name: 'Invoices', name: 'Invoices',
id: undefined, id: undefined,
location: 'regular-invoice', location: type,
}) })
axios let order = getters.invoiceSorting.sorting.sort === 'DESC' ? '-' : ''
.get('/api/v1/invoicing/invoices/regular' + getters.invoiceSorting.URI)
.then(response => {
commit('LOADING_STATE', {loading: false, data: response.data})
})
.catch(() => {
Vue.prototype.$isSomethingWrong()
})
.finally(() => {
events.$emit('scrollTop')
})
},
getAdvanceInvoices: ({commit, getters}) => {
commit('LOADING_STATE', {loading: true, data: []})
commit('STORE_CURRENT_FOLDER', {
name: 'Advance Invoices',
id: undefined,
location: 'advance-invoice',
})
axios axios
.get('/api/v1/invoicing/invoices/advance' + getters.invoiceSorting.URI) .get(`/api/v1/invoicing/invoices?filter[invoice_type]=${type}&sort=${order}${getters.invoiceSorting.sorting.field}`)
.then(response => { .then(response => {
commit('LOADING_STATE', {loading: false, data: response.data}) commit('LOADING_STATE', {loading: false, data: response.data})
}) })
@@ -61,8 +42,10 @@ const actions = {
location: 'clients', location: 'clients',
}) })
let order = getters.invoiceSorting.sorting.sort === 'DESC' ? '-' : ''
axios axios
.get('/api/v1/invoicing/clients' + getters.invoiceSorting.URI) .get(`/api/v1/invoicing/clients?sort=${order}${getters.invoiceSorting.sorting.field}`)
.then(response => { .then(response => {
commit('LOADING_STATE', {loading: false, data: response.data}) commit('LOADING_STATE', {loading: false, data: response.data})
}) })