mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Working on migrations
This commit is contained in:
parent
0991dbf8d7
commit
b5fe5070b5
@ -383,7 +383,8 @@ class CheckData extends Command
|
||||
$wrong_paid_to_dates = 0;
|
||||
|
||||
foreach (Client::cursor() as $client) {
|
||||
$invoice_balance = $client->invoices->where('is_deleted', false)->where('status_id', '>', 1)->sum('balance');
|
||||
//$invoice_balance = $client->invoices->where('is_deleted', false)->where('status_id', '>', 1)->sum('balance');
|
||||
$invoice_balance = Invoice::where('client_id', $client->id)->where('is_deleted', false)->where('status_id', '>', 1)->withTrashed()->sum('balance');
|
||||
|
||||
$ledger = CompanyLedger::where('client_id', $client->id)->orderBy('id', 'DESC')->first();
|
||||
|
||||
@ -395,7 +396,7 @@ class CheckData extends Command
|
||||
}
|
||||
}
|
||||
|
||||
$this->logMessage("{$wrong_paid_to_dates} clients with incorrect paid_to_dates");
|
||||
$this->logMessage("{$wrong_paid_to_dates} clients with incorrect client balances");
|
||||
}
|
||||
|
||||
private function checkLogoFiles()
|
||||
|
@ -125,6 +125,7 @@ class ImportMigrations extends Command
|
||||
{
|
||||
$company = Company::factory()->create([
|
||||
'account_id' => $account->id,
|
||||
'is_disabled' => true,
|
||||
]);
|
||||
|
||||
if (! $account->default_company_id) {
|
||||
|
@ -115,10 +115,10 @@ class Import implements ShouldQueue
|
||||
'vendors',
|
||||
'projects',
|
||||
'products',
|
||||
'credits',
|
||||
'invoices',
|
||||
'recurring_invoices',
|
||||
'quotes',
|
||||
'credits',
|
||||
'payments',
|
||||
'company_gateways',
|
||||
'client_gateway_tokens',
|
||||
@ -180,6 +180,8 @@ class Import implements ShouldQueue
|
||||
{
|
||||
set_time_limit(0);
|
||||
|
||||
info(print_r(array_keys($this->data),1));
|
||||
|
||||
foreach ($this->data as $key => $resource) {
|
||||
if (! in_array($key, $this->available_imports)) {
|
||||
//throw new ResourceNotAvailableForMigration("Resource {$key} is not available for migration.");
|
||||
@ -777,7 +779,8 @@ class Import implements ShouldQueue
|
||||
}
|
||||
|
||||
private function processPayments(array $data): void
|
||||
{
|
||||
{info(print_r($this->ids,1));
|
||||
|
||||
Payment::reguard();
|
||||
|
||||
$rules = [
|
||||
@ -838,6 +841,11 @@ class Import implements ShouldQueue
|
||||
//depending on the status, we do a final action.
|
||||
$payment = $this->updatePaymentForStatus($payment, $modified['status_id']);
|
||||
|
||||
if($modified['is_deleted'])
|
||||
$payment->service()->deletePayment();
|
||||
|
||||
// if(isset($modified['deleted_at']))
|
||||
// $payment->delete();
|
||||
}
|
||||
|
||||
Payment::reguard();
|
||||
|
@ -73,6 +73,9 @@ class ActivityRepository extends BaseRepository
|
||||
*/
|
||||
public function createBackup($entity, $activity)
|
||||
{
|
||||
if($entity->company->is_disabled)
|
||||
return;
|
||||
|
||||
$backup = new Backup();
|
||||
|
||||
if (get_class($entity) == Invoice::class || get_class($entity) == Quote::class || get_class($entity) == Credit::class) {
|
||||
|
@ -36,11 +36,15 @@ class DeletePayment
|
||||
|
||||
public function run()
|
||||
{
|
||||
if($this->payment->is_deleted)
|
||||
return $this->payment;
|
||||
|
||||
return $this->setStatus(Payment::STATUS_CANCELLED) //sets status of payment
|
||||
->updateCreditables() //return the credits first
|
||||
->adjustInvoices()
|
||||
->updateClient()
|
||||
->deletePaymentables()
|
||||
->cleanupPayment()
|
||||
->save();
|
||||
}
|
||||
|
||||
@ -52,6 +56,15 @@ class DeletePayment
|
||||
|
||||
//set applied amount to 0
|
||||
|
||||
private function cleanupPayment()
|
||||
{
|
||||
$this->payment->is_deleted = true;
|
||||
// $entity->save();
|
||||
$this->payment->delete();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function deletePaymentables()
|
||||
{
|
||||
$this->payment->paymentables()->update(['deleted_at' => now()]);
|
||||
|
@ -577,10 +577,10 @@ trait GeneratesCounter
|
||||
$search[] = '{$counter}';
|
||||
$replace[] = $counter;
|
||||
|
||||
$search[] = '{$clientCounter}';
|
||||
$search[] = '{$client_counter}';
|
||||
$replace[] = $counter;
|
||||
|
||||
$search[] = '{$groupCounter}';
|
||||
$search[] = '{$group_counter}';
|
||||
$replace[] = $counter;
|
||||
|
||||
if (strstr($pattern, '{$user_id}')) {
|
||||
@ -600,20 +600,39 @@ trait GeneratesCounter
|
||||
$replace[] = str_replace($format, $date, $matches[1]);
|
||||
}
|
||||
|
||||
$search[] = '{$custom1}';
|
||||
$replace[] = $entity->custom_value1;
|
||||
if($entity instanceof Client){
|
||||
$search[] = '{$client_custom1}';
|
||||
$replace[] = $entity->custom_value1;
|
||||
|
||||
$search[] = '{$custom2}';
|
||||
$replace[] = $entity->custom_value2;
|
||||
$search[] = '{$client_custom2}';
|
||||
$replace[] = $entity->custom_value2;
|
||||
|
||||
$search[] = '{$custom3}';
|
||||
$replace[] = $entity->custom_value3;
|
||||
$search[] = '{$client_custom3}';
|
||||
$replace[] = $entity->custom_value3;
|
||||
|
||||
$search[] = '{$custom4}';
|
||||
$replace[] = $entity->custom_value4;
|
||||
$search[] = '{$client_custom4}';
|
||||
$replace[] = $entity->custom_value4;
|
||||
|
||||
$search[] = '{$id_number}';
|
||||
$replace[] = $entity->id_number;
|
||||
$search[] = '{$id_number}';
|
||||
$replace[] = $entity->id_number;
|
||||
}
|
||||
else
|
||||
{
|
||||
$search[] = '{$client_custom1}';
|
||||
$replace[] = $entity->client->custom_value1;
|
||||
|
||||
$search[] = '{$client_custom2}';
|
||||
$replace[] = $entity->client->custom_value2;
|
||||
|
||||
$search[] = '{$client_custom3}';
|
||||
$replace[] = $entity->client->custom_value3;
|
||||
|
||||
$search[] = '{$client_custom4}';
|
||||
$replace[] = $entity->client->custom_value4;
|
||||
|
||||
$search[] = '{$id_number}';
|
||||
$replace[] = $entity->client->id_number;
|
||||
}
|
||||
|
||||
return str_replace($search, $replace, $pattern);
|
||||
}
|
||||
|
@ -95,6 +95,55 @@
|
||||
document.addEventListener('DOMContentLoaded', function(event) {
|
||||
document.getElementById('loader').style.display = 'none';
|
||||
});
|
||||
|
||||
/*
|
||||
function invokeServiceWorkerUpdateFlow() {
|
||||
// you have a better UI here, reloading is not a great user experince here.
|
||||
const confirmed = confirm('New version of the app is available. Refresh now');
|
||||
if (confirmed) {
|
||||
window.location.reload();
|
||||
}
|
||||
}
|
||||
async function handleServiceWorker() {
|
||||
if ('serviceWorker' in navigator) {
|
||||
// get the ServiceWorkerRegistration instance
|
||||
const registration = await navigator.serviceWorker.getRegistration();
|
||||
// (it is also returned from navigator.serviceWorker.register() function)
|
||||
|
||||
if (registration) {
|
||||
// detect Service Worker update available and wait for it to become installed
|
||||
registration.addEventListener('updatefound', () => {
|
||||
if (registration.installing) {
|
||||
// wait until the new Service worker is actually installed (ready to take over)
|
||||
registration.installing.addEventListener('statechange', () => {
|
||||
if (registration.waiting) {
|
||||
// if there's an existing controller (previous Service Worker), show the prompt
|
||||
if (navigator.serviceWorker.controller) {
|
||||
invokeServiceWorkerUpdateFlow(registration);
|
||||
} else {
|
||||
// otherwise it's the first install, nothing to do
|
||||
console.log('Service Worker initialized for the first time');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
let refreshing = false;
|
||||
|
||||
// detect controller change and refresh the page
|
||||
navigator.serviceWorker.addEventListener('controllerchange', () => {
|
||||
if (!refreshing) {
|
||||
window.location.reload();
|
||||
refreshing = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
handleServiceWorker();
|
||||
*/
|
||||
</script>
|
||||
|
||||
<script defer src="main.dart.js?v={{ config('ninja.app_version') }}" type="application/javascript"></script>
|
||||
|
Loading…
x
Reference in New Issue
Block a user