mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-08 05:54:29 -04:00
save mailbox at company
This commit is contained in:
parent
8bd9f34d98
commit
a6f9275144
@ -49,6 +49,11 @@ class CompanyFactory
|
||||
$company->markdown_enabled = false;
|
||||
$company->tax_data = new TaxModel();
|
||||
$company->first_month_of_year = 1;
|
||||
|
||||
// default mailbox
|
||||
$company->expense_mailbox = config('ninja.inbound_expense.webhook.mailbox_template') != '' ?
|
||||
str_replace('{{company_key}}', $company->company_key, config('ninja.inbound_expense.webhook.mailbox_template')) : null;
|
||||
|
||||
return $company;
|
||||
}
|
||||
}
|
||||
|
@ -86,14 +86,14 @@ class ExpenseMailboxJob implements ShouldQueue
|
||||
|
||||
private function getImapCredentials()
|
||||
{
|
||||
$servers = array_map('trim', explode(",", config('ninja.imap_inbound_expense.servers')));
|
||||
$ports = explode(",", config('ninja.imap_inbound_expense.servers'));
|
||||
$users = explode(",", config('ninja.imap_inbound_expense.servers'));
|
||||
$passwords = explode(",", config('ninja.imap_inbound_expense.servers'));
|
||||
$companies = explode(",", config('ninja.imap_inbound_expense.servers'));
|
||||
$servers = array_map('trim', explode(",", config('ninja.inbound_expense.imap.servers')));
|
||||
$ports = explode(",", config('ninja.inbound_expense.imap.servers'));
|
||||
$users = explode(",", config('ninja.inbound_expense.imap.servers'));
|
||||
$passwords = explode(",", config('ninja.inbound_expense.imap.servers'));
|
||||
$companies = explode(",", config('ninja.inbound_expense.imap.servers'));
|
||||
|
||||
if (sizeOf($servers) != sizeOf($ports) || sizeOf($servers) != sizeOf($users) || sizeOf($servers) != sizeOf($passwords) || sizeOf($servers) != sizeOf($companies))
|
||||
throw new \Exception('invalid configuration imap_inbound_expenses (wrong element-count)');
|
||||
throw new \Exception('invalid configuration inbound_expense.imap (wrong element-count)');
|
||||
|
||||
foreach ($companies as $index => $companyId) {
|
||||
$this->imap_credentials[$companyId] = [
|
||||
|
@ -111,6 +111,8 @@ use Laracasts\Presenter\PresentableTrait;
|
||||
* @property int $convert_expense_currency
|
||||
* @property int $notify_vendor_when_paid
|
||||
* @property int $invoice_task_hours
|
||||
* @property boolean $expense_import
|
||||
* @property string|null $expense_mailbox
|
||||
* @property int $deleted_at
|
||||
* @property-read \App\Models\Account $account
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Activity> $activities
|
||||
@ -352,6 +354,8 @@ class Company extends BaseModel
|
||||
'calculate_taxes',
|
||||
'tax_data',
|
||||
'e_invoice_certificate_passphrase',
|
||||
'expense_import',
|
||||
'expense_mailbox', // TODO: @turbo124 custom validation: self-hosted => free change, hosted => not changeable, only changeable with env-mask
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
|
@ -228,11 +228,17 @@ return [
|
||||
'secret' => env('PAYPAL_SECRET', null),
|
||||
'client_id' => env('PAYPAL_CLIENT_ID', null),
|
||||
],
|
||||
'imap_inbound_expense' => [
|
||||
'servers' => env('IMAP_INBOUND_EXPENSE_SERVERS', ''),
|
||||
'ports' => env('IMAP_INBOUND_EXPENSE_PORTS', ''),
|
||||
'users' => env('IMAP_INBOUND_EXPENSE_USERS', ''),
|
||||
'passwords' => env('IMAP_INBOUND_EXPENSE_PASSWORDS', ''),
|
||||
'companies' => env('IMAP_INBOUND_EXPENSE_COMPANIES', ''),
|
||||
]
|
||||
'inbound_expense' => [
|
||||
'imap' => [
|
||||
'servers' => env('INBOUND_EXPENSE_IMAP_SERVERS', ''),
|
||||
'ports' => env('INBOUND_EXPENSE_IMAP_PORTS', ''),
|
||||
'users' => env('INBOUND_EXPENSE_IMAP_USERS', ''),
|
||||
'passwords' => env('INBOUND_EXPENSE_IMAP_PASSWORDS', ''),
|
||||
'companies' => env('INBOUND_EXPENSE_IMAP_COMPANIES', ''),
|
||||
],
|
||||
'webhook' => [
|
||||
'mailbox_template' => env('INBOUND_EXPENSE_WEBHOOK_MAILBOXTEMPLATE', null),
|
||||
'mailbox_template_enterprise' => env('INBOUND_EXPENSE_WEBHOOK_MAILBOXTEMPLATE_ENTERPRISE', '{{input}}@expense.invoicing.co'),
|
||||
],
|
||||
],
|
||||
];
|
||||
|
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Company;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
@ -11,7 +12,14 @@ return new class extends Migration {
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('company', function (Blueprint $table) {
|
||||
$table->string("expense_import")->default(true);
|
||||
$table->boolean("expense_import")->default(true);
|
||||
$table->string("expense_mailbox")->nullable();
|
||||
});
|
||||
Company::query()->cursor()->each(function ($company) { // TODO: @turbo124 check migration on staging environment with real data to ensure, this works as exspected
|
||||
$company->expense_mailbox = config('ninja.inbound_expense.webhook.mailbox_template') != '' ?
|
||||
str_replace('{{company_key}}', $company->company_key, config('ninja.inbound_expense.webhook.mailbox_template')) : null;
|
||||
|
||||
$company->save();
|
||||
});
|
||||
Schema::table('vendor', function (Blueprint $table) {
|
||||
$table->string("expense_sender_email")->nullable();
|
||||
|
Loading…
x
Reference in New Issue
Block a user