mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-03 15:34:37 -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)
|
public function getExpenseCategoryId($name)
|
||||||
{
|
{
|
||||||
|
/** @var \App\Models\ExpenseCategory $ec */
|
||||||
|
|
||||||
$ec = ExpenseCategory::where('company_id', $this->company->id)
|
$ec = ExpenseCategory::where('company_id', $this->company->id)
|
||||||
->where('is_deleted', false)
|
->where('is_deleted', false)
|
||||||
->whereRaw("LOWER(REPLACE(`name`, ' ' ,'')) = ?", [
|
->whereRaw("LOWER(REPLACE(`name`, ' ' ,'')) = ?", [
|
||||||
@ -607,6 +609,13 @@ class BaseTransformer
|
|||||||
])
|
])
|
||||||
->first();
|
->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;
|
return $ec ? $ec->id : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ class CompanyTaxRate implements ShouldQueue
|
|||||||
->where('country_id', 840)
|
->where('country_id', 840)
|
||||||
->whereNotNull('postal_code')
|
->whereNotNull('postal_code')
|
||||||
->whereNull('tax_data')
|
->whereNull('tax_data')
|
||||||
->whereFalse('is_tax_exempt')
|
->where('is_tax_exempt', false)
|
||||||
->cursor()
|
->cursor()
|
||||||
->each(function ($client) {
|
->each(function ($client) {
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||||||
* @property int|null $created_at
|
* @property int|null $created_at
|
||||||
* @property int|null $updated_at
|
* @property int|null $updated_at
|
||||||
* @property int|null $deleted_at
|
* @property int|null $deleted_at
|
||||||
* @property int $is_deleted
|
* @property bool $is_deleted
|
||||||
* @property string $color
|
* @property string $color
|
||||||
* @property int|null $bank_category_id
|
* @property int|null $bank_category_id
|
||||||
* @property-read \App\Models\Expense|null $expense
|
* @property-read \App\Models\Expense|null $expense
|
||||||
|
Loading…
x
Reference in New Issue
Block a user