Skip to content

Commit

Permalink
Patches from v5-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
turbo124 committed Jul 20, 2022
2 parents dda60fb + 138fb7a commit e337abe
Show file tree
Hide file tree
Showing 37 changed files with 226 additions and 277 deletions.
2 changes: 1 addition & 1 deletion VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.4.10
5.4.11
3 changes: 2 additions & 1 deletion app/Factory/InvoiceFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ public static function create(int $company_id, int $user_id) :Invoice
$invoice->user_id = $user_id;
$invoice->company_id = $company_id;
$invoice->recurring_id = null;

$invoice->exchange_rate = 1;

return $invoice;
}
}
2 changes: 2 additions & 0 deletions app/Http/Controllers/MigrationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ public function purgeCompanySaveSettings(Request $request, Company $company)
$company->tasks()->forceDelete();
$company->vendors()->forceDelete();
$company->expenses()->forceDelete();
$company->purchase_orders()->forceDelete();

$settings = $company->settings;

Expand All @@ -198,6 +199,7 @@ public function purgeCompanySaveSettings(Request $request, Company $company)
$settings->ticket_number_counter = 1;
$settings->payment_number_counter = 1;
$settings->project_number_counter = 1;
$settings->purchase_order_number_counter = 1;

$company->settings = $settings;

Expand Down
3 changes: 0 additions & 3 deletions app/Http/Controllers/SelfUpdateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,10 +262,7 @@ private function testWritable()
continue;
}

//nlog($file->getPathname());

