1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

Refactor for data providers for templates

This commit is contained in:
David Bomba 2023-10-01 15:40:50 +11:00
parent 2dd98ccbc5
commit 9231dab999
3 changed files with 113 additions and 107 deletions

File diff suppressed because one or more lines are too long

193
composer.lock generated
View File

@ -3397,16 +3397,16 @@
},
{
"name": "horstoeko/zugferd",
"version": "v1.0.29",
"version": "v1.0.30",
"source": {
"type": "git",
"url": "https://github.com/horstoeko/zugferd.git",
"reference": "9fb81e2e9a16d10bec8bf655484aae11bdca1997"
"reference": "b5e85651fe2e53eef82aa086c9245b7f5229433f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/horstoeko/zugferd/zipball/9fb81e2e9a16d10bec8bf655484aae11bdca1997",
"reference": "9fb81e2e9a16d10bec8bf655484aae11bdca1997",
"url": "https://api.github.com/repos/horstoeko/zugferd/zipball/b5e85651fe2e53eef82aa086c9245b7f5229433f",
"reference": "b5e85651fe2e53eef82aa086c9245b7f5229433f",
"shasum": ""
},
"require": {
@ -3464,9 +3464,9 @@
],
"support": {
"issues": "https://github.com/horstoeko/zugferd/issues",
"source": "https://github.com/horstoeko/zugferd/tree/v1.0.29"
"source": "https://github.com/horstoeko/zugferd/tree/v1.0.30"
},
"time": "2023-09-23T06:15:04+00:00"
"time": "2023-09-30T13:42:02+00:00"
},
{
"name": "http-interop/http-factory-guzzle",
@ -4487,16 +4487,16 @@
},
{
"name": "laravel/prompts",
"version": "v0.1.9",
"version": "v0.1.10",
"source": {
"type": "git",
"url": "https://github.com/laravel/prompts.git",
"reference": "b603410e7af1040aa2d29e0a2cdca570bb63e827"
"reference": "37ed55f6950d921a87d5beeab16d03f8de26b060"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/prompts/zipball/b603410e7af1040aa2d29e0a2cdca570bb63e827",
"reference": "b603410e7af1040aa2d29e0a2cdca570bb63e827",
"url": "https://api.github.com/repos/laravel/prompts/zipball/37ed55f6950d921a87d5beeab16d03f8de26b060",
"reference": "37ed55f6950d921a87d5beeab16d03f8de26b060",
"shasum": ""
},
"require": {
@ -4538,9 +4538,9 @@
],
"support": {
"issues": "https://github.com/laravel/prompts/issues",
"source": "https://github.com/laravel/prompts/tree/v0.1.9"
"source": "https://github.com/laravel/prompts/tree/v0.1.10"
},
"time": "2023-09-26T13:14:20+00:00"
"time": "2023-09-29T07:26:07+00:00"
},
{
"name": "laravel/serializable-closure",
@ -10621,16 +10621,16 @@
},
{
"name": "symfony/error-handler",
"version": "v6.3.2",
"version": "v6.3.5",
"source": {
"type": "git",
"url": "https://github.com/symfony/error-handler.git",
"reference": "85fd65ed295c4078367c784e8a5a6cee30348b7a"
"reference": "1f69476b64fb47105c06beef757766c376b548c4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/error-handler/zipball/85fd65ed295c4078367c784e8a5a6cee30348b7a",
"reference": "85fd65ed295c4078367c784e8a5a6cee30348b7a",
"url": "https://api.github.com/repos/symfony/error-handler/zipball/1f69476b64fb47105c06beef757766c376b548c4",
"reference": "1f69476b64fb47105c06beef757766c376b548c4",
"shasum": ""
},
"require": {
@ -10675,7 +10675,7 @@
"description": "Provides tools to manage errors and ease debugging PHP code",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/error-handler/tree/v6.3.2"
"source": "https://github.com/symfony/error-handler/tree/v6.3.5"
},
"funding": [
{
@ -10691,7 +10691,7 @@
"type": "tidelift"
}
],
"time": "2023-07-16T17:05:46+00:00"
"time": "2023-09-12T06:57:20+00:00"
},
{
"name": "symfony/event-dispatcher",
@ -10914,16 +10914,16 @@
},
{
"name": "symfony/finder",
"version": "v6.3.3",
"version": "v6.3.5",
"source": {
"type": "git",
"url": "https://github.com/symfony/finder.git",
"reference": "9915db259f67d21eefee768c1abcf1cc61b1fc9e"
"reference": "a1b31d88c0e998168ca7792f222cbecee47428c4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/finder/zipball/9915db259f67d21eefee768c1abcf1cc61b1fc9e",
"reference": "9915db259f67d21eefee768c1abcf1cc61b1fc9e",
"url": "https://api.github.com/repos/symfony/finder/zipball/a1b31d88c0e998168ca7792f222cbecee47428c4",
"reference": "a1b31d88c0e998168ca7792f222cbecee47428c4",
"shasum": ""
},
"require": {
@ -10958,7 +10958,7 @@
"description": "Finds files and directories via an intuitive fluent interface",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/finder/tree/v6.3.3"
"source": "https://github.com/symfony/finder/tree/v6.3.5"
},
"funding": [
{
@ -10974,20 +10974,20 @@
"type": "tidelift"
}
],
"time": "2023-07-31T08:31:44+00:00"
"time": "2023-09-26T12:56:25+00:00"
},
{
"name": "symfony/http-client",
"version": "v6.3.2",
"version": "v6.3.5",
"source": {
"type": "git",
"url": "https://github.com/symfony/http-client.git",
"reference": "15f9f4bad62bfcbe48b5dedd866f04a08fc7ff00"
"reference": "213e564da4cbf61acc9728d97e666bcdb868c10d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/http-client/zipball/15f9f4bad62bfcbe48b5dedd866f04a08fc7ff00",
"reference": "15f9f4bad62bfcbe48b5dedd866f04a08fc7ff00",
"url": "https://api.github.com/repos/symfony/http-client/zipball/213e564da4cbf61acc9728d97e666bcdb868c10d",
"reference": "213e564da4cbf61acc9728d97e666bcdb868c10d",
"shasum": ""
},
"require": {
@ -11050,7 +11050,7 @@
"http"
],
"support": {
"source": "https://github.com/symfony/http-client/tree/v6.3.2"
"source": "https://github.com/symfony/http-client/tree/v6.3.5"
},
"funding": [
{
@ -11066,7 +11066,7 @@
"type": "tidelift"
}
],
"time": "2023-07-05T08:41:27+00:00"
"time": "2023-09-29T15:57:12+00:00"
},
{
"name": "symfony/http-client-contracts",
@ -11148,16 +11148,16 @@
},
{
"name": "symfony/http-foundation",
"version": "v6.3.4",
"version": "v6.3.5",
"source": {
"type": "git",
"url": "https://github.com/symfony/http-foundation.git",
"reference": "cac1556fdfdf6719668181974104e6fcfa60e844"
"reference": "b50f5e281d722cb0f4c296f908bacc3e2b721957"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/http-foundation/zipball/cac1556fdfdf6719668181974104e6fcfa60e844",
"reference": "cac1556fdfdf6719668181974104e6fcfa60e844",
"url": "https://api.github.com/repos/symfony/http-foundation/zipball/b50f5e281d722cb0f4c296f908bacc3e2b721957",
"reference": "b50f5e281d722cb0f4c296f908bacc3e2b721957",
"shasum": ""
},
"require": {
@ -11205,7 +11205,7 @@
"description": "Defines an object-oriented layer for the HTTP specification",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/http-foundation/tree/v6.3.4"
"source": "https://github.com/symfony/http-foundation/tree/v6.3.5"
},
"funding": [
{
@ -11221,20 +11221,20 @@
"type": "tidelift"
}
],
"time": "2023-08-22T08:20:46+00:00"
"time": "2023-09-04T21:33:54+00:00"
},
{
"name": "symfony/http-kernel",
"version": "v6.3.4",
"version": "v6.3.5",
"source": {
"type": "git",
"url": "https://github.com/symfony/http-kernel.git",
"reference": "36abb425b4af863ae1fe54d8a8b8b4c76a2bccdb"
"reference": "9f991a964368bee8d883e8d57ced4fe9fff04dfc"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/http-kernel/zipball/36abb425b4af863ae1fe54d8a8b8b4c76a2bccdb",
"reference": "36abb425b4af863ae1fe54d8a8b8b4c76a2bccdb",
"url": "https://api.github.com/repos/symfony/http-kernel/zipball/9f991a964368bee8d883e8d57ced4fe9fff04dfc",
"reference": "9f991a964368bee8d883e8d57ced4fe9fff04dfc",
"shasum": ""
},
"require": {
@ -11318,7 +11318,7 @@
"description": "Provides a structured process for converting a Request into a Response",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/http-kernel/tree/v6.3.4"
"source": "https://github.com/symfony/http-kernel/tree/v6.3.5"
},
"funding": [
{
@ -11334,7 +11334,7 @@
"type": "tidelift"
}
],
"time": "2023-08-26T13:54:49+00:00"
"time": "2023-09-30T06:37:04+00:00"
},
{
"name": "symfony/intl",
@ -11420,16 +11420,16 @@
},
{
"name": "symfony/mailer",
"version": "v6.3.0",
"version": "v6.3.5",
"source": {
"type": "git",
"url": "https://github.com/symfony/mailer.git",
"reference": "7b03d9be1dea29bfec0a6c7b603f5072a4c97435"
"reference": "d89611a7830d51b5e118bca38e390dea92f9ea06"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/mailer/zipball/7b03d9be1dea29bfec0a6c7b603f5072a4c97435",
"reference": "7b03d9be1dea29bfec0a6c7b603f5072a4c97435",
"url": "https://api.github.com/repos/symfony/mailer/zipball/d89611a7830d51b5e118bca38e390dea92f9ea06",
"reference": "d89611a7830d51b5e118bca38e390dea92f9ea06",
"shasum": ""
},
"require": {
@ -11480,7 +11480,7 @@
"description": "Helps sending emails",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/mailer/tree/v6.3.0"
"source": "https://github.com/symfony/mailer/tree/v6.3.5"
},
"funding": [
{
@ -11496,20 +11496,20 @@
"type": "tidelift"
}
],
"time": "2023-05-29T12:49:39+00:00"
"time": "2023-09-06T09:47:15+00:00"
},
{
"name": "symfony/mailgun-mailer",
"version": "v6.3.2",
"version": "v6.3.5",
"source": {
"type": "git",
"url": "https://github.com/symfony/mailgun-mailer.git",
"reference": "df371e42a4c2a78a28c8de910f96949040e308fd"
"reference": "b467aba49c8240a71f7027c213d9d140ba1abce7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/mailgun-mailer/zipball/df371e42a4c2a78a28c8de910f96949040e308fd",
"reference": "df371e42a4c2a78a28c8de910f96949040e308fd",
"url": "https://api.github.com/repos/symfony/mailgun-mailer/zipball/b467aba49c8240a71f7027c213d9d140ba1abce7",
"reference": "b467aba49c8240a71f7027c213d9d140ba1abce7",
"shasum": ""
},
"require": {
@ -11549,7 +11549,7 @@
"description": "Symfony Mailgun Mailer Bridge",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/mailgun-mailer/tree/v6.3.2"
"source": "https://github.com/symfony/mailgun-mailer/tree/v6.3.5"
},
"funding": [
{
@ -11565,20 +11565,20 @@
"type": "tidelift"
}
],
"time": "2023-07-20T10:26:17+00:00"
"time": "2023-09-29T17:30:10+00:00"
},
{
"name": "symfony/mime",
"version": "v6.3.3",
"version": "v6.3.5",
"source": {
"type": "git",
"url": "https://github.com/symfony/mime.git",
"reference": "9a0cbd52baa5ba5a5b1f0cacc59466f194730f98"
"reference": "d5179eedf1cb2946dbd760475ebf05c251ef6a6e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/mime/zipball/9a0cbd52baa5ba5a5b1f0cacc59466f194730f98",
"reference": "9a0cbd52baa5ba5a5b1f0cacc59466f194730f98",
"url": "https://api.github.com/repos/symfony/mime/zipball/d5179eedf1cb2946dbd760475ebf05c251ef6a6e",
"reference": "d5179eedf1cb2946dbd760475ebf05c251ef6a6e",
"shasum": ""
},
"require": {
@ -11633,7 +11633,7 @@
"mime-type"
],
"support": {
"source": "https://github.com/symfony/mime/tree/v6.3.3"
"source": "https://github.com/symfony/mime/tree/v6.3.5"
},
"funding": [
{
@ -11649,7 +11649,7 @@
"type": "tidelift"
}
],
"time": "2023-07-31T07:08:24+00:00"
"time": "2023-09-29T06:59:36+00:00"
},
{
"name": "symfony/options-resolver",
@ -13010,16 +13010,16 @@
},
{
"name": "symfony/routing",
"version": "v6.3.3",
"version": "v6.3.5",
"source": {
"type": "git",
"url": "https://github.com/symfony/routing.git",
"reference": "e7243039ab663822ff134fbc46099b5fdfa16f6a"
"reference": "82616e59acd3e3d9c916bba798326cb7796d7d31"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/routing/zipball/e7243039ab663822ff134fbc46099b5fdfa16f6a",
"reference": "e7243039ab663822ff134fbc46099b5fdfa16f6a",
"url": "https://api.github.com/repos/symfony/routing/zipball/82616e59acd3e3d9c916bba798326cb7796d7d31",
"reference": "82616e59acd3e3d9c916bba798326cb7796d7d31",
"shasum": ""
},
"require": {
@ -13073,7 +13073,7 @@
"url"
],
"support": {
"source": "https://github.com/symfony/routing/tree/v6.3.3"
"source": "https://github.com/symfony/routing/tree/v6.3.5"
},
"funding": [
{
@ -13089,7 +13089,7 @@
"type": "tidelift"
}
],
"time": "2023-07-31T07:08:24+00:00"
"time": "2023-09-20T16:05:51+00:00"
},
{
"name": "symfony/service-contracts",
@ -13175,16 +13175,16 @@
},
{
"name": "symfony/string",
"version": "v6.3.2",
"version": "v6.3.5",
"source": {
"type": "git",
"url": "https://github.com/symfony/string.git",
"reference": "53d1a83225002635bca3482fcbf963001313fb68"
"reference": "13d76d0fb049051ed12a04bef4f9de8715bea339"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/string/zipball/53d1a83225002635bca3482fcbf963001313fb68",
"reference": "53d1a83225002635bca3482fcbf963001313fb68",
"url": "https://api.github.com/repos/symfony/string/zipball/13d76d0fb049051ed12a04bef4f9de8715bea339",
"reference": "13d76d0fb049051ed12a04bef4f9de8715bea339",
"shasum": ""
},
"require": {
@ -13241,7 +13241,7 @@
"utf8"
],
"support": {
"source": "https://github.com/symfony/string/tree/v6.3.2"
"source": "https://github.com/symfony/string/tree/v6.3.5"
},
"funding": [
{
@ -13257,7 +13257,7 @@
"type": "tidelift"
}
],
"time": "2023-07-05T08:41:27+00:00"
"time": "2023-09-18T10:38:32+00:00"
},
{
"name": "symfony/translation",
@ -13508,16 +13508,16 @@
},
{
"name": "symfony/validator",
"version": "v6.3.4",
"version": "v6.3.5",
"source": {
"type": "git",
"url": "https://github.com/symfony/validator.git",
"reference": "0c8435154920b9bbe93bece675234c244cadf73b"
"reference": "48e815ba3b5eb72e632588dbf7ea2dc4e608ee47"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/validator/zipball/0c8435154920b9bbe93bece675234c244cadf73b",
"reference": "0c8435154920b9bbe93bece675234c244cadf73b",
"url": "https://api.github.com/repos/symfony/validator/zipball/48e815ba3b5eb72e632588dbf7ea2dc4e608ee47",
"reference": "48e815ba3b5eb72e632588dbf7ea2dc4e608ee47",
"shasum": ""
},
"require": {
@ -13584,7 +13584,7 @@
"description": "Provides tools to validate values",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/validator/tree/v6.3.4"
"source": "https://github.com/symfony/validator/tree/v6.3.5"
},
"funding": [
{
@ -13600,20 +13600,20 @@
"type": "tidelift"
}
],
"time": "2023-08-17T15:49:05+00:00"
"time": "2023-09-29T07:41:15+00:00"
},
{
"name": "symfony/var-dumper",
"version": "v6.3.4",
"version": "v6.3.5",
"source": {
"type": "git",
"url": "https://github.com/symfony/var-dumper.git",
"reference": "2027be14f8ae8eae999ceadebcda5b4909b81d45"
"reference": "3d9999376be5fea8de47752837a3e1d1c5f69ef5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/var-dumper/zipball/2027be14f8ae8eae999ceadebcda5b4909b81d45",
"reference": "2027be14f8ae8eae999ceadebcda5b4909b81d45",
"url": "https://api.github.com/repos/symfony/var-dumper/zipball/3d9999376be5fea8de47752837a3e1d1c5f69ef5",
"reference": "3d9999376be5fea8de47752837a3e1d1c5f69ef5",
"shasum": ""
},
"require": {
@ -13668,7 +13668,7 @@
"dump"
],
"support": {
"source": "https://github.com/symfony/var-dumper/tree/v6.3.4"
"source": "https://github.com/symfony/var-dumper/tree/v6.3.5"
},
"funding": [
{
@ -13684,7 +13684,7 @@
"type": "tidelift"
}
],
"time": "2023-08-24T14:51:05+00:00"
"time": "2023-09-12T10:11:35+00:00"
},
{
"name": "symfony/yaml",
@ -15181,16 +15181,16 @@
},
{
"name": "friendsofphp/php-cs-fixer",
"version": "v3.30.0",
"version": "v3.34.0",
"source": {
"type": "git",
"url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git",
"reference": "95c64693b2f149966a2bc05a7a4981b0343ea52f"
"reference": "7c7a4ad2ed8fe50df3e25528218b13d383608f23"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/95c64693b2f149966a2bc05a7a4981b0343ea52f",
"reference": "95c64693b2f149966a2bc05a7a4981b0343ea52f",
"url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/7c7a4ad2ed8fe50df3e25528218b13d383608f23",
"reference": "7c7a4ad2ed8fe50df3e25528218b13d383608f23",
"shasum": ""
},
"require": {
@ -15211,6 +15211,9 @@
"symfony/process": "^5.4 || ^6.0",
"symfony/stopwatch": "^5.4 || ^6.0"
},
"conflict": {
"stevebauman/unfinalize": "*"
},
"require-dev": {
"facile-it/paraunit": "^1.3 || ^2.0",
"justinrainbow/json-schema": "^5.2",
@ -15264,7 +15267,7 @@
],
"support": {
"issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues",
"source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.30.0"
"source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.34.0"
},
"funding": [
{
@ -15272,7 +15275,7 @@
"type": "github"
}
],
"time": "2023-09-26T22:10:43+00:00"
"time": "2023-09-29T15:34:26+00:00"
},
{
"name": "hamcrest/hamcrest-php",
@ -15983,16 +15986,16 @@
},
{
"name": "phpstan/phpstan",
"version": "1.10.35",
"version": "1.10.36",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan.git",
"reference": "e730e5facb75ffe09dfb229795e8c01a459f26c3"
"reference": "ffa3089511121a672e62969404e4fddc753f9b15"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/e730e5facb75ffe09dfb229795e8c01a459f26c3",
"reference": "e730e5facb75ffe09dfb229795e8c01a459f26c3",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/ffa3089511121a672e62969404e4fddc753f9b15",
"reference": "ffa3089511121a672e62969404e4fddc753f9b15",
"shasum": ""
},
"require": {
@ -16041,7 +16044,7 @@
"type": "tidelift"
}
],
"time": "2023-09-19T15:27:56+00:00"
"time": "2023-09-29T14:07:45+00:00"
},
{
"name": "phpunit/php-code-coverage",

View File

@ -229,11 +229,6 @@ class TemplateTest extends TestCase
$arr = $response->json();
// $p = Payment::with('client','invoices','paymentables','credits')
// ->where('id', $this->decodePrimaryKey($arr['data']['id']))->first();
// nlog($p->toArray());
$start = microtime(true);
$p = Payment::with('client','invoices','paymentables','credits')
@ -251,7 +246,8 @@ class TemplateTest extends TestCase
$this->assertIsArray($data);
$start = microtime(true);
\DB::enableQueryLog();
\DB::enableQueryLog();
$invoices = Invoice::with('client','payments.client','payments.paymentables','payments.credits','credits.client')
->orderBy('id','desc')
@ -260,8 +256,9 @@ class TemplateTest extends TestCase
->get()
->map(function($invoice){
$payments = [];
$payments = $invoice->payments->map(function ($payment){
nlog(microtime(true));
// nlog(microtime(true));
return $this->transformPayment($payment);
})->toArray();
@ -318,16 +315,19 @@ class TemplateTest extends TestCase
'payment_balance' => $invoice->client->payment_balance,
'credit_balance' => $invoice->client->credit_balance,
],
'payments' => $payments
'payments' => $payments,
];
})->toArray();
});
$queries = \DB::getQueryLog();
$count = count($queries);
nlog("query count = {$count}");
nlog($invoices);
$this->assertIsArray($invoices);
$x = $invoices->toArray();
nlog(json_encode(htmlspecialchars(json_encode($x), ENT_QUOTES, 'UTF-8')));
// nlog($invoices->toJson());
$this->assertIsArray($invoices->toArray());
nlog("end invoices = " . microtime(true) - $start);