Skip to content

Commit

Permalink
Merge pull request #8688 from turbo124/v5-stable
Browse files Browse the repository at this point in the history
v5.6.25
  • Loading branch information
turbo124 committed Aug 3, 2023
2 parents ca1b3ba + c22a3c2 commit b404751
Show file tree
Hide file tree
Showing 92 changed files with 496 additions and 1,079 deletions.
2 changes: 1 addition & 1 deletion VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.6.24
5.6.25
4 changes: 2 additions & 2 deletions app/Console/Commands/CreateSingleAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -723,10 +723,10 @@ private function createGateways($company, $user)
$cg->config = encrypt(config('ninja.testvars.paypal_rest'));
$cg->save();

$gateway_types = $cg->driver()->gatewayTypes();
// $gateway_types = $cg->driver()->gatewayTypes();

$fees_and_limits = new stdClass;
$fees_and_limits->{$gateway_types[0]} = new FeesAndLimits;
$fees_and_limits->{3} = new FeesAndLimits;

$cg->fees_and_limits = $fees_and_limits;
$cg->save();
Expand Down
3 changes: 0 additions & 3 deletions app/Export/CSV/BaseExport.php
Original file line number Diff line number Diff line change
Expand Up @@ -623,9 +623,6 @@ private function resolveInvoiceKey($column, $entity, $transformer)
} elseif ($transformed_invoice && array_key_exists(str_replace("invoice.", "", $column), $transformed_invoice)) {
return $transformed_invoice[$column];
}

// if($column == 'status')
// return $entity->stringStatus($entity->status_id);

return '';
}
Expand Down
2 changes: 1 addition & 1 deletion app/Factory/RecurringExpenseToExpenseFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static function create(RecurringExpense $recurring_expense) :Expense
$expense->custom_value2 = $recurring_expense->custom_value2;
$expense->custom_value3 = $recurring_expense->custom_value3;
$expense->custom_value4 = $recurring_expense->custom_value4;
$expense->transaction_id = $recurring_expense->transaction_id;
$expense->transaction_id = null;
$expense->category_id = $recurring_expense->category_id;
$expense->payment_type_id = $recurring_expense->payment_type_id;
$expense->project_id = $recurring_expense->project_id;
Expand Down
1 change: 1 addition & 0 deletions app/Filters/ExpenseFilters.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public function filter(string $filter = ''): Builder

