- 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

View File

@@ -12,9 +12,9 @@ use Kyslik\ColumnSortable\Sortable;
use App\Notifications\ResetPassword;
use Illuminate\Support\Facades\Storage;
use Illuminate\Notifications\Notifiable;
use Makingcg\Invoice\Http\Traits\Invoiceable;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Makingcg\Invoice\App\Traits\Invoiceable;
class User extends Authenticatable
{

194
composer.lock generated
View File

@@ -712,16 +712,16 @@
},
{
"name": "composer/package-versions-deprecated",
"version": "1.11.99.1",
"version": "1.11.99.2",
"source": {
"type": "git",
"url": "https://github.com/composer/package-versions-deprecated.git",
"reference": "7413f0b55a051e89485c5cb9f765fe24bb02a7b6"
"reference": "c6522afe5540d5fc46675043d3ed5a45a740b27c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/composer/package-versions-deprecated/zipball/7413f0b55a051e89485c5cb9f765fe24bb02a7b6",
"reference": "7413f0b55a051e89485c5cb9f765fe24bb02a7b6",
"url": "https://api.github.com/repos/composer/package-versions-deprecated/zipball/c6522afe5540d5fc46675043d3ed5a45a740b27c",
"reference": "c6522afe5540d5fc46675043d3ed5a45a740b27c",
"shasum": ""
},
"require": {
@@ -765,7 +765,7 @@
"description": "Composer plugin that provides efficient querying for installed package versions (no runtime IO)",
"support": {
"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": [
{
@@ -781,7 +781,7 @@
"type": "tidelift"
}
],
"time": "2020-11-11T10:22:58+00:00"
"time": "2021-05-24T07:46:03+00:00"
},
{
"name": "composer/semver",
@@ -3754,7 +3754,7 @@
"dist": {
"type": "path",
"url": "../vuefilemanager-invoicing",
"reference": "397ccf463f15abaef111501681fa69d5785c4d73"
"reference": "51dc6322d98cd7fc487eb2bd4b5582442c1f7c4f"
},
"require": {
"barryvdh/laravel-snappy": "^0.4.8",
@@ -3765,14 +3765,16 @@
"laravel/cashier": "^12.13",
"laravel/sanctum": "^2.11",
"php": "^8.0",
"spatie/data-transfer-object": "^3.1",
"spatie/laravel-package-tools": "^1.4.3",
"spatie/laravel-query-builder": "^3.4.0",
"spatie/laravel-queueable-action": "^2.11",
"teamtnt/laravel-scout-tntsearch-driver": "^11.3"
},
"require-dev": {
"brianium/paratest": "^6.2",
"ext-json": "*",
"friendsofphp/php-cs-fixer": "^2.19",
"friendsofphp/php-cs-fixer": "^3.0",
"nunomaduro/collision": "^5.3",
"orchestra/testbench": "^6.15",
"phpunit/phpunit": "^9.3",
@@ -3784,11 +3786,12 @@
"laravel": {
"providers": [
"Makingcg\\Invoice\\InvoiceServiceProvider",
"Kyslik\\ColumnSortable\\ColumnSortableServiceProvider"
"Kyslik\\ColumnSortable\\ColumnSortableServiceProvider",
"Spatie\\QueryBuilder\\QueryBuilderServiceProvider"
],
"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": {
"psr-4": {
"Makingcg\\Invoice\\Tests\\": "tests"
"App\\": "src/App/",
"Domain\\": "src/Domain/",
"Support\\": "src/Support/",
"Tests\\": "tests/"
}
},
"scripts": {
@@ -7213,6 +7219,72 @@
],
"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",
"version": "2.21.1",
@@ -7365,16 +7437,16 @@
},
{
"name": "spatie/laravel-package-tools",
"version": "1.7.0",
"version": "1.9.0",
"source": {
"type": "git",
"url": "https://github.com/spatie/laravel-package-tools.git",
"reference": "a28108b61dac8a83de6c97f09a5a1e98f4d75522"
"reference": "cf4c4cec220575e2864c6082842d76822421f1b1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/spatie/laravel-package-tools/zipball/a28108b61dac8a83de6c97f09a5a1e98f4d75522",
"reference": "a28108b61dac8a83de6c97f09a5a1e98f4d75522",
"url": "https://api.github.com/repos/spatie/laravel-package-tools/zipball/cf4c4cec220575e2864c6082842d76822421f1b1",
"reference": "cf4c4cec220575e2864c6082842d76822421f1b1",
"shasum": ""
},
"require": {
@@ -7413,7 +7485,7 @@
],
"support": {
"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": [
{
@@ -7421,7 +7493,77 @@
"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",
@@ -10336,16 +10478,16 @@
},
{
"name": "vimeo/psalm",
"version": "4.7.2",
"version": "4.7.3",
"source": {
"type": "git",
"url": "https://github.com/vimeo/psalm.git",
"reference": "83a0325c0a95c0ab531d6b90c877068b464377b5"
"reference": "38c452ae584467e939d55377aaf83b5a26f19dd1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/vimeo/psalm/zipball/83a0325c0a95c0ab531d6b90c877068b464377b5",
"reference": "83a0325c0a95c0ab531d6b90c877068b464377b5",
"url": "https://api.github.com/repos/vimeo/psalm/zipball/38c452ae584467e939d55377aaf83b5a26f19dd1",
"reference": "38c452ae584467e939d55377aaf83b5a26f19dd1",
"shasum": ""
},
"require": {
@@ -10364,7 +10506,7 @@
"felixfbecker/advanced-json-rpc": "^3.0.3",
"felixfbecker/language-server-protocol": "^1.5",
"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",
"php": "^7.1|^8",
"sebastian/diff": "^3.0 || ^4.0",
@@ -10384,7 +10526,7 @@
"phpspec/prophecy": ">=1.9.0",
"phpunit/phpunit": "^9.0",
"psalm/plugin-phpunit": "^0.13",
"slevomat/coding-standard": "^6.3.11",
"slevomat/coding-standard": "^7.0",
"squizlabs/php_codesniffer": "^3.5",
"symfony/process": "^4.3",
"weirdan/phpunit-appveyor-reporter": "^1.0.0",
@@ -10435,9 +10577,9 @@
],
"support": {
"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",

View File

@@ -50,13 +50,13 @@
"/chunks/invoices.js": "/chunks/invoices.js?id=44cc3fb563e6711fcf9f",
"/chunks/not-found-shared.js": "/chunks/not-found-shared.js?id=4ead3393f11e9d24a662",
"/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-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/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/edit-invoice.js": "/chunks/oasis/invoices/edit-invoice.js?id=88f4d717ca4817c4a153",
"/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=3f25967c0e5edd323773",
"/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~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~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/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"
}

View File

@@ -117,29 +117,22 @@
methods: {
goTo(location) {
let routes = {
'regular-invoice': 'getRegularInvoices',
'advance-invoice': 'getAdvanceInvoices',
'clients': 'getClients',
'regular-invoice': ['getInvoices', 'regular-invoice'],
'advance-invoice': ['getInvoices', 'advance-invoice'],
'clients': ['getClients'],
}
if (this.$route.name !== 'InvoicesList') {
this.$router.push({name: 'InvoicesList'})
}
this.$store.dispatch(routes[location])
this.$store.dispatch(...routes[location])
},
},
mounted() {
if (! this.currentFolder) {
this.$store.commit('STORE_CURRENT_FOLDER', {
name: this.$t('in.nav.invoices'),
id: undefined,
location: 'regular-invoice',
})
this.$store.dispatch('getRegularInvoices')
this.$store.dispatch('getInvoices', 'regular-invoice')
}
events.$on('mobile-menu:show', () => this.isScaledDown = true)

View File

@@ -516,6 +516,12 @@
},
'invoice.client_ico': function (val) {
this.getCompanyDetails(val)
},
'isDiscount': function (val) {
if (!val) {
this.invoice.discount_type = undefined
this.invoice.discount_rate = undefined
}
}
},
data() {
@@ -636,10 +642,7 @@
})
// Reload invoices and go to invoice page
this.$store.dispatch({
'regular-invoice': 'getRegularInvoices',
'advance-invoice': 'getAdvanceInvoices',
}[this.invoice.invoice_type])
this.$store.dispatch('getInvoices', this.invoice.invoice_type)
this.$router.push({name: 'InvoicesList'})
})

View File

@@ -416,6 +416,14 @@
return total
}
},
watch: {
'isDiscount': function (val) {
if (!val) {
this.invoice.discount_type = undefined
this.invoice.discount_rate = undefined
}
}
},
data() {
return {
fullDetails: undefined,
@@ -498,10 +506,7 @@
.put(`/api/v1/invoicing/invoices/${this.$route.params.id}`, this.invoice)
.then(() => {
this.$store.dispatch({
'regular-invoice': 'getRegularInvoices',
'advance-invoice': 'getAdvanceInvoices',
}[this.invoice.invoice_type])
this.$store.dispatch('getInvoices', this.invoice.invoice_type)
this.$router.push({name: 'InvoicesList'})

View File

@@ -35,11 +35,11 @@ export default {
methods: {
showLocation(location) {
let routes = {
'regular-invoice': 'getRegularInvoices',
'advance-invoice': 'getAdvanceInvoices',
'clients': 'getClients',
'regular-invoice': ['getInvoices', 'regular-invoice'],
'advance-invoice': ['getInvoices', 'advance-invoice'],
'clients': ['getClients'],
}
this.$store.dispatch(routes[location])
this.$store.dispatch(...routes[location])
}
}
}

View File

@@ -22,7 +22,7 @@ const OasisHelpers = {
location: 'regular-invoice',
})
store.dispatch('getRegularInvoices')
store.dispatch('getInvoices', 'regular-invoice')
}
Vue.prototype.$getInvoiceDataByLocation = function () {
@@ -32,12 +32,12 @@ const OasisHelpers = {
: undefined
let actions = {
'regular-invoice': 'getRegularInvoices',
'advance-invoice': 'getAdvanceInvoices',
'clients': 'getClients',
'regular-invoice': ['getInvoices', 'regular-invoice'],
'advance-invoice': ['getInvoices', 'advance-invoice'],
'clients': ['getClients'],
}
store.dispatch(actions[currentLocation])
store.dispatch(...actions[currentLocation])
}
Vue.prototype.$shareInvoice = function (entry) {
@@ -98,12 +98,12 @@ const OasisHelpers = {
} else if (typeof value !== 'undefined') {
let locations = {
'regular-invoice': 'getRegularInvoices',
'advance-invoice': 'getAdvanceInvoices',
'clients': 'getClients',
'regular-invoice': ['getInvoices', 'regular-invoice'],
'advance-invoice': ['getInvoices', 'advance-invoice'],
'clients': ['getClients'],
}
store.dispatch(locations[store.getters.currentFolder.location])
store.dispatch(...locations[store.getters.currentFolder.location])
store.commit('CHANGE_SEARCHING_STATE', false)
}

View File

@@ -10,38 +10,19 @@ const defaultState = {
}
const actions = {
getRegularInvoices: ({commit, getters}) => {
getInvoices: ({commit, getters}, type) => {
commit('LOADING_STATE', {loading: true, data: []})
commit('STORE_CURRENT_FOLDER', {
name: 'Invoices',
id: undefined,
location: 'regular-invoice',
location: type,
})
axios
.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',
})
let order = getters.invoiceSorting.sorting.sort === 'DESC' ? '-' : ''
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 => {
commit('LOADING_STATE', {loading: false, data: response.data})
})
@@ -61,8 +42,10 @@ const actions = {
location: 'clients',
})
let order = getters.invoiceSorting.sorting.sort === 'DESC' ? '-' : ''
axios
.get('/api/v1/invoicing/clients' + getters.invoiceSorting.URI)
.get(`/api/v1/invoicing/clients?sort=${order}${getters.invoiceSorting.sorting.field}`)
.then(response => {
commit('LOADING_STATE', {loading: false, data: response.data})
})