Adjustments for when deleting invoices paid with a credit

This commit is contained in:
David Bomba 2025-03-06 19:36:37 +11:00
parent 4f4ab9d02b
commit 68109972df
6 changed files with 47 additions and 98 deletions

View File

@ -322,7 +322,7 @@ class Client extends BaseModel implements HasLocalePreference
public function locations(): \Illuminate\Database\Eloquent\Relations\HasMany public function locations(): \Illuminate\Database\Eloquent\Relations\HasMany
{ {
return $this->hasMany(Location::class)->withTrashed(); return $this->hasMany(Location::class);
} }
/** /**

View File

@ -56,6 +56,13 @@ class BaseDriver extends AbstractPaymentDriver
/* The Invitation */ /* The Invitation */
public $invitation; public $invitation;
/**
* Indicates if returning responses should be headless or classic redirect.
*
* @var bool
*/
public bool $headless = false;
/** /**
* The Client * The Client
* *
@ -173,6 +180,13 @@ class BaseDriver extends AbstractPaymentDriver
return $fields; return $fields;
} }
public function setHeadless($headless): self
{
$this->headless = $headless;
return $this;
}
/** /**
* Authorize a payment method. * Authorize a payment method.
* *

View File

@ -106,13 +106,6 @@ class StripePaymentDriver extends BaseDriver
public const SYSTEM_LOG_TYPE = SystemLog::TYPE_STRIPE; public const SYSTEM_LOG_TYPE = SystemLog::TYPE_STRIPE;
/**
* Indicates if returning responses should be headless or classic redirect.
*
* @var bool
*/
public bool $headless = false;
/** /**
* Initializes the Stripe API. * Initializes the Stripe API.
* @return self * @return self

View File

@ -13,6 +13,7 @@ namespace App\Services\Invoice;
use App\Events\Invoice\InvoiceWasDeleted; use App\Events\Invoice\InvoiceWasDeleted;
use App\Jobs\Inventory\AdjustProductInventory; use App\Jobs\Inventory\AdjustProductInventory;
use App\Models\Credit;
use App\Models\Invoice; use App\Models\Invoice;
use App\Models\Quote; use App\Models\Quote;
use App\Services\AbstractService; use App\Services\AbstractService;
@ -199,6 +200,16 @@ class MarkInvoiceDeleted extends AbstractService
->where('paymentable_type', '=', 'invoices') ->where('paymentable_type', '=', 'invoices')
->where('paymentable_id', $this->invoice->id) ->where('paymentable_id', $this->invoice->id)
->update(['deleted_at' => now()]); ->update(['deleted_at' => now()]);
$pp = \App\Models\Paymentable::where('payment_id', $payment->id)
->where('paymentable_type', \App\Models\Credit::class)
->where('amount', $this->invoice->amount)
->first();
if($pp) {
$pp->delete();
}
}); });
return $this; return $this;

View File

@ -64,7 +64,6 @@
"hyvor/php-json-exporter": "^0.0.3", "hyvor/php-json-exporter": "^0.0.3",
"imdhemy/laravel-purchases": "^1.7", "imdhemy/laravel-purchases": "^1.7",
"intervention/image": "^2.5", "intervention/image": "^2.5",
"invoiceninja/admin-api": "dev-main",
"invoiceninja/einvoice": "dev-main", "invoiceninja/einvoice": "dev-main",
"invoiceninja/inspector": "^3.0", "invoiceninja/inspector": "^3.0",
"invoiceninja/ubl_invoice": "^2", "invoiceninja/ubl_invoice": "^2",
@ -225,8 +224,9 @@
"url": "https://github.com/turbo124/snappdf" "url": "https://github.com/turbo124/snappdf"
}, },
{ {
"type": "vcs", "type": "path",
"url": "https://github.com/invoiceninja/admin-api" "url": "../admin-api"
} }
], ],
"minimum-stability": "dev", "minimum-stability": "dev",

105
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "d7f18cbb363582cea71dd4423f38539e", "content-hash": "2937b569c924dcc633b94288887c722c",
"packages": [ "packages": [
{ {
"name": "adrienrn/php-mimetyper", "name": "adrienrn/php-mimetyper",
@ -4511,74 +4511,6 @@
], ],
"time": "2022-05-21T17:30:32+00:00" "time": "2022-05-21T17:30:32+00:00"
}, },
{
"name": "invoiceninja/admin-api",
"version": "dev-main",
"source": {
"type": "git",
"url": "git@github.com:invoiceninja/admin-api.git",
"reference": "20e652814f85db0f1825236843bb168b363859ee"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/invoiceninja/admin-api/zipball/20e652814f85db0f1825236843bb168b363859ee",
"reference": "20e652814f85db0f1825236843bb168b363859ee",
"shasum": ""
},
"require": {
"afosto/yaac": "^1.5",
"asm/php-ansible": "dev-main",
"ext-curl": "*",
"ext-dom": "*",
"ext-json": "*",
"ext-libxml": "*",
"ext-simplexml": "*",
"illuminate/database": "^11",
"illuminate/support": "^11",
"imdhemy/laravel-purchases": "^1.7",
"php": "^8.2|^8.3|^8.4"
},
"require-dev": {
"larastan/larastan": "^3.0",
"orchestra/testbench": "^9.0",
"phpstan/phpstan": "^2.0",
"phpunit/phpunit": "^11.0"
},
"default-branch": true,
"type": "library",
"extra": {
"laravel": {
"providers": [
"InvoiceNinja\\AdminApi\\Providers\\AdminApiServiceProvider"
]
}
},
"autoload": {
"psr-4": {
"InvoiceNinja\\AdminApi\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"InvoiceNinja\\AdminApi\\Tests\\": "tests/"
}
},
"license": [
"Elastic"
],
"authors": [
{
"name": "David Bomba",
"email": "turbo124@gmail.com"
}
],
"description": "API endpoints for the admin interface",
"support": {
"source": "https://github.com/invoiceninja/admin-api/tree/main",
"issues": "https://github.com/invoiceninja/admin-api/issues"
},
"time": "2025-03-05T05:43:36+00:00"
},
{ {
"name": "invoiceninja/einvoice", "name": "invoiceninja/einvoice",
"version": "dev-main", "version": "dev-main",
@ -17340,16 +17272,16 @@
}, },
{ {
"name": "brianium/paratest", "name": "brianium/paratest",
"version": "v7.8.2", "version": "v7.8.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/paratestphp/paratest.git", "url": "https://github.com/paratestphp/paratest.git",
"reference": "22c45ae560825291f11b32455878b89e718e758c" "reference": "a585c346ddf1bec22e51e20b5387607905604a71"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/paratestphp/paratest/zipball/22c45ae560825291f11b32455878b89e718e758c", "url": "https://api.github.com/repos/paratestphp/paratest/zipball/a585c346ddf1bec22e51e20b5387607905604a71",
"reference": "22c45ae560825291f11b32455878b89e718e758c", "reference": "a585c346ddf1bec22e51e20b5387607905604a71",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -17360,19 +17292,19 @@
"fidry/cpu-core-counter": "^1.2.0", "fidry/cpu-core-counter": "^1.2.0",
"jean85/pretty-package-versions": "^2.1.0", "jean85/pretty-package-versions": "^2.1.0",
"php": "~8.2.0 || ~8.3.0 || ~8.4.0", "php": "~8.2.0 || ~8.3.0 || ~8.4.0",
"phpunit/php-code-coverage": "^11.0.8 || ^12", "phpunit/php-code-coverage": "^11.0.9 || ^12.0.4",
"phpunit/php-file-iterator": "^5.1.0 || ^6", "phpunit/php-file-iterator": "^5.1.0 || ^6",
"phpunit/php-timer": "^7.0.1 || ^8", "phpunit/php-timer": "^7.0.1 || ^8",
"phpunit/phpunit": "^11.5.7 || ^12.0.1", "phpunit/phpunit": "^11.5.11 || ^12.0.6",
"sebastian/environment": "^7.2.0 || ^8", "sebastian/environment": "^7.2.0 || ^8",
"symfony/console": "^6.4.17 || ^7.2.1", "symfony/console": "^6.4.17 || ^7.2.1",
"symfony/process": "^6.4.15 || ^7.2.0" "symfony/process": "^6.4.19 || ^7.2.4"
}, },
"require-dev": { "require-dev": {
"doctrine/coding-standard": "^12.0.0", "doctrine/coding-standard": "^12.0.0",
"ext-pcov": "*", "ext-pcov": "*",
"ext-posix": "*", "ext-posix": "*",
"phpstan/phpstan": "^2.1.5", "phpstan/phpstan": "^2.1.6",
"phpstan/phpstan-deprecation-rules": "^2.0.1", "phpstan/phpstan-deprecation-rules": "^2.0.1",
"phpstan/phpstan-phpunit": "^2.0.4", "phpstan/phpstan-phpunit": "^2.0.4",
"phpstan/phpstan-strict-rules": "^2.0.3", "phpstan/phpstan-strict-rules": "^2.0.3",
@ -17417,7 +17349,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/paratestphp/paratest/issues", "issues": "https://github.com/paratestphp/paratest/issues",
"source": "https://github.com/paratestphp/paratest/tree/v7.8.2" "source": "https://github.com/paratestphp/paratest/tree/v7.8.3"
}, },
"funding": [ "funding": [
{ {
@ -17429,7 +17361,7 @@
"type": "paypal" "type": "paypal"
} }
], ],
"time": "2025-02-19T07:26:44+00:00" "time": "2025-03-05T08:29:11+00:00"
}, },
{ {
"name": "clue/ndjson-react", "name": "clue/ndjson-react",
@ -19041,16 +18973,16 @@
}, },
{ {
"name": "phpunit/phpunit", "name": "phpunit/phpunit",
"version": "11.5.10", "version": "11.5.11",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git", "url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "d5df2b32d729562ff8db634678d71085ee579006" "reference": "3946ac38410be7440186c6e74584f31b15107fc7"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/d5df2b32d729562ff8db634678d71085ee579006", "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/3946ac38410be7440186c6e74584f31b15107fc7",
"reference": "d5df2b32d729562ff8db634678d71085ee579006", "reference": "3946ac38410be7440186c6e74584f31b15107fc7",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -19064,7 +18996,7 @@
"phar-io/manifest": "^2.0.4", "phar-io/manifest": "^2.0.4",
"phar-io/version": "^3.2.1", "phar-io/version": "^3.2.1",
"php": ">=8.2", "php": ">=8.2",
"phpunit/php-code-coverage": "^11.0.8", "phpunit/php-code-coverage": "^11.0.9",
"phpunit/php-file-iterator": "^5.1.0", "phpunit/php-file-iterator": "^5.1.0",
"phpunit/php-invoker": "^5.0.1", "phpunit/php-invoker": "^5.0.1",
"phpunit/php-text-template": "^4.0.1", "phpunit/php-text-template": "^4.0.1",
@ -19122,7 +19054,7 @@
"support": { "support": {
"issues": "https://github.com/sebastianbergmann/phpunit/issues", "issues": "https://github.com/sebastianbergmann/phpunit/issues",
"security": "https://github.com/sebastianbergmann/phpunit/security/policy", "security": "https://github.com/sebastianbergmann/phpunit/security/policy",
"source": "https://github.com/sebastianbergmann/phpunit/tree/11.5.10" "source": "https://github.com/sebastianbergmann/phpunit/tree/11.5.11"
}, },
"funding": [ "funding": [
{ {
@ -19138,7 +19070,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2025-02-25T06:11:48+00:00" "time": "2025-03-05T07:36:02+00:00"
}, },
{ {
"name": "react/cache", "name": "react/cache",
@ -21281,7 +21213,6 @@
"asm/php-ansible": 20, "asm/php-ansible": 20,
"beganovich/snappdf": 20, "beganovich/snappdf": 20,
"horstoeko/orderx": 20, "horstoeko/orderx": 20,
"invoiceninja/admin-api": 20,
"invoiceninja/einvoice": 20, "invoiceninja/einvoice": 20,
"socialiteproviders/apple": 20 "socialiteproviders/apple": 20
}, },