minor fixes

This commit is contained in:
David Bomba 2025-05-16 07:19:26 +10:00
parent 2929b15cad
commit 0de38c78a1
6 changed files with 95 additions and 24 deletions

View File

@ -639,4 +639,9 @@ class Account extends BaseModel
return 0;
}
public function canTrial(): bool
{
return !$this->is_trial && empty($this->plan) && $this->created_at > time() - (60 * 60 * 24 * 14);
}
}

View File

@ -164,11 +164,13 @@ class DeletePayment
$reduced_paid_to_date = $this->payment->amount < 0 ? $this->payment->amount * -1 : min(0, ($this->payment->amount - $this->payment->refunded - $this->_paid_to_date_deleted) * -1);
$this->payment
->client
->service()
->updatePaidToDate($reduced_paid_to_date)
->save();
if($reduced_paid_to_date != 0) {
$this->payment
->client
->service()
->updatePaidToDate($reduced_paid_to_date)
->save();
}
}
return $this;

View File

@ -89,13 +89,14 @@ class AccountTransformer extends EntityTransformer
'hosted_company_count' => (int) $account->hosted_company_count,
'is_hosted' => (bool) Ninja::isHosted(),
'set_react_as_default_ap' => (bool) $account->set_react_as_default_ap,
'trial_days_left' => Ninja::isHosted() ? (int) $account->getTrialDays() : 0,
'trial_days_left' => Ninja::isSelfHost() ? (int) $account->getTrialDays() : 0,
'account_sms_verified' => (bool) $account->account_sms_verified,
'has_iap_plan' => (bool)$account->inapp_transaction_id,
'tax_api_enabled' => (bool) config('services.tax.zip_tax.key') ? true : false,
'nordigen_enabled' => (bool) (config('ninja.nordigen.secret_id') && config('ninja.nordigen.secret_key')) ? true : false,
'upload_extensions' => (string) "png,ai,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx,webp,xml,zip,csv,ods,odt,odp,".config('ninja.upload_extensions'),
'e_invoice_quota' => (int) $account->e_invoice_quota,
'can_trial' => (bool) $account->canTrial(),
];
}

View File

@ -116,7 +116,8 @@
"twig/twig": "^3.14",
"twilio/sdk": "^6.40",
"wikimedia/composer-merge-plugin": "^2.1",
"wildbit/postmark-php": "^4.0"
"wildbit/postmark-php": "^4.0",
"invoiceninja/admin-api": "dev-main"
},
"require-dev": {
"barryvdh/laravel-debugbar": "^3.6",

94
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "4361272676d998d08fb1926198065b39",
"content-hash": "f6635e28eff8ba2e1ba889d1ef9dd2d6",
"packages": [
{
"name": "adrienrn/php-mimetyper",
@ -4666,6 +4666,65 @@
],
"time": "2022-05-21T17:30:32+00:00"
},
{
"name": "invoiceninja/admin-api",
"version": "dev-main",
"dist": {
"type": "path",
"url": "../admin-api",
"reference": "82e98a684098d3f5d2581d9416e580a9cf29c0d5"
},
"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"
},
"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",
"transport-options": {
"relative": true
}
},
{
"name": "invoiceninja/einvoice",
"version": "dev-main",
@ -5533,16 +5592,16 @@
},
{
"name": "laravel/octane",
"version": "v2.9.1",
"version": "v2.9.3",
"source": {
"type": "git",
"url": "https://github.com/laravel/octane.git",
"reference": "445002b2551c837d60cda4324259063c356dfb56"
"reference": "8278bdb3ae7a9a7380841e18e9cf52d909502647"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/octane/zipball/445002b2551c837d60cda4324259063c356dfb56",
"reference": "445002b2551c837d60cda4324259063c356dfb56",
"url": "https://api.github.com/repos/laravel/octane/zipball/8278bdb3ae7a9a7380841e18e9cf52d909502647",
"reference": "8278bdb3ae7a9a7380841e18e9cf52d909502647",
"shasum": ""
},
"require": {
@ -5619,7 +5678,7 @@
"issues": "https://github.com/laravel/octane/issues",
"source": "https://github.com/laravel/octane"
},
"time": "2025-04-13T21:10:35+00:00"
"time": "2025-05-14T14:05:50+00:00"
},
{
"name": "laravel/prompts",
@ -5682,16 +5741,16 @@
},
{
"name": "laravel/scout",
"version": "v10.14.1",
"version": "v10.15.0",
"source": {
"type": "git",
"url": "https://github.com/laravel/scout.git",
"reference": "6ae3ec83ceacb554f395df9fe15318a14b79bb39"
"reference": "102fe09ae1c045c6f9cf1b3a2234e1fadb2198f2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/scout/zipball/6ae3ec83ceacb554f395df9fe15318a14b79bb39",
"reference": "6ae3ec83ceacb554f395df9fe15318a14b79bb39",
"url": "https://api.github.com/repos/laravel/scout/zipball/102fe09ae1c045c6f9cf1b3a2234e1fadb2198f2",
"reference": "102fe09ae1c045c6f9cf1b3a2234e1fadb2198f2",
"shasum": ""
},
"require": {
@ -5759,7 +5818,7 @@
"issues": "https://github.com/laravel/scout/issues",
"source": "https://github.com/laravel/scout"
},
"time": "2025-04-01T14:58:03+00:00"
"time": "2025-05-13T13:34:05+00:00"
},
{
"name": "laravel/serializable-closure",
@ -18750,16 +18809,16 @@
},
{
"name": "phpstan/phpstan",
"version": "1.12.25",
"version": "1.12.26",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan.git",
"reference": "e310849a19e02b8bfcbb63147f495d8f872dd96f"
"reference": "84cbf8f018e01834b9b1ac3dacf3b9780e209e53"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/e310849a19e02b8bfcbb63147f495d8f872dd96f",
"reference": "e310849a19e02b8bfcbb63147f495d8f872dd96f",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/84cbf8f018e01834b9b1ac3dacf3b9780e209e53",
"reference": "84cbf8f018e01834b9b1ac3dacf3b9780e209e53",
"shasum": ""
},
"require": {
@ -18804,7 +18863,7 @@
"type": "github"
}
],
"time": "2025-04-27T12:20:45+00:00"
"time": "2025-05-14T11:08:32+00:00"
},
{
"name": "phpunit/php-code-coverage",
@ -21380,7 +21439,8 @@
"beganovich/snappdf": 20,
"horstoeko/orderx": 20,
"invoiceninja/einvoice": 20,
"socialiteproviders/apple": 20
"socialiteproviders/apple": 20,
"invoiceninja/admin-api": 20
},
"prefer-stable": true,
"prefer-lowest": false,

View File

@ -5579,6 +5579,8 @@ $lang = array(
'added_location' => 'Successfully added location',
'send_emails' => 'Send Emails',
'send_emails_permission' => 'Allow user to send emails',
'cancel_trial' => 'Cancel Trial',
'cancel_trial_description' => 'This will cancel your trial and remove all paid features from your account.',
);
return $lang;