return $this->builder->where(function ($query) use ($filter) {
$query->where('number', 'like', '%'.$filter.'%')
->orWhere('amount', 'like', '%'.$filter.'%')
->orWhere('public_notes', 'like', '%'.$filter.'%')
->orWhere('custom_value1', 'like', '%'.$filter.'%')
->orWhere('custom_value2', 'like', '%'.$filter.'%')
Expand Down
2 changes: 0 additions & 2 deletions app/Filters/QueryFilters.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,6 @@ public function with_trashed($value)

/**
* @return Builder
* @throws RuntimeException
*/
public function without_deleted_clients(): Builder
{
Expand All @@ -302,7 +301,6 @@ public function without_deleted_clients(): Builder

/**
* @return Builder
* @throws RuntimeException
*/
public function without_deleted_vendors(): Builder
{
Expand Down
2 changes: 1 addition & 1 deletion app/Filters/QuoteFilters.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function filter(string $filter = ''): Builder
* - paused
* - completed
*
* @param string client_status The invoice status as seen by the client
* @param string $value The invoice status as seen by the client
* @return Builder
*/
public function client_status(string $value = ''): Builder
Expand Down
1 change: 1 addition & 0 deletions app/Helpers/Invoice/ProRata.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public function refundItems(Invoice $invoice, $is_credit = false) :array
return [];
}

/** @var \App\Models\RecurringInvoice $recurring_invoice **/
$recurring_invoice = RecurringInvoice::find($invoice->recurring_id)->first();

if (! $recurring_invoice) {
Expand Down
2 changes: 2 additions & 0 deletions app/Http/Controllers/EmailController.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ private function sendPurchaseOrder($entity_obj, $data, $template)

private function resolveClass(string $entity): string
{
$class = '';

match ($entity) {
'invoice' => $class = Invoice::class,
'App\Models\Invoice' => $class = Invoice::class,
Expand Down
3 changes: 1 addition & 2 deletions app/Http/Controllers/LicenseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use App\Models\Account;
use App\Utils\CurlUtils;
use Carbon\Carbon;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Http;
use stdClass;
Expand Down Expand Up @@ -137,7 +136,7 @@ public function index()
}
} else {
$error = [
'message' => trans('texts.white_label_license_error'),
'message' => 'There was an issue connecting to the license server. Please check your network.',
'errors' => new stdClass,
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,17 @@ class BulkBankTransactionRequest extends Request
*/
public function authorize() : bool
{
return auth()->user()->isAdmin();
/** @var \App\Models\User $user **/
$user = auth()->user();

return $user->isAdmin();
}

public function rules()
public function rules(): array
{
return [
'ids' => 'required|bail|array',
'action' => 'in:archive,restore,delete,convert_matched'
'action' => 'in:archive,restore,delete,convert_matched,unlink'
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ public function rules()
$rules['vendor_id'] = 'bail|required|exists:vendors,id,company_id,'.auth()->user()->company()->id.',is_deleted,0';
}

if (isset($this->expense_id)) {
$rules['expense_id'] = 'bail|required|exists:expenses,id,company_id,'.auth()->user()->company()->id.',is_deleted,0';
}
// if (isset($this->expense_id)) {
// $rules['expense_id'] = 'bail|required|exists:expenses,id,company_id,'.auth()->user()->company()->id.',is_deleted,0';
// }

$rules['bank_integration_id'] = 'bail|required|exists:bank_integrations,id,company_id,'.auth()->user()->company()->id.',is_deleted,0';

Expand All @@ -67,9 +67,9 @@ public function prepareForValidation()
$input['vendor_id'] = $this->decodePrimaryKey($input['vendor_id']);
}

if (array_key_exists('expense_id', $input) && strlen($input['expense_id']) > 1) {
$input['expense_id'] = $this->decodePrimaryKey($input['expense_id']);
}
// if (array_key_exists('expense_id', $input) && strlen($input['expense_id']) > 1) {
// $input['expense_id'] = $this->decodePrimaryKey($input['expense_id']);
// }

if (array_key_exists('ninja_category_id', $input) && strlen($input['ninja_category_id']) > 1) {
$input['ninja_category_id'] = $this->decodePrimaryKey($input['ninja_category_id']);
Expand Down
6 changes: 4 additions & 2 deletions app/Http/Requests/Migration/UploadMigrationFileRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,17 @@ class UploadMigrationFileRequest extends Request
*/
public function authorize()
{
return auth()->user()->isAdmin();
/** @var \App\Models\User $user */
$user = auth()->user();
return $user->isAdmin();
}

/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
public function rules(): array
{
$rules = [
'migration' => [],
Expand Down
10 changes: 6 additions & 4 deletions app/Http/Requests/Payment/RefundPaymentRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ class RefundPaymentRequest extends Request
*/
public function authorize() : bool
{
return auth()->user()->isAdmin();
/** @var \App\Models\User $user */
$user = auth()->user();
return $user->isAdmin();
}

public function prepareForValidation()
Expand Down Expand Up @@ -62,12 +64,12 @@ public function prepareForValidation()
$this->replace($input);
}

public function rules()
public function rules(): array
{
$input = $this->all();

$rules = [
'id' => 'bail|required',
'id' => 'bail|required', //@phpstan-ignore-line
'id' => new ValidRefundableRequest($input),
'amount' => 'numeric',
'date' => 'required',
Expand All @@ -79,7 +81,7 @@ public function rules()
return $rules;
}

public function payment() :?Payment
public function payment(): ?\App\Models\Payment
{
$input = $this->all();

Expand Down
74 changes: 38 additions & 36 deletions app/Http/ValidationRules/Payment/ValidRefundableRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ public function passes($attribute, $value)
return false;
}

$payment = Payment::whereId($this->input['id'])->withTrashed()->first();
/**@var \App\Models\Payment $payment **/
$payment = Payment::where('id', $this->input['id'])->withTrashed()->first();

if (! $payment) {
$this->error_msg = ctrans('texts.unable_to_retrieve_payment');
Expand All @@ -55,7 +56,6 @@ public function passes($attribute, $value)
}

$request_invoices = request()->has('invoices') ? $this->input['invoices'] : [];
// $request_credits = request()->has('credits') ? $this->input['credits'] : [];

if ($payment->invoices()->exists()) {
foreach ($payment->invoices as $paymentable_invoice) {
Expand All @@ -76,7 +76,8 @@ public function passes($attribute, $value)

private function checkInvoiceIsPaymentable($invoice, $payment)
{
$invoice = Invoice::whereId($invoice['invoice_id'])->whereCompanyId($payment->company_id)->withTrashed()->first();
/**@var \App\Models\Invoice $invoice **/
$invoice = Invoice::where('id', $invoice['invoice_id'])->where('company_id', $payment->company_id)->withTrashed()->first();

if (! $invoice) {
$this->error_msg = 'Invoice not found for refund';
Expand All @@ -99,24 +100,25 @@ private function checkInvoiceIsPaymentable($invoice, $payment)
}
}

private function checkCreditIsPaymentable($credit, $payment)
{
$credit = Credit::whereId($credit['credit_id'])->whereCompanyId($payment->company_id)->first();
// private function checkCreditIsPaymentable($credit, $payment)
// {
// /** @var \App\Models\Credit $credit */
// $credit = Credit::whereId($credit['credit_id'])->whereCompanyId($payment->company_id)->first();

if ($payment->credits()->exists()) {
$paymentable_credit = $payment->credits->where('id', $credit->id)->first();
// if ($payment->credits()->exists()) {
// $paymentable_credit = $payment->credits->where('id', $credit->id)->first();

if (! $paymentable_credit) {
$this->error_msg = ctrans('texts.credit_not_related_to_payment', ['credit' => $credit->hashed_id]);
// if (! $paymentable_credit) {
// $this->error_msg = ctrans('texts.credit_not_related_to_payment', ['credit' => $credit->hashed_id]);

return false;
}
} else {
$this->error_msg = ctrans('texts.credit_not_related_to_payment', ['credit' => $credit->hashed_id]);
// return false;
// }
// } else {
// $this->error_msg = ctrans('texts.credit_not_related_to_payment', ['credit' => $credit->hashed_id]);

return false;
}
}
// return false;
// }
// }

private function checkInvoice($paymentable, $request_invoices)
{
Expand Down Expand Up @@ -145,32 +147,32 @@ private function checkInvoice($paymentable, $request_invoices)
}
}

private function checkCredit($paymentable, $request_credits)
{
$record_found = null;
// private function checkCredit($paymentable, $request_credits)
// {
// $record_found = null;

foreach ($request_credits as $request_credit) {
if ($request_credit['credit_id'] == $paymentable->pivot->paymentable_id) {
$record_found = true;
// foreach ($request_credits as $request_credit) {
// if ($request_credit['credit_id'] == $paymentable->pivot->paymentable_id) {
// $record_found = true;

$refundable_amount = ($paymentable->pivot->amount - $paymentable->pivot->refunded);
// $refundable_amount = ($paymentable->pivot->amount - $paymentable->pivot->refunded);

if ($request_credit['amount'] > $refundable_amount) {
$credit = $paymentable;
// if ($request_credit['amount'] > $refundable_amount) {
// $credit = $paymentable;

$this->error_msg = ctrans('texts.max_refundable_credit', ['credit' => $credit->hashed_id, 'amount' => $refundable_amount]);
// $this->error_msg = ctrans('texts.max_refundable_credit', ['credit' => $credit->hashed_id, 'amount' => $refundable_amount]);

return false;
}
}
}
// return false;
// }
// }
// }

if (! $record_found) {
$this->error_msg = ctrans('texts.refund_without_credits');
// if (! $record_found) {
// $this->error_msg = ctrans('texts.refund_without_credits');

return false;
}
}
// return false;
// }
// }

/**
* @return string
Expand Down
2 changes: 1 addition & 1 deletion app/Http/ValidationRules/ValidRefundableInvoices.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public function passes($attribute, $value)
return false;
}

/**@var \App\Models\Payment $payment **/
$payment = Payment::whereId($this->input['id'])->first();

if (! $payment) {
Expand All @@ -71,7 +72,6 @@ public function passes($attribute, $value)

foreach ($this->input['invoices'] as $val) {
if ($val['invoice_id'] == $invoice->id) {
//$pivot_record = $invoice->payments->where('id', $invoice->id)->first();
$pivot_record = $payment->paymentables->where('paymentable_id', $invoice->id)->first();

if ($val['amount'] > ($pivot_record->amount - $pivot_record->refunded)) {
Expand Down
2 changes: 1 addition & 1 deletion app/Jobs/Bank/MatchBankTransactions.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ private function checkPayable($invoices) :bool

private function linkExpense($input)
{
$this->bt = BankTransaction::find($input['id']);
$this->bt = BankTransaction::withTrashed()->find($input['id']);

if (!$this->bt) {
return $this;
Expand Down
2 changes: 1 addition & 1 deletion app/Jobs/Cron/RecurringExpensesCron.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ private function generateExpense(RecurringExpense $recurring_expense)

$recurring_expense->next_send_date = $recurring_expense->nextSendDate();
$recurring_expense->next_send_date_client = $recurring_expense->next_send_date;

$recurring_expense->last_sent_date = now();
$recurring_expense->remaining_cycles = $recurring_expense->remainingCycles();
$recurring_expense->save();
}
Expand Down
15 changes: 1 addition & 14 deletions app/Jobs/Report/ProfitAndLoss.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,8 @@ class ProfitAndLoss implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

protected Company $company;

protected array $payload;

/**
* Create a new job instance.
*
* @param RecurringInvoice $recurring_invoice
* @param string $db
*/
public function __construct(Company $company, array $payload)
public function __construct(protected Company $company, protected array $payload)
{
$this->company = $company;

$this->payload = $payload;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/Jobs/Util/ApplePayDomain.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,6 @@ private function getDomain()

$parsed_url = parse_url($domain);

return $parsed_url['host'];
return $parsed_url['host'] ?? '';
}
}
2 changes: 1 addition & 1 deletion app/Jobs/Util/RefreshPdfs.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ public function handle()
CreateEntityPdf::dispatch($invitation);
});
}
}
}

0 comments on commit b404751

Please sign in to comment.