mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-23 20:00:33 -04:00
Add daily checks for credit balances
This commit is contained in:
parent
35e21e4551
commit
b63b3c707e
@ -12,6 +12,7 @@
|
|||||||
namespace App\Jobs\Ninja;
|
namespace App\Jobs\Ninja;
|
||||||
|
|
||||||
use App\Libraries\MultiDB;
|
use App\Libraries\MultiDB;
|
||||||
|
use App\Models\Client;
|
||||||
use App\Models\Company;
|
use App\Models\Company;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
@ -61,5 +62,17 @@ class CompanySizeCheck implements ShouldQueue
|
|||||||
$company->account->companies()->update(['is_large' => true]);
|
$company->account->companies()->update(['is_large' => true]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
nlog("updating all client credit balances");
|
||||||
|
|
||||||
|
Client::where('updated_at', '>', now()->subDay())
|
||||||
|
->cursor()
|
||||||
|
->each(function ($client){
|
||||||
|
|
||||||
|
$client->credit_balance = $client->service()->getCreditBalance();
|
||||||
|
$client->save();
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ class CreditRepository extends BaseRepository
|
|||||||
|
|
||||||
$credit = $credit->service()->deleteCredit()->save();
|
$credit = $credit->service()->deleteCredit()->save();
|
||||||
|
|
||||||
return parent::restore($credit);
|
return parent::delete($credit);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user