mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Fixes for csv imports - exclude deleted data
This commit is contained in:
parent
f4aeee59fa
commit
49a5a739da
@ -71,6 +71,7 @@ class BaseTransformer
|
|||||||
|
|
||||||
$client_id_search = $this->company
|
$client_id_search = $this->company
|
||||||
->clients()
|
->clients()
|
||||||
|
->where('is_deleted', false)
|
||||||
->where('id_number', $client_name);
|
->where('id_number', $client_name);
|
||||||
|
|
||||||
if ($client_id_search->count() >= 1) {
|
if ($client_id_search->count() >= 1) {
|
||||||
@ -79,6 +80,7 @@ class BaseTransformer
|
|||||||
|
|
||||||
$client_name_search = $this->company
|
$client_name_search = $this->company
|
||||||
->clients()
|
->clients()
|
||||||
|
->where('is_deleted', false)
|
||||||
->where('name', $client_name);
|
->where('name', $client_name);
|
||||||
|
|
||||||
if ($client_name_search->count() >= 1) {
|
if ($client_name_search->count() >= 1) {
|
||||||
@ -86,10 +88,11 @@ class BaseTransformer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!empty($client_email)) {
|
if (!empty($client_email)) {
|
||||||
$contacts = ClientContact::where(
|
$contacts = ClientContact::whereHas('client', function($query){
|
||||||
'company_id',
|
$query->where('is_deleted', false);
|
||||||
$this->company->id
|
})
|
||||||
)->where('email', $client_email);
|
->where('company_id', $this->company->id)
|
||||||
|
->where('email', $client_email);
|
||||||
|
|
||||||
if ($contacts->count() >= 1) {
|
if ($contacts->count() >= 1) {
|
||||||
return $contacts->first()->client_id;
|
return $contacts->first()->client_id;
|
||||||
@ -109,6 +112,7 @@ class BaseTransformer
|
|||||||
{
|
{
|
||||||
return $this->company
|
return $this->company
|
||||||
->clients()
|
->clients()
|
||||||
|
->where('is_deleted', false)
|
||||||
->whereRaw("LOWER(REPLACE(`name`, ' ' ,'')) = ?", [
|
->whereRaw("LOWER(REPLACE(`name`, ' ' ,'')) = ?", [
|
||||||
strtolower(str_replace(' ', '', $name)),
|
strtolower(str_replace(' ', '', $name)),
|
||||||
])
|
])
|
||||||
@ -124,6 +128,7 @@ class BaseTransformer
|
|||||||
{
|
{
|
||||||
return $this->company
|
return $this->company
|
||||||
->vendors()
|
->vendors()
|
||||||
|
->where('is_deleted', false)
|
||||||
->whereRaw("LOWER(REPLACE(`name`, ' ' ,'')) = ?", [
|
->whereRaw("LOWER(REPLACE(`name`, ' ' ,'')) = ?", [
|
||||||
strtolower(str_replace(' ', '', $name)),
|
strtolower(str_replace(' ', '', $name)),
|
||||||
])
|
])
|
||||||
@ -139,6 +144,7 @@ class BaseTransformer
|
|||||||
{
|
{
|
||||||
return $this->company
|
return $this->company
|
||||||
->projects()
|
->projects()
|
||||||
|
->where('is_deleted', false)
|
||||||
->whereRaw("LOWER(REPLACE(`name`, ' ' ,'')) = ?", [
|
->whereRaw("LOWER(REPLACE(`name`, ' ' ,'')) = ?", [
|
||||||
strtolower(str_replace(' ', '', $name)),
|
strtolower(str_replace(' ', '', $name)),
|
||||||
])
|
])
|
||||||
@ -154,6 +160,7 @@ class BaseTransformer
|
|||||||
{
|
{
|
||||||
return $this->company
|
return $this->company
|
||||||
->products()
|
->products()
|
||||||
|
->where('is_deleted', false)
|
||||||
->whereRaw("LOWER(REPLACE(`product_key`, ' ' ,'')) = ?", [
|
->whereRaw("LOWER(REPLACE(`product_key`, ' ' ,'')) = ?", [
|
||||||
strtolower(str_replace(' ', '', $key)),
|
strtolower(str_replace(' ', '', $key)),
|
||||||
])
|
])
|
||||||
@ -186,6 +193,7 @@ class BaseTransformer
|
|||||||
{
|
{
|
||||||
$client = $this->company
|
$client = $this->company
|
||||||
->clients()
|
->clients()
|
||||||
|
->where('is_deleted', false)
|
||||||
->whereRaw("LOWER(REPLACE(`name`, ' ' ,'')) = ?", [
|
->whereRaw("LOWER(REPLACE(`name`, ' ' ,'')) = ?", [
|
||||||
strtolower(str_replace(' ', '', $name)),
|
strtolower(str_replace(' ', '', $name)),
|
||||||
])
|
])
|
||||||
@ -203,6 +211,7 @@ class BaseTransformer
|
|||||||
{
|
{
|
||||||
$product = $this->company
|
$product = $this->company
|
||||||
->products()
|
->products()
|
||||||
|
->where('is_deleted', false)
|
||||||
->whereRaw("LOWER(REPLACE(`product_key`, ' ' ,'')) = ?", [
|
->whereRaw("LOWER(REPLACE(`product_key`, ' ' ,'')) = ?", [
|
||||||
strtolower(str_replace(' ', '', $key)),
|
strtolower(str_replace(' ', '', $key)),
|
||||||
])
|
])
|
||||||
@ -273,6 +282,7 @@ class BaseTransformer
|
|||||||
|
|
||||||
$tax_rate = $this->company
|
$tax_rate = $this->company
|
||||||
->tax_rates()
|
->tax_rates()
|
||||||
|
->where('is_deleted', false)
|
||||||
->whereRaw("LOWER(REPLACE(`name`, ' ' ,'')) = ?", [
|
->whereRaw("LOWER(REPLACE(`name`, ' ' ,'')) = ?", [
|
||||||
strtolower(str_replace(' ', '', $name)),
|
strtolower(str_replace(' ', '', $name)),
|
||||||
])
|
])
|
||||||
@ -292,6 +302,7 @@ class BaseTransformer
|
|||||||
|
|
||||||
$tax_rate = $this->company
|
$tax_rate = $this->company
|
||||||
->tax_rates()
|
->tax_rates()
|
||||||
|
->where('is_deleted', false)
|
||||||
->whereRaw("LOWER(REPLACE(`name`, ' ' ,'')) = ?", [
|
->whereRaw("LOWER(REPLACE(`name`, ' ' ,'')) = ?", [
|
||||||
strtolower(str_replace(' ', '', $name)),
|
strtolower(str_replace(' ', '', $name)),
|
||||||
])
|
])
|
||||||
@ -341,6 +352,7 @@ class BaseTransformer
|
|||||||
{
|
{
|
||||||
$invoice = $this->company
|
$invoice = $this->company
|
||||||
->invoices()
|
->invoices()
|
||||||
|
->where('is_deleted', false)
|
||||||
->whereRaw("LOWER(REPLACE(`number`, ' ' ,'')) = ?", [
|
->whereRaw("LOWER(REPLACE(`number`, ' ' ,'')) = ?", [
|
||||||
strtolower(str_replace(' ', '', $invoice_number)),
|
strtolower(str_replace(' ', '', $invoice_number)),
|
||||||
])
|
])
|
||||||
@ -358,6 +370,7 @@ class BaseTransformer
|
|||||||
{
|
{
|
||||||
return $this->company
|
return $this->company
|
||||||
->invoices()
|
->invoices()
|
||||||
|
->where('is_deleted', false)
|
||||||
->whereRaw("LOWER(REPLACE(`number`, ' ' ,'')) = ?", [
|
->whereRaw("LOWER(REPLACE(`number`, ' ' ,'')) = ?", [
|
||||||
strtolower(str_replace(' ', '', $invoice_number)),
|
strtolower(str_replace(' ', '', $invoice_number)),
|
||||||
])
|
])
|
||||||
@ -371,6 +384,7 @@ class BaseTransformer
|
|||||||
{
|
{
|
||||||
return $this->company
|
return $this->company
|
||||||
->expenses()
|
->expenses()
|
||||||
|
->where('is_deleted', false)
|
||||||
->whereRaw("LOWER(REPLACE(`number`, ' ' ,'')) = ?", [
|
->whereRaw("LOWER(REPLACE(`number`, ' ' ,'')) = ?", [
|
||||||
strtolower(str_replace(' ', '', $expense_number)),
|
strtolower(str_replace(' ', '', $expense_number)),
|
||||||
])
|
])
|
||||||
@ -386,6 +400,7 @@ class BaseTransformer
|
|||||||
{
|
{
|
||||||
return $this->company
|
return $this->company
|
||||||
->quotes()
|
->quotes()
|
||||||
|
->where('is_deleted', false)
|
||||||
->whereRaw("LOWER(REPLACE(`number`, ' ' ,'')) = ?", [
|
->whereRaw("LOWER(REPLACE(`number`, ' ' ,'')) = ?", [
|
||||||
strtolower(str_replace(' ', '', $quote_number)),
|
strtolower(str_replace(' ', '', $quote_number)),
|
||||||
])
|
])
|
||||||
@ -401,6 +416,7 @@ class BaseTransformer
|
|||||||
{
|
{
|
||||||
$invoice = $this->company
|
$invoice = $this->company
|
||||||
->invoices()
|
->invoices()
|
||||||
|
->where('is_deleted', false)
|
||||||
->whereRaw("LOWER(REPLACE(`number`, ' ' ,'')) = ?", [
|
->whereRaw("LOWER(REPLACE(`number`, ' ' ,'')) = ?", [
|
||||||
strtolower(str_replace(' ', '', $invoice_number)),
|
strtolower(str_replace(' ', '', $invoice_number)),
|
||||||
])
|
])
|
||||||
@ -418,6 +434,7 @@ class BaseTransformer
|
|||||||
{
|
{
|
||||||
$vendor = $this->company
|
$vendor = $this->company
|
||||||
->vendors()
|
->vendors()
|
||||||
|
->where('is_deleted', false)
|
||||||
->whereRaw("LOWER(REPLACE(`name`, ' ' ,'')) = ?", [
|
->whereRaw("LOWER(REPLACE(`name`, ' ' ,'')) = ?", [
|
||||||
strtolower(str_replace(' ', '', $name)),
|
strtolower(str_replace(' ', '', $name)),
|
||||||
])
|
])
|
||||||
@ -452,6 +469,7 @@ class BaseTransformer
|
|||||||
{
|
{
|
||||||
$ec = $this->company
|
$ec = $this->company
|
||||||
->expense_categories()
|
->expense_categories()
|
||||||
|
->where('is_deleted', false)
|
||||||
->whereRaw("LOWER(REPLACE(`name`, ' ' ,'')) = ?", [
|
->whereRaw("LOWER(REPLACE(`name`, ' ' ,'')) = ?", [
|
||||||
strtolower(str_replace(' ', '', $name)),
|
strtolower(str_replace(' ', '', $name)),
|
||||||
])
|
])
|
||||||
@ -486,6 +504,7 @@ class BaseTransformer
|
|||||||
{
|
{
|
||||||
$project = $this->company
|
$project = $this->company
|
||||||
->projects()
|
->projects()
|
||||||
|
->where('is_deleted', false)
|
||||||
->whereRaw("LOWER(REPLACE(`name`, ' ' ,'')) = ?", [
|
->whereRaw("LOWER(REPLACE(`name`, ' ' ,'')) = ?", [
|
||||||
strtolower(str_replace(' ', '', $name)),
|
strtolower(str_replace(' ', '', $name)),
|
||||||
])
|
])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user