diff --git a/app/Commands/Command.php b/app/Commands/Command.php
index d6a8d61150ae..e0be76979932 100644
--- a/app/Commands/Command.php
+++ b/app/Commands/Command.php
@@ -1,5 +1,10 @@
-info("=== Client:{$client->id} Balance:{$client->balance} Actual Balance:{$client->actual_balance} ===");
- $foundProblem = false;
$lastBalance = 0;
$lastAdjustment = 0;
$lastCreatedAt = null;
@@ -182,8 +183,16 @@ class CheckData extends Command {
$activities = DB::table('activities')
->where('client_id', '=', $client->id)
->orderBy('activities.id')
- ->get(['activities.id', 'activities.created_at', 'activities.activity_type_id', 'activities.adjustment', 'activities.balance', 'activities.invoice_id']);
- //$this->info(var_dump($activities));
+ ->get(
+ [
+ 'activities.id',
+ 'activities.created_at',
+ 'activities.activity_type_id',
+ 'activities.adjustment',
+ 'activities.balance',
+ 'activities.invoice_id'
+ ]
+ );
foreach ($activities as $activity) {
@@ -231,13 +240,11 @@ class CheckData extends Command {
// **Fix for allowing converting a recurring invoice to a normal one without updating the balance**
if ($noAdjustment && $invoice->invoice_type_id == INVOICE_TYPE_STANDARD && !$invoice->is_recurring) {
$this->info("No adjustment for new invoice:{$activity->invoice_id} amount:{$invoice->amount} invoiceTypeId:{$invoice->invoice_type_id} isRecurring:{$invoice->is_recurring}");
- $foundProblem = true;
$clientFix += $invoice->amount;
$activityFix = $invoice->amount;
// **Fix for updating balance when creating a quote or recurring invoice**
} elseif ($activity->adjustment != 0 && ($invoice->invoice_type_id == INVOICE_TYPE_QUOTE || $invoice->is_recurring)) {
$this->info("Incorrect adjustment for new invoice:{$activity->invoice_id} adjustment:{$activity->adjustment} invoiceTypeId:{$invoice->invoice_type_id} isRecurring:{$invoice->is_recurring}");
- $foundProblem = true;
$clientFix -= $activity->adjustment;
$activityFix = 0;
}
@@ -245,7 +252,6 @@ class CheckData extends Command {
// **Fix for updating balance when deleting a recurring invoice**
if ($activity->adjustment != 0 && $invoice->is_recurring) {
$this->info("Incorrect adjustment for deleted invoice adjustment:{$activity->adjustment}");
- $foundProblem = true;
if ($activity->balance != $lastBalance) {
$clientFix -= $activity->adjustment;
}
@@ -255,7 +261,6 @@ class CheckData extends Command {
// **Fix for updating balance when archiving an invoice**
if ($activity->adjustment != 0 && !$invoice->is_recurring) {
$this->info("Incorrect adjustment for archiving invoice adjustment:{$activity->adjustment}");
- $foundProblem = true;
$activityFix = 0;
$clientFix += $activity->adjustment;
}
@@ -263,12 +268,10 @@ class CheckData extends Command {
// **Fix for updating balance when updating recurring invoice**
if ($activity->adjustment != 0 && $invoice->is_recurring) {
$this->info("Incorrect adjustment for updated recurring invoice adjustment:{$activity->adjustment}");
- $foundProblem = true;
$clientFix -= $activity->adjustment;
$activityFix = 0;
} else if ((strtotime($activity->created_at) - strtotime($lastCreatedAt) <= 1) && $activity->adjustment > 0 && $activity->adjustment == $lastAdjustment) {
$this->info("Duplicate adjustment for updated invoice adjustment:{$activity->adjustment}");
- $foundProblem = true;
$clientFix -= $activity->adjustment;
$activityFix = 0;
}
@@ -276,7 +279,6 @@ class CheckData extends Command {
// **Fix for updating balance when updating a quote**
if ($activity->balance != $lastBalance) {
$this->info("Incorrect adjustment for updated quote adjustment:{$activity->adjustment}");
- $foundProblem = true;
$clientFix += $lastBalance - $activity->balance;
$activityFix = 0;
}
@@ -284,7 +286,6 @@ class CheckData extends Command {
// **Fix for deleting payment after deleting invoice**
if ($activity->adjustment != 0 && $invoice->is_deleted && $activity->created_at > $invoice->deleted_at) {
$this->info("Incorrect adjustment for deleted payment adjustment:{$activity->adjustment}");
- $foundProblem = true;
$activityFix = 0;
$clientFix -= $activity->adjustment;
}
diff --git a/app/Console/Commands/CreateTestData.php b/app/Console/Commands/CreateTestData.php
index a75922635f75..f4364e5d0675 100644
--- a/app/Console/Commands/CreateTestData.php
+++ b/app/Console/Commands/CreateTestData.php
@@ -1,5 +1,8 @@
- $invoice->id,
@@ -167,9 +171,9 @@ class CreateTestData extends Command
}
/**
- * @param $vendor
+ * @param Vendor $vendor
*/
- private function createExpense($vendor)
+ private function createExpense(Vendor $vendor)
{
for ($i=0; $i<$this->count; $i++) {
$data = [
diff --git a/app/Console/Commands/GenerateResources.php b/app/Console/Commands/GenerateResources.php
index 9826f3c70b07..2766a906c1bd 100644
--- a/app/Console/Commands/GenerateResources.php
+++ b/app/Console/Commands/GenerateResources.php
@@ -1,4 +1,6 @@
-comment(PHP_EOL.Inspiring::quote().PHP_EOL);
- }
+ /**
+ * Execute the console command.
+ *
+ * @return mixed
+ */
+ public function handle()
+ {
+ $this->comment(PHP_EOL . Inspiring::quote() . PHP_EOL);
+ }
}
diff --git a/app/Console/Commands/PruneData.php b/app/Console/Commands/PruneData.php
index 1c04e1ab5fcf..c7e3f834709a 100644
--- a/app/Console/Commands/PruneData.php
+++ b/app/Console/Commands/PruneData.php
@@ -1,4 +1,6 @@
-path() != 'get_started') {
// https://gist.github.com/jrmadsen67/bd0f9ad0ef1ed6bb594e
return redirect()
- ->back()
- ->withInput($request->except('password', '_token'))
- ->with([
- 'warning' => trans('texts.token_expired')
- ]);
+ ->back()
+ ->withInput($request->except('password', '_token'))
+ ->with([
+ 'warning' => trans('texts.token_expired')
+ ]);
}
}
// In production, except for maintenance mode, we'll show a custom error screen
if (Utils::isNinjaProd()
&& !Utils::isDownForMaintenance()
- && !($e instanceof HttpResponseException)) {
+ && !($e instanceof HttpResponseException)
+ ) {
$data = [
'error' => get_class($e),
'hideHeader' => true,
];
-
+
return response()->view('error', $data);
} else {
return parent::render($request, $e);
}
- }
+ }
}
diff --git a/app/Handlers/InvoiceEventHandler.php b/app/Handlers/InvoiceEventHandler.php
index 924a9590ee36..986cac7a08be 100644
--- a/app/Handlers/InvoiceEventHandler.php
+++ b/app/Handlers/InvoiceEventHandler.php
@@ -1,51 +1,83 @@
-userMailer = $userMailer;
- $this->contactMailer = $contactMailer;
- }
+ /**
+ * @var ContactMailer
+ */
+ protected $contactMailer;
- public function subscribe($events)
- {
- $events->listen('invoice.sent', 'InvoiceEventHandler@onSent');
- $events->listen('invoice.viewed', 'InvoiceEventHandler@onViewed');
- $events->listen('invoice.paid', 'InvoiceEventHandler@onPaid');
- }
+ /**
+ * InvoiceEventHandler constructor.
+ *
+ * @param UserMailer $userMailer
+ * @param ContactMailer $contactMailer
+ */
+ public function __construct(UserMailer $userMailer, ContactMailer $contactMailer)
+ {
+ $this->userMailer = $userMailer;
+ $this->contactMailer = $contactMailer;
+ }
- public function onSent($invoice)
- {
- $this->sendNotifications($invoice, 'sent');
- }
+ /**
+ * @param $events
+ */
+ public function subscribe($events)
+ {
+ $events->listen('invoice.sent', 'InvoiceEventHandler@onSent');
+ $events->listen('invoice.viewed', 'InvoiceEventHandler@onViewed');
+ $events->listen('invoice.paid', 'InvoiceEventHandler@onPaid');
+ }
- public function onViewed($invoice)
- {
- $this->sendNotifications($invoice, 'viewed');
- }
+ /**
+ * @param Invoice $invoice
+ */
+ public function onSent(Invoice $invoice)
+ {
+ $this->sendNotifications($invoice, 'sent');
+ }
- public function onPaid($payment)
- {
- $this->contactMailer->sendPaymentConfirmation($payment);
+ /**
+ * @param Invoice $invoice
+ */
+ public function onViewed(Invoice $invoice)
+ {
+ $this->sendNotifications($invoice, 'viewed');
+ }
- $this->sendNotifications($payment->invoice, 'paid', $payment);
- }
+ /**
+ * @param Payment $payment
+ */
+ public function onPaid(Payment $payment)
+ {
+ $this->contactMailer->sendPaymentConfirmation($payment);
- private function sendNotifications($invoice, $type, $payment = null)
- {
- foreach ($invoice->account->users as $user)
- {
- if ($user->{'notify_' . $type})
- {
+ $this->sendNotifications($payment->invoice, 'paid', $payment);
+ }
+
+ /**
+ * @param Invoice $invoice
+ * @param $type
+ * @param null $payment
+ */
+ private function sendNotifications(Invoice $invoice, $type, $payment = null)
+ {
+ foreach ($invoice->account->users as $user) {
+ if ($user->{'notify_' . $type}) {
$this->userMailer->sendNotification($user, $invoice, $type, $payment);
- }
- }
- }
+ }
+ }
+ }
}
\ No newline at end of file
diff --git a/app/Ninja/Datatables/AccountGatewayDatatable.php b/app/Ninja/Datatables/AccountGatewayDatatable.php
index 09c701873462..b56a40311328 100644
--- a/app/Ninja/Datatables/AccountGatewayDatatable.php
+++ b/app/Ninja/Datatables/AccountGatewayDatatable.php
@@ -1,12 +1,20 @@
-public_id}");
},
- function ($model) {
+ function () {
return Auth::user()->can('create', ENTITY_TASK);
}
],
@@ -83,7 +94,7 @@ class ClientDatatable extends EntityDatatable
function ($model) {
return URL::to("invoices/create/{$model->public_id}");
},
- function ($model) {
+ function () {
return Auth::user()->can('create', ENTITY_INVOICE);
}
],
@@ -92,13 +103,13 @@ class ClientDatatable extends EntityDatatable
function ($model) {
return URL::to("quotes/create/{$model->public_id}");
},
- function ($model) {
+ function () {
return Auth::user()->hasFeature(FEATURE_QUOTES) && Auth::user()->can('create', ENTITY_INVOICE);
}
],
[
'--divider--', function(){return false;},
- function ($model) {
+ function () {
$user = Auth::user();
return ($user->can('create', ENTITY_TASK) || $user->can('create', ENTITY_INVOICE)) && ($user->can('create', ENTITY_PAYMENT) || $user->can('create', ENTITY_CREDIT) || $user->can('create', ENTITY_EXPENSE));
}
@@ -108,7 +119,7 @@ class ClientDatatable extends EntityDatatable
function ($model) {
return URL::to("payments/create/{$model->public_id}");
},
- function ($model) {
+ function () {
return Auth::user()->can('create', ENTITY_PAYMENT);
}
],
@@ -117,7 +128,7 @@ class ClientDatatable extends EntityDatatable
function ($model) {
return URL::to("credits/create/{$model->public_id}");
},
- function ($model) {
+ function () {
return Auth::user()->can('create', ENTITY_CREDIT);
}
],
@@ -126,7 +137,7 @@ class ClientDatatable extends EntityDatatable
function ($model) {
return URL::to("expenses/create/0/{$model->public_id}");
},
- function ($model) {
+ function () {
return Auth::user()->can('create', ENTITY_EXPENSE);
}
]
diff --git a/app/Ninja/Datatables/CreditDatatable.php b/app/Ninja/Datatables/CreditDatatable.php
index 7f258e377d1d..931dfd23fd17 100644
--- a/app/Ninja/Datatables/CreditDatatable.php
+++ b/app/Ninja/Datatables/CreditDatatable.php
@@ -1,13 +1,21 @@
-client_public_id}") . '?paymentTypeId=1';
},
- function ($model) {
+ function () {
return Auth::user()->can('create', ENTITY_PAYMENT);
}
]
diff --git a/app/Ninja/Datatables/EntityDatatable.php b/app/Ninja/Datatables/EntityDatatable.php
index 085645ff2069..d5dabbff95ad 100644
--- a/app/Ninja/Datatables/EntityDatatable.php
+++ b/app/Ninja/Datatables/EntityDatatable.php
@@ -1,22 +1,47 @@
-isBulkEdit = $isBulkEdit;
$this->hideClient = $hideClient;
}
+ /**
+ * @return array
+ */
public function columns()
{
return [];
}
+ /**
+ * @return array
+ */
public function actions()
{
return [];
diff --git a/app/Ninja/Datatables/ExpenseCategoryDatatable.php b/app/Ninja/Datatables/ExpenseCategoryDatatable.php
index 7ef850b0a49c..55a37cbb18cc 100644
--- a/app/Ninja/Datatables/ExpenseCategoryDatatable.php
+++ b/app/Ninja/Datatables/ExpenseCategoryDatatable.php
@@ -1,13 +1,20 @@
-
$label
";
}
-
}
diff --git a/app/Ninja/Datatables/InvoiceDatatable.php b/app/Ninja/Datatables/InvoiceDatatable.php
index b9fa70aa0a43..01428f29e2b0 100644
--- a/app/Ninja/Datatables/InvoiceDatatable.php
+++ b/app/Ninja/Datatables/InvoiceDatatable.php
@@ -1,13 +1,21 @@
-entityType;
@@ -72,6 +80,9 @@ class InvoiceDatatable extends EntityDatatable
];
}
+ /**
+ * @return array
+ */
public function actions()
{
$entityType = $this->entityType;
@@ -91,7 +102,7 @@ class InvoiceDatatable extends EntityDatatable
function ($model) use ($entityType) {
return URL::to("{$entityType}s/{$model->public_id}/clone");
},
- function ($model) {
+ function () {
return Auth::user()->can('create', ENTITY_INVOICE);
}
],
@@ -155,6 +166,11 @@ class InvoiceDatatable extends EntityDatatable
];
}
+ /**
+ * @param $model
+ *
+ * @return string
+ */
private function getStatusLabel($model)
{
$entityType = $this->entityType;
@@ -189,5 +205,4 @@ class InvoiceDatatable extends EntityDatatable
return "$label
";
}
-
}
diff --git a/app/Ninja/Datatables/PaymentDatatable.php b/app/Ninja/Datatables/PaymentDatatable.php
index 20f2cd025892..c8175e4a924f 100644
--- a/app/Ninja/Datatables/PaymentDatatable.php
+++ b/app/Ninja/Datatables/PaymentDatatable.php
@@ -1,20 +1,32 @@
-payment_status_name));
$class = 'default';
diff --git a/app/Ninja/Datatables/ProductDatatable.php b/app/Ninja/Datatables/ProductDatatable.php
index a5b3cbfc218d..f412e84788cd 100644
--- a/app/Ninja/Datatables/ProductDatatable.php
+++ b/app/Ninja/Datatables/ProductDatatable.php
@@ -1,14 +1,22 @@
-invoice_number) {
diff --git a/app/Ninja/Datatables/TaxRateDatatable.php b/app/Ninja/Datatables/TaxRateDatatable.php
index 3e16aba9ee19..88fe2e0dd16c 100644
--- a/app/Ninja/Datatables/TaxRateDatatable.php
+++ b/app/Ninja/Datatables/TaxRateDatatable.php
@@ -1,11 +1,19 @@
-accountGateway = $accountGateway;
$this->invitation = $invitation;
@@ -54,6 +91,9 @@ class BasePaymentDriver
}
}
+ /**
+ * @return array
+ */
public function gatewayTypes()
{
return [
@@ -66,44 +106,74 @@ class BasePaymentDriver
return in_array($type, $this->gatewayTypes());
}
- // when set to true we won't pass the card details with the form
+ /**
+ * When set to true we won't pass the card details with the form
+ *
+ * @return bool
+ */
public function tokenize()
{
return false;
}
- // set payment method as pending until confirmed
+ /**
+ * Set payment method as pending until confirmed
+ *
+ * @return bool
+ */
public function isTwoStep()
{
return false;
}
+ /**
+ * @return string
+ */
public function providerName()
{
return strtolower($this->accountGateway->gateway->provider);
}
+ /**
+ * @return mixed
+ */
protected function invoice()
{
return $this->invitation->invoice;
}
+ /**
+ * @return mixed
+ */
protected function contact()
{
return $this->invitation->contact;
}
+ /**
+ * @return mixed
+ */
protected function client()
{
return $this->invoice()->client;
}
+ /**
+ * @return mixed
+ */
protected function account()
{
return $this->client()->account;
}
- public function startPurchase($input = false, $sourceId = false)
+ /**
+ * @param array $input
+ * @param bool $sourceId
+ *
+ * @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\View\View
+ * @throws Exception
+ */
+ public function startPurchase(array $input = false, $sourceId = false)
{
$this->input = $input;
$this->sourceId = $sourceId;
@@ -150,7 +220,11 @@ class BasePaymentDriver
return view($this->paymentView(), $data);
}
- // check if a custom view exists for this provider
+ /**
+ * Check if a custom view exists for this provider
+ *
+ * @return mixed
+ */
protected function paymentView()
{
$file = sprintf('%s/views/payments/%s/%s.blade.php', resource_path(), $this->providerName(), $this->gatewayType);
@@ -162,7 +236,11 @@ class BasePaymentDriver
}
}
- // check if a custom partial exists for this provider
+ /**
+ * Check if a custom partial exists for this provider
+ *
+ * @return bool
+ */
public function partialView()
{
$file = sprintf('%s/views/payments/%s/partial.blade.php', resource_path(), $this->providerName());
@@ -174,6 +252,9 @@ class BasePaymentDriver
}
}
+ /**
+ * @return array
+ */
public function rules()
{
$rules = [];
@@ -209,6 +290,9 @@ class BasePaymentDriver
return $rules;
}
+ /**
+ * @return mixed
+ */
protected function gateway()
{
if ($this->gateway) {
@@ -221,7 +305,14 @@ class BasePaymentDriver
return $this->gateway;
}
- public function completeOnsitePurchase($input = false, $paymentMethod = false)
+ /**
+ * @param bool $input
+ * @param PaymentMethod $paymentMethod
+ *
+ * @return Payment|mixed|void
+ * @throws Exception
+ */
+ public function completeOnsitePurchase($input = false, PaymentMethod $paymentMethod = false)
{
$this->input = count($input) ? $input : false;
$gateway = $this->gateway();
@@ -315,7 +406,12 @@ class BasePaymentDriver
$client->save();
}
- protected function paymentDetails($paymentMethod = false)
+ /**
+ * @param PaymentMethod $paymentMethod
+ *
+ * @return array
+ */
+ protected function paymentDetails(PaymentMethod $paymentMethod = false)
{
$invoice = $this->invoice();
$completeUrl = url('complete/' . $this->invitation->invitation_key . '/' . $this->gatewayType);
@@ -345,9 +441,13 @@ class BasePaymentDriver
return $data;
}
- private function paymentDetailsFromInput($input)
+ /**
+ * @param array $input
+ *
+ * @return array
+ */
+ private function paymentDetailsFromInput(array $input)
{
- $invoice = $this->invoice();
$client = $this->client();
$data = [
@@ -388,9 +488,11 @@ class BasePaymentDriver
return $data;
}
+ /**
+ * @return array
+ */
public function paymentDetailsFromClient()
{
- $invoice = $this->invoice();
$client = $this->client();
$contact = $this->invitation->contact ?: $client->contacts()->first();
@@ -416,6 +518,9 @@ class BasePaymentDriver
];
}
+ /**
+ * @return bool
+ */
protected function shouldCreateToken()
{
if ($this->isGatewayType(GATEWAY_TYPE_BANK_TRANSFER)) {
@@ -433,19 +538,11 @@ class BasePaymentDriver
return boolval(array_get($this->input, 'token_billing'));
}
- /*
- protected function tokenDetails()
- {
- $details = [];
-
- if ($customer = $this->customer()) {
- $details['customerReference'] = $customer->token;
- }
-
- return $details;
- }
- */
-
+ /**
+ * @param bool $clientId
+ *
+ * @return null
+ */
public function customer($clientId = false)
{
if ($this->customer) {
@@ -467,27 +564,51 @@ class BasePaymentDriver
return $this->customer;
}
+ /**
+ * @param $customer
+ *
+ * @return bool
+ */
protected function checkCustomerExists($customer)
{
return true;
}
+ /**
+ * @param $client
+ * @param $publicId
+ * @param $amount1
+ * @param $amount2
+ *
+ * @throws Exception
+ */
public function verifyBankAccount($client, $publicId, $amount1, $amount2)
{
throw new Exception('verifyBankAccount not implemented');
}
- public function removePaymentMethod($paymentMethod)
+ /**
+ * @param PaymentMethod $paymentMethod
+ * @throws Exception
+ */
+ public function removePaymentMethod(PaymentMethod $paymentMethod)
{
$paymentMethod->delete();
}
- // Some gateways (ie, Checkout.com and Braintree) require generating a token before paying for the invoice
+ /**
+ * Some gateways (ie, Checkout.com and Braintree) require generating a token before paying for the invoice
+ *
+ * @return null
+ */
public function createTransactionToken()
{
return null;
}
+ /**
+ * @return PaymentMethod
+ */
public function createToken()
{
$account = $this->account();
@@ -502,17 +623,6 @@ class BasePaymentDriver
$customer->save();
}
- /*
- // archive the old payment method
- $paymentMethod = PaymentMethod::clientId($this->client()->id)
- ->isBankAccount($this->isGatewayType(GATEWAY_TYPE_BANK_TRANSFER))
- ->first();
-
- if ($paymentMethod) {
- $paymentMethod->delete();
- }
- */
-
$paymentMethod = $this->createPaymentMethod($customer);
if ($paymentMethod && ! $customer->default_payment_method_id) {
@@ -523,13 +633,24 @@ class BasePaymentDriver
return $paymentMethod;
}
+ /**
+ * @param $customer
+ *
+ * @return mixed
+ */
protected function creatingCustomer($customer)
{
return $customer;
}
+ /**
+ * @param $customer
+ *
+ * @return PaymentMethod
+ */
public function createPaymentMethod($customer)
{
+ /** @var PaymentMethod $paymentMethod */
$paymentMethod = PaymentMethod::createNew($this->invitation);
$paymentMethod->contact_id = $this->contact()->id;
$paymentMethod->ip = Request::ip();
@@ -544,7 +665,12 @@ class BasePaymentDriver
return $paymentMethod;
}
- protected function creatingPaymentMethod($paymentMethod)
+ /**
+ * @param PaymentMethod $paymentMethod
+ *
+ * @return PaymentMethod
+ */
+ protected function creatingPaymentMethod(PaymentMethod $paymentMethod)
{
return $paymentMethod;
}
@@ -554,7 +680,13 @@ class BasePaymentDriver
}
- public function createPayment($ref = false, $paymentMethod = null)
+ /**
+ * @param bool $ref
+ * @param PaymentMethod|null $paymentMethod
+ *
+ * @return Payment|mixed
+ */
+ public function createPayment($ref = false, PaymentMethod $paymentMethod = null)
{
$invitation = $this->invitation;
$invoice = $this->invoice();
@@ -641,12 +773,24 @@ class BasePaymentDriver
return $payment;
}
- protected function creatingPayment($payment, $paymentMethod)
+ /**
+ * @param Payment $payment
+ * @param $paymentMethod
+ *
+ * @return Payment
+ */
+ protected function creatingPayment(Payment $payment, $paymentMethod)
{
return $payment;
}
- public function refundPayment($payment, $amount = 0)
+ /**
+ * @param Payment $payment
+ * @param int $amount
+ *
+ * @return bool
+ */
+ public function refundPayment(Payment $payment, $amount = 0)
{
if ($amount) {
$amount = min($amount, $payment->getCompletedAmount());
@@ -678,7 +822,13 @@ class BasePaymentDriver
return false;
}
- protected function refundDetails($payment, $amount)
+ /**
+ * @param Payment $payment
+ * @param $amount
+ *
+ * @return array
+ */
+ protected function refundDetails(Payment $payment, $amount)
{
return [
'amount' => $amount,
@@ -686,7 +836,14 @@ class BasePaymentDriver
];
}
- protected function attemptVoidPayment($response, $payment, $amount)
+ /**
+ * @param $response
+ * @param Payment $payment
+ * @param $amount
+ *
+ * @return bool
+ */
+ protected function attemptVoidPayment($response, Payment $payment, $amount)
{
// Partial refund not allowed for unsettled transactions
return $amount == $payment->amount;
@@ -697,6 +854,12 @@ class BasePaymentDriver
return $payment;
}
+ /**
+ * @param $input
+ *
+ * @return bool|mixed
+ * @throws Exception
+ */
public function completeOffsitePurchase($input)
{
$this->input = $input;
@@ -730,6 +893,9 @@ class BasePaymentDriver
return $this->createPayment($ref);
}
+ /**
+ * @return array
+ */
public function tokenLinks()
{
if ( ! $this->customer()) {
@@ -767,6 +933,9 @@ class BasePaymentDriver
return $links;
}
+ /**
+ * @return array
+ */
public function paymentLinks()
{
$links = [];
@@ -785,6 +954,11 @@ class BasePaymentDriver
return $links;
}
+ /**
+ * @param $gatewayType
+ *
+ * @return string
+ */
protected function paymentUrl($gatewayType)
{
$account = $this->account();
@@ -802,6 +976,11 @@ class BasePaymentDriver
return $url;
}
+ /**
+ * @param $cardName
+ *
+ * @return mixed
+ */
protected function parseCardType($cardName) {
$cardTypes = [
'visa' => PAYMENT_TYPE_VISA,
@@ -834,6 +1013,11 @@ class BasePaymentDriver
}
}
+ /**
+ * @param $input
+ *
+ * @throws Exception
+ */
public function handleWebHook($input)
{
throw new Exception('Unsupported gateway');
diff --git a/app/Ninja/PaymentDrivers/BitPayPaymentDriver.php b/app/Ninja/PaymentDrivers/BitPayPaymentDriver.php
index df1821acdb96..97fbde394869 100644
--- a/app/Ninja/PaymentDrivers/BitPayPaymentDriver.php
+++ b/app/Ninja/PaymentDrivers/BitPayPaymentDriver.php
@@ -1,12 +1,19 @@
-isGatewayType(GATEWAY_TYPE_PAYPAL)) {
- /*
- if ( ! $sourceId || empty($input['device_data'])) {
- throw new Exception();
- }
-
- Session::put($this->invitation->id . 'device_data', $input['device_data']);
- */
-
$data['details'] = ! empty($input['device_data']) ? json_decode($input['device_data']) : false;
}
return $data;
}
+ /**
+ * @param $customer
+ *
+ * @return bool
+ */
protected function checkCustomerExists($customer)
{
if ( ! parent::checkCustomerExists($customer)) {
@@ -60,7 +82,12 @@ class BraintreePaymentDriver extends BasePaymentDriver
return ($customer instanceof Customer);
}
- protected function paymentDetails($paymentMethod = false)
+ /**
+ * @param PaymentMethod $paymentMethod
+ *
+ * @return array
+ */
+ protected function paymentDetails(PaymentMethod $paymentMethod = false)
{
$data = parent::paymentDetails($paymentMethod);
@@ -81,6 +108,9 @@ class BraintreePaymentDriver extends BasePaymentDriver
return $data;
}
+ /**
+ * @return PaymentMethod|bool
+ */
public function createToken()
{
if ($customer = $this->customer()) {
@@ -113,6 +143,9 @@ class BraintreePaymentDriver extends BasePaymentDriver
return parent::createToken();
}
+ /**
+ * @return array
+ */
private function customerData()
{
return [
@@ -125,6 +158,11 @@ class BraintreePaymentDriver extends BasePaymentDriver
];
}
+ /**
+ * @param $customer
+ *
+ * @return mixed
+ */
public function creatingCustomer($customer)
{
$customer->token = $this->tokenResponse->customerId;
@@ -132,7 +170,12 @@ class BraintreePaymentDriver extends BasePaymentDriver
return $customer;
}
- protected function creatingPaymentMethod($paymentMethod)
+ /**
+ * @param PaymentMethod $paymentMethod
+ *
+ * @return PaymentMethod|null
+ */
+ protected function creatingPaymentMethod(PaymentMethod $paymentMethod)
{
$response = $this->tokenResponse;
@@ -152,7 +195,13 @@ class BraintreePaymentDriver extends BasePaymentDriver
return $paymentMethod;
}
- public function removePaymentMethod($paymentMethod)
+ /**
+ * @param PaymentMethod $paymentMethod
+ *
+ * @return bool
+ * @throws Exception
+ */
+ public function removePaymentMethod(PaymentMethod $paymentMethod)
{
parent::removePaymentMethod($paymentMethod);
@@ -167,7 +216,14 @@ class BraintreePaymentDriver extends BasePaymentDriver
}
}
- protected function attemptVoidPayment($response, $payment, $amount)
+ /**
+ * @param $response
+ * @param Payment $payment
+ * @param $amount
+ *
+ * @return bool
+ */
+ protected function attemptVoidPayment($response, Payment $payment, $amount)
{
if ( ! parent::attemptVoidPayment($response, $payment, $amount)) {
return false;
@@ -185,6 +241,9 @@ class BraintreePaymentDriver extends BasePaymentDriver
return false;
}
+ /**
+ * @return mixed
+ */
public function createTransactionToken()
{
return $this->gateway()
diff --git a/app/Ninja/PaymentDrivers/CheckoutComPaymentDriver.php b/app/Ninja/PaymentDrivers/CheckoutComPaymentDriver.php
index ede0b678234b..b292507d7fa9 100644
--- a/app/Ninja/PaymentDrivers/CheckoutComPaymentDriver.php
+++ b/app/Ninja/PaymentDrivers/CheckoutComPaymentDriver.php
@@ -1,7 +1,17 @@
-gateway()->purchase([
@@ -21,7 +31,12 @@ class CheckoutComPaymentDriver extends BasePaymentDriver
return false;
}
- protected function paymentDetails($paymentMethod = false)
+ /**
+ * @param PaymentMethod $paymentMethod
+ *
+ * @return array
+ */
+ protected function paymentDetails(PaymentMethod $paymentMethod = false)
{
$data = parent::paymentDetails();
diff --git a/app/Ninja/PaymentDrivers/CybersourcePaymentDriver.php b/app/Ninja/PaymentDrivers/CybersourcePaymentDriver.php
index 29299eb94fb2..64e49ae74c9b 100644
--- a/app/Ninja/PaymentDrivers/CybersourcePaymentDriver.php
+++ b/app/Ninja/PaymentDrivers/CybersourcePaymentDriver.php
@@ -1,10 +1,24 @@
-createPayment($input['bill_trans_ref_no']);
diff --git a/app/Ninja/PaymentDrivers/DwollaPaymentDriver.php b/app/Ninja/PaymentDrivers/DwollaPaymentDriver.php
index 26f5626c8c3d..d372d159cccc 100644
--- a/app/Ninja/PaymentDrivers/DwollaPaymentDriver.php
+++ b/app/Ninja/PaymentDrivers/DwollaPaymentDriver.php
@@ -1,12 +1,23 @@
-paymentDetails();
diff --git a/app/Ninja/PaymentDrivers/PayFastPaymentDriver.php b/app/Ninja/PaymentDrivers/PayFastPaymentDriver.php
index 79b49b23499e..08c54432a170 100644
--- a/app/Ninja/PaymentDrivers/PayFastPaymentDriver.php
+++ b/app/Ninja/PaymentDrivers/PayFastPaymentDriver.php
@@ -1,9 +1,17 @@
-isGateway(GATEWAY_PAYFAST) && Request::has('pt')) {
diff --git a/app/Ninja/PaymentDrivers/PayPalExpressPaymentDriver.php b/app/Ninja/PaymentDrivers/PayPalExpressPaymentDriver.php
index ad11a8c1287b..9ac25cf2142a 100644
--- a/app/Ninja/PaymentDrivers/PayPalExpressPaymentDriver.php
+++ b/app/Ninja/PaymentDrivers/PayPalExpressPaymentDriver.php
@@ -1,8 +1,18 @@
-payer_id = $this->input['PayerID'];
diff --git a/app/Ninja/PaymentDrivers/PayPalProPaymentDriver.php b/app/Ninja/PaymentDrivers/PayPalProPaymentDriver.php
index 0c8344cb5705..840ac556f9e9 100644
--- a/app/Ninja/PaymentDrivers/PayPalProPaymentDriver.php
+++ b/app/Ninja/PaymentDrivers/PayPalProPaymentDriver.php
@@ -1,7 +1,17 @@
-accountGateway->getPublishableStripeKey();
}
+ /**
+ * @return array
+ */
public function rules()
{
$rules = parent::rules();
@@ -39,6 +56,11 @@ class StripePaymentDriver extends BasePaymentDriver
return $rules;
}
+ /**
+ * @param $customer
+ *
+ * @return bool
+ */
protected function checkCustomerExists($customer)
{
$response = $this->gateway()
@@ -63,12 +85,20 @@ class StripePaymentDriver extends BasePaymentDriver
return true;
}
+ /**
+ * @return bool
+ */
public function isTwoStep()
{
return $this->isGatewayType(GATEWAY_TYPE_BANK_TRANSFER) && empty($this->input['plaidPublicToken']);
}
- protected function paymentDetails($paymentMethod = false)
+ /**
+ * @param PaymentMethod $paymentMethod
+ *
+ * @return array
+ */
+ protected function paymentDetails(PaymentMethod $paymentMethod = false)
{
$data = parent::paymentDetails($paymentMethod);
@@ -93,6 +123,10 @@ class StripePaymentDriver extends BasePaymentDriver
return $data;
}
+ /**
+ * @return PaymentMethod
+ * @throws Exception
+ */
public function createToken()
{
$invoice = $this->invitation->invoice;
@@ -126,6 +160,11 @@ class StripePaymentDriver extends BasePaymentDriver
}
}
+ /**
+ * @param $customer
+ *
+ * @return mixed
+ */
public function creatingCustomer($customer)
{
$customer->token = $this->tokenResponse['id'];
@@ -133,7 +172,12 @@ class StripePaymentDriver extends BasePaymentDriver
return $customer;
}
- protected function creatingPaymentMethod($paymentMethod)
+ /**
+ * @param PaymentMethod $paymentMethod
+ *
+ * @return PaymentMethod|bool
+ */
+ protected function creatingPaymentMethod(PaymentMethod $paymentMethod)
{
$data = $this->tokenResponse;
@@ -175,16 +219,30 @@ class StripePaymentDriver extends BasePaymentDriver
return $paymentMethod;
}
- protected function creatingPayment($payment, $paymentMethod)
+ /**
+ * @param Payment $payment
+ * @param PaymentMethod $paymentMethod
+ *
+ * @return Payment
+ */
+ protected function creatingPayment(Payment $payment, PaymentMethod $paymentMethod)
{
if ($this->isGatewayType(GATEWAY_TYPE_BANK_TRANSFER, $paymentMethod)) {
- $payment->payment_status_id = $this->purchaseResponse['status'] == 'succeeded' ? PAYMENT_STATUS_COMPLETED : PAYMENT_STATUS_PENDING;
+ $payment->payment_status_id = $this->purchaseResponse['status'] == 'succeeded'
+ ? PAYMENT_STATUS_COMPLETED
+ : PAYMENT_STATUS_PENDING;
}
return $payment;
}
- public function removePaymentMethod($paymentMethod)
+ /**
+ * @param PaymentMethod $paymentMethod
+ *
+ * @return bool
+ * @throws Exception
+ */
+ public function removePaymentMethod(PaymentMethod $paymentMethod)
{
parent::removePaymentMethod($paymentMethod);
@@ -204,6 +262,13 @@ class StripePaymentDriver extends BasePaymentDriver
}
}
+ /**
+ * @param $publicToken
+ * @param $accountId
+ *
+ * @return mixed
+ * @throws Exception
+ */
private function getPlaidToken($publicToken, $accountId)
{
$clientId = $this->accountGateway->getPlaidClientId();
@@ -246,6 +311,14 @@ class StripePaymentDriver extends BasePaymentDriver
}
}
+ /**
+ * @param $client
+ * @param $publicId
+ * @param $amount1
+ * @param $amount2
+ *
+ * @return bool|mixed|string
+ */
public function verifyBankAccount($client, $publicId, $amount1, $amount2)
{
$customer = $this->customer($client->id);
@@ -276,6 +349,13 @@ class StripePaymentDriver extends BasePaymentDriver
return true;
}
+ /**
+ * @param $method
+ * @param $url
+ * @param null $body
+ *
+ * @return mixed|string
+ */
public function makeStripeCall($method, $url, $body = null)
{
$apiKey = $this->accountGateway->getConfig()->apiKey;
@@ -312,6 +392,12 @@ class StripePaymentDriver extends BasePaymentDriver
}
}
+ /**
+ * @param $input
+ *
+ * @return array|string
+ * @throws Exception
+ */
public function handleWebHook($input)
{
$eventId = array_get($input, 'id');
diff --git a/app/Ninja/PaymentDrivers/TwoCheckoutPaymentDriver.php b/app/Ninja/PaymentDrivers/TwoCheckoutPaymentDriver.php
index 005611d4a034..f94df7f04493 100644
--- a/app/Ninja/PaymentDrivers/TwoCheckoutPaymentDriver.php
+++ b/app/Ninja/PaymentDrivers/TwoCheckoutPaymentDriver.php
@@ -1,11 +1,24 @@
-createPayment($input['order_number']);
}
diff --git a/app/Ninja/PaymentDrivers/WePayPaymentDriver.php b/app/Ninja/PaymentDrivers/WePayPaymentDriver.php
index 74f2f05d3bf0..d92014642b19 100644
--- a/app/Ninja/PaymentDrivers/WePayPaymentDriver.php
+++ b/app/Ninja/PaymentDrivers/WePayPaymentDriver.php
@@ -1,12 +1,21 @@
-accountGateway);
@@ -77,22 +105,6 @@ class WePayPaymentDriver extends BasePaymentDriver
'payment_bank_id' => $token,
]);
} else {
- // Authorize credit card
- $tokenResponse = $wepay->request('credit_card/authorize', [
- 'client_id' => WEPAY_CLIENT_ID,
- 'client_secret' => WEPAY_CLIENT_SECRET,
- 'credit_card_id' => $token,
- ]);
-
- // Update the callback uri and get the card details
- $tokenResponse = $wepay->request('credit_card/modify', [
- 'client_id' => WEPAY_CLIENT_ID,
- 'client_secret' => WEPAY_CLIENT_SECRET,
- 'credit_card_id' => $token,
- 'auto_update' => WEPAY_AUTO_UPDATE,
- 'callback_uri' => $this->accountGateway->getWebhookUrl(),
- ]);
-
$this->tokenResponse = $wepay->request('credit_card', [
'client_id' => WEPAY_CLIENT_ID,
'client_secret' => WEPAY_CLIENT_SECRET,
@@ -103,23 +115,12 @@ class WePayPaymentDriver extends BasePaymentDriver
return parent::createToken();
}
- /*
- public function creatingCustomer($customer)
- {
- if ($gatewayResponse instanceof \Omnipay\WePay\Message\CustomCheckoutResponse) {
- $wepay = \Utils::setupWePay($accountGateway);
- $paymentMethodType = $gatewayResponse->getData()['payment_method']['type'];
-
- $gatewayResponse = $wepay->request($paymentMethodType, array(
- 'client_id' => WEPAY_CLIENT_ID,
- 'client_secret' => WEPAY_CLIENT_SECRET,
- $paymentMethodType.'_id' => $gatewayResponse->getData()['payment_method'][$paymentMethodType]['id'],
- ));
- }
- }
- */
-
- protected function creatingPaymentMethod($paymentMethod)
+ /**
+ * @param PaymentMethod $paymentMethod
+ *
+ * @return PaymentMethod
+ */
+ protected function creatingPaymentMethod(PaymentMethod $paymentMethod)
{
$source = $this->tokenResponse;
@@ -148,7 +149,13 @@ class WePayPaymentDriver extends BasePaymentDriver
return $paymentMethod;
}
- public function removePaymentMethod($paymentMethod)
+ /**
+ * @param PaymentMethod $paymentMethod
+ *
+ * @return bool
+ * @throws Exception
+ */
+ public function removePaymentMethod(PaymentMethod $paymentMethod)
{
parent::removePaymentMethod($paymentMethod);
@@ -166,7 +173,13 @@ class WePayPaymentDriver extends BasePaymentDriver
}
}
- protected function refundDetails($payment, $amount)
+ /**
+ * @param Payment $payment
+ * @param $amount
+ *
+ * @return array
+ */
+ protected function refundDetails(Payment $payment, $amount)
{
$data = parent::refundDetails($payment, $amount);
@@ -182,7 +195,7 @@ class WePayPaymentDriver extends BasePaymentDriver
return $data;
}
- protected function attemptVoidPayment($response, $payment, $amount)
+ protected function attemptVoidPayment($response, Payment $payment, $amount)
{
if ( ! parent::attemptVoidPayment($response, $payment, $amount)) {
return false;
@@ -224,8 +237,6 @@ class WePayPaymentDriver extends BasePaymentDriver
if ($source->state == 'deleted') {
$paymentMethod->delete();
- } else {
- //$this->paymentService->convertPaymentMethodFromWePay($source, null, $paymentMethod)->save();
}
return 'Processed successfully';
diff --git a/app/Ninja/Repositories/AccountGatewayRepository.php b/app/Ninja/Repositories/AccountGatewayRepository.php
index c59b0d77abab..91f7b5c0216a 100644
--- a/app/Ninja/Repositories/AccountGatewayRepository.php
+++ b/app/Ninja/Repositories/AccountGatewayRepository.php
@@ -1,14 +1,27 @@
-users as $user) {
if ($userAccount = self::findUserAccounts($user->id)) {
$userAccount->removeUserId($user->id);
@@ -681,7 +689,11 @@ class AccountRepository
return $code;
}
- public function createTokens($user, $name)
+ /**
+ * @param User $user
+ * @param $name
+ */
+ public function createTokens(User $user, $name)
{
$name = trim($name) ?: 'TOKEN';
$users = $this->findUsers($user);
@@ -698,7 +710,12 @@ class AccountRepository
}
}
- public function getUserAccountId($account)
+ /**
+ * @param Account $account
+ *
+ * @return bool|mixed
+ */
+ public function getUserAccountId(Account $account)
{
$user = $account->users()->first();
$userAccount = $this->findUserAccounts($user->id);
@@ -706,7 +723,11 @@ class AccountRepository
return $userAccount ? $userAccount->id : false;
}
- public function save($data, $account)
+ /**
+ * @param $data
+ * @param Account $account
+ */
+ public function save($data, Account $account)
{
$account->fill($data);
$account->save();
diff --git a/app/Ninja/Repositories/ActivityRepository.php b/app/Ninja/Repositories/ActivityRepository.php
index 7ea2616b62f2..41606547406b 100644
--- a/app/Ninja/Repositories/ActivityRepository.php
+++ b/app/Ninja/Repositories/ActivityRepository.php
@@ -1,4 +1,6 @@
-get();
}
+ /**
+ * @param null $filter
+ * @param bool $userId
+ *
+ * @return $this
+ */
public function find($filter = null, $userId = false)
{
$query = DB::table('clients')
@@ -68,7 +84,13 @@ class ClientRepository extends BaseRepository
return $query;
}
- public function save($data, $client = null)
+ /**
+ * @param $data
+ * @param Client|null $client
+ *
+ * @return Client|mixed
+ */
+ public function save($data, Client $client = null)
{
$publicId = isset($data['public_id']) ? $data['public_id'] : false;
@@ -95,12 +117,6 @@ class ClientRepository extends BaseRepository
$client->fill($data);
$client->save();
- /*
- if ( ! isset($data['contact']) && ! isset($data['contacts'])) {
- return $client;
- }
- */
-
$first = true;
$contacts = isset($data['contact']) ? [$data['contact']] : $data['contacts'];
$contactIds = [];
diff --git a/app/Ninja/Repositories/ContactRepository.php b/app/Ninja/Repositories/ContactRepository.php
index 6f157c1c40b8..2b26485cbd3f 100644
--- a/app/Ninja/Repositories/ContactRepository.php
+++ b/app/Ninja/Repositories/ContactRepository.php
@@ -1,9 +1,19 @@
-get();
}
+ /**
+ * @return $this
+ */
public function find()
{
$accountid = \Auth::user()->account_id;
@@ -50,6 +63,12 @@ class DocumentRepository extends BaseRepository
return $query;
}
+ /**
+ * @param $data
+ * @param null $doc_array
+ *
+ * @return mixed
+ */
public function upload($data, &$doc_array=null)
{
$uploaded = $data['file'];
@@ -177,6 +196,14 @@ class DocumentRepository extends BaseRepository
return $document;
}
+ /**
+ * @param $contactId
+ * @param $entityType
+ * @param $search
+ *
+ * @return \Illuminate\Http\JsonResponse
+ * @throws \Exception
+ */
public function getClientDatatable($contactId, $entityType, $search)
{
diff --git a/app/Ninja/Repositories/ExpenseCategoryRepository.php b/app/Ninja/Repositories/ExpenseCategoryRepository.php
index 90edbd2d7412..c2ceebdab74a 100644
--- a/app/Ninja/Repositories/ExpenseCategoryRepository.php
+++ b/app/Ninja/Repositories/ExpenseCategoryRepository.php
@@ -1,17 +1,26 @@
-documentRepo = $documentRepo;
}
+ /**
+ * @return mixed
+ */
public function all()
{
return Expense::scope()
@@ -31,6 +49,11 @@ class ExpenseRepository extends BaseRepository
->get();
}
+ /**
+ * @param $vendorPublicId
+ *
+ * @return mixed
+ */
public function findVendor($vendorPublicId)
{
$vendorId = Vendor::getPrivateId($vendorPublicId);
@@ -40,6 +63,11 @@ class ExpenseRepository extends BaseRepository
return $query;
}
+ /**
+ * @param null $filter
+ *
+ * @return $this
+ */
public function find($filter = null)
{
$accountid = \Auth::user()->account_id;
@@ -110,7 +138,13 @@ class ExpenseRepository extends BaseRepository
return $query;
}
- public function save($input, $expense = null)
+ /**
+ * @param array $input
+ * @param Expense|null $expense
+ *
+ * @return Expense|mixed
+ */
+ public function save(array $input, Expense $expense = null)
{
$publicId = isset($input['public_id']) ? $input['public_id'] : false;
@@ -174,6 +208,12 @@ class ExpenseRepository extends BaseRepository
return $expense;
}
+ /**
+ * @param $ids
+ * @param $action
+ *
+ * @return int
+ */
public function bulk($ids, $action)
{
$expenses = Expense::withTrashed()->scope($ids)->get();
@@ -194,6 +234,6 @@ class ExpenseRepository extends BaseRepository
}
}
- return count($tasks);
+ return $expenses->count();
}
}
diff --git a/app/Ninja/Repositories/InvoiceRepository.php b/app/Ninja/Repositories/InvoiceRepository.php
index 0249f764b625..bfc3e270c48e 100644
--- a/app/Ninja/Repositories/InvoiceRepository.php
+++ b/app/Ninja/Repositories/InvoiceRepository.php
@@ -748,6 +748,7 @@ class InvoiceRepository extends BaseRepository
/**
* @param Invoice $recurInvoice
+ *
* @return mixed
*/
public function createRecurringInvoice(Invoice $recurInvoice)
@@ -839,6 +840,7 @@ class InvoiceRepository extends BaseRepository
/**
* @param Account $account
+ *
* @return mixed
*/
public function findNeedingReminding(Account $account)
diff --git a/app/Ninja/Repositories/NinjaRepository.php b/app/Ninja/Repositories/NinjaRepository.php
index d1dc7abede6e..e16e20a80c16 100644
--- a/app/Ninja/Repositories/NinjaRepository.php
+++ b/app/Ninja/Repositories/NinjaRepository.php
@@ -1,10 +1,20 @@
-first();
@@ -12,6 +22,7 @@ class NinjaRepository
return;
}
+ /** @var Company $company */
$company = $account->company;
$company->plan = !empty($data['plan']) && $data['plan'] != PLAN_FREE?$data['plan']:null;
$company->plan_term = !empty($data['plan_term'])?$data['plan_term']:null;
diff --git a/app/Ninja/Repositories/PaymentRepository.php b/app/Ninja/Repositories/PaymentRepository.php
index f75f9a186755..582085df17c4 100644
--- a/app/Ninja/Repositories/PaymentRepository.php
+++ b/app/Ninja/Repositories/PaymentRepository.php
@@ -1,18 +1,31 @@
-invoice->is_deleted) {
@@ -210,6 +240,11 @@ class PaymentRepository extends BaseRepository
parent::delete($payment);
}
+ /**
+ * @param $payment
+ *
+ * @return bool
+ */
public function restore($payment)
{
if ($payment->invoice->is_deleted) {
diff --git a/app/Ninja/Repositories/PaymentTermRepository.php b/app/Ninja/Repositories/PaymentTermRepository.php
index bde31c20a81d..3eea4b3b771f 100644
--- a/app/Ninja/Repositories/PaymentTermRepository.php
+++ b/app/Ninja/Repositories/PaymentTermRepository.php
@@ -1,18 +1,27 @@
-where('payment_terms.account_id', '=', $accountId)
->where('payment_terms.deleted_at', '=', null)
->select('payment_terms.public_id', 'payment_terms.name', 'payment_terms.num_days', 'payment_terms.deleted_at');
}
diff --git a/app/Ninja/Repositories/ProductRepository.php b/app/Ninja/Repositories/ProductRepository.php
index 61cee1eec7d7..3f2053f9603b 100644
--- a/app/Ninja/Repositories/ProductRepository.php
+++ b/app/Ninja/Repositories/ProductRepository.php
@@ -1,15 +1,26 @@
-get();
}
+ /**
+ * @param $accountId
+ *
+ * @return $this
+ */
public function find($accountId)
{
return DB::table('products')
@@ -37,7 +53,13 @@ class ProductRepository extends BaseRepository
);
}
- public function save($data, $product = null)
+ /**
+ * @param array $data
+ * @param Product|null $product
+ *
+ * @return Product|mixed
+ */
+ public function save(array $data, Product $product = null)
{
$publicId = isset($data['public_id']) ? $data['public_id'] : false;
diff --git a/app/Ninja/Repositories/ReferralRepository.php b/app/Ninja/Repositories/ReferralRepository.php
index ca12f960fd35..813059840fdf 100644
--- a/app/Ninja/Repositories/ReferralRepository.php
+++ b/app/Ninja/Repositories/ReferralRepository.php
@@ -1,9 +1,19 @@
-get();
diff --git a/app/Ninja/Repositories/TaskRepository.php b/app/Ninja/Repositories/TaskRepository.php
index db78cba3bf38..4ac8bad94d55 100644
--- a/app/Ninja/Repositories/TaskRepository.php
+++ b/app/Ninja/Repositories/TaskRepository.php
@@ -1,12 +1,23 @@
-scope($ids)->get();
diff --git a/app/Ninja/Repositories/TaxRateRepository.php b/app/Ninja/Repositories/TaxRateRepository.php
index f737256e85bf..b28a66d35dc3 100644
--- a/app/Ninja/Repositories/TaxRateRepository.php
+++ b/app/Ninja/Repositories/TaxRateRepository.php
@@ -1,16 +1,28 @@
-select('tax_rates.public_id', 'tax_rates.name', 'tax_rates.rate', 'tax_rates.deleted_at');
}
- public function save($data, $taxRate = null)
+ /**
+ * @param array $data
+ * @param TaxRate|null $taxRate
+ *
+ * @return TaxRate|mixed
+ */
+ public function save(array $data, TaxRate $taxRate = null)
{
if ($taxRate) {
// do nothing
@@ -35,41 +53,4 @@ class TaxRateRepository extends BaseRepository
return $taxRate;
}
-
- /*
- public function save($taxRates)
- {
- $taxRateIds = [];
-
- foreach ($taxRates as $record) {
- if (!isset($record->rate) || (isset($record->is_deleted) && $record->is_deleted)) {
- continue;
- }
-
- if (!isset($record->name) || !trim($record->name)) {
- continue;
- }
-
- if ($record->public_id) {
- $taxRate = TaxRate::scope($record->public_id)->firstOrFail();
- } else {
- $taxRate = TaxRate::createNew();
- }
-
- $taxRate->rate = Utils::parseFloat($record->rate);
- $taxRate->name = trim($record->name);
- $taxRate->save();
-
- $taxRateIds[] = $taxRate->public_id;
- }
-
- $taxRates = TaxRate::scope()->get();
-
- foreach ($taxRates as $taxRate) {
- if (!in_array($taxRate->public_id, $taxRateIds)) {
- $taxRate->delete();
- }
- }
- }
- */
}
diff --git a/app/Ninja/Repositories/TokenRepository.php b/app/Ninja/Repositories/TokenRepository.php
index 16fa02f800f8..083deef2a015 100644
--- a/app/Ninja/Repositories/TokenRepository.php
+++ b/app/Ninja/Repositories/TokenRepository.php
@@ -1,16 +1,29 @@
-fill($data);
$user->save();
diff --git a/app/Ninja/Repositories/VendorContactRepository.php b/app/Ninja/Repositories/VendorContactRepository.php
index a348f05977f3..6d6d9100eeac 100644
--- a/app/Ninja/Repositories/VendorContactRepository.php
+++ b/app/Ninja/Repositories/VendorContactRepository.php
@@ -1,18 +1,25 @@
-send_invoice = true;
$contact->vendor_id = $data['vendor_id'];
$contact->is_primary = VendorContact::scope()->where('vendor_id', '=', $contact->vendor_id)->count() == 0;
} else {
diff --git a/app/Ninja/Repositories/VendorRepository.php b/app/Ninja/Repositories/VendorRepository.php
index 1f848e0a0b9a..5668b48de7ad 100644
--- a/app/Ninja/Repositories/VendorRepository.php
+++ b/app/Ninja/Repositories/VendorRepository.php
@@ -1,16 +1,26 @@
-get();
}
+ /**
+ * @param null $filter
+ *
+ * @return $this
+ */
public function find($filter = null)
{
$query = DB::table('vendors')
@@ -60,7 +75,13 @@ class VendorRepository extends BaseRepository
return $query;
}
- public function save($data, $vendor = null)
+ /**
+ * @param array $data
+ * @param Vendor|null $vendor
+ *
+ * @return Vendor|mixed
+ */
+ public function save(array $data, Vendor $vendor = null)
{
$publicId = isset($data['public_id']) ? $data['public_id'] : false;
@@ -75,15 +96,7 @@ class VendorRepository extends BaseRepository
$vendor->fill($data);
$vendor->save();
-
- $first = true;
- $vendorcontacts = isset($data['vendor_contact']) ? [$data['vendor_contact']] : $data['vendor_contacts'];
-
- foreach ($vendorcontacts as $vendorcontact) {
- $vendorcontact = $vendor->addVendorContact($vendorcontact, $first);
- $first = false;
- }
-
+
return $vendor;
}
}
diff --git a/app/Policies/ClientPolicy.php b/app/Policies/ClientPolicy.php
index 4610c139fbfa..81e64a73e02a 100644
--- a/app/Policies/ClientPolicy.php
+++ b/app/Policies/ClientPolicy.php
@@ -2,4 +2,10 @@
namespace App\Policies;
-class ClientPolicy extends EntityPolicy {}
\ No newline at end of file
+/**
+ * Class ClientPolicy
+ */
+class ClientPolicy extends EntityPolicy
+{
+
+}
\ No newline at end of file
diff --git a/app/Policies/CreditPolicy.php b/app/Policies/CreditPolicy.php
index 539bc7e51889..c0d1ca2660ac 100644
--- a/app/Policies/CreditPolicy.php
+++ b/app/Policies/CreditPolicy.php
@@ -2,4 +2,10 @@
namespace App\Policies;
-class CreditPolicy extends EntityPolicy {}
\ No newline at end of file
+/**
+ * Class CreditPolicy
+ */
+class CreditPolicy extends EntityPolicy
+{
+
+}
\ No newline at end of file
diff --git a/app/Policies/DocumentPolicy.php b/app/Policies/DocumentPolicy.php
index 0af6e80a2af6..8ebadcb2e0c9 100644
--- a/app/Policies/DocumentPolicy.php
+++ b/app/Policies/DocumentPolicy.php
@@ -2,6 +2,7 @@
namespace App\Policies;
+use App\Models\Document;
use App\Models\User;
/**
@@ -11,6 +12,7 @@ class DocumentPolicy extends EntityPolicy
{
/**
* @param User $user
+ *
* @return bool
*/
public static function create(User $user)
@@ -20,10 +22,11 @@ class DocumentPolicy extends EntityPolicy
/**
* @param User $user
- * @param Document $document
+ * @param $item
+ *
* @return bool
*/
- public static function view(User $user, $document)
+ public static function view(User $user, $item)
{
if ($user->hasPermission('view_all')) {
return true;
diff --git a/app/Policies/ExpensePolicy.php b/app/Policies/ExpensePolicy.php
index d281d2f407c2..97dce5cad343 100644
--- a/app/Policies/ExpensePolicy.php
+++ b/app/Policies/ExpensePolicy.php
@@ -4,6 +4,9 @@ namespace App\Policies;
use App\Models\User;
+/**
+ * Class ExpensePolicy
+ */
class ExpensePolicy extends EntityPolicy
{
/**
diff --git a/app/Policies/InvoicePolicy.php b/app/Policies/InvoicePolicy.php
index aa72b4c0533c..5a7f7ebfc465 100644
--- a/app/Policies/InvoicePolicy.php
+++ b/app/Policies/InvoicePolicy.php
@@ -2,4 +2,10 @@
namespace App\Policies;
-class InvoicePolicy extends EntityPolicy {}
+/**
+ * Class InvoicePolicy
+ */
+class InvoicePolicy extends EntityPolicy
+{
+
+}
diff --git a/app/Policies/PaymentPolicy.php b/app/Policies/PaymentPolicy.php
index e9c3fc582a3f..eaf3c7d85877 100644
--- a/app/Policies/PaymentPolicy.php
+++ b/app/Policies/PaymentPolicy.php
@@ -2,4 +2,10 @@
namespace App\Policies;
-class PaymentPolicy extends EntityPolicy {}
\ No newline at end of file
+/**
+ * Class PaymentPolicy
+ */
+class PaymentPolicy extends EntityPolicy
+{
+
+}
\ No newline at end of file
diff --git a/app/Policies/TokenPolicy.php b/app/Policies/TokenPolicy.php
index 36e37e313a69..a26805d66865 100644
--- a/app/Policies/TokenPolicy.php
+++ b/app/Policies/TokenPolicy.php
@@ -2,12 +2,28 @@
namespace App\Policies;
+use App\Models\User;
+
+/**
+ * Class TokenPolicy
+ */
class TokenPolicy extends EntityPolicy {
- public static function edit($user, $item) {
+ /**
+ * @param User $user
+ * @param $item
+ *
+ * @return bool
+ */
+ public static function edit(User $user, $item) {
return $user->hasPermission('admin');
}
- public static function create($user) {
+ /**
+ * @param User $user
+ *
+ * @return bool
+ */
+ public static function create(User $user) {
return $user->hasPermission('admin');
}
}
\ No newline at end of file
diff --git a/app/Policies/VendorPolicy.php b/app/Policies/VendorPolicy.php
index 8c388193251d..9e2d4a8a6403 100644
--- a/app/Policies/VendorPolicy.php
+++ b/app/Policies/VendorPolicy.php
@@ -4,10 +4,14 @@ namespace App\Policies;
use App\Models\User;
+/**
+ * Class VendorPolicy
+ */
class VendorPolicy extends EntityPolicy
{
/**
* @param User $user
+ *
* @return bool
*/
public static function create(User $user) {