mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Fix for calculate payouts
This commit is contained in:
parent
fa5cb690ba
commit
1a554ea1e3
@ -42,7 +42,6 @@ class CalculatePayouts extends Command
|
|||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
$this->info('Running CalculatePayouts...');
|
|
||||||
$type = strtolower($this->option('type'));
|
$type = strtolower($this->option('type'));
|
||||||
|
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
@ -61,7 +60,6 @@ class CalculatePayouts extends Command
|
|||||||
$userMap = [];
|
$userMap = [];
|
||||||
|
|
||||||
foreach ($servers as $server) {
|
foreach ($servers as $server) {
|
||||||
$this->info('Processing users: ' . $server->name);
|
|
||||||
config(['database.default' => $server->name]);
|
config(['database.default' => $server->name]);
|
||||||
|
|
||||||
$users = User::where('referral_code', '!=', '')
|
$users = User::where('referral_code', '!=', '')
|
||||||
@ -72,7 +70,6 @@ class CalculatePayouts extends Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach ($servers as $server) {
|
foreach ($servers as $server) {
|
||||||
$this->info('Processing companies: ' . $server->name);
|
|
||||||
config(['database.default' => $server->name]);
|
config(['database.default' => $server->name]);
|
||||||
|
|
||||||
$companies = Company::where('referral_code', '!=', '')
|
$companies = Company::where('referral_code', '!=', '')
|
||||||
@ -80,6 +77,8 @@ class CalculatePayouts extends Command
|
|||||||
->whereNotNull('payment_id')
|
->whereNotNull('payment_id')
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
|
$this->info('User,Client,Date,Amount,Reference');
|
||||||
|
|
||||||
foreach ($companies as $company) {
|
foreach ($companies as $company) {
|
||||||
if (!isset($userMap[$company->referral_code])) {
|
if (!isset($userMap[$company->referral_code])) {
|
||||||
continue;
|
continue;
|
||||||
@ -91,12 +90,14 @@ class CalculatePayouts extends Command
|
|||||||
if ($payment) {
|
if ($payment) {
|
||||||
$client = $payment->client;
|
$client = $payment->client;
|
||||||
|
|
||||||
$this->info("User: $user");
|
|
||||||
$this->info("Client: " . $client->getDisplayName());
|
|
||||||
|
|
||||||
foreach ($client->payments as $payment) {
|
foreach ($client->payments as $payment) {
|
||||||
$amount = $payment->getCompletedAmount();
|
$amount = $payment->getCompletedAmount();
|
||||||
$this->info("Date: $payment->payment_date, Amount: $amount, Reference: $payment->transaction_reference");
|
$this->info('"' . $user . '",' .
|
||||||
|
'"' . $client->getDisplayName() . '",' .
|
||||||
|
$payment->payment_date . ',' .
|
||||||
|
$amount . ',' .
|
||||||
|
$payment->transaction_reference
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user