mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-04 21:34:40 -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;
|
$wrong_paid_to_dates = 0;
|
||||||
|
|
||||||
foreach (Client::cursor() as $client) {
|
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();
|
$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()
|
private function checkLogoFiles()
|
||||||
|
@ -125,6 +125,7 @@ class ImportMigrations extends Command
|
|||||||
{
|
{
|
||||||
$company = Company::factory()->create([
|
$company = Company::factory()->create([
|
||||||
'account_id' => $account->id,
|
'account_id' => $account->id,
|
||||||
|
'is_disabled' => true,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (! $account->default_company_id) {
|
if (! $account->default_company_id) {
|
||||||
|
@ -115,10 +115,10 @@ class Import implements ShouldQueue
|
|||||||
'vendors',
|
'vendors',
|
||||||
'projects',
|
'projects',
|
||||||
'products',
|
'products',
|
||||||
|
'credits',
|
||||||
'invoices',
|
'invoices',
|
||||||
'recurring_invoices',
|
'recurring_invoices',
|
||||||
'quotes',
|
'quotes',
|
||||||
'credits',
|
|
||||||
'payments',
|
'payments',
|
||||||
'company_gateways',
|
'company_gateways',
|
||||||
'client_gateway_tokens',
|
'client_gateway_tokens',
|
||||||
@ -180,6 +180,8 @@ class Import implements ShouldQueue
|
|||||||
{
|
{
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
|
|
||||||
|
info(print_r(array_keys($this->data),1));
|
||||||
|
|
||||||
foreach ($this->data as $key => $resource) {
|
foreach ($this->data as $key => $resource) {
|
||||||
if (! in_array($key, $this->available_imports)) {
|
if (! in_array($key, $this->available_imports)) {
|
||||||
//throw new ResourceNotAvailableForMigration("Resource {$key} is not available for migration.");
|
//throw new ResourceNotAvailableForMigration("Resource {$key} is not available for migration.");
|
||||||
@ -777,7 +779,8 @@ class Import implements ShouldQueue
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function processPayments(array $data): void
|
private function processPayments(array $data): void
|
||||||
{
|
{info(print_r($this->ids,1));
|
||||||
|
|
||||||
Payment::reguard();
|
Payment::reguard();
|
||||||
|
|
||||||
$rules = [
|
$rules = [
|
||||||
@ -838,6 +841,11 @@ class Import implements ShouldQueue
|
|||||||
//depending on the status, we do a final action.
|
//depending on the status, we do a final action.
|
||||||
$payment = $this->updatePaymentForStatus($payment, $modified['status_id']);
|
$payment = $this->updatePaymentForStatus($payment, $modified['status_id']);
|
||||||
|
|
||||||
|
if($modified['is_deleted'])
|
||||||
|
$payment->service()->deletePayment();
|
||||||
|
|
||||||
|
// if(isset($modified['deleted_at']))
|
||||||
|
// $payment->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
Payment::reguard();
|
Payment::reguard();
|
||||||
|
@ -73,6 +73,9 @@ class ActivityRepository extends BaseRepository
|
|||||||
*/
|
*/
|
||||||
public function createBackup($entity, $activity)
|
public function createBackup($entity, $activity)
|
||||||
{
|
{
|
||||||
|
if($entity->company->is_disabled)
|
||||||
|
return;
|
||||||
|
|
||||||
$backup = new Backup();
|
$backup = new Backup();
|
||||||
|
|
||||||
if (get_class($entity) == Invoice::class || get_class($entity) == Quote::class || get_class($entity) == Credit::class) {
|
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()
|
public function run()
|
||||||
{
|
{
|
||||||
|
if($this->payment->is_deleted)
|
||||||
|
return $this->payment;
|
||||||
|
|
||||||
return $this->setStatus(Payment::STATUS_CANCELLED) //sets status of payment
|
return $this->setStatus(Payment::STATUS_CANCELLED) //sets status of payment
|
||||||
->updateCreditables() //return the credits first
|
->updateCreditables() //return the credits first
|
||||||
->adjustInvoices()
|
->adjustInvoices()
|
||||||
->updateClient()
|
->updateClient()
|
||||||
->deletePaymentables()
|
->deletePaymentables()
|
||||||
|
->cleanupPayment()
|
||||||
->save();
|
->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,6 +56,15 @@ class DeletePayment
|
|||||||
|
|
||||||
//set applied amount to 0
|
//set applied amount to 0
|
||||||
|
|
||||||
|
private function cleanupPayment()
|
||||||
|
{
|
||||||
|
$this->payment->is_deleted = true;
|
||||||
|
// $entity->save();
|
||||||
|
$this->payment->delete();
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
private function deletePaymentables()
|
private function deletePaymentables()
|
||||||
{
|
{
|
||||||
$this->payment->paymentables()->update(['deleted_at' => now()]);
|
$this->payment->paymentables()->update(['deleted_at' => now()]);
|
||||||
|
@ -577,10 +577,10 @@ trait GeneratesCounter
|
|||||||
$search[] = '{$counter}';
|
$search[] = '{$counter}';
|
||||||
$replace[] = $counter;
|
$replace[] = $counter;
|
||||||
|
|
||||||
$search[] = '{$clientCounter}';
|
$search[] = '{$client_counter}';
|
||||||
$replace[] = $counter;
|
$replace[] = $counter;
|
||||||
|
|
||||||
$search[] = '{$groupCounter}';
|
$search[] = '{$group_counter}';
|
||||||
$replace[] = $counter;
|
$replace[] = $counter;
|
||||||
|
|
||||||
if (strstr($pattern, '{$user_id}')) {
|
if (strstr($pattern, '{$user_id}')) {
|
||||||
@ -600,20 +600,39 @@ trait GeneratesCounter
|
|||||||
$replace[] = str_replace($format, $date, $matches[1]);
|
$replace[] = str_replace($format, $date, $matches[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$search[] = '{$custom1}';
|
if($entity instanceof Client){
|
||||||
|
$search[] = '{$client_custom1}';
|
||||||
$replace[] = $entity->custom_value1;
|
$replace[] = $entity->custom_value1;
|
||||||
|
|
||||||
$search[] = '{$custom2}';
|
$search[] = '{$client_custom2}';
|
||||||
$replace[] = $entity->custom_value2;
|
$replace[] = $entity->custom_value2;
|
||||||
|
|
||||||
$search[] = '{$custom3}';
|
$search[] = '{$client_custom3}';
|
||||||
$replace[] = $entity->custom_value3;
|
$replace[] = $entity->custom_value3;
|
||||||
|
|
||||||
$search[] = '{$custom4}';
|
$search[] = '{$client_custom4}';
|
||||||
$replace[] = $entity->custom_value4;
|
$replace[] = $entity->custom_value4;
|
||||||
|
|
||||||
$search[] = '{$id_number}';
|
$search[] = '{$id_number}';
|
||||||
$replace[] = $entity->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);
|
return str_replace($search, $replace, $pattern);
|
||||||
}
|
}
|
||||||
|
@ -95,6 +95,55 @@
|
|||||||
document.addEventListener('DOMContentLoaded', function(event) {
|
document.addEventListener('DOMContentLoaded', function(event) {
|
||||||
document.getElementById('loader').style.display = 'none';
|
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>
|
||||||
|
|
||||||
<script defer src="main.dart.js?v={{ config('ninja.app_version') }}" type="application/javascript"></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