mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Merge pull request #4668 from turbo124/v5-develop
Fixes for recurring invoice cron query
This commit is contained in:
commit
9e3b28f6ac
@ -325,8 +325,8 @@ class CheckData extends Command
|
|||||||
// $total_amount = $invoice->payments->whereNull('deleted_at')->sum('pivot.amount');
|
// $total_amount = $invoice->payments->whereNull('deleted_at')->sum('pivot.amount');
|
||||||
// $total_refund = $invoice->payments->whereNull('deleted_at')->sum('pivot.refunded');
|
// $total_refund = $invoice->payments->whereNull('deleted_at')->sum('pivot.refunded');
|
||||||
|
|
||||||
$total_amount = $invoice->payments->where('is_deleted', false)->whereIn('status_id', [Payment::STATUS_COMPLETED, Payment:: STATUS_PENDING, Payment::STATUS_PARTIALLY_REFUNDED])->sum('pivot.amount');
|
$total_amount = $invoice->payments->where('is_deleted', false)->whereIn('status_id', [Payment::STATUS_COMPLETED, Payment:: STATUS_PENDING, Payment::STATUS_PARTIALLY_REFUNDED, Payment::STATUS_REFUNDED])->sum('pivot.amount');
|
||||||
$total_refund = $invoice->payments->where('is_deleted', false)->whereIn('status_id', [Payment::STATUS_COMPLETED, Payment:: STATUS_PENDING, Payment::STATUS_PARTIALLY_REFUNDED])->sum('pivot.refunded');
|
$total_refund = $invoice->payments->where('is_deleted', false)->whereIn('status_id', [Payment::STATUS_COMPLETED, Payment:: STATUS_PENDING, Payment::STATUS_PARTIALLY_REFUNDED, Payment::STATUS_REFUNDED])->sum('pivot.refunded');
|
||||||
|
|
||||||
$total_invoice_payments += ($total_amount - $total_refund);
|
$total_invoice_payments += ($total_amount - $total_refund);
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
* @OA\Property(property="project_id", type="string", example="", description="________"),
|
* @OA\Property(property="project_id", type="string", example="", description="________"),
|
||||||
* @OA\Property(property="number", type="string", example="", description="________"),
|
* @OA\Property(property="number", type="string", example="", description="________"),
|
||||||
* @OA\Property(property="time_log", type="string", example="", description="________"),
|
* @OA\Property(property="time_log", type="string", example="", description="________"),
|
||||||
* @OA\Property(property="start_time", type="integer", example="", description="________"),
|
|
||||||
* @OA\Property(property="is_running", type="boolean", example=true, description="________"),
|
* @OA\Property(property="is_running", type="boolean", example=true, description="________"),
|
||||||
* @OA\Property(property="is_deleted", type="boolean", example=true, description="________"),
|
* @OA\Property(property="is_deleted", type="boolean", example=true, description="________"),
|
||||||
* @OA\Property(property="task_status_id", type="string", example="", description="________"),
|
* @OA\Property(property="task_status_id", type="string", example="", description="________"),
|
||||||
|
@ -41,8 +41,9 @@ class RecurringInvoicesCron
|
|||||||
nlog("Sending recurring invoices ".Carbon::now()->format('Y-m-d h:i:s'));
|
nlog("Sending recurring invoices ".Carbon::now()->format('Y-m-d h:i:s'));
|
||||||
|
|
||||||
if (! config('ninja.db.multi_db_enabled')) {
|
if (! config('ninja.db.multi_db_enabled')) {
|
||||||
$recurring_invoices = RecurringInvoice::whereDate('next_send_date', '=', now())
|
$recurring_invoices = RecurringInvoice::whereDate('next_send_date', '<=', now())
|
||||||
->where('status_id', RecurringInvoice::STATUS_ACTIVE)
|
->where('status_id', RecurringInvoice::STATUS_ACTIVE)
|
||||||
|
->where('remaining_cycles', '!=', '0')
|
||||||
->with('company')
|
->with('company')
|
||||||
->cursor();
|
->cursor();
|
||||||
|
|
||||||
@ -60,8 +61,9 @@ class RecurringInvoicesCron
|
|||||||
foreach (MultiDB::$dbs as $db) {
|
foreach (MultiDB::$dbs as $db) {
|
||||||
MultiDB::setDB($db);
|
MultiDB::setDB($db);
|
||||||
|
|
||||||
$recurring_invoices = RecurringInvoice::whereDate('next_send_date', '=', now())
|
$recurring_invoices = RecurringInvoice::whereDate('next_send_date', '<=', now())
|
||||||
->where('status_id', RecurringInvoice::STATUS_ACTIVE)
|
->where('status_id', RecurringInvoice::STATUS_ACTIVE)
|
||||||
|
->where('remaining_cycles', '!=', '0')
|
||||||
->with('company')
|
->with('company')
|
||||||
->cursor();
|
->cursor();
|
||||||
|
|
||||||
|
@ -65,15 +65,8 @@ class Gateway extends StaticModel
|
|||||||
$link = 'https://dashboard.stripe.com/account/apikeys';
|
$link = 'https://dashboard.stripe.com/account/apikeys';
|
||||||
}
|
}
|
||||||
|
|
||||||
// $key = 'texts.gateway_help_'.$this->id;
|
|
||||||
// $str = trans($key, [
|
|
||||||
// 'link' => "<a href='$link' >Click here</a>",
|
|
||||||
// 'complete_link' => url('/complete'),
|
|
||||||
// ]);
|
|
||||||
|
|
||||||
return $link;
|
return $link;
|
||||||
|
|
||||||
//return $key != $str ? $str : '';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -93,7 +86,7 @@ class Gateway extends StaticModel
|
|||||||
break;
|
break;
|
||||||
case 20:
|
case 20:
|
||||||
return [GatewayType::CREDIT_CARD => ['refund' => true, 'token_billing' => true],
|
return [GatewayType::CREDIT_CARD => ['refund' => true, 'token_billing' => true],
|
||||||
GatewayType::BANK_TRANSFER => ['refund' => true, 'token_billing' => true],
|
GatewayType::BANK_TRANSFER => ['refund' => true, 'token_billing' => true, 'webhooks' => ['source.chargeable']],
|
||||||
GatewayType::ALIPAY => ['refund' => false, 'token_billing' => false],
|
GatewayType::ALIPAY => ['refund' => false, 'token_billing' => false],
|
||||||
GatewayType::APPLE_PAY => ['refund' => false, 'token_billing' => false]]; //Stripe
|
GatewayType::APPLE_PAY => ['refund' => false, 'token_billing' => false]]; //Stripe
|
||||||
break;
|
break;
|
||||||
|
@ -36,7 +36,7 @@ class CompanyPresenter extends EntityPresenter
|
|||||||
$settings = $this->entity->settings;
|
$settings = $this->entity->settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (strlen($settings->company_logo) > 0) ? $settings->company_logo : 'https://www.invoiceninja.com/wp-content/uploads/2019/01/InvoiceNinja-Logo-Round-300x300.png';
|
return (strlen($settings->company_logo) > 0) ? url($settings->company_logo) : 'https://www.invoiceninja.com/wp-content/uploads/2019/01/InvoiceNinja-Logo-Round-300x300.png';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function address($settings = null)
|
public function address($settings = null)
|
||||||
|
@ -75,8 +75,8 @@ class TaskRepository extends BaseRepository
|
|||||||
}
|
}
|
||||||
|
|
||||||
$task->time_log = json_encode($time_log);
|
$task->time_log = json_encode($time_log);
|
||||||
$task->start_time = $task->start_time ?: $task->calcStartTime();
|
// $task->start_time = $task->start_time ?: $task->calcStartTime();
|
||||||
$task->duration = $task->calcDuration();
|
// $task->duration = $task->calcDuration();
|
||||||
|
|
||||||
$task->save();
|
$task->save();
|
||||||
|
|
||||||
|
@ -142,7 +142,7 @@ class RefundPayment
|
|||||||
*/
|
*/
|
||||||
private function setStatus()
|
private function setStatus()
|
||||||
{
|
{
|
||||||
if ($this->refund_data['amount'] == $this->payment->amount) {
|
if ($this->total_refund == $this->payment->amount) {
|
||||||
$this->payment->status_id = Payment::STATUS_REFUNDED;
|
$this->payment->status_id = Payment::STATUS_REFUNDED;
|
||||||
} else {
|
} else {
|
||||||
$this->payment->status_id = Payment::STATUS_PARTIALLY_REFUNDED;
|
$this->payment->status_id = Payment::STATUS_PARTIALLY_REFUNDED;
|
||||||
|
@ -47,7 +47,7 @@ class TaskTransformer extends EntityTransformer
|
|||||||
'user_id' => (string) $this->encodePrimaryKey($task->user_id),
|
'user_id' => (string) $this->encodePrimaryKey($task->user_id),
|
||||||
'assigned_user_id' => (string) $this->encodePrimaryKey($task->assigned_user_id),
|
'assigned_user_id' => (string) $this->encodePrimaryKey($task->assigned_user_id),
|
||||||
'number' => (string) $task->number ?: '',
|
'number' => (string) $task->number ?: '',
|
||||||
'start_time' => (int) $task->start_time,
|
// 'start_time' => (int) $task->start_time,
|
||||||
'description' => (string) $task->description ?: '',
|
'description' => (string) $task->description ?: '',
|
||||||
'duration' => (int) $task->duration ?: 0,
|
'duration' => (int) $task->duration ?: 0,
|
||||||
'rate' => (float) $task->rate ?: 0,
|
'rate' => (float) $task->rate ?: 0,
|
||||||
|
@ -49,7 +49,7 @@ trait GeneratesCounter
|
|||||||
//todo handle if we have specific client patterns in the future
|
//todo handle if we have specific client patterns in the future
|
||||||
$pattern = $client->getSetting('invoice_number_pattern');
|
$pattern = $client->getSetting('invoice_number_pattern');
|
||||||
//Determine if we are using client_counters
|
//Determine if we are using client_counters
|
||||||
if (strpos($pattern, 'clientCounter')) {
|
if (strpos($pattern, 'clientCounter') || strpos($pattern, 'client_counter')) {
|
||||||
if (property_exists($client->settings, 'invoice_number_counter')) {
|
if (property_exists($client->settings, 'invoice_number_counter')) {
|
||||||
$counter = $client->settings->invoice_number_counter;
|
$counter = $client->settings->invoice_number_counter;
|
||||||
} else {
|
} else {
|
||||||
@ -57,7 +57,7 @@ trait GeneratesCounter
|
|||||||
}
|
}
|
||||||
|
|
||||||
$counter_entity = $client;
|
$counter_entity = $client;
|
||||||
} elseif (strpos($pattern, 'groupCounter')) {
|
} elseif (strpos($pattern, 'groupCounter') || strpos($pattern, 'group_counter')) {
|
||||||
$counter = $client->group_settings->invoice_number_counter;
|
$counter = $client->group_settings->invoice_number_counter;
|
||||||
$counter_entity = $client->group_settings;
|
$counter_entity = $client->group_settings;
|
||||||
} else {
|
} else {
|
||||||
@ -96,10 +96,10 @@ trait GeneratesCounter
|
|||||||
//todo handle if we have specific client patterns in the future
|
//todo handle if we have specific client patterns in the future
|
||||||
$pattern = $client->getSetting('credit_number_pattern');
|
$pattern = $client->getSetting('credit_number_pattern');
|
||||||
//Determine if we are using client_counters
|
//Determine if we are using client_counters
|
||||||
if (strpos($pattern, 'clientCounter')) {
|
if (strpos($pattern, 'clientCounter') || strpos($pattern, 'client_counter')) {
|
||||||
$counter = $client->settings->credit_number_counter;
|
$counter = $client->settings->credit_number_counter;
|
||||||
$counter_entity = $client;
|
$counter_entity = $client;
|
||||||
} elseif (strpos($pattern, 'groupCounter')) {
|
} elseif (strpos($pattern, 'groupCounter') || strpos($pattern, 'group_counter')) {
|
||||||
$counter = $client->group_settings->credit_number_counter;
|
$counter = $client->group_settings->credit_number_counter;
|
||||||
$counter_entity = $client->group_settings;
|
$counter_entity = $client->group_settings;
|
||||||
} else {
|
} else {
|
||||||
@ -132,10 +132,10 @@ trait GeneratesCounter
|
|||||||
//todo handle if we have specific client patterns in the future
|
//todo handle if we have specific client patterns in the future
|
||||||
$pattern = $client->getSetting('quote_number_pattern');
|
$pattern = $client->getSetting('quote_number_pattern');
|
||||||
//Determine if we are using client_counters
|
//Determine if we are using client_counters
|
||||||
if (strpos($pattern, 'clientCounter')) {
|
if (strpos($pattern, 'clientCounter') || strpos($pattern, 'client_counter')) {
|
||||||
$counter = $client->settings->{$used_counter};
|
$counter = $client->settings->{$used_counter};
|
||||||
$counter_entity = $client;
|
$counter_entity = $client;
|
||||||
} elseif (strpos($pattern, 'groupCounter')) {
|
} elseif (strpos($pattern, 'groupCounter') || strpos($pattern, 'group_counter')) {
|
||||||
$counter = $client->group_settings->{$used_counter};
|
$counter = $client->group_settings->{$used_counter};
|
||||||
$counter_entity = $client->group_settings;
|
$counter_entity = $client->group_settings;
|
||||||
} else {
|
} else {
|
||||||
|
@ -22,14 +22,9 @@ trait Uploadable
|
|||||||
{
|
{
|
||||||
public function removeLogo($company)
|
public function removeLogo($company)
|
||||||
{
|
{
|
||||||
$company_logo = $company->settings->company_logo;
|
|
||||||
|
|
||||||
$file_name = basename($company_logo);
|
if (Storage::exists($company->settings->company_logo)) {
|
||||||
|
UnlinkFile::dispatchNow(config('filesystems.default'), $company->settings->company_logo);
|
||||||
$storage_path = $company->company_key . '/' . $file_name;
|
|
||||||
|
|
||||||
if (Storage::exists($storage_path)) {
|
|
||||||
UnlinkFile::dispatchNow(config('filesystems.default'), $storage_path);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,6 +33,8 @@ trait Uploadable
|
|||||||
if ($file) {
|
if ($file) {
|
||||||
$path = UploadAvatar::dispatchNow($file, $company->company_key);
|
$path = UploadAvatar::dispatchNow($file, $company->company_key);
|
||||||
|
|
||||||
|
$path = str_replace(config("ninja.app_url"), "", $path);
|
||||||
|
|
||||||
info("the path {$path}");
|
info("the path {$path}");
|
||||||
|
|
||||||
if ($path) {
|
if ($path) {
|
||||||
|
@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Models\Company;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class FixCompanySettingsUrl extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
|
||||||
|
Company::all()->each(function ($company){
|
||||||
|
|
||||||
|
$settings = $company->settings;
|
||||||
|
|
||||||
|
$company_logo = $settings->company_logo;
|
||||||
|
$company_logo = str_replace(config('ninja.app_url'), '', $company_logo);
|
||||||
|
|
||||||
|
$settings->company_logo = $company_logo;
|
||||||
|
|
||||||
|
$company->settings = $settings;
|
||||||
|
$company->save();
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::table('companies', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('logo');
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::table('tasks', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('start_time');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
8374
swagger.json
8374
swagger.json
File diff suppressed because it is too large
Load Diff
@ -71,7 +71,6 @@ class TaskApiTest extends TestCase
|
|||||||
$arr = $response->json();
|
$arr = $response->json();
|
||||||
$response->assertStatus(200);
|
$response->assertStatus(200);
|
||||||
|
|
||||||
$this->assertGreaterThan(0, $arr['data']['start_time']);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testTaskPut()
|
public function testTaskPut()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user