if ($file->isFile() && ! $file->isWritable()) {
// throw new FilePermissionsFailure($file);
nlog("Cannot update system because {$file->getFileName()} is not writable");
throw new FilePermissionsFailure("Cannot update system because {$file->getFileName()} is not writable");

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/StripeConnectController.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public function completed(InitializeStripeConnectRequest $request)
$company_gateway->setConfig($payload);
$company_gateway->save();

StripeWebhook::dispatch($company->company_key, $company_gateway->id);
// StripeWebhook::dispatch($company->company_key, $company_gateway->id);

//response here
return view('auth.connect.completed');
Expand Down
4 changes: 0 additions & 4 deletions app/Http/Requests/Company/StoreCompanyRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@ public function prepareForValidation()
{
$input = $this->all();

//https not sure i should be forcing this.
// if(array_key_exists('portal_domain', $input) && strlen($input['portal_domain']) > 1)
// $input['portal_domain'] = str_replace("http:", "https:", $input['portal_domain']);

if (array_key_exists('google_analytics_url', $input)) {
$input['google_analytics_key'] = $input['google_analytics_url'];
}
Expand Down
2 changes: 1 addition & 1 deletion app/Jobs/Company/CompanyImport.php
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ private function importSettings()
$settings->ticket_number_counter = 1;
$settings->payment_number_counter = 1;
$settings->project_number_counter = 1;
$settings->purchase_order_counter = 1;
$settings->purchase_order_number_counter = 1;
$this->company->settings = $co->settings;
// $this->company->settings = $this->backup_file->company->settings;
$this->company->save();
Expand Down
6 changes: 3 additions & 3 deletions app/Listeners/Invoice/InvoiceArchivedActivity.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ class InvoiceArchivedActivity implements ShouldQueue
{
protected $activity_repo;

public $delay = 5;

public $delay = 15;
/**
* Create the event listener.
*
Expand All @@ -42,7 +42,7 @@ public function __construct(ActivityRepository $activity_repo)
public function handle($event)
{
MultiDB::setDb($event->company->db);

$fields = new stdClass;

$user_id = array_key_exists('user_id', $event->event_vars) ? $event->event_vars['user_id'] : $event->invoice->user_id;
Expand Down
10 changes: 6 additions & 4 deletions app/Listeners/Invoice/InvoicePaidActivity.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ class InvoicePaidActivity implements ShouldQueue
{
protected $activity_repo;

public $delay = 5;

public $delay = 10;
/**
* Create the event listener.
*
Expand All @@ -41,6 +41,7 @@ public function __construct(ActivityRepository $activity_repo)
*/
public function handle($event)
{

MultiDB::setDb($event->company->db);

$fields = new stdClass;
Expand All @@ -52,10 +53,11 @@ public function handle($event)
$fields->company_id = $event->invoice->company_id;
$fields->activity_type_id = Activity::PAID_INVOICE;
$fields->payment_id = $event->payment->id;

$this->activity_repo->save($fields, $event->invoice, $event->event_vars);

if ($event->invoice->subscription()->exists()) {
if($event->invoice->subscription()->exists())
{
$event->invoice->subscription->service()->planPaid($event->invoice);
}

Expand Down
53 changes: 53 additions & 0 deletions app/Models/Invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@
use App\Helpers\Invoice\InvoiceSum;
use App\Helpers\Invoice\InvoiceSumInclusive;
use App\Jobs\Entity\CreateEntityPdf;
use App\Models\Expense;
use App\Models\Presenters\InvoicePresenter;
use App\Models\Task;
use App\Services\Invoice\InvoiceService;
use App\Services\Ledger\LedgerService;
use App\Utils\Ninja;
use App\Utils\Traits\Invoice\ActionsInvoice;
use App\Utils\Traits\MakesDates;
use App\Utils\Traits\MakesHash;
use App\Utils\Traits\MakesInvoiceValues;
use App\Utils\Traits\MakesReminders;
use App\Utils\Traits\NumberFormatter;
Expand Down Expand Up @@ -565,6 +568,56 @@ public function transaction_event()
];
}

public function expense_documents()
{

$line_items = $this->line_items;

$expense_ids = [];

foreach($line_items as $item)
{

if(property_exists($item, 'expense_id'))
{
$expense_ids[] = $item->expense_id;
}

}

return Expense::whereIn('id', $this->transformKeys($expense_ids))
->where('invoice_documents', 1)
->where('company_id', $this->company_id)
->cursor();

}

public function task_documents()
{

$line_items = $this->line_items;

$task_ids = [];

foreach($line_items as $item)
{

if(property_exists($item, 'task_id'))
{
$task_ids[] = $item->task_id;
}

}

return Task::whereIn('id', $this->transformKeys($task_ids))
->whereHas('company', function($query){
$query->where('invoice_task_documents', 1);
})
->where('company_id', $this->company_id)
->cursor();

}

public function translate_entity()
{
return ctrans('texts.invoice');
Expand Down
8 changes: 4 additions & 4 deletions app/Models/Task.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,22 +71,22 @@ public function user()

public function client()
{
return $this->belongsTo(Client::class);
return $this->belongsTo(Client::class)->withTrashed();
}

public function status()
{
return $this->belongsTo(TaskStatus::class);
return $this->belongsTo(TaskStatus::class)->withTrashed();
}

public function invoice()
{
return $this->belongsTo(Invoice::class);
return $this->belongsTo(Invoice::class)->withTrashed();
}

public function project()
{
return $this->belongsTo(Project::class);
return $this->belongsTo(Project::class)->withTrashed();
}

public function calcStartTime()
Expand Down
2 changes: 1 addition & 1 deletion app/PaymentDrivers/Stripe/Alipay.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function paymentResponse(PaymentResponseRequest $request)
$this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, $request->all());
$this->stripe->payment_hash->save();

if ($request->redirect_status == 'succeeded') {
if (in_array($request->redirect_status, ['succeeded', 'pending'])) {
return $this->processSuccesfulRedirect($request->source);
}

Expand Down
2 changes: 1 addition & 1 deletion app/PaymentDrivers/Stripe/Bancontact.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function paymentResponse($request)
$this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, $request->all());
$this->stripe->payment_hash->save();

if ($request->redirect_status == 'succeeded') {
if (in_array($request->redirect_status, ['succeeded','pending'])) {
return $this->processSuccessfulPayment($request->payment_intent);
}

Expand Down
2 changes: 1 addition & 1 deletion app/PaymentDrivers/Stripe/EPS.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function paymentResponse($request)
$this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, $request->all());
$this->stripe->payment_hash->save();

if ($request->redirect_status == 'succeeded') {
if (in_array($request->redirect_status, ['succeeded','pending'])) {
return $this->processSuccessfulPayment($request->payment_intent);
}

Expand Down
2 changes: 1 addition & 1 deletion app/PaymentDrivers/Stripe/FPX.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function paymentResponse($request)
$this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, $request->all());
$this->stripe->payment_hash->save();

if ($request->redirect_status == 'succeeded') {
if (in_array($request->redirect_status, ['succeeded','pending'])) {
return $this->processSuccessfulPayment($request->payment_intent);
}

Expand Down
2 changes: 1 addition & 1 deletion app/PaymentDrivers/Stripe/GIROPAY.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function paymentResponse($request)
$this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, $request->all());
$this->stripe->payment_hash->save();

if ($request->redirect_status == 'succeeded') {
if (in_array($request->redirect_status, ['succeeded','pending'])) {
return $this->processSuccessfulPayment($request->payment_intent);
}

Expand Down
2 changes: 1 addition & 1 deletion app/PaymentDrivers/Stripe/PRZELEWY24.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function paymentResponse($request)
$this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, $request->all());
$this->stripe->payment_hash->save();

if ($request->redirect_status == 'succeeded') {
if (in_array($request->redirect_status, ['succeeded','pending'])) {
return $this->processSuccessfulPayment($request->payment_intent);
}

Expand Down
3 changes: 2 additions & 1 deletion app/PaymentDrivers/Stripe/SOFORT.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,11 @@ private function buildReturnUrl(): string

public function paymentResponse($request)
{

$this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, $request->all());
$this->stripe->payment_hash->save();

if ($request->redirect_status == 'succeeded') {
if (in_array($request->redirect_status, ['succeeded','pending'])) {
return $this->processSuccessfulPayment($request->payment_intent);
}

Expand Down
2 changes: 1 addition & 1 deletion app/PaymentDrivers/Stripe/iDeal.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function paymentResponse($request)
$this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, $request->all());
$this->stripe->payment_hash->save();

if ($request->redirect_status == 'succeeded') {
if (in_array($request->redirect_status, ['succeeded','pending'])) {
return $this->processSuccessfulPayment($request->payment_intent);
}

Expand Down
3 changes: 3 additions & 0 deletions app/Services/Invoice/InvoiceService.php
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,9 @@ public function updateStatus()
} elseif ($this->invoice->balance > 0 && $this->invoice->balance < $this->invoice->amount) {
$this->invoice->status_id = Invoice::STATUS_PARTIAL;
}
elseif ($this->invoice->balance < 0) {
$this->invoice->status_id = Invoice::STATUS_SENT;
}

return $this;
}
Expand Down
Loading

0 comments on commit e337abe

Please sign in to comment.