mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Add expense categories if they do not exist on import
This commit is contained in:
parent
e5c3c1b257
commit
524901c872
@ -600,6 +600,8 @@ class BaseTransformer
|
||||
*/
|
||||
public function getExpenseCategoryId($name)
|
||||
{
|
||||
/** @var \App\Models\ExpenseCategory $ec */
|
||||
|
||||
$ec = ExpenseCategory::where('company_id', $this->company->id)
|
||||
->where('is_deleted', false)
|
||||
->whereRaw("LOWER(REPLACE(`name`, ' ' ,'')) = ?", [
|
||||
@ -607,6 +609,13 @@ class BaseTransformer
|
||||
])
|
||||
->first();
|
||||
|
||||
if($ec)
|
||||
return $ec->id;
|
||||
|
||||
$ec = \App\Factory\ExpenseCategoryFactory::create($this->company->id, $this->company->owner()->id);
|
||||
$ec->name = $name;
|
||||
$ec->save();
|
||||
|
||||
return $ec ? $ec->id : null;
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ class CompanyTaxRate implements ShouldQueue
|
||||
->where('country_id', 840)
|
||||
->whereNotNull('postal_code')
|
||||
->whereNull('tax_data')
|
||||
->whereFalse('is_tax_exempt')
|
||||
->where('is_tax_exempt', false)
|
||||
->cursor()
|
||||
->each(function ($client) {
|
||||
|
||||
|
@ -24,7 +24,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
* @property int|null $created_at
|
||||
* @property int|null $updated_at
|
||||
* @property int|null $deleted_at
|
||||
* @property int $is_deleted
|
||||
* @property bool $is_deleted
|
||||
* @property string $color
|
||||
* @property int|null $bank_category_id
|
||||
* @property-read \App\Models\Expense|null $expense
|
||||
|
Loading…
x
Reference in New Issue
Block a user