mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Merge pull request #8651 from turbo124/v5-develop
Updates for purging clients
This commit is contained in:
commit
3ce4a7249b
@ -164,6 +164,17 @@ class ExpenseFilters extends QueryFilters
|
||||
return $this->builder;
|
||||
}
|
||||
|
||||
if ($sort_col[0] == 'client_id') {
|
||||
return $this->builder->orderBy(\App\Models\Client::select('name')
|
||||
->whereColumn('clients.id', 'expenses.client_id'), $sort_col[1]);
|
||||
}
|
||||
|
||||
if ($sort_col[0] == 'vendor_id') {
|
||||
return $this->builder->orderBy(\App\Models\Vendor::select('name')
|
||||
->whereColumn('vendors.id', 'expenses.vendor_id'), $sort_col[1]);
|
||||
}
|
||||
|
||||
|
||||
if (is_array($sort_col) && in_array($sort_col[1], ['asc', 'desc']) && in_array($sort_col[0], ['public_notes', 'date', 'id_number', 'custom_value1', 'custom_value2', 'custom_value3', 'custom_value4'])) {
|
||||
return $this->builder->orderBy($sort_col[0], $sort_col[1]);
|
||||
}
|
||||
|
@ -123,6 +123,11 @@ class PurchaseOrderFilters extends QueryFilters
|
||||
return $this->builder;
|
||||
}
|
||||
|
||||
if ($sort_col[0] == 'vendor_id') {
|
||||
return $this->builder->orderBy(\App\Models\Vendor::select('name')
|
||||
->whereColumn('vendors.id', 'purchase_orders.vendor_id'), $sort_col[1]);
|
||||
}
|
||||
|
||||
return $this->builder->orderBy($sort_col[0], $sort_col[1]);
|
||||
}
|
||||
|
||||
|
@ -48,8 +48,6 @@ class PdfSlot extends Component
|
||||
|
||||
private $entity_type;
|
||||
|
||||
protected $listeners = ['viewportChanged' => 'getPdf'];
|
||||
|
||||
public $show_cost = true;
|
||||
|
||||
public $show_quantity = true;
|
||||
|
@ -398,6 +398,9 @@ class Import implements ShouldQueue
|
||||
$data = $this->transformCompanyData($data);
|
||||
|
||||
if (Ninja::isHosted()) {
|
||||
|
||||
$data['subdomain'] = str_replace("_","",$data['subdomain']);
|
||||
|
||||
if (!MultiDB::checkDomainAvailable($data['subdomain'])) {
|
||||
$data['subdomain'] = MultiDB::randomSubdomainGenerator();
|
||||
}
|
||||
|
@ -347,6 +347,11 @@ class Client extends BaseModel implements HasLocalePreference
|
||||
return $this->hasMany(Credit::class)->withTrashed();
|
||||
}
|
||||
|
||||
public function purgeable_activities()
|
||||
{
|
||||
return $this->hasMany(Activity::class);
|
||||
}
|
||||
|
||||
public function activities()
|
||||
{
|
||||
return $this->hasMany(Activity::class)->take(50)->orderBy('id', 'desc');
|
||||
|
@ -136,7 +136,7 @@ class ClientRepository extends BaseRepository
|
||||
$client->projects()->forceDelete();
|
||||
$client->credits()->forceDelete();
|
||||
$client->quotes()->forceDelete();
|
||||
$client->activities()->forceDelete();
|
||||
$client->purgeable_activities()->forceDelete();
|
||||
$client->recurring_invoices()->forceDelete();
|
||||
$client->expenses()->forceDelete();
|
||||
$client->recurring_expenses()->forceDelete();
|
||||
|
@ -148,7 +148,7 @@ class DeletePayment
|
||||
|
||||
$client
|
||||
->service()
|
||||
->updatePaidToDate(($paymentable_credit->pivot->amount) * -1)
|
||||
// ->updatePaidToDate(($paymentable_credit->pivot->amount) * -1)
|
||||
->adjustCreditBalance($paymentable_credit->pivot->amount)
|
||||
->save();
|
||||
});
|
||||
|
@ -1,24 +1,19 @@
|
||||
<div>
|
||||
<div class="flex flex-col items-end mb-2">
|
||||
<button wire:loading.attr="disabled" wire:click="downloadPdf" class="bg-gray-100 hover:bg-gray-200 text-gray-800 font-bold px-2 rounded inline-flex">
|
||||
<div class="flex flex-col items-end mb-2" x-data>
|
||||
<button wire:loading.attr="disabled" wire:click="downloadPdf" class="bg-gray-100 hover:bg-gray-200 text-gray-800 font-bold px-2 rounded inline-flex" type="button">
|
||||
<span>{{ ctrans('texts.download_pdf') }}</span>
|
||||
<div wire:loading wire:target="downloadPdf">
|
||||
<svg class="animate-spin h-5 w-5 text-blue" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
|
||||
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
|
||||
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
|
||||
</svg>
|
||||
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
<div class="hidden lg:block">
|
||||
<div wire:init="getPdf()">
|
||||
@if($pdf)
|
||||
<!-- <iframe id="pdf-iframe" src="{!! $pdf !!}" class="h-screen w-full border-0 mt-4"></iframe> -->
|
||||
<iframe id="pdf-iframe" src="/{{ $route_entity }}/showBlob/{{ $pdf }}" class="h-screen w-full border-0 mt-4"></iframe>
|
||||
@else
|
||||
<div class="flex mt-4 place-items-center">
|
||||
<span class="loader m-auto"></span>
|
||||
<div class="flex mt-4 place-items-center" id="loader" wire:ignore>
|
||||
<span class="loader m-auto" wire:ignore></span>
|
||||
<style type="text/css">
|
||||
.loader {
|
||||
width: 48px;
|
||||
@ -52,8 +47,11 @@
|
||||
75% {clip-path:polygon(50% 50%,0 0,100% 0,100% 100%,0 100%,0 100%)}
|
||||
100% {clip-path:polygon(50% 50%,0 0,100% 0,100% 100%,0 100%,0 0)}
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
</div>
|
||||
@if($pdf)
|
||||
<!-- <iframe id="pdf-iframe" src="{!! $pdf !!}" class="h-screen w-full border-0 mt-4"></iframe> -->
|
||||
<iframe id="pdf-iframe" src="/{{ $route_entity }}/showBlob/{{ $pdf }}" class="h-screen w-full border-0 mt-4"></iframe>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
@ -61,4 +59,42 @@
|
||||
<div class="block lg:hidden">
|
||||
@include('portal.ninja2020.components.html-viewer')
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
waitForElement("#pdf-iframe", 0).then(function(){
|
||||
const iframe = document.getElementById("pdf-iframe");
|
||||
|
||||
iframe.addEventListener("load", function () {
|
||||
const loader = document.getElementById("loader")
|
||||
loader.classList.add("hidden");
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
function waitForElement(querySelector, timeout){
|
||||
return new Promise((resolve, reject)=>{
|
||||
var timer = false;
|
||||
if(document.querySelectorAll(querySelector).length) return resolve();
|
||||
const observer = new MutationObserver(()=>{
|
||||
if(document.querySelectorAll(querySelector).length){
|
||||
observer.disconnect();
|
||||
if(timer !== false) clearTimeout(timer);
|
||||
return resolve();
|
||||
}
|
||||
});
|
||||
observer.observe(document.body, {
|
||||
childList: true,
|
||||
subtree: true
|
||||
});
|
||||
if(timeout) timer = setTimeout(()=>{
|
||||
observer.disconnect();
|
||||
reject();
|
||||
}, timeout);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
</script>
|
@ -14,6 +14,7 @@ namespace Tests\Feature\Export;
|
||||
use Tests\TestCase;
|
||||
use App\Models\User;
|
||||
use App\Models\Client;
|
||||
use App\Models\Credit;
|
||||
use League\Csv\Reader;
|
||||
use App\Models\Account;
|
||||
use App\Models\Company;
|
||||
@ -253,7 +254,8 @@ class ReportCsvGenerationTest extends TestCase
|
||||
'X-API-SECRET' => config('ninja.api_secret'),
|
||||
'X-API-TOKEN' => $this->token,
|
||||
])->post('/api/v1/reports/credits', $data);
|
||||
|
||||
$response->assertStatus(200);
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user