Rollback for new payment flow

This commit is contained in:
David Bomba 2024-08-22 16:45:06 +10:00
parent af92ce8d37
commit 036aca49a4
395 changed files with 2920 additions and 4709 deletions

View File

@ -1169,7 +1169,7 @@ class CheckData extends Command
->whereNull('exchange_rate') ->whereNull('exchange_rate')
->orWhere('exchange_rate', 0) ->orWhere('exchange_rate', 0)
->cursor() ->cursor()
->each(function ($expense){ ->each(function ($expense) {
$expense->exchange_rate = 1; $expense->exchange_rate = 1;
$expense->saveQuietly(); $expense->saveQuietly();

View File

@ -131,7 +131,8 @@ class BaseRule implements RuleInterface
return $this; return $this;
} }
public function shouldCalcTax(): bool { public function shouldCalcTax(): bool
{
return $this->should_calc_tax && $this->checkIfInvoiceLocked(); return $this->should_calc_tax && $this->checkIfInvoiceLocked();
} }
/** /**
@ -404,8 +405,9 @@ class BaseRule implements RuleInterface
{ {
$lock_invoices = $this->client->getSetting('lock_invoices'); $lock_invoices = $this->client->getSetting('lock_invoices');
if($this->invoice instanceof RecurringInvoice) if($this->invoice instanceof RecurringInvoice) {
return true; return true;
}
switch ($lock_invoices) { switch ($lock_invoices) {
case 'off': case 'off':

View File

@ -251,8 +251,7 @@ class Rule extends BaseRule implements RuleInterface
$this->reduced_tax_rate = 0; $this->reduced_tax_rate = 0;
} elseif(!in_array($this->client_subregion, $this->eu_country_codes)) { } elseif(!in_array($this->client_subregion, $this->eu_country_codes)) {
$this->defaultForeign(); $this->defaultForeign();
} elseif(in_array($this->client_subregion, $this->eu_country_codes) && ((strlen($this->client->vat_number ?? '') == 1) || $this->client->has_valid_vat_number)) { //eu country / no valid vat } elseif(in_array($this->client_subregion, $this->eu_country_codes) && ((strlen($this->client->vat_number ?? '') == 1) || !$this->client->has_valid_vat_number)) { //eu country / no valid vat
// if(($this->client->company->tax_data->seller_subregion != $this->client_subregion) && $this->client->company->tax_data->regions->EU->has_sales_above_threshold) {
if($this->client->company->tax_data->seller_subregion != $this->client_subregion) { if($this->client->company->tax_data->seller_subregion != $this->client_subregion) {
// nlog("eu zone with sales above threshold"); // nlog("eu zone with sales above threshold");
$this->tax_rate = $this->client->company->tax_data->regions->EU->subregions->{$this->client->country->iso_3166_2}->tax_rate ?? 0; $this->tax_rate = $this->client->company->tax_data->regions->EU->subregions->{$this->client->country->iso_3166_2}->tax_rate ?? 0;

View File

@ -48,8 +48,7 @@ class TaxModel
public function migrate(): self public function migrate(): self
{ {
if($this->version == 'alpha') if($this->version == 'alpha') {
{
$this->regions->EU->subregions->PL = new \stdClass(); $this->regions->EU->subregions->PL = new \stdClass();
$this->regions->EU->subregions->PL->tax_rate = 23; $this->regions->EU->subregions->PL->tax_rate = 23;
$this->regions->EU->subregions->PL->tax_name = 'VAT'; $this->regions->EU->subregions->PL->tax_name = 'VAT';

View File

@ -11,7 +11,8 @@
namespace App\DataProviders; namespace App\DataProviders;
final class CAProvinces { final class CAProvinces
{
/** /**
* The provinces and territories of Canada * The provinces and territories of Canada
* *
@ -39,7 +40,8 @@ final class CAProvinces {
* @param string $abbreviation * @param string $abbreviation
* @return string * @return string
*/ */
public static function getName($abbreviation) { public static function getName($abbreviation)
{
return self::$provinces[$abbreviation]; return self::$provinces[$abbreviation];
} }
@ -48,7 +50,8 @@ final class CAProvinces {
* *
* @return array * @return array
*/ */
public static function get() { public static function get()
{
return self::$provinces; return self::$provinces;
} }
@ -58,7 +61,8 @@ final class CAProvinces {
* @param string $name * @param string $name
* @return string * @return string
*/ */
public static function getAbbreviation($name) { public static function getAbbreviation($name)
{
return array_search(ucwords($name), self::$provinces); return array_search(ucwords($name), self::$provinces);
} }
} }

View File

@ -130,7 +130,7 @@ class ActivityExport extends BaseExport
$query->cursor() $query->cursor()
->each(function ($entity) { ->each(function ($entity) {
/** @var \App\Models\Activity $entity */ /** @var \App\Models\Activity $entity */
$this->buildRow($entity); $this->buildRow($entity);
}); });

View File

@ -1041,7 +1041,7 @@ class BaseExport
$recurring_filters = []; $recurring_filters = [];
if($this->company->getSetting('report_include_drafts')){ if($this->company->getSetting('report_include_drafts')) {
$recurring_filters[] = RecurringInvoice::STATUS_DRAFT; $recurring_filters[] = RecurringInvoice::STATUS_DRAFT;
} }

View File

@ -133,7 +133,7 @@ class ClientExport extends BaseExport
$query->where('is_deleted', 0); $query->where('is_deleted', 0);
} }
$query = $this->addDateRange($query,' clients'); $query = $this->addDateRange($query, ' clients');
if($this->input['document_email_attachment'] ?? false) { if($this->input['document_email_attachment'] ?? false) {
$this->queueDocuments($query); $this->queueDocuments($query);
@ -157,7 +157,7 @@ class ClientExport extends BaseExport
$query->cursor() $query->cursor()
->each(function ($client) { ->each(function ($client) {
/** @var \App\Models\Client $client */ /** @var \App\Models\Client $client */
$this->csv->insertOne($this->buildRow($client)); $this->csv->insertOne($this->buildRow($client));
}); });

View File

@ -101,7 +101,7 @@ class DocumentExport extends BaseExport
$query->cursor() $query->cursor()
->each(function ($entity) { ->each(function ($entity) {
/** @var mixed $entity */ /** @var mixed $entity */
$this->csv->insertOne($this->buildRow($entity)); $this->csv->insertOne($this->buildRow($entity));
}); });

View File

@ -269,8 +269,7 @@ class ExpenseExport extends BaseExport
if($expense->uses_inclusive_taxes) { if($expense->uses_inclusive_taxes) {
$entity['expense.net_amount'] = round($expense->amount, $precision) - $total_tax_amount; $entity['expense.net_amount'] = round($expense->amount, $precision) - $total_tax_amount;
} } else {
else {
$entity['expense.net_amount'] = round($expense->amount, $precision); $entity['expense.net_amount'] = round($expense->amount, $precision);
} }

View File

@ -115,7 +115,7 @@ class PaymentExport extends BaseExport
$query->cursor() $query->cursor()
->each(function ($entity) { ->each(function ($entity) {
/** @var \App\Models\Payment $entity */ /** @var \App\Models\Payment $entity */
$this->csv->insertOne($this->buildRow($entity)); $this->csv->insertOne($this->buildRow($entity));
}); });

View File

@ -106,8 +106,8 @@ class ProductExport extends BaseExport
$query->cursor() $query->cursor()
->each(function ($entity) { ->each(function ($entity) {
/** @var \App\Models\Product $entity */ /** @var \App\Models\Product $entity */
$this->csv->insertOne($this->buildRow($entity)); $this->csv->insertOne($this->buildRow($entity));
}); });
return $this->csv->toString(); return $this->csv->toString();

View File

@ -122,8 +122,8 @@ class PurchaseOrderExport extends BaseExport
$query->cursor() $query->cursor()
->each(function ($purchase_order) { ->each(function ($purchase_order) {
/** @var \App\Models\PurchaseOrder $purchase_order */ /** @var \App\Models\PurchaseOrder $purchase_order */
$this->csv->insertOne($this->buildRow($purchase_order)); $this->csv->insertOne($this->buildRow($purchase_order));
}); });
return $this->csv->toString(); return $this->csv->toString();

View File

@ -102,14 +102,14 @@ class PurchaseOrderItemExport extends BaseExport
$query->cursor() $query->cursor()
->each(function ($resource) { ->each(function ($resource) {
/** @var \App\Models\PurchaseOrder $resource */ /** @var \App\Models\PurchaseOrder $resource */
$this->iterateItems($resource); $this->iterateItems($resource);
foreach($this->storage_array as $row) { foreach($this->storage_array as $row) {
$this->storage_item_array[] = $this->processItemMetaData($row, $resource); $this->storage_item_array[] = $this->processItemMetaData($row, $resource);
} }
$this->storage_array = []; $this->storage_array = [];
}); });
@ -130,8 +130,8 @@ class PurchaseOrderItemExport extends BaseExport
$query->cursor() $query->cursor()
->each(function ($purchase_order) { ->each(function ($purchase_order) {
/** @var \App\Models\PurchaseOrder $purchase_order */ /** @var \App\Models\PurchaseOrder $purchase_order */
$this->iterateItems($purchase_order); $this->iterateItems($purchase_order);
}); });
$this->csv->insertAll($this->storage_array); $this->csv->insertAll($this->storage_array);

View File

@ -107,8 +107,8 @@ class TaskExport extends BaseExport
$query->cursor() $query->cursor()
->each(function ($entity) { ->each(function ($entity) {
/** @var \App\Models\Task $entity*/ /** @var \App\Models\Task $entity*/
$this->buildRow($entity); $this->buildRow($entity);
}); });
$this->csv->insertAll($this->storage_array); $this->csv->insertAll($this->storage_array);

View File

@ -110,8 +110,8 @@ class VendorExport extends BaseExport
$query->cursor() $query->cursor()
->each(function ($vendor) { ->each(function ($vendor) {
/** @var \App\Models\Vendor $vendor */ /** @var \App\Models\Vendor $vendor */
$this->csv->insertOne($this->buildRow($vendor)); $this->csv->insertOne($this->buildRow($vendor));
}); });
return $this->csv->toString(); return $this->csv->toString();

View File

@ -149,43 +149,43 @@ class RecurringExpenseToExpenseFactory
} }
// if (Str::contains($match, '|')) { // if (Str::contains($match, '|')) {
$parts = explode('|', $match); // [ '[MONTH', 'MONTH+2]' ] $parts = explode('|', $match); // [ '[MONTH', 'MONTH+2]' ]
$left = substr($parts[0], 1); // 'MONTH' $left = substr($parts[0], 1); // 'MONTH'
$right = substr($parts[1], 0, -1); // MONTH+2 $right = substr($parts[1], 0, -1); // MONTH+2
// If left side is not part of replacements, skip. // If left side is not part of replacements, skip.
if (! array_key_exists($left, $replacements['ranges'])) { if (! array_key_exists($left, $replacements['ranges'])) {
continue; continue;
} }
$_left = Carbon::createFromDate(now()->year, now()->month)->translatedFormat('F Y'); $_left = Carbon::createFromDate(now()->year, now()->month)->translatedFormat('F Y');
$_right = ''; $_right = '';
// If right side doesn't have any calculations, replace with raw ranges keyword. // If right side doesn't have any calculations, replace with raw ranges keyword.
if (! Str::contains($right, ['-', '+', '/', '*'])) { if (! Str::contains($right, ['-', '+', '/', '*'])) {
$_right = Carbon::createFromDate(now()->year, now()->month)->translatedFormat('F Y'); $_right = Carbon::createFromDate(now()->year, now()->month)->translatedFormat('F Y');
} }
// If right side contains one of math operations, calculate. // If right side contains one of math operations, calculate.
if (Str::contains($right, ['+'])) { if (Str::contains($right, ['+'])) {
$operation = preg_match_all('/(?!^-)[+*\/-](\s?-)?/', $right, $_matches); $operation = preg_match_all('/(?!^-)[+*\/-](\s?-)?/', $right, $_matches);
$_operation = array_shift($_matches)[0]; // + - $_operation = array_shift($_matches)[0]; // + -
$_value = explode($_operation, $right); // [MONTHYEAR, 4] $_value = explode($_operation, $right); // [MONTHYEAR, 4]
$_right = Carbon::createFromDate(now()->year, now()->month)->addMonths($_value[1])->translatedFormat('F Y'); //@phpstan-ignore-line $_right = Carbon::createFromDate(now()->year, now()->month)->addMonths($_value[1])->translatedFormat('F Y'); //@phpstan-ignore-line
} }
$replacement = sprintf('%s to %s', $_left, $_right); $replacement = sprintf('%s to %s', $_left, $_right);
$value = preg_replace( $value = preg_replace(
sprintf('/%s/', preg_quote($match)), sprintf('/%s/', preg_quote($match)),
$replacement, $replacement,
$value, $value,
1 1
); );
// } // }
} }

View File

@ -105,7 +105,7 @@ class CreditFilters extends QueryFilters
JSON_UNQUOTE(JSON_EXTRACT(line_items, '$[*].product_key')) JSON_UNQUOTE(JSON_EXTRACT(line_items, '$[*].product_key'))
), '$[*]') ), '$[*]')
) LIKE ?", ['%'.$filter.'%']); ) LIKE ?", ['%'.$filter.'%']);
// ->orWhereRaw("JSON_UNQUOTE(JSON_EXTRACT(line_items, '$[*].notes')) LIKE ?", ['%'.$filter.'%']); // ->orWhereRaw("JSON_UNQUOTE(JSON_EXTRACT(line_items, '$[*].notes')) LIKE ?", ['%'.$filter.'%']);
}); });
} }

View File

@ -162,8 +162,9 @@ class ExpenseFilters extends QueryFilters
{ {
$categories_exploded = explode(",", $categories); $categories_exploded = explode(",", $categories);
if(empty($categories) || count(array_filter($categories_exploded)) == 0) if(empty($categories) || count(array_filter($categories_exploded)) == 0) {
return $this->builder; return $this->builder;
}
$categories_keys = $this->transformKeys($categories_exploded); $categories_keys = $this->transformKeys($categories_exploded);

View File

@ -132,7 +132,7 @@ class InvoiceFilters extends QueryFilters
JSON_UNQUOTE(JSON_EXTRACT(line_items, '$[*].product_key')) JSON_UNQUOTE(JSON_EXTRACT(line_items, '$[*].product_key'))
), '$[*]') ), '$[*]')
) LIKE ?", ['%'.$filter.'%']); ) LIKE ?", ['%'.$filter.'%']);
// ->orWhereRaw("JSON_UNQUOTE(JSON_EXTRACT(line_items, '$[*].notes')) LIKE ?", ['%'.$filter.'%']); // ->orWhereRaw("JSON_UNQUOTE(JSON_EXTRACT(line_items, '$[*].notes')) LIKE ?", ['%'.$filter.'%']);
}); });
} }

View File

@ -53,7 +53,7 @@ class QuoteFilters extends QueryFilters
JSON_UNQUOTE(JSON_EXTRACT(line_items, '$[*].product_key')) JSON_UNQUOTE(JSON_EXTRACT(line_items, '$[*].product_key'))
), '$[*]') ), '$[*]')
) LIKE ?", ['%'.$filter.'%']); ) LIKE ?", ['%'.$filter.'%']);
// ->orWhereRaw("JSON_UNQUOTE(JSON_EXTRACT(line_items, '$[*].notes')) LIKE ?", ['%'.$filter.'%']); // ->orWhereRaw("JSON_UNQUOTE(JSON_EXTRACT(line_items, '$[*].notes')) LIKE ?", ['%'.$filter.'%']);
}); });
} }

View File

@ -56,7 +56,7 @@ class RecurringInvoiceFilters extends QueryFilters
JSON_UNQUOTE(JSON_EXTRACT(line_items, '$[*].product_key')) JSON_UNQUOTE(JSON_EXTRACT(line_items, '$[*].product_key'))
), '$[*]') ), '$[*]')
) LIKE ?", ['%'.$filter.'%']); ) LIKE ?", ['%'.$filter.'%']);
//->orWhereRaw("JSON_UNQUOTE(JSON_EXTRACT(line_items, '$[*].notes')) LIKE ?", ['%'.$filter.'%']); //->orWhereRaw("JSON_UNQUOTE(JSON_EXTRACT(line_items, '$[*].notes')) LIKE ?", ['%'.$filter.'%']);
}); });
} }
@ -141,7 +141,7 @@ class RecurringInvoiceFilters extends QueryFilters
return $this->builder->orderByRaw("REGEXP_REPLACE(number,'[^0-9]+','')+0 " . $dir); return $this->builder->orderByRaw("REGEXP_REPLACE(number,'[^0-9]+','')+0 " . $dir);
} }
if($sort_col[0] == 'status_id'){ if($sort_col[0] == 'status_id') {
return $this->builder->orderBy('status_id', $dir)->orderBy('last_sent_date', $dir); return $this->builder->orderBy('status_id', $dir)->orderBy('last_sent_date', $dir);
} }

View File

@ -254,17 +254,20 @@ class ActivityController extends BaseController
$activity->client_id = $entity->client_id; $activity->client_id = $entity->client_id;
$activity->project_id = $entity->project_id; $activity->project_id = $entity->project_id;
$activity->vendor_id = $entity->vendor_id; $activity->vendor_id = $entity->vendor_id;
// no break
case Task::class: case Task::class:
$activity->task_id = $entity->id; $activity->task_id = $entity->id;
$activity->expense_id = $entity->id; $activity->expense_id = $entity->id;
$activity->client_id = $entity->client_id; $activity->client_id = $entity->client_id;
$activity->project_id = $entity->project_id; $activity->project_id = $entity->project_id;
$activity->vendor_id = $entity->vendor_id; $activity->vendor_id = $entity->vendor_id;
// no break
case Payment::class: case Payment::class:
$activity->payment_id = $entity->id; $activity->payment_id = $entity->id;
$activity->expense_id = $entity->id; $activity->expense_id = $entity->id;
$activity->client_id = $entity->client_id; $activity->client_id = $entity->client_id;
$activity->project_id = $entity->project_id; $activity->project_id = $entity->project_id;
// no break
default: default:
# code... # code...
break; break;

View File

@ -41,8 +41,9 @@ class ContactLoginController extends Controller
$company = false; $company = false;
$account = false; $account = false;
if($request->query('intended')) if($request->query('intended')) {
$request->session()->put('url.intended', $request->query('intended')); $request->session()->put('url.intended', $request->query('intended'));
}
if ($request->session()->has('company_key')) { if ($request->session()->has('company_key')) {
MultiDB::findAndSetDbByCompanyKey($request->session()->get('company_key')); MultiDB::findAndSetDbByCompanyKey($request->session()->get('company_key'));
@ -142,8 +143,9 @@ class ContactLoginController extends Controller
$this->setRedirectPath(); $this->setRedirectPath();
if($intended) if($intended) {
$this->redirectTo = $intended; $this->redirectTo = $intended;
}
return $request->wantsJson() return $request->wantsJson()
? new JsonResponse([], 204) ? new JsonResponse([], 204)

View File

@ -934,7 +934,7 @@ class BaseController extends Controller
} elseif (in_array($this->entity_type, [Design::class, GroupSetting::class, PaymentTerm::class, TaskStatus::class])) { } elseif (in_array($this->entity_type, [Design::class, GroupSetting::class, PaymentTerm::class, TaskStatus::class])) {
// nlog($this->entity_type); // nlog($this->entity_type);
} else { } else {
$query->where(function ($q) use ($user){ //grouping these together improves query performance significantly) $query->where(function ($q) use ($user) { //grouping these together improves query performance significantly)
$q->where('user_id', '=', $user->id)->orWhere('assigned_user_id', $user->id); $q->where('user_id', '=', $user->id)->orWhere('assigned_user_id', $user->id);
}); });
} }
@ -996,7 +996,7 @@ class BaseController extends Controller
if(request()->has('einvoice')) { if(request()->has('einvoice')) {
if(class_exists(Schema::class)){ if(class_exists(Schema::class)) {
$ro = new Schema(); $ro = new Schema();
$response_data['einvoice_schema'] = $ro('Peppol'); $response_data['einvoice_schema'] = $ro('Peppol');
} }

View File

@ -19,7 +19,6 @@ use Illuminate\Http\Request;
*/ */
class BrevoController extends BaseController class BrevoController extends BaseController
{ {
public function __construct() public function __construct()
{ {
} }

View File

@ -115,7 +115,7 @@ class InvitationController extends Controller
]); ]);
} }
if(!auth()->guard('contact')->check()){ if(!auth()->guard('contact')->check()) {
$this->middleware('auth:contact'); $this->middleware('auth:contact');
return redirect()->route('client.login', ['intended' => route('client.'.$entity.'.show', [$entity => $this->encodePrimaryKey($invitation->{$key}), 'silent' => $is_silent])]); return redirect()->route('client.login', ['intended' => route('client.'.$entity.'.show', [$entity => $this->encodePrimaryKey($invitation->{$key}), 'silent' => $is_silent])]);
} }

View File

@ -126,7 +126,7 @@ class PaymentController extends Controller
// if($payment_hash) // if($payment_hash)
$invoice = $payment_hash->fee_invoice; $invoice = $payment_hash->fee_invoice;
// else // else
// $invoice = Invoice::with('client')->where('id',$payment_hash->fee_invoice_id)->orderBy('id','desc')->first(); // $invoice = Invoice::with('client')->where('id',$payment_hash->fee_invoice_id)->orderBy('id','desc')->first();
// $invoice = Invoice::with('client')->find($payment_hash->fee_invoice_id); // $invoice = Invoice::with('client')->find($payment_hash->fee_invoice_id);

View File

@ -3,7 +3,7 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Http\Requests\Quickbooks\AuthorizedQuickbooksRequest; use App\Http\Requests\Quickbooks\AuthorizedQuickbooksRequest;
use \Closure; use Closure;
use App\Utils\Ninja; use App\Utils\Ninja;
use App\Models\Company; use App\Models\Company;
use App\Libraries\MultiDB; use App\Libraries\MultiDB;
@ -19,7 +19,6 @@ use App\Services\Import\Quickbooks\QuickbooksService;
class ImportQuickbooksController extends BaseController class ImportQuickbooksController extends BaseController
{ {
private array $import_entities = [ private array $import_entities = [
'client' => 'Customer', 'client' => 'Customer',
'invoice' => 'Invoice', 'invoice' => 'Invoice',
@ -46,7 +45,6 @@ class ImportQuickbooksController extends BaseController
/** /**
* Determine if the user is authorized to make this request. * Determine if the user is authorized to make this request.
* *
* @return bool
*/ */
public function authorizeQuickbooks(AuthQuickbooksRequest $request, string $token) public function authorizeQuickbooks(AuthQuickbooksRequest $request, string $token)
{ {
@ -74,17 +72,19 @@ class ImportQuickbooksController extends BaseController
$this->getData($data); $this->getData($data);
} }
protected function getData($data) { protected function getData($data)
{
$entity = $this->import_entities[$data['type']]; $entity = $this->import_entities[$data['type']];
$cache_name = "{$data['hash']}-{$data['type']}"; $cache_name = "{$data['hash']}-{$data['type']}";
// TODO: Get or put cache or DB? // TODO: Get or put cache or DB?
if(! Cache::has($cache_name) ) if(! Cache::has($cache_name)) {
{
$contents = call_user_func([$this->service, "fetch{$entity}s"]); $contents = call_user_func([$this->service, "fetch{$entity}s"]);
if($contents->isEmpty()) return; if($contents->isEmpty()) {
return;
}
Cache::put($cache_name, base64_encode( $contents->toJson()), 600); Cache::put($cache_name, base64_encode($contents->toJson()), 600);
} }
} }
@ -117,20 +117,19 @@ class ImportQuickbooksController extends BaseController
*/ */
public function import(Request $request) public function import(Request $request)
{ {
$hash = Str::random(32); // $hash = Str::random(32);
foreach($request->input('import_types') as $type) // foreach($request->input('import_types') as $type) {
{ // $this->preimport($type, $hash);
$this->preimport($type, $hash); // }
} // /** @var \App\Models\User $user */
/** @var \App\Models\User $user */ // // $user = auth()->user() ?? Auth::loginUsingId(60);
// $user = auth()->user() ?? Auth::loginUsingId(60); // $data = ['import_types' => $request->input('import_types') ] + compact('hash');
$data = ['import_types' => $request->input('import_types') ] + compact('hash'); // if (Ninja::isHosted()) {
if (Ninja::isHosted()) { // QuickbooksIngest::dispatch($data, $user->company());
QuickbooksIngest::dispatch( $data , $user->company() ); // } else {
} else { // QuickbooksIngest::dispatch($data, $user->company());
QuickbooksIngest::dispatch($data, $user->company() ); // }
}
return response()->json(['message' => 'Processing'], 200); // return response()->json(['message' => 'Processing'], 200);
} }
} }

View File

@ -503,7 +503,7 @@ class InvoiceController extends BaseController
$invoices = Invoice::withTrashed()->whereIn('id', $this->transformKeys($ids))->company()->get(); $invoices = Invoice::withTrashed()->whereIn('id', $this->transformKeys($ids))->company()->get();
if ($invoices->count() == 0 ) { if ($invoices->count() == 0) {
return response()->json(['message' => 'No Invoices Found']); return response()->json(['message' => 'No Invoices Found']);
} }

View File

@ -20,7 +20,6 @@ use Illuminate\Http\Request;
*/ */
class MailgunWebhookController extends BaseController class MailgunWebhookController extends BaseController
{ {
public function __construct() public function __construct()
{ {
} }
@ -35,7 +34,7 @@ class MailgunWebhookController extends BaseController
} }
if(\hash_equals(\hash_hmac('sha256', $input['signature']['timestamp'] . $input['signature']['token'], config('services.mailgun.webhook_signing_key')), $input['signature']['signature'])) { if(\hash_equals(\hash_hmac('sha256', $input['signature']['timestamp'] . $input['signature']['token'], config('services.mailgun.webhook_signing_key')), $input['signature']['signature'])) {
ProcessMailgunWebhook::dispatch($request->all())->delay(rand(2,10)); ProcessMailgunWebhook::dispatch($request->all())->delay(rand(2, 10));
} }
return response()->json(['message' => 'Success.'], 200); return response()->json(['message' => 'Success.'], 200);

View File

@ -22,7 +22,6 @@ use Illuminate\Support\Str;
class OneTimeTokenController extends BaseController class OneTimeTokenController extends BaseController
{ {
public function __construct() public function __construct()
{ {
parent::__construct(); parent::__construct();

View File

@ -19,7 +19,6 @@ use Illuminate\Http\Request;
*/ */
class PostMarkController extends BaseController class PostMarkController extends BaseController
{ {
public function __construct() public function __construct()
{ {
} }

View File

@ -297,8 +297,7 @@ class PreviewController extends BaseController
->setTemplate($design_object) ->setTemplate($design_object)
->mock(); ->mock();
} catch(SyntaxError $e) { } catch(SyntaxError $e) {
} } catch(\Exception $e) {
catch(\Exception $e) {
return response()->json(['message' => 'invalid data access', 'errors' => ['design.design.body' => $e->getMessage()]], 422); return response()->json(['message' => 'invalid data access', 'errors' => ['design.design.body' => $e->getMessage()]], 422);
} }

View File

@ -181,8 +181,9 @@ class SelfUpdateController extends BaseController
public function checkVersion() public function checkVersion()
{ {
if(Ninja::isHosted()) if(Ninja::isHosted()) {
return '5.10.SaaS'; return '5.10.SaaS';
}
return trim(file_get_contents(config('ninja.version_url'))); return trim(file_get_contents(config('ninja.version_url')));
} }

View File

@ -85,7 +85,10 @@ class ThrottleRequestsWithPredis extends \Illuminate\Routing\Middleware\Throttle
protected function tooManyAttempts($key, $maxAttempts, $decaySeconds) protected function tooManyAttempts($key, $maxAttempts, $decaySeconds)
{ {
$limiter = new DurationLimiter( $limiter = new DurationLimiter(
$this->getRedisConnection(), $key, $maxAttempts, $decaySeconds $this->getRedisConnection(),
$key,
$maxAttempts,
$decaySeconds
); );
return tap(! $limiter->acquire(), function () use ($key, $limiter) { return tap(! $limiter->acquire(), function () use ($key, $limiter) {

View File

@ -68,11 +68,12 @@ class StoreNoteRequest extends Request
public function getEntity() public function getEntity()
{ {
if(!$this->entity) if(!$this->entity) {
return false; return false;
}
$class = "\\App\\Models\\".ucfirst(Str::camel(rtrim($this->entity, 's'))); $class = "\\App\\Models\\".ucfirst(Str::camel(rtrim($this->entity, 's')));
return $class::withTrashed()->find(is_string($this->entity_id) ? $this->decodePrimaryKey($this->entity_id) : $this->entity_id); return $class::withTrashed()->find(is_string($this->entity_id) ? $this->decodePrimaryKey($this->entity_id) : $this->entity_id);
} }

View File

@ -66,8 +66,7 @@ class ShowCalculatedFieldRequest extends Request
$input['end_date'] = now()->format('Y-m-d'); $input['end_date'] = now()->format('Y-m-d');
} }
if(isset($input['period']) && $input['period'] == 'previous') if(isset($input['period']) && $input['period'] == 'previous') {
{
$dates = $this->calculatePreviousPeriodStartAndEndDates($input, $user->company()); $dates = $this->calculatePreviousPeriodStartAndEndDates($input, $user->company());
$input['start_date'] = $dates[0]; $input['start_date'] = $dates[0];
$input['end_date'] = $dates[1]; $input['end_date'] = $dates[1];

View File

@ -40,8 +40,9 @@ class BulkInvoiceRequest extends Request
/** @var \App\Models\User $user */ /** @var \App\Models\User $user */
$user = auth()->user(); $user = auth()->user();
if(\Illuminate\Support\Facades\Cache::has($this->ip()."|".$this->input('action', 0)."|".$user->company()->company_key)) if(\Illuminate\Support\Facades\Cache::has($this->ip()."|".$this->input('action', 0)."|".$user->company()->company_key)) {
throw new DuplicatePaymentException('Duplicate request.', 429); throw new DuplicatePaymentException('Duplicate request.', 429);
}
\Illuminate\Support\Facades\Cache::put(($this->ip()."|".$this->input('action', 0)."|".$user->company()->company_key), true, 1); \Illuminate\Support\Facades\Cache::put(($this->ip()."|".$this->input('action', 0)."|".$user->company()->company_key), true, 1);

View File

@ -80,8 +80,9 @@ class StorePaymentRequest extends Request
/** @var \App\Models\User $user */ /** @var \App\Models\User $user */
$user = auth()->user(); $user = auth()->user();
if(\Illuminate\Support\Facades\Cache::has($this->ip()."|".$this->input('amount', 0)."|".$this->input('client_id', '')."|".$user->company()->company_key)) if(\Illuminate\Support\Facades\Cache::has($this->ip()."|".$this->input('amount', 0)."|".$this->input('client_id', '')."|".$user->company()->company_key)) {
throw new DuplicatePaymentException('Duplicate request.', 429); throw new DuplicatePaymentException('Duplicate request.', 429);
}
\Illuminate\Support\Facades\Cache::put(($this->ip()."|".$this->input('amount', 0)."|".$this->input('client_id', '')."|".$user->company()->company_key), true, 1); \Illuminate\Support\Facades\Cache::put(($this->ip()."|".$this->input('amount', 0)."|".$this->input('client_id', '')."|".$user->company()->company_key), true, 1);

View File

@ -44,7 +44,7 @@ class StoreQuoteRequest extends Request
$rules = []; $rules = [];
$rules['client_id'] = ['required', 'bail', Rule::exists('clients', 'id')->where('company_id', $user->company()->id)->where('is_deleted',0)]; $rules['client_id'] = ['required', 'bail', Rule::exists('clients', 'id')->where('company_id', $user->company()->id)->where('is_deleted', 0)];
if ($this->file('documents') && is_array($this->file('documents'))) { if ($this->file('documents') && is_array($this->file('documents'))) {
$rules['documents.*'] = $this->fileValidation(); $rules['documents.*'] = $this->fileValidation();

View File

@ -17,7 +17,6 @@ use Illuminate\Auth\Access\AuthorizationException;
class GenericReportRequest extends Request class GenericReportRequest extends Request
{ {
/** /**
* Determine if the user is authorized to make this request. * Determine if the user is authorized to make this request.
* *

View File

@ -15,7 +15,6 @@ use App\Http\Requests\Request;
class DisconnectUserMailerRequest extends Request class DisconnectUserMailerRequest extends Request
{ {
/** /**
* Determine if the user is authorized to make this request. * Determine if the user is authorized to make this request.
* *

View File

@ -77,8 +77,7 @@ class UpdateUserRequest extends Request
unset($input['oauth_user_token']); unset($input['oauth_user_token']);
} }
if(isset($input['password']) && is_string($input['password'])) if(isset($input['password']) && is_string($input['password'])) {
{
$input['password'] = trim($input['password']); $input['password'] = trim($input['password']);
} }

View File

@ -34,8 +34,7 @@ class ValidClientScheme implements ValidationRule, ValidatorAwareRule
public function validate(string $attribute, mixed $value, Closure $fail): void public function validate(string $attribute, mixed $value, Closure $fail): void
{ {
if(isset($value['Invoice'])) if(isset($value['Invoice'])) {
{
$r = new EInvoice(); $r = new EInvoice();
$errors = $r->validateRequest($value['Invoice'], ClientLevel::class); $errors = $r->validateRequest($value['Invoice'], ClientLevel::class);

View File

@ -24,7 +24,6 @@ use Illuminate\Contracts\Validation\ValidatorAwareRule;
*/ */
class ValidCompanyScheme implements ValidationRule, ValidatorAwareRule class ValidCompanyScheme implements ValidationRule, ValidatorAwareRule
{ {
/** /**
* The validator instance. * The validator instance.
* *
@ -35,8 +34,7 @@ class ValidCompanyScheme implements ValidationRule, ValidatorAwareRule
public function validate(string $attribute, mixed $value, Closure $fail): void public function validate(string $attribute, mixed $value, Closure $fail): void
{ {
if(isset($value['Invoice'])) if(isset($value['Invoice'])) {
{
$r = new EInvoice(); $r = new EInvoice();
$errors = $r->validateRequest($value['Invoice'], CompanyLevel::class); $errors = $r->validateRequest($value['Invoice'], CompanyLevel::class);

View File

@ -89,7 +89,7 @@ class ValidInvoicesRules implements Rule
} elseif (floatval($invoice['amount']) > floatval($inv->balance)) { } elseif (floatval($invoice['amount']) > floatval($inv->balance)) {
$this->error_msg = ctrans('texts.amount_greater_than_balance_v5'); $this->error_msg = ctrans('texts.amount_greater_than_balance_v5');
return false; return false;
} elseif($inv->is_deleted){ } elseif($inv->is_deleted) {
$this->error_msg = 'One or more invoices in this request have since been deleted'; $this->error_msg = 'One or more invoices in this request have since been deleted';
return false; return false;
} }

View File

@ -42,8 +42,9 @@ class AccountComponent extends Component
"authorization_type" => 'Online' "authorization_type" => 'Online'
]; ];
public function __construct(public array $account) { public function __construct(public array $account)
$this->attributes = $this->newAttributeBag(Arr::only($this->account, $this->fields) ); {
$this->attributes = $this->newAttributeBag(Arr::only($this->account, $this->fields));
} }
public function render() public function render()

View File

@ -34,21 +34,25 @@ class AddressComponent extends Component
'country' => 'US' 'country' => 'US'
]; ];
public function __construct(public array $address) { public function __construct(public array $address)
if(strlen($this->address['state']) > 2 ) { {
if(strlen($this->address['state']) > 2) {
$this->address['state'] = $this->address['country'] == 'US' ? array_search($this->address['state'], USStates::$states) : CAProvinces::getAbbreviation($this->address['state']); $this->address['state'] = $this->address['country'] == 'US' ? array_search($this->address['state'], USStates::$states) : CAProvinces::getAbbreviation($this->address['state']);
} }
$this->attributes = $this->newAttributeBag( $this->attributes = $this->newAttributeBag(
Arr::only(Arr::mapWithKeys($this->address, function ($item, $key) { Arr::only(
return in_array($key, ['address1','address2','state'])?[ (['address1'=>'address_1','address2'=>'address_2','state'=>'province_code'])[$key] => $item ] :[ $key => $item ]; Arr::mapWithKeys($this->address, function ($item, $key) {
}), return in_array($key, ['address1','address2','state']) ? [ (['address1' => 'address_1','address2' => 'address_2','state' => 'province_code'])[$key] => $item ] : [ $key => $item ];
$this->fields) ); }),
$this->fields
)
);
} }
public function render() public function render()
{ {
return render('gateways.rotessa.components.address', $this->attributes->getAttributes() + $this->defaults ); return render('gateways.rotessa.components.address', $this->attributes->getAttributes() + $this->defaults);
} }
} }

View File

@ -18,21 +18,20 @@ use App\Models\ClientContact;
use Illuminate\Support\Arr; use Illuminate\Support\Arr;
use Illuminate\View\View; use Illuminate\View\View;
// Contact Component // Contact Component
class ContactComponent extends Component class ContactComponent extends Component
{ {
public function __construct(ClientContact $contact)
public function __construct(ClientContact $contact) { {
$contact = collect($contact->client->contacts->firstWhere('is_primary', 1)->toArray())->merge([ $contact = collect($contact->client->contacts->firstWhere('is_primary', 1)->toArray())->merge([
'home_phone' =>$contact->client->phone, 'home_phone' => $contact->client->phone,
'custom_identifier' => $contact->client->client_hash, 'custom_identifier' => $contact->client->client_hash,
'name' =>$contact->client->name, 'name' => $contact->client->name,
'id' => null, 'id' => null,
] )->all(); ])->all();
$this->attributes = $this->newAttributeBag(Arr::only($contact, $this->fields) ); $this->attributes = $this->newAttributeBag(Arr::only($contact, $this->fields));
} }
private $fields = [ private $fields = [
@ -53,6 +52,6 @@ class ContactComponent extends Component
public function render() public function render()
{ {
return render('gateways.rotessa.components.contact', $this->attributes->getAttributes() + $this->defaults ); return render('gateways.rotessa.components.contact', $this->attributes->getAttributes() + $this->defaults);
} }
} }

View File

@ -137,9 +137,9 @@ class PortalComposer
$data[] = ['title' => ctrans('texts.statement'), 'url' => 'client.statement', 'icon' => 'activity']; $data[] = ['title' => ctrans('texts.statement'), 'url' => 'client.statement', 'icon' => 'activity'];
// if (Ninja::isHosted() && auth()->guard('contact')->user()->company->id == config('ninja.ninja_default_company_id')) { // if (Ninja::isHosted() && auth()->guard('contact')->user()->company->id == config('ninja.ninja_default_company_id')) {
$data[] = ['title' => ctrans('texts.plan'), 'url' => 'client.plan', 'icon' => 'credit-card']; $data[] = ['title' => ctrans('texts.plan'), 'url' => 'client.plan', 'icon' => 'credit-card'];
// } else { // } else {
$data[] = ['title' => ctrans('texts.subscriptions'), 'url' => 'client.subscriptions.index', 'icon' => 'calendar']; $data[] = ['title' => ctrans('texts.subscriptions'), 'url' => 'client.subscriptions.index', 'icon' => 'calendar'];
// } // }
if (auth()->guard('contact')->user()->client->getSetting('client_initiated_payments')) { if (auth()->guard('contact')->user()->client->getSetting('client_initiated_payments')) {

View File

@ -12,23 +12,24 @@
namespace App\Import\Providers; namespace App\Import\Providers;
use App\Models\Invoice; use App\Models\Invoice;
use App\Factory\ProductFactory;
use App\Factory\ClientFactory; use App\Factory\ClientFactory;
use App\Factory\InvoiceFactory; use App\Factory\InvoiceFactory;
use App\Factory\PaymentFactory; use App\Factory\PaymentFactory;
use App\Factory\ProductFactory;
use App\Import\ImportException;
use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\Cache;
use App\Repositories\ClientRepository; use App\Repositories\ClientRepository;
use App\Repositories\InvoiceRepository; use App\Repositories\InvoiceRepository;
use App\Repositories\ProductRepository;
use App\Repositories\PaymentRepository; use App\Repositories\PaymentRepository;
use App\Repositories\ProductRepository;
use App\Http\Requests\Client\StoreClientRequest; use App\Http\Requests\Client\StoreClientRequest;
use App\Http\Requests\Product\StoreProductRequest;
use App\Http\Requests\Invoice\StoreInvoiceRequest; use App\Http\Requests\Invoice\StoreInvoiceRequest;
use App\Http\Requests\Payment\StorePaymentRequest; use App\Http\Requests\Payment\StorePaymentRequest;
use App\Http\Requests\Product\StoreProductRequest;
use App\Import\Transformer\Quickbooks\ClientTransformer; use App\Import\Transformer\Quickbooks\ClientTransformer;
use App\Import\Transformer\Quickbooks\InvoiceTransformer; use App\Import\Transformer\Quickbooks\InvoiceTransformer;
use App\Import\Transformer\Quickbooks\ProductTransformer;
use App\Import\Transformer\Quickbooks\PaymentTransformer; use App\Import\Transformer\Quickbooks\PaymentTransformer;
use App\Import\Transformer\Quickbooks\ProductTransformer;
class Quickbooks extends BaseImport class Quickbooks extends BaseImport
{ {
@ -94,10 +95,11 @@ class Quickbooks extends BaseImport
$this->entity_count['products'] = $count; $this->entity_count['products'] = $count;
} }
public function getData($type) { public function getData($type)
{
// get the data from cache? file? or api ? // get the data from cache? file? or api ?
return json_decode(base64_decode(Cache::get("{$this->hash}-$type")), 1); return json_decode(base64_decode(Cache::get("{$this->hash}-{$type}")), true);
} }
public function payment() public function payment()
@ -143,7 +145,7 @@ class Quickbooks extends BaseImport
$this->repository = app()->make($this->repository_name); $this->repository = app()->make($this->repository_name);
$this->repository->import_mode = true; $this->repository->import_mode = true;
$this->transformer = new InvoiceTransformer($this->company); $this->transformer = new InvoiceTransformer($this->company);
$invoice_count = $this->ingestInvoices($data,''); $invoice_count = $this->ingestInvoices($data, '');
$this->entity_count['invoices'] = $invoice_count; $this->entity_count['invoices'] = $invoice_count;
$this->company->update_products = $initial_update_products_value; $this->company->update_products = $initial_update_products_value;
$this->company->save(); $this->company->save();
@ -198,8 +200,7 @@ class Quickbooks extends BaseImport
'error' => $validator->errors()->all(), 'error' => $validator->errors()->all(),
]; ];
} else { } else {
if(!Invoice::where('number',$invoice_data['number'])->get()->first()) if(!Invoice::where('number', $invoice_data['number'])->first()) {
{
$invoice = InvoiceFactory::create( $invoice = InvoiceFactory::create(
$this->company->id, $this->company->id,
$this->company->owner()->id $this->company->owner()->id

View File

@ -244,8 +244,7 @@ class Wave extends BaseImport implements ImportInterface
if (empty($expense_data['vendor_id'])) { if (empty($expense_data['vendor_id'])) {
$vendor_data['user_id'] = $this->getUserIDForRecord($expense_data); $vendor_data['user_id'] = $this->getUserIDForRecord($expense_data);
if(isset($raw_expense['Vendor Name']) || isset($raw_expense['Vendor'])) if(isset($raw_expense['Vendor Name']) || isset($raw_expense['Vendor'])) {
{
$vendor_repository->save( $vendor_repository->save(
['name' => isset($raw_expense['Vendor Name']) ? $raw_expense['Vendor Name'] : isset($raw_expense['Vendor'])], ['name' => isset($raw_expense['Vendor Name']) ? $raw_expense['Vendor Name'] : isset($raw_expense['Vendor'])],
$vendor = VendorFactory::create( $vendor = VendorFactory::create(

View File

@ -119,8 +119,9 @@ class BaseTransformer
{ {
$code = array_key_exists($key, $data) ? $data[$key] : false; $code = array_key_exists($key, $data) ? $data[$key] : false;
if(!$code) if(!$code) {
return $this->company->settings->currency_id; return $this->company->settings->currency_id;
}
/** @var \Illuminate\Support\Collection<\App\Models\Currency> */ /** @var \Illuminate\Support\Collection<\App\Models\Currency> */
$currencies = app('currencies'); $currencies = app('currencies');

View File

@ -24,7 +24,6 @@ use Illuminate\Support\Str;
*/ */
class ClientTransformer extends BaseTransformer class ClientTransformer extends BaseTransformer
{ {
use CommonTrait { use CommonTrait {
transform as preTransform; transform as preTransform;
} }
@ -49,7 +48,7 @@ class ClientTransformer extends BaseTransformer
{ {
parent::__construct($company); parent::__construct($company);
$this->model = new Model; $this->model = new Model();
} }
@ -68,12 +67,13 @@ class ClientTransformer extends BaseTransformer
} }
$transformed_data = $this->preTransform($data); $transformed_data = $this->preTransform($data);
$transformed_data['contacts'][0] = $this->getContacts($data)->toArray()+['company_id' => $this->company->id ]; $transformed_data['contacts'][0] = $this->getContacts($data)->toArray() + ['company_id' => $this->company->id ];
return $transformed_data; return $transformed_data;
} }
protected function getContacts($data) { protected function getContacts($data)
{
return (new ClientContact())->fill([ return (new ClientContact())->fill([
'first_name' => $this->getString($data, 'GivenName'), 'first_name' => $this->getString($data, 'GivenName'),
'last_name' => $this->getString($data, 'FamilyName'), 'last_name' => $this->getString($data, 'FamilyName'),
@ -84,12 +84,14 @@ class ClientTransformer extends BaseTransformer
} }
public function getShipAddrCountry($data,$field) { public function getShipAddrCountry($data, $field)
return is_null(($c = $this->getString($data,$field))) ? null : $this->getCountryId($c); {
return is_null(($c = $this->getString($data, $field))) ? null : $this->getCountryId($c);
} }
public function getBillAddrCountry($data,$field) { public function getBillAddrCountry($data, $field)
return is_null(($c = $this->getString($data,$field))) ? null : $this->getCountryId($c); {
return is_null(($c = $this->getString($data, $field))) ? null : $this->getCountryId($c);
} }
} }

View File

@ -8,8 +8,9 @@ trait CommonTrait
{ {
protected $model; protected $model;
public function getString($data,$field) { public function getString($data, $field)
return Arr::get($data,$field); {
return Arr::get($data, $field);
} }
public function getCreateTime($data, $field = null) public function getCreateTime($data, $field = null)
@ -19,7 +20,7 @@ trait CommonTrait
public function getLastUpdatedTime($data, $field = null) public function getLastUpdatedTime($data, $field = null)
{ {
return $this->parseDateOrNull($data,'MetaData.LastUpdatedTime'); return $this->parseDateOrNull($data, 'MetaData.LastUpdatedTime');
} }
public function transform($data) public function transform($data)
@ -27,7 +28,7 @@ trait CommonTrait
$transformed = []; $transformed = [];
foreach ($this->fillable as $key => $field) { foreach ($this->fillable as $key => $field) {
$transformed[$key] = is_null((($v = $this->getString($data, $field))))? null : (method_exists($this, ($method = "get{$field}")) ? call_user_func([$this, $method], $data, $field ) : $this->getString($data,$field)); $transformed[$key] = is_null((($v = $this->getString($data, $field)))) ? null : (method_exists($this, ($method = "get{$field}")) ? call_user_func([$this, $method], $data, $field) : $this->getString($data, $field));
} }
return $this->model->fillable(array_keys($this->fillable))->fill($transformed)->toArray() + ['company_id' => $this->company->id ] ; return $this->model->fillable(array_keys($this->fillable))->fill($transformed)->toArray() + ['company_id' => $this->company->id ] ;

View File

@ -11,10 +11,11 @@
namespace App\Import\Transformer\Quickbooks; namespace App\Import\Transformer\Quickbooks;
use Illuminate\Support\Str; use App\Models\Invoice;
use Illuminate\Support\Arr; use Illuminate\Support\Arr;
use App\Import\ImportException; use Illuminate\Support\Str;
use App\DataMapper\InvoiceItem; use App\DataMapper\InvoiceItem;
use App\Import\ImportException;
use App\Models\Invoice as Model; use App\Models\Invoice as Model;
use App\Import\Transformer\BaseTransformer; use App\Import\Transformer\BaseTransformer;
use App\Import\Transformer\Quickbooks\CommonTrait; use App\Import\Transformer\Quickbooks\CommonTrait;
@ -48,7 +49,7 @@ class InvoiceTransformer extends BaseTransformer
{ {
parent::__construct($company); parent::__construct($company);
$this->model = new Model; $this->model = new Model();
} }
public function getInvoiceStatus($data) public function getInvoiceStatus($data)
@ -58,33 +59,34 @@ class InvoiceTransformer extends BaseTransformer
public function transform($data) public function transform($data)
{ {
return $this->preTransform($data) + $this->getInvoiceClient($data); return $this->preTransform($data) + $this->getInvoiceClient($data);
} }
public function getTotalAmt($data) public function getTotalAmt($data)
{ {
return (float) $this->getString($data,'TotalAmt'); return (float) $this->getString($data, 'TotalAmt');
} }
public function getLine($data) public function getLine($data)
{ {
return array_map(function ($item) { return array_map(function ($item) {
return [ return [
'description' => $this->getString($item,'Description'), 'description' => $this->getString($item, 'Description'),
'product_key' => $this->getString($item,'Description'), 'product_key' => $this->getString($item, 'Description'),
'quantity' => (int) $this->getString($item,'SalesItemLineDetail.Qty'), 'quantity' => (int) $this->getString($item, 'SalesItemLineDetail.Qty'),
'unit_price' =>(double) $this->getString($item,'SalesItemLineDetail.UnitPrice'), 'unit_price' => (float) $this->getString($item, 'SalesItemLineDetail.UnitPrice'),
'line_total' => (double) $this->getString($item,'Amount'), 'line_total' => (float) $this->getString($item, 'Amount'),
'cost' =>(double) $this->getString($item,'SalesItemLineDetail.UnitPrice'), 'cost' => (float) $this->getString($item, 'SalesItemLineDetail.UnitPrice'),
'product_cost' => (double) $this->getString($item,'SalesItemLineDetail.UnitPrice'), 'product_cost' => (float) $this->getString($item, 'SalesItemLineDetail.UnitPrice'),
'tax_amount' => (double) $this->getString($item,'TxnTaxDetail.TotalTax'), 'tax_amount' => (float) $this->getString($item, 'TxnTaxDetail.TotalTax'),
]; ];
}, array_filter($this->getString($data,'Line'), function ($item) { }, array_filter($this->getString($data, 'Line'), function ($item) {
return $this->getString($item,'DetailType') !== 'SubTotalLineDetail'; return $this->getString($item, 'DetailType') !== 'SubTotalLineDetail';
})); }));
} }
public function getInvoiceClient($data, $field = null) { public function getInvoiceClient($data, $field = null)
{
/** /**
* "CustomerRef": { * "CustomerRef": {
"value": "23", "value": "23",
@ -135,23 +137,22 @@ class InvoiceTransformer extends BaseTransformer
$customer = explode(" ", $this->getString($data, 'CustomerRef.name')); $customer = explode(" ", $this->getString($data, 'CustomerRef.name'));
$customer = ['GivenName' => $customer[0], 'FamilyName' => $customer[1]]; $customer = ['GivenName' => $customer[0], 'FamilyName' => $customer[1]];
$has_company = property_exists($bill_address, 'Line4'); $has_company = property_exists($bill_address, 'Line4');
$address = $has_company? $bill_address->Line4 : $bill_address->Line3; $address = $has_company ? $bill_address->Line4 : $bill_address->Line3;
$address_1 = substr($address, 0, stripos($address,',')); $address_1 = substr($address, 0, stripos($address, ','));
$address =array_filter( [$address_1] + (explode(' ', substr($address, stripos($address,",") + 1 )))); $address = array_filter([$address_1] + (explode(' ', substr($address, stripos($address, ",") + 1))));
$client_id = null; $client_id = null;
$client = $client =
[ [
"CompanyName" => $has_company? $bill_address->Line2 : $bill_address->Line1, "CompanyName" => $has_company ? $bill_address->Line2 : $bill_address->Line1,
"BillAddr" => array_combine(['City','CountrySubDivisionCode','PostalCode'], array_pad($address,3,'N/A') ) + ['Line1' => $has_company? $bill_address->Line3 : $bill_address->Line2 ], "BillAddr" => array_combine(['City','CountrySubDivisionCode','PostalCode'], array_pad($address, 3, 'N/A')) + ['Line1' => $has_company ? $bill_address->Line3 : $bill_address->Line2 ],
"ShipAddr" => $ship_address "ShipAddr" => $ship_address
] + $customer + ['PrimaryEmailAddr' => ['Address' => $this->getString($data, 'BillEmail.Address') ]]; ] + $customer + ['PrimaryEmailAddr' => ['Address' => $this->getString($data, 'BillEmail.Address') ]];
if($this->hasClient($client['CompanyName'])) if($this->hasClient($client['CompanyName'])) {
{ $client_id = $this->getClient($client['CompanyName'], $this->getString($client, 'PrimaryEmailAddr.Address'));
$client_id = $this->getClient($client['CompanyName'],$this->getString($client, 'PrimaryEmailAddr.Address'));
} }
return ['client'=> (new ClientTransformer($this->company))->transform($client), 'client_id'=> $client_id ]; return ['client' => (new ClientTransformer($this->company))->transform($client), 'client_id' => $client_id ];
} }
public function getDueDate($data) public function getDueDate($data)
@ -161,36 +162,39 @@ class InvoiceTransformer extends BaseTransformer
public function getDeposit($data) public function getDeposit($data)
{ {
return (double) $this->getString($data,'Deposit'); return (float) $this->getString($data, 'Deposit');
} }
public function getBalance($data) public function getBalance($data)
{ {
return (double) $this->getString($data,'Balance'); return (float) $this->getString($data, 'Balance');
} }
public function getCustomerMemo($data) public function getCustomerMemo($data)
{ {
return $this->getString($data,'CustomerMemo.value'); return $this->getString($data, 'CustomerMemo.value');
} }
public function getDocNumber($data, $field = null) public function getDocNumber($data, $field = null)
{ {
return sprintf("%s-%s", return sprintf(
$this->getString($data, 'DocNumber'), "%s-%s",
$this->getString($data, 'Id.value') $this->getString($data, 'DocNumber'),
); $this->getString($data, 'Id.value')
);
} }
public function getLinkedTxn($data) public function getLinkedTxn($data)
{ {
$payments = $this->getString($data,'LinkedTxn'); $payments = $this->getString($data, 'LinkedTxn');
if(empty($payments)) return []; if(empty($payments)) {
return [];
}
return [[ return [[
'amount' => $this->getTotalAmt($data), 'amount' => $this->getTotalAmt($data),
'date' => $this->parseDateOrNull($data, 'TxnDate') 'date' => $this->parseDateOrNull($data, 'TxnDate')
]]; ]];
} }
} }

View File

@ -44,10 +44,11 @@ class PaymentTransformer extends BaseTransformer
{ {
parent::__construct($company); parent::__construct($company);
$this->model = new Model; $this->model = new Model();
} }
public function getTotalAmt($data, $field = null) { public function getTotalAmt($data, $field = null)
{
return (float) $this->getString($data, $field); return (float) $this->getString($data, $field);
} }
@ -56,9 +57,9 @@ class PaymentTransformer extends BaseTransformer
return $this->parseDateOrNull($data, $field); return $this->parseDateOrNull($data, $field);
} }
public function getCustomerRef($data, $field = null ) public function getCustomerRef($data, $field = null)
{ {
return $this->getClient($this->getString($data, 'CustomerRef.name'),null); return $this->getClient($this->getString($data, 'CustomerRef.name'), null);
} }
public function getCurrencyRef($data, $field = null) public function getCurrencyRef($data, $field = null)
@ -69,9 +70,13 @@ class PaymentTransformer extends BaseTransformer
public function getLine($data, $field = null) public function getLine($data, $field = null)
{ {
$invoices = []; $invoices = [];
$invoice = $this->getString($data,'Line.LinkedTxn.TxnType'); $invoice = $this->getString($data, 'Line.LinkedTxn.TxnType');
if(is_null($invoice) || $invoice !== 'Invoice') return $invoices; if(is_null($invoice) || $invoice !== 'Invoice') {
if( is_null( ($invoice_id = $this->getInvoiceId($this->getString($data, 'Line.LinkedTxn.TxnId.value')))) ) return $invoices; return $invoices;
}
if(is_null(($invoice_id = $this->getInvoiceId($this->getString($data, 'Line.LinkedTxn.TxnId.value'))))) {
return $invoices;
}
return [[ return [[
'amount' => (float) $this->getString($data, 'Line.Amount'), 'amount' => (float) $this->getString($data, 'Line.Amount'),
@ -79,16 +84,18 @@ class PaymentTransformer extends BaseTransformer
]]; ]];
} }
/** /**
* @param $invoice_number * @param $invoice_number
* *
* @return int|null * @return int|null
*/ */
public function getInvoiceId($invoice_number) public function getInvoiceId($invoice_number)
{ {
$invoice = Invoice::query()->where('company_id', $this->company->id) $invoice = Invoice::query()->where('company_id', $this->company->id)
->where('is_deleted', false) ->where('is_deleted', false)
->where("number", "LIKE", ->where(
"number",
"LIKE",
"%-$invoice_number%", "%-$invoice_number%",
) )
->first(); ->first();

View File

@ -22,7 +22,6 @@ use App\Import\ImportException;
*/ */
class ProductTransformer extends BaseTransformer class ProductTransformer extends BaseTransformer
{ {
use CommonTrait; use CommonTrait;
protected $fillable = [ protected $fillable = [
@ -41,19 +40,22 @@ class ProductTransformer extends BaseTransformer
{ {
parent::__construct($company); parent::__construct($company);
$this->model = new Model; $this->model = new Model();
} }
public function getQtyOnHand($data, $field = null) { public function getQtyOnHand($data, $field = null)
{
return (int) $this->getString($data, $field); return (int) $this->getString($data, $field);
} }
public function getPurchaseCost($data, $field = null) { public function getPurchaseCost($data, $field = null)
return (double) $this->getString($data, $field); {
return (float) $this->getString($data, $field);
} }
public function getUnitPrice($data, $field = null) { public function getUnitPrice($data, $field = null)
{
return (float) $this->getString($data, $field); return (float) $this->getString($data, $field);
} }
} }

View File

@ -38,12 +38,13 @@ class ExpenseTransformer extends BaseTransformer
$tax_rate = $total_tax > 0 ? round(($total_tax / $amount) * 100, 3) : 0; $tax_rate = $total_tax > 0 ? round(($total_tax / $amount) * 100, 3) : 0;
if(isset($data['Notes / Memo']) && strlen($data['Notes / Memo']) > 1) if(isset($data['Notes / Memo']) && strlen($data['Notes / Memo']) > 1) {
$public_notes = $data['Notes / Memo']; $public_notes = $data['Notes / Memo'];
elseif (isset($data['Transaction Description']) && strlen($data['Transaction Description']) > 1) } elseif (isset($data['Transaction Description']) && strlen($data['Transaction Description']) > 1) {
$public_notes = $data['Transaction Description']; $public_notes = $data['Transaction Description'];
else } else {
$public_notes = ''; $public_notes = '';
}
$transformed = [ $transformed = [

View File

@ -237,7 +237,7 @@ class MatchBankTransactions implements ShouldQueue
$amount = $this->bt->amount; $amount = $this->bt->amount;
if ($_invoices->count() >0 && $this->checkPayable($_invoices)) { if ($_invoices->count() > 0 && $this->checkPayable($_invoices)) {
$this->createPayment($_invoices, $amount); $this->createPayment($_invoices, $amount);
$this->bts->push($this->bt->id); $this->bts->push($this->bt->id);
@ -387,7 +387,7 @@ class MatchBankTransactions implements ShouldQueue
$hashed_keys = []; $hashed_keys = [];
foreach($this->attachable_invoices as $attachable_invoice){ //@phpstan-ignore-line foreach($this->attachable_invoices as $attachable_invoice) { //@phpstan-ignore-line
$hashed_keys[] = $this->encodePrimaryKey($attachable_invoice['id']); $hashed_keys[] = $this->encodePrimaryKey($attachable_invoice['id']);
} }

View File

@ -114,8 +114,7 @@ class RecurringExpensesCron
$exchange_rate = new CurrencyApi(); $exchange_rate = new CurrencyApi();
$expense->exchange_rate = $exchange_rate->exchangeRate($expense->currency_id, (int)$expense->company->settings->currency_id, Carbon::parse($expense->date)); $expense->exchange_rate = $exchange_rate->exchangeRate($expense->currency_id, (int)$expense->company->settings->currency_id, Carbon::parse($expense->date));
} } else {
else {
$expense->exchange_rate = 1; $expense->exchange_rate = 1;
} }

View File

@ -12,7 +12,10 @@ use Illuminate\Foundation\Bus\Dispatchable;
class QuickbooksIngest implements ShouldQueue class QuickbooksIngest implements ShouldQueue
{ {
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; use Dispatchable;
use InteractsWithQueue;
use Queueable;
use SerializesModels;
protected $engine; protected $engine;
protected $request; protected $request;
@ -35,7 +38,7 @@ class QuickbooksIngest implements ShouldQueue
MultiDB::setDb($this->company->db); MultiDB::setDb($this->company->db);
set_time_limit(0); set_time_limit(0);
$engine = new Quickbooks(['import_type' => 'client', 'hash'=> $this->request['hash'] ], $this->company); $engine = new Quickbooks(['import_type' => 'client', 'hash' => $this->request['hash'] ], $this->company);
foreach ($this->request['import_types'] as $entity) { foreach ($this->request['import_types'] as $entity) {
$engine->import($entity); $engine->import($entity);
} }

View File

@ -48,12 +48,11 @@ class TaskAssigned implements ShouldQueue
$company_user = $this->task->assignedCompanyUser(); $company_user = $this->task->assignedCompanyUser();
if(($company_user instanceof CompanyUser) && $this->findEntityAssignedNotification($company_user, 'task')) if(($company_user instanceof CompanyUser) && $this->findEntityAssignedNotification($company_user, 'task')) {
{
$mo = new EmailObject(); $mo = new EmailObject();
$mo->subject = ctrans('texts.task_assigned_subject', ['task' => $this->task->number, 'date' => now()->setTimeZone($this->task->company->timezone()->name)->format($this->task->company->date_format()) ]); $mo->subject = ctrans('texts.task_assigned_subject', ['task' => $this->task->number, 'date' => now()->setTimeZone($this->task->company->timezone()->name)->format($this->task->company->date_format()) ]);
$mo->body = ctrans('texts.task_assigned_body',['task' => $this->task->number, 'description' => $this->task->description ?? '', 'client' => $this->task->client ? $this->task->client->present()->name() : ' ']); $mo->body = ctrans('texts.task_assigned_body', ['task' => $this->task->number, 'description' => $this->task->description ?? '', 'client' => $this->task->client ? $this->task->client->present()->name() : ' ']);
$mo->text_body = ctrans('texts.task_assigned_body',['task' => $this->task->number, 'description' => $this->task->description ?? '', 'client' => $this->task->client ? $this->task->client->present()->name() : ' ']); $mo->text_body = ctrans('texts.task_assigned_body', ['task' => $this->task->number, 'description' => $this->task->description ?? '', 'client' => $this->task->client ? $this->task->client->present()->name() : ' ']);
$mo->company_key = $this->task->company->company_key; $mo->company_key = $this->task->company->company_key;
$mo->html_template = 'email.template.generic'; $mo->html_template = 'email.template.generic';
$mo->to = [new Address($this->task->assigned_user->email, $this->task->assigned_user->present()->name())]; $mo->to = [new Address($this->task->assigned_user->email, $this->task->assigned_user->present()->name())];

View File

@ -363,10 +363,11 @@ class BillingPortalPurchase extends Component
$method_values = array_column($this->methods, 'is_paypal'); $method_values = array_column($this->methods, 'is_paypal');
$is_paypal = in_array('1', $method_values); $is_paypal = in_array('1', $method_values);
if($is_paypal && !$this->steps['check_rff']) if($is_paypal && !$this->steps['check_rff']) {
$this->rff(); $this->rff();
elseif(!$this->steps['check_rff']) } elseif(!$this->steps['check_rff']) {
$this->steps['fetched_payment_methods'] = true; $this->steps['fetched_payment_methods'] = true;
}
$this->heading_text = ctrans('texts.payment_methods'); $this->heading_text = ctrans('texts.payment_methods');

View File

@ -515,8 +515,7 @@ class BillingPortalPurchasev2 extends Component
strlen($this->contact_email ?? '') == 0 || strlen($this->contact_email ?? '') == 0 ||
strlen($this->client_city ?? '') == 0 || strlen($this->client_city ?? '') == 0 ||
strlen($this->client_postal_code ?? '') == 0 strlen($this->client_postal_code ?? '') == 0
) ) {
{
$this->check_rff = true; $this->check_rff = true;
} }

View File

@ -143,7 +143,7 @@ class InvoicePay extends Component
$this->payment_method_accepted = true; $this->payment_method_accepted = true;
$company_gateway = CompanyGateway::find($company_gateway_id); $company_gateway = CompanyGateway::query()->find($company_gateway_id);
$this->checkRequiredFields($company_gateway); $this->checkRequiredFields($company_gateway);
} }
@ -240,8 +240,9 @@ class InvoicePay extends Component
nlog($this->invoices); nlog($this->invoices);
if(is_array($this->invoices)) if(is_array($this->invoices)) {
$this->invoices = Invoice::find($this->transformKeys($this->invoices)); $this->invoices = Invoice::find($this->transformKeys($this->invoices));
}
$invoices = $this->invoices->filter(function ($i) { $invoices = $this->invoices->filter(function ($i) {
$i = $i->service() $i = $i->service()

View File

@ -16,10 +16,8 @@ use Livewire\Component;
class Signature extends Component class Signature extends Component
{ {
public function render() public function render()
{ {
return render('components.livewire.signature'); return render('components.livewire.signature');
} }
} }

View File

@ -18,7 +18,6 @@ use Livewire\Component;
class UnderOverPayment extends Component class UnderOverPayment extends Component
{ {
use WithSecureContext; use WithSecureContext;
public $payableAmount; public $payableAmount;
@ -45,29 +44,28 @@ class UnderOverPayment extends Component
$settings = $this->getContext()['settings']; $settings = $this->getContext()['settings'];
foreach($payableInvoices as $key => $invoice){ foreach($payableInvoices as $key => $invoice) {
$payableInvoices[$key]['amount'] = Number::parseFloat($invoice['formatted_amount']); $payableInvoices[$key]['amount'] = Number::parseFloat($invoice['formatted_amount']);
} }
$input_amount = collect($payableInvoices)->sum('amount'); $input_amount = collect($payableInvoices)->sum('amount');
if($settings->client_portal_allow_under_payment && $settings->client_portal_under_payment_minimum != 0) if($settings->client_portal_allow_under_payment && $settings->client_portal_under_payment_minimum != 0) {
{ if($input_amount <= $settings->client_portal_under_payment_minimum) {
if($input_amount <= $settings->client_portal_under_payment_minimum){
// return error message under payment too low. // return error message under payment too low.
$this->errors = ctrans('texts.minimum_required_payment', ['amount' => $settings->client_portal_under_payment_minimum]); $this->errors = ctrans('texts.minimum_required_payment', ['amount' => $settings->client_portal_under_payment_minimum]);
$this->dispatch('errorMessageUpdate', errors: $this->errors); $this->dispatch('errorMessageUpdate', errors: $this->errors);
} }
} }
if(!$settings->client_portal_allow_over_payment && ($input_amount > $this->invoice_amount)){ if(!$settings->client_portal_allow_over_payment && ($input_amount > $this->invoice_amount)) {
$this->errors = ctrans('texts.over_payments_disabled'); $this->errors = ctrans('texts.over_payments_disabled');
$this->dispatch('errorMessageUpdate', errors: $this->errors); $this->dispatch('errorMessageUpdate', errors: $this->errors);
} }
if(!$this->errors){ if(!$this->errors) {
$this->setContext('payable_invoices', $payableInvoices); $this->setContext('payable_invoices', $payableInvoices);
$this->dispatch('payable-amount', payable_amount: $input_amount ); $this->dispatch('payable-amount', payable_amount: $input_amount);
} }
} }

View File

@ -197,8 +197,8 @@ class RequiredClientInfo extends Component
MultiDB::setDb($this->db); MultiDB::setDb($this->db);
$contact = ClientContact::withTrashed()->with(['client' => function ($query) { $contact = ClientContact::withTrashed()->with(['client' => function ($query) {
$query->without('gateway_tokens', 'documents', 'contacts.company', 'contacts'); // Exclude 'grandchildren' relation of 'client' $query->without('gateway_tokens', 'documents', 'contacts.company', 'contacts'); // Exclude 'grandchildren' relation of 'client'
}])->find($this->contact_id); }])->find($this->contact_id);
$this->company_gateway = CompanyGateway::withTrashed()->with('company')->find($this->company_gateway_id); $this->company_gateway = CompanyGateway::withTrashed()->with('company')->find($this->company_gateway_id);
$company = $this->company_gateway->company; $company = $this->company_gateway->company;

View File

@ -26,7 +26,7 @@ class TemplateEmail extends Mailable
/** @var \App\Models\Client $client */ /** @var \App\Models\Client $client */
private $client; private $client;
/** @var \App\Models\ClientContact | \App\Models\VendorContact $contact */ /** @var \App\Models\ClientContact | \App\Models\VendorContact $contact */
private $contact; private $contact;
@ -65,7 +65,7 @@ class TemplateEmail extends Mailable
} }
$link_string = '<ul>'; $link_string = '<ul>';
$link_string .= "<li>{ctrans('texts.download_files')}</li>"; $link_string .= "<li>{ctrans('texts.download_files')}</li>";
foreach ($this->build_email->getAttachmentLinks() as $link) { foreach ($this->build_email->getAttachmentLinks() as $link) {
$link_string .= "<li>{$link}</li>"; $link_string .= "<li>{$link}</li>";
} }

View File

@ -449,8 +449,9 @@ class Activity extends StaticModel
$replacements['created_at'] = $this->created_at ?? ''; $replacements['created_at'] = $this->created_at ?? '';
$replacements['ip'] = $this->ip ?? ''; $replacements['ip'] = $this->ip ?? '';
if($this->activity_type_id == 141) if($this->activity_type_id == 141) {
$replacements = $this->harvestNoteEntities($replacements); $replacements = $this->harvestNoteEntities($replacements);
}
return $replacements; return $replacements;
@ -472,12 +473,12 @@ class Activity extends StaticModel
]; ];
foreach($entities as $entity) foreach($entities as $entity) {
{
$entity_key = substr($entity, 1); $entity_key = substr($entity, 1);
if($this?->{$entity_key}) if($this?->{$entity_key}) {
$replacements = array_merge($replacements, $this->matchVar($entity)); $replacements = array_merge($replacements, $this->matchVar($entity));
}
} }

View File

@ -374,10 +374,9 @@ class BaseModel extends Model
$files->push($company_docs); $files->push($company_docs);
try{ try {
$pdf = (new PdfMerge($files->flatten()->toArray()))->run(); $pdf = (new PdfMerge($files->flatten()->toArray()))->run();
} } catch(\Exception $e) {
catch(\Exception $e){
nlog("Exception:: BaseModel:: PdfMerge::" . $e->getMessage()); nlog("Exception:: BaseModel:: PdfMerge::" . $e->getMessage());
} }

View File

@ -118,7 +118,7 @@ use Laracasts\Presenter\PresentableTrait;
* @property string|null $smtp_port * @property string|null $smtp_port
* @property string|null $smtp_encryption * @property string|null $smtp_encryption
* @property string|null $smtp_local_domain * @property string|null $smtp_local_domain
* @property string|null $quickbooks * @property object|null $quickbooks
* @property boolean $smtp_verify_peer * @property boolean $smtp_verify_peer
* @property-read \App\Models\Account $account * @property-read \App\Models\Account $account
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Activity> $activities * @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Activity> $activities

View File

@ -106,8 +106,8 @@ class Gateway extends StaticModel
} elseif ($this->id == 62) { } elseif ($this->id == 62) {
$link = 'https://docs.btcpayserver.org/InvoiceNinja/'; $link = 'https://docs.btcpayserver.org/InvoiceNinja/';
} elseif ($this->id == 63) { } elseif ($this->id == 63) {
$link = 'https://rotessa.com'; $link = 'https://rotessa.com';
} }
return $link; return $link;
} }
@ -226,15 +226,15 @@ class Gateway extends StaticModel
return [ return [
GatewayType::CRYPTO => ['refund' => true, 'token_billing' => false, 'webhooks' => ['confirmed', 'paid_out', 'failed', 'fulfilled']], GatewayType::CRYPTO => ['refund' => true, 'token_billing' => false, 'webhooks' => ['confirmed', 'paid_out', 'failed', 'fulfilled']],
]; //BTCPay ]; //BTCPay
case 63: case 63:
return [ return [
GatewayType::BANK_TRANSFER => [ GatewayType::BANK_TRANSFER => [
'refund' => false, 'refund' => false,
'token_billing' => true, 'token_billing' => true,
'webhooks' => [], 'webhooks' => [],
], ],
GatewayType::ACSS => ['refund' => false, 'token_billing' => true, 'webhooks' => []] GatewayType::ACSS => ['refund' => false, 'token_billing' => true, 'webhooks' => []]
]; // Rotessa ]; // Rotessa
default: default:
return []; return [];
} }

View File

@ -431,9 +431,9 @@ class Invoice extends BaseModel
public function isPayable(): bool public function isPayable(): bool
{ {
if($this->is_deleted || $this->status_id == self::STATUS_PAID) if($this->is_deleted || $this->status_id == self::STATUS_PAID) {
return false; return false;
elseif ($this->status_id == self::STATUS_DRAFT && $this->is_deleted == false) { } elseif ($this->status_id == self::STATUS_DRAFT && $this->is_deleted == false) {
return true; return true;
} elseif ($this->status_id == self::STATUS_SENT && $this->is_deleted == false) { } elseif ($this->status_id == self::STATUS_SENT && $this->is_deleted == false) {
return true; return true;

View File

@ -408,21 +408,21 @@ class Quote extends BaseModel
$client->getSetting('quote_num_days_reminder1') $client->getSetting('quote_num_days_reminder1')
) && ! $this->reminder1_sent) { ) && ! $this->reminder1_sent) {
return 'reminder1'; return 'reminder1';
// } elseif ($this->inReminderWindow( // } elseif ($this->inReminderWindow(
// $client->getSetting('schedule_reminder2'), // $client->getSetting('schedule_reminder2'),
// $client->getSetting('num_days_reminder2') // $client->getSetting('num_days_reminder2')
// ) && ! $this->reminder2_sent) { // ) && ! $this->reminder2_sent) {
// return 'reminder2'; // return 'reminder2';
// } elseif ($this->inReminderWindow( // } elseif ($this->inReminderWindow(
// $client->getSetting('schedule_reminder3'), // $client->getSetting('schedule_reminder3'),
// $client->getSetting('num_days_reminder3') // $client->getSetting('num_days_reminder3')
// ) && ! $this->reminder3_sent) { // ) && ! $this->reminder3_sent) {
// return 'reminder3'; // return 'reminder3';
// } elseif ($this->checkEndlessReminder( // } elseif ($this->checkEndlessReminder(
// $this->reminder_last_sent, // $this->reminder_last_sent,
// $client->getSetting('endless_reminder_frequency_id') // $client->getSetting('endless_reminder_frequency_id')
// )) { // )) {
// return 'endless_reminder'; // return 'endless_reminder';
} else { } else {
return $entity_string; return $entity_string;
} }
@ -435,8 +435,9 @@ class Quote extends BaseModel
*/ */
public function canRemind(): bool public function canRemind(): bool
{ {
if (in_array($this->status_id, [self::STATUS_DRAFT, self::STATUS_APPROVED, self::STATUS_CONVERTED]) || $this->is_deleted) if (in_array($this->status_id, [self::STATUS_DRAFT, self::STATUS_APPROVED, self::STATUS_CONVERTED]) || $this->is_deleted) {
return false; return false;
}
return true; return true;

View File

@ -296,8 +296,7 @@ class Task extends BaseModel
$client_currency = $this->client->getSetting('currency_id'); $client_currency = $this->client->getSetting('currency_id');
$company_currency = $this->company->getSetting('currency_id'); $company_currency = $this->company->getSetting('currency_id');
if($client_currency != $company_currency) if($client_currency != $company_currency) {
{
$converter = new CurrencyApi(); $converter = new CurrencyApi();
return $converter->convert($this->taskValue(), $client_currency, $company_currency); return $converter->convert($this->taskValue(), $client_currency, $company_currency);
} }
@ -308,7 +307,7 @@ class Task extends BaseModel
public function taskValue(): float public function taskValue(): float
{ {
return round(($this->calcDuration() / 3600) * $this->getRate(),2); return round(($this->calcDuration() / 3600) * $this->getRate(), 2);
} }
public function processLogs() public function processLogs()
@ -374,8 +373,9 @@ class Task extends BaseModel
public function assignedCompanyUser() public function assignedCompanyUser()
{ {
if(!$this->assigned_user_id) if(!$this->assigned_user_id) {
return false; return false;
}
return CompanyUser::where('company_id', $this->company_id)->where('user_id', $this->assigned_user_id)->first(); return CompanyUser::where('company_id', $this->company_id)->where('user_id', $this->assigned_user_id)->first();
} }

View File

@ -66,7 +66,7 @@ class EmailQuotaNotification extends Notification
{ {
$content = "Email quota exceeded by Account {$this->account->key} \n"; $content = "Email quota exceeded by Account {$this->account->key} \n";
$owner = $this->account->companies()->first()->owner() ?? $this->account->users()->orderBy('id','asc')->first(); $owner = $this->account->companies()->first()->owner() ?? $this->account->users()->orderBy('id', 'asc')->first();
$owner_name = $owner->present()->name() ?? 'No Owner Found'; $owner_name = $owner->present()->name() ?? 'No Owner Found';
$owner_email = $owner->email ?? 'No Owner Email Found'; $owner_email = $owner->email ?? 'No Owner Email Found';

View File

@ -21,7 +21,6 @@ use App\Models\PaymentHash;
use App\Models\PaymentType; use App\Models\PaymentType;
use App\Models\SystemLog; use App\Models\SystemLog;
use App\PaymentDrivers\AuthorizePaymentDriver; use App\PaymentDrivers\AuthorizePaymentDriver;
use App\PaymentDrivers\Common\LivewireMethodInterface;
use App\Utils\Traits\MakesHash; use App\Utils\Traits\MakesHash;
use net\authorize\api\contract\v1\DeleteCustomerPaymentProfileRequest; use net\authorize\api\contract\v1\DeleteCustomerPaymentProfileRequest;
use net\authorize\api\contract\v1\DeleteCustomerProfileRequest; use net\authorize\api\contract\v1\DeleteCustomerProfileRequest;
@ -31,7 +30,7 @@ use net\authorize\api\controller\DeleteCustomerProfileController;
/** /**
* Class AuthorizeCreditCard. * Class AuthorizeCreditCard.
*/ */
class AuthorizeCreditCard implements LivewireMethodInterface class AuthorizeCreditCard
{ {
use MakesHash; use MakesHash;
@ -42,7 +41,7 @@ class AuthorizeCreditCard implements LivewireMethodInterface
$this->authorize = $authorize; $this->authorize = $authorize;
} }
public function paymentData(array $data): array public function processPaymentView($data)
{ {
$tokens = ClientGatewayToken::where('client_id', $this->authorize->client->id) $tokens = ClientGatewayToken::where('client_id', $this->authorize->client->id)
->where('company_gateway_id', $this->authorize->company_gateway->id) ->where('company_gateway_id', $this->authorize->company_gateway->id)
@ -55,13 +54,6 @@ class AuthorizeCreditCard implements LivewireMethodInterface
$data['public_client_id'] = $this->authorize->init()->getPublicClientKey(); $data['public_client_id'] = $this->authorize->init()->getPublicClientKey();
$data['api_login_id'] = $this->authorize->company_gateway->getConfigField('apiLoginId'); $data['api_login_id'] = $this->authorize->company_gateway->getConfigField('apiLoginId');
return $data;
}
public function processPaymentView($data)
{
$data = $this->paymentData($data);
return render('gateways.authorize.credit_card.pay', $data); return render('gateways.authorize.credit_card.pay', $data);
} }
@ -321,9 +313,4 @@ class AuthorizeCreditCard implements LivewireMethodInterface
'invoices' => $vars['invoices'], 'invoices' => $vars['invoices'],
]; ];
} }
public function livewirePaymentView(array $data): string
{
return 'gateways.authorize.credit_card.pay_livewire';
}
} }

View File

@ -14,7 +14,6 @@ namespace App\PaymentDrivers\BTCPay;
use App\Models\Payment; use App\Models\Payment;
use App\PaymentDrivers\BTCPayPaymentDriver; use App\PaymentDrivers\BTCPayPaymentDriver;
use App\PaymentDrivers\Common\LivewireMethodInterface;
use App\Utils\Traits\MakesHash; use App\Utils\Traits\MakesHash;
use App\PaymentDrivers\Common\MethodInterface; use App\PaymentDrivers\Common\MethodInterface;
use App\Http\Requests\ClientPortal\Payments\PaymentResponseRequest; use App\Http\Requests\ClientPortal\Payments\PaymentResponseRequest;
@ -25,7 +24,7 @@ use App\Services\Email\EmailObject;
use App\Services\Email\Email; use App\Services\Email\Email;
use Illuminate\Support\Facades\App; use Illuminate\Support\Facades\App;
class BTCPay implements MethodInterface, LivewireMethodInterface class BTCPay implements MethodInterface
{ {
use MakesHash; use MakesHash;
@ -50,7 +49,9 @@ class BTCPay implements MethodInterface, LivewireMethodInterface
public function paymentView($data) public function paymentView($data)
{ {
$data = $this->paymentData($data); $data['gateway'] = $this->driver_class;
$data['amount'] = $data['total']['amount_with_fee'];
$data['currency'] = $this->driver_class->client->getCurrencyCode();
return render('gateways.btcpay.pay', $data); return render('gateways.btcpay.pay', $data);
} }
@ -175,24 +176,4 @@ class BTCPay implements MethodInterface, LivewireMethodInterface
throw new PaymentFailed('Error during BTCPay refund : ' . $e->getMessage()); throw new PaymentFailed('Error during BTCPay refund : ' . $e->getMessage());
} }
} }
/**
* @inheritDoc
*/
public function livewirePaymentView(array $data): string
{
return 'gateways.btcpay.pay_livewire';
}
/**
* @inheritDoc
*/
public function paymentData(array $data): array
{
$data['gateway'] = $this->driver_class;
$data['amount'] = $data['total']['amount_with_fee'];
$data['currency'] = $this->driver_class->client->getCurrencyCode();
return $data;
}
} }

View File

@ -867,14 +867,4 @@ class BaseDriver extends AbstractPaymentDriver
{ {
} }
public function livewirePaymentView(array $data): string
{
return $this->payment_method->livewirePaymentView($data);
}
public function processPaymentViewData(array $data): array
{
return $this->payment_method->paymentData($data);
}
} }

View File

@ -20,12 +20,11 @@ use App\Models\Payment;
use App\Models\PaymentType; use App\Models\PaymentType;
use App\Models\SystemLog; use App\Models\SystemLog;
use App\PaymentDrivers\BraintreePaymentDriver; use App\PaymentDrivers\BraintreePaymentDriver;
use App\PaymentDrivers\Common\LivewireMethodInterface;
use App\PaymentDrivers\Common\MethodInterface; use App\PaymentDrivers\Common\MethodInterface;
use App\Utils\Traits\MakesHash; use App\Utils\Traits\MakesHash;
use Illuminate\Http\Request; use Illuminate\Http\Request;
class ACH implements MethodInterface, LivewireMethodInterface class ACH implements MethodInterface
{ {
use MakesHash; use MakesHash;
@ -98,7 +97,10 @@ class ACH implements MethodInterface, LivewireMethodInterface
public function paymentView(array $data) public function paymentView(array $data)
{ {
$data = $this->paymentData($data); $data['gateway'] = $this->braintree;
$data['currency'] = $this->braintree->client->getCurrencyCode();
$data['payment_method_id'] = GatewayType::BANK_TRANSFER;
$data['amount'] = $this->braintree->payment_hash->data->amount_with_fee;
return render('gateways.braintree.ach.pay', $data); return render('gateways.braintree.ach.pay', $data);
} }
@ -179,24 +181,4 @@ class ACH implements MethodInterface, LivewireMethodInterface
throw new PaymentFailed($response->transaction->additionalProcessorResponse, $response->transaction->processorResponseCode); throw new PaymentFailed($response->transaction->additionalProcessorResponse, $response->transaction->processorResponseCode);
} }
/**
* @inheritDoc
*/
public function livewirePaymentView(array $data): string
{
return 'gateways.braintree.ach.pay_livewire';
}
/**
* @inheritDoc
*/
public function paymentData(array $data): array
{
$data['gateway'] = $this->braintree;
$data['currency'] = $this->braintree->client->getCurrencyCode();
$data['payment_method_id'] = GatewayType::BANK_TRANSFER;
$data['amount'] = $this->braintree->payment_hash->data->amount_with_fee;
return $data;
}
} }

View File

@ -21,9 +21,8 @@ use App\Models\Payment;
use App\Models\PaymentType; use App\Models\PaymentType;
use App\Models\SystemLog; use App\Models\SystemLog;
use App\PaymentDrivers\BraintreePaymentDriver; use App\PaymentDrivers\BraintreePaymentDriver;
use App\PaymentDrivers\Common\LivewireMethodInterface;
class CreditCard implements LivewireMethodInterface class CreditCard
{ {
/** /**
* @var BraintreePaymentDriver * @var BraintreePaymentDriver
@ -77,7 +76,6 @@ class CreditCard implements LivewireMethodInterface
public function paymentView(array $data) public function paymentView(array $data)
{ {
<<<<<<< HEAD
$data['gateway'] = $this->braintree; $data['gateway'] = $this->braintree;
$data['client_token'] = $this->braintree->gateway->clientToken()->generate(); $data['client_token'] = $this->braintree->gateway->clientToken()->generate();
$data['threeds'] = $this->threeDParameters($data); $data['threeds'] = $this->threeDParameters($data);
@ -89,9 +87,6 @@ class CreditCard implements LivewireMethodInterface
'merchantAccountId' => $this->braintree->company_gateway->getConfigField('merchantAccountId'), 'merchantAccountId' => $this->braintree->company_gateway->getConfigField('merchantAccountId'),
]); ]);
} }
=======
$data = $this->paymentData($data);
>>>>>>> new_payment_flow
return render('gateways.braintree.credit_card.pay', $data); return render('gateways.braintree.credit_card.pay', $data);
} }
@ -283,32 +278,4 @@ class CreditCard implements LivewireMethodInterface
return $this->braintree->processInternallyFailedPayment($this->braintree, $e); return $this->braintree->processInternallyFailedPayment($this->braintree, $e);
} }
} }
/**
* @inheritDoc
*/
public function livewirePaymentView(array $data): string
{
return 'gateways.braintree.credit_card.pay_livewire';
}
/**
* @inheritDoc
*/
public function paymentData(array $data): array
{
$data['gateway'] = $this->braintree;
$data['client_token'] = $this->braintree->gateway->clientToken()->generate();
$data['threeds'] = $this->threeDParameters($data);
$data['threeds_enable'] = $this->braintree->company_gateway->getConfigField('threeds') ? "true" : "false";
if ($this->braintree->company_gateway->getConfigField('merchantAccountId')) {
/** https://developer.paypal.com/braintree/docs/reference/request/client-token/generate#merchant_account_id */
$data['client_token'] = $this->braintree->gateway->clientToken()->generate([
'merchantAccountId' => $this->braintree->company_gateway->getConfigField('merchantAccountId'),
]);
}
return $data;
}
} }

View File

@ -10,9 +10,8 @@ use App\Models\Payment;
use App\Models\PaymentType; use App\Models\PaymentType;
use App\Models\SystemLog; use App\Models\SystemLog;
use App\PaymentDrivers\BraintreePaymentDriver; use App\PaymentDrivers\BraintreePaymentDriver;
use App\PaymentDrivers\Common\LivewireMethodInterface;
class PayPal implements LivewireMethodInterface class PayPal
{ {
/** /**
* @var BraintreePaymentDriver * @var BraintreePaymentDriver
@ -46,7 +45,8 @@ class PayPal implements LivewireMethodInterface
*/ */
public function paymentView(array $data) public function paymentView(array $data)
{ {
$data = $this->paymentData($data); $data['gateway'] = $this->braintree;
$data['client_token'] = $this->braintree->gateway->clientToken()->generate();
return render('gateways.braintree.paypal.pay', $data); return render('gateways.braintree.paypal.pay', $data);
} }
@ -188,23 +188,4 @@ class PayPal implements LivewireMethodInterface
return $this->braintree->processInternallyFailedPayment($this->braintree, $e); return $this->braintree->processInternallyFailedPayment($this->braintree, $e);
} }
} }
/**
* @inheritDoc
*/
public function livewirePaymentView(array $data): string
{
return 'gateways.braintree.paypal.pay_livewire';
}
/**
* @inheritDoc
*/
public function paymentData(array $data): array
{
$data['gateway'] = $this->braintree;
$data['client_token'] = $this->braintree->gateway->clientToken()->generate();
return $data;
}
} }

View File

@ -19,7 +19,6 @@ use App\Models\ClientGatewayToken;
use App\Models\GatewayType; use App\Models\GatewayType;
use App\Models\SystemLog; use App\Models\SystemLog;
use App\PaymentDrivers\CheckoutComPaymentDriver; use App\PaymentDrivers\CheckoutComPaymentDriver;
use App\PaymentDrivers\Common\LivewireMethodInterface;
use App\PaymentDrivers\Common\MethodInterface; use App\PaymentDrivers\Common\MethodInterface;
use App\Utils\Traits\MakesHash; use App\Utils\Traits\MakesHash;
use Checkout\CheckoutApiException; use Checkout\CheckoutApiException;
@ -33,7 +32,7 @@ use Illuminate\Contracts\View\Factory;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\View\View; use Illuminate\View\View;
class CreditCard implements MethodInterface, LivewireMethodInterface class CreditCard implements MethodInterface
{ {
use Utilities; use Utilities;
use MakesHash; use MakesHash;
@ -141,7 +140,7 @@ class CreditCard implements MethodInterface, LivewireMethodInterface
} }
} }
public function paymentData(array $data): array public function paymentView($data)
{ {
$data['gateway'] = $this->checkout; $data['gateway'] = $this->checkout;
$data['company_gateway'] = $this->checkout->company_gateway; $data['company_gateway'] = $this->checkout->company_gateway;
@ -151,25 +150,9 @@ class CreditCard implements MethodInterface, LivewireMethodInterface
$data['raw_value'] = $data['total']['amount_with_fee']; $data['raw_value'] = $data['total']['amount_with_fee'];
$data['customer_email'] = $this->checkout->client->present()->email(); $data['customer_email'] = $this->checkout->client->present()->email();
return $data;
}
public function paymentView($data, $livewire = false)
{
$data = $this->paymentData($data);
if ($livewire) {
return render('gateways.checkout.credit_card.pay_livewire', $data);
}
return render('gateways.checkout.credit_card.pay', $data); return render('gateways.checkout.credit_card.pay', $data);
} }
public function livewirePaymentView(array $data): string
{
return 'gateways.checkout.credit_card.livewire_pay';
}
public function paymentResponse(PaymentResponseRequest $request) public function paymentResponse(PaymentResponseRequest $request)
{ {
$state = [ $state = [

View File

@ -12,7 +12,6 @@
namespace App\PaymentDrivers; namespace App\PaymentDrivers;
use App\PaymentDrivers\Common\LivewireMethodInterface;
use Exception; use Exception;
use App\Models\Company; use App\Models\Company;
use App\Models\Invoice; use App\Models\Invoice;

View File

@ -17,11 +17,10 @@ use App\Jobs\Util\SystemLogger;
use App\Models\GatewayType; use App\Models\GatewayType;
use App\Models\PaymentType; use App\Models\PaymentType;
use App\Models\SystemLog; use App\Models\SystemLog;
use App\PaymentDrivers\Common\LivewireMethodInterface;
use App\PaymentDrivers\EwayPaymentDriver; use App\PaymentDrivers\EwayPaymentDriver;
use App\Utils\Traits\MakesHash; use App\Utils\Traits\MakesHash;
class CreditCard implements LivewireMethodInterface class CreditCard
{ {
use MakesHash; use MakesHash;
@ -103,18 +102,11 @@ class CreditCard implements LivewireMethodInterface
return $token; return $token;
} }
public function paymentData(array $data): array public function paymentView($data)
{ {
$data['gateway'] = $this->eway_driver; $data['gateway'] = $this->eway_driver;
$data['public_api_key'] = $this->eway_driver->company_gateway->getConfigField('publicApiKey'); $data['public_api_key'] = $this->eway_driver->company_gateway->getConfigField('publicApiKey');
return $data;
}
public function paymentView($data)
{
$data = $this->paymentData($data);
return render('gateways.eway.pay', $data); return render('gateways.eway.pay', $data);
} }
@ -284,8 +276,4 @@ class CreditCard implements LivewireMethodInterface
return $payment; return $payment;
} }
public function livewirePaymentView(array $data): string
{
return 'gateways.eway.pay_livewire';
}
} }

View File

@ -19,12 +19,11 @@ use App\Models\Payment;
use App\Models\PaymentHash; use App\Models\PaymentHash;
use App\Models\PaymentType; use App\Models\PaymentType;
use App\Models\SystemLog; use App\Models\SystemLog;
use App\PaymentDrivers\Common\LivewireMethodInterface;
use App\PaymentDrivers\FortePaymentDriver; use App\PaymentDrivers\FortePaymentDriver;
use App\Utils\Traits\MakesHash; use App\Utils\Traits\MakesHash;
use Illuminate\Support\Facades\Validator; use Illuminate\Support\Facades\Validator;
class ACH implements LivewireMethodInterface class ACH
{ {
use MakesHash; use MakesHash;
@ -80,8 +79,10 @@ class ACH implements LivewireMethodInterface
public function paymentView(array $data) public function paymentView(array $data)
{ {
$data = $this->paymentData($data); $this->forte->payment_hash->data = array_merge((array) $this->forte->payment_hash->data, $data);
$this->forte->payment_hash->save();
$data['gateway'] = $this->forte;
return render('gateways.forte.ach.pay', $data); return render('gateways.forte.ach.pay', $data);
} }
@ -174,25 +175,4 @@ class ACH implements LivewireMethodInterface
return redirect()->route('client.payments.show', ['payment' => $payment->hashed_id]); return redirect()->route('client.payments.show', ['payment' => $payment->hashed_id]);
} }
/**
* @inheritDoc
*/
public function livewirePaymentView(array $data): string
{
return 'gateways.forte.ach.pay_livewire';
}
/**
* @inheritDoc
*/
public function paymentData(array $data): array
{
$this->forte->payment_hash->data = array_merge((array) $this->forte->payment_hash->data, $data);
$this->forte->payment_hash->save();
$data['gateway'] = $this->forte;
return $data;
}
} }

View File

@ -20,12 +20,11 @@ use App\Models\Payment;
use App\Models\PaymentHash; use App\Models\PaymentHash;
use App\Models\PaymentType; use App\Models\PaymentType;
use App\Models\SystemLog; use App\Models\SystemLog;
use App\PaymentDrivers\Common\LivewireMethodInterface;
use App\PaymentDrivers\FortePaymentDriver; use App\PaymentDrivers\FortePaymentDriver;
use App\Utils\Traits\MakesHash; use App\Utils\Traits\MakesHash;
use Illuminate\Support\Facades\Validator; use Illuminate\Support\Facades\Validator;
class CreditCard implements LivewireMethodInterface class CreditCard
{ {
use MakesHash; use MakesHash;
@ -158,8 +157,10 @@ class CreditCard implements LivewireMethodInterface
public function paymentView(array $data) public function paymentView(array $data)
{ {
$data = $this->paymentData($data); $this->forte->payment_hash->data = array_merge((array) $this->forte->payment_hash->data, $data);
$this->forte->payment_hash->save();
$data['gateway'] = $this->forte;
return render('gateways.forte.credit_card.pay', $data); return render('gateways.forte.credit_card.pay', $data);
} }
@ -286,25 +287,4 @@ class CreditCard implements LivewireMethodInterface
return redirect()->route('client.payments.show', ['payment' => $payment->hashed_id]); return redirect()->route('client.payments.show', ['payment' => $payment->hashed_id]);
} }
/**
* @inheritDoc
*/
public function livewirePaymentView(array $data): string
{
return 'gateways.forte.credit_card.pay_livewire';
}
/**
* @inheritDoc
*/
public function paymentData(array $data): array
{
$this->forte->payment_hash->data = array_merge((array) $this->forte->payment_hash->data, $data);
$this->forte->payment_hash->save();
$data['gateway'] = $this->forte;
return $data;
}
} }

View File

@ -20,7 +20,6 @@ use App\Models\Invoice;
use App\Models\Payment; use App\Models\Payment;
use App\Models\PaymentType; use App\Models\PaymentType;
use App\Models\SystemLog; use App\Models\SystemLog;
use App\PaymentDrivers\Common\LivewireMethodInterface;
use App\PaymentDrivers\Common\MethodInterface; use App\PaymentDrivers\Common\MethodInterface;
use App\PaymentDrivers\GoCardlessPaymentDriver; use App\PaymentDrivers\GoCardlessPaymentDriver;
use App\Utils\Traits\MakesHash; use App\Utils\Traits\MakesHash;
@ -32,7 +31,7 @@ use Illuminate\Routing\Redirector;
use Illuminate\View\View; use Illuminate\View\View;
//@deprecated //@deprecated
class ACH implements MethodInterface, LivewireMethodInterface class ACH implements MethodInterface
{ {
use MakesHash; use MakesHash;
@ -147,7 +146,9 @@ class ACH implements MethodInterface, LivewireMethodInterface
*/ */
public function paymentView(array $data): View public function paymentView(array $data): View
{ {
$data = $this->paymentData($data); $data['gateway'] = $this->go_cardless;
$data['amount'] = $this->go_cardless->convertToGoCardlessAmount($data['total']['amount_with_fee'], $this->go_cardless->client->currency()->precision);
$data['currency'] = $this->go_cardless->client->getCurrencyCode();
return render('gateways.gocardless.ach.pay', $data); return render('gateways.gocardless.ach.pay', $data);
} }
@ -256,23 +257,4 @@ class ACH implements MethodInterface, LivewireMethodInterface
throw new PaymentFailed('Failed to process the payment.', 500); throw new PaymentFailed('Failed to process the payment.', 500);
} }
/**
* @inheritDoc
*/
public function livewirePaymentView(array $data): string
{
return 'gateways.gocardless.ach.pay_livewire';
}
/**
* @inheritDoc
*/
public function paymentData(array $data): array
{
$data['gateway'] = $this->go_cardless;
$data['amount'] = $this->go_cardless->convertToGoCardlessAmount($data['total']['amount_with_fee'], $this->go_cardless->client->currency()->precision);
$data['currency'] = $this->go_cardless->client->getCurrencyCode();
return $data;
}
} }

View File

@ -21,7 +21,6 @@ use App\Models\Invoice;
use App\Models\Payment; use App\Models\Payment;
use App\Models\PaymentType; use App\Models\PaymentType;
use App\Models\SystemLog; use App\Models\SystemLog;
use App\PaymentDrivers\Common\LivewireMethodInterface;
use App\PaymentDrivers\Common\MethodInterface; use App\PaymentDrivers\Common\MethodInterface;
use App\PaymentDrivers\GoCardlessPaymentDriver; use App\PaymentDrivers\GoCardlessPaymentDriver;
use App\Utils\Traits\MakesHash; use App\Utils\Traits\MakesHash;
@ -30,7 +29,7 @@ use Illuminate\Http\Request;
use Illuminate\Routing\Redirector; use Illuminate\Routing\Redirector;
use Illuminate\View\View; use Illuminate\View\View;
class DirectDebit implements MethodInterface, LivewireMethodInterface class DirectDebit implements MethodInterface
{ {
use MakesHash; use MakesHash;
@ -219,7 +218,9 @@ class DirectDebit implements MethodInterface, LivewireMethodInterface
*/ */
public function paymentView(array $data): View public function paymentView(array $data): View
{ {
$data = $this->paymentData($data); $data['gateway'] = $this->go_cardless;
$data['amount'] = $this->go_cardless->convertToGoCardlessAmount($data['total']['amount_with_fee'], $this->go_cardless->client->currency()->precision);
$data['currency'] = $this->go_cardless->client->getCurrencyCode();
return render('gateways.gocardless.direct_debit.pay', $data); return render('gateways.gocardless.direct_debit.pay', $data);
} }
@ -329,24 +330,4 @@ class DirectDebit implements MethodInterface, LivewireMethodInterface
throw new PaymentFailed('Failed to process the payment.', 500); throw new PaymentFailed('Failed to process the payment.', 500);
} }
/**
* @inheritDoc
*/
public function livewirePaymentView(array $data): string
{
return 'gateways.gocardless.direct_debit.pay_livewire';
}
/**
* @inheritDoc
*/
public function paymentData(array $data): array
{
$data['gateway'] = $this->go_cardless;
$data['amount'] = $this->go_cardless->convertToGoCardlessAmount($data['total']['amount_with_fee'], $this->go_cardless->client->currency()->precision);
$data['currency'] = $this->go_cardless->client->getCurrencyCode();
return $data;
}
} }

View File

@ -9,14 +9,13 @@ use App\Models\GatewayType;
use App\Models\Payment; use App\Models\Payment;
use App\Models\PaymentType; use App\Models\PaymentType;
use App\Models\SystemLog; use App\Models\SystemLog;
use App\PaymentDrivers\Common\LivewireMethodInterface;
use App\PaymentDrivers\Common\MethodInterface; use App\PaymentDrivers\Common\MethodInterface;
use App\PaymentDrivers\GoCardlessPaymentDriver; use App\PaymentDrivers\GoCardlessPaymentDriver;
use Illuminate\Contracts\Container\BindingResolutionException; use Illuminate\Contracts\Container\BindingResolutionException;
use Illuminate\Http\RedirectResponse; use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request; use Illuminate\Http\Request;
class InstantBankPay implements MethodInterface, LivewireMethodInterface class InstantBankPay implements MethodInterface
{ {
protected GoCardlessPaymentDriver $go_cardless; protected GoCardlessPaymentDriver $go_cardless;
@ -195,8 +194,9 @@ class InstantBankPay implements MethodInterface, LivewireMethodInterface
* Process unsuccessful payments for Direct Debit. * Process unsuccessful payments for Direct Debit.
* *
* @param ResourcesPayment $payment * @param ResourcesPayment $payment
* @return never
*/ */
public function processUnsuccessfulPayment(\GoCardlessPro\Resources\Payment $payment): void public function processUnsuccessfulPayment(\GoCardlessPro\Resources\Payment $payment)
{ {
PaymentFailureMailer::dispatch($this->go_cardless->client, $payment->status, $this->go_cardless->client->company, $this->go_cardless->payment_hash->data->amount_with_fee); PaymentFailureMailer::dispatch($this->go_cardless->client, $payment->status, $this->go_cardless->client->company, $this->go_cardless->payment_hash->data->amount_with_fee);
@ -221,24 +221,4 @@ class InstantBankPay implements MethodInterface, LivewireMethodInterface
$this->go_cardless->client->company, $this->go_cardless->client->company,
); );
} }
/**
* @inheritDoc
*/
public function livewirePaymentView(array $data): string
{
// not supported, this is offsite payment method.
return '';
}
/**
* @inheritDoc
*/
public function paymentData(array $data): array
{
$this->paymentView($data);
return $data;
}
} }

View File

@ -20,7 +20,6 @@ use App\Models\Invoice;
use App\Models\Payment; use App\Models\Payment;
use App\Models\PaymentType; use App\Models\PaymentType;
use App\Models\SystemLog; use App\Models\SystemLog;
use App\PaymentDrivers\Common\LivewireMethodInterface;
use App\PaymentDrivers\Common\MethodInterface; use App\PaymentDrivers\Common\MethodInterface;
use App\PaymentDrivers\GoCardlessPaymentDriver; use App\PaymentDrivers\GoCardlessPaymentDriver;
use App\Utils\Traits\MakesHash; use App\Utils\Traits\MakesHash;
@ -30,7 +29,7 @@ use Illuminate\Http\Request;
use Illuminate\Routing\Redirector; use Illuminate\Routing\Redirector;
use Illuminate\View\View; use Illuminate\View\View;
class SEPA implements MethodInterface, LivewireMethodInterface class SEPA implements MethodInterface
{ {
use MakesHash; use MakesHash;
@ -146,7 +145,9 @@ class SEPA implements MethodInterface, LivewireMethodInterface
*/ */
public function paymentView(array $data): View public function paymentView(array $data): View
{ {
$data = $this->paymentData($data); $data['gateway'] = $this->go_cardless;
$data['amount'] = $this->go_cardless->convertToGoCardlessAmount($data['total']['amount_with_fee'], $this->go_cardless->client->currency()->precision);
$data['currency'] = $this->go_cardless->client->getCurrencyCode();
return render('gateways.gocardless.sepa.pay', $data); return render('gateways.gocardless.sepa.pay', $data);
} }
@ -256,24 +257,4 @@ class SEPA implements MethodInterface, LivewireMethodInterface
throw new PaymentFailed('Failed to process the payment.', 500); throw new PaymentFailed('Failed to process the payment.', 500);
} }
/**
* @inheritDoc
*/
public function livewirePaymentView(array $data): string
{
return 'gateways.gocardless.sepa.pay_livewire';
}
/**
* @inheritDoc
*/
public function paymentData(array $data): array
{
$data['gateway'] = $this->go_cardless;
$data['amount'] = $this->go_cardless->convertToGoCardlessAmount($data['total']['amount_with_fee'], $this->go_cardless->client->currency()->precision);
$data['currency'] = $this->go_cardless->client->getCurrencyCode();
return $data;
}
} }

View File

@ -19,14 +19,13 @@ use App\Models\GatewayType;
use App\Models\Payment; use App\Models\Payment;
use App\Models\PaymentType; use App\Models\PaymentType;
use App\Models\SystemLog; use App\Models\SystemLog;
use App\PaymentDrivers\Common\LivewireMethodInterface;
use App\PaymentDrivers\Common\MethodInterface; use App\PaymentDrivers\Common\MethodInterface;
use App\PaymentDrivers\MolliePaymentDriver; use App\PaymentDrivers\MolliePaymentDriver;
use Illuminate\Http\RedirectResponse; use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\View\View; use Illuminate\View\View;
class Bancontact implements MethodInterface, LivewireMethodInterface class Bancontact implements MethodInterface
{ {
protected MolliePaymentDriver $mollie; protected MolliePaymentDriver $mollie;
@ -210,24 +209,4 @@ class Bancontact implements MethodInterface, LivewireMethodInterface
{ {
return $this->processSuccessfulPayment($payment, 'open'); return $this->processSuccessfulPayment($payment, 'open');
} }
/**
* @inheritDoc
*/
public function livewirePaymentView(array $data): string
{
// Doesn't support, it's offsite payment method.
return '';
}
/**
* @inheritDoc
*/
public function paymentData(array $data): array
{
$this->paymentView($data);
return $data;
}
} }

View File

@ -19,7 +19,6 @@ use App\Models\GatewayType;
use App\Models\Payment; use App\Models\Payment;
use App\Models\PaymentType; use App\Models\PaymentType;
use App\Models\SystemLog; use App\Models\SystemLog;
use App\PaymentDrivers\Common\LivewireMethodInterface;
use App\PaymentDrivers\Common\MethodInterface; use App\PaymentDrivers\Common\MethodInterface;
use App\PaymentDrivers\MolliePaymentDriver; use App\PaymentDrivers\MolliePaymentDriver;
use Exception; use Exception;
@ -29,7 +28,7 @@ use Illuminate\Routing\Redirector;
use Illuminate\View\View; use Illuminate\View\View;
use Mollie\Api\Resources\Payment as ResourcesPayment; use Mollie\Api\Resources\Payment as ResourcesPayment;
class BankTransfer implements MethodInterface, LivewireMethodInterface class BankTransfer implements MethodInterface
{ {
protected MolliePaymentDriver $mollie; protected MolliePaymentDriver $mollie;
@ -207,24 +206,4 @@ class BankTransfer implements MethodInterface, LivewireMethodInterface
{ {
return $this->processSuccessfulPayment($payment, 'open'); return $this->processSuccessfulPayment($payment, 'open');
} }
/**
* @inheritDoc
*/
public function livewirePaymentView(array $data): string
{
// Doesn't support, it's offsite payment method.
return '';
}
/**
* @inheritDoc
*/
public function paymentData(array $data): array
{
$this->paymentView($data);
return $data;
}
} }

View File

@ -10,13 +10,12 @@ use App\Models\GatewayType;
use App\Models\Payment; use App\Models\Payment;
use App\Models\PaymentType; use App\Models\PaymentType;
use App\Models\SystemLog; use App\Models\SystemLog;
use App\PaymentDrivers\Common\LivewireMethodInterface;
use App\PaymentDrivers\MolliePaymentDriver; use App\PaymentDrivers\MolliePaymentDriver;
use Illuminate\Contracts\View\Factory; use Illuminate\Contracts\View\Factory;
use Illuminate\Http\RedirectResponse; use Illuminate\Http\RedirectResponse;
use Illuminate\View\View; use Illuminate\View\View;
class CreditCard implements LivewireMethodInterface class CreditCard
{ {
/** /**
* @var MolliePaymentDriver * @var MolliePaymentDriver
@ -38,7 +37,7 @@ class CreditCard implements LivewireMethodInterface
*/ */
public function paymentView(array $data) public function paymentView(array $data)
{ {
$data = $this->paymentData($data); $data['gateway'] = $this->mollie;
return render('gateways.mollie.credit_card.pay', $data); return render('gateways.mollie.credit_card.pay', $data);
} }
@ -258,22 +257,4 @@ class CreditCard implements LivewireMethodInterface
{ {
return redirect()->route('client.payment_methods.index'); return redirect()->route('client.payment_methods.index');
} }
/**
* @inheritDoc
*/
public function livewirePaymentView(array $data): string
{
return 'gateways.mollie.credit_card.pay_livewire';
}
/**
* @inheritDoc
*/
public function paymentData(array $data): array
{
$data['gateway'] = $this->mollie;
return $data;
}
} }

View File

@ -19,14 +19,13 @@ use App\Models\GatewayType;
use App\Models\Payment; use App\Models\Payment;
use App\Models\PaymentType; use App\Models\PaymentType;
use App\Models\SystemLog; use App\Models\SystemLog;
use App\PaymentDrivers\Common\LivewireMethodInterface;
use App\PaymentDrivers\Common\MethodInterface; use App\PaymentDrivers\Common\MethodInterface;
use App\PaymentDrivers\MolliePaymentDriver; use App\PaymentDrivers\MolliePaymentDriver;
use Illuminate\Http\RedirectResponse; use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\View\View; use Illuminate\View\View;
class IDEAL implements MethodInterface, LivewireMethodInterface class IDEAL implements MethodInterface
{ {
protected MolliePaymentDriver $mollie; protected MolliePaymentDriver $mollie;
@ -210,24 +209,4 @@ class IDEAL implements MethodInterface, LivewireMethodInterface
{ {
return $this->processSuccessfulPayment($payment, 'open'); return $this->processSuccessfulPayment($payment, 'open');
} }
/**
* @inheritDoc
*/
public function livewirePaymentView(array $data): string
{
// Doesn't support, it's offsite payment method.
return '';
}
/**
* @inheritDoc
*/
public function paymentData(array $data): array
{
$this->paymentView($data);
return $data;
}
} }

View File

@ -19,14 +19,13 @@ use App\Models\GatewayType;
use App\Models\Payment; use App\Models\Payment;
use App\Models\PaymentType; use App\Models\PaymentType;
use App\Models\SystemLog; use App\Models\SystemLog;
use App\PaymentDrivers\Common\LivewireMethodInterface;
use App\PaymentDrivers\Common\MethodInterface; use App\PaymentDrivers\Common\MethodInterface;
use App\PaymentDrivers\MolliePaymentDriver; use App\PaymentDrivers\MolliePaymentDriver;
use Illuminate\Http\RedirectResponse; use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\View\View; use Illuminate\View\View;
class KBC implements MethodInterface, LivewireMethodInterface class KBC implements MethodInterface
{ {
protected MolliePaymentDriver $mollie; protected MolliePaymentDriver $mollie;
@ -194,24 +193,4 @@ class KBC implements MethodInterface, LivewireMethodInterface
return redirect()->route('client.payments.show', ['payment' => $this->mollie->encodePrimaryKey($payment_record->id)]); return redirect()->route('client.payments.show', ['payment' => $this->mollie->encodePrimaryKey($payment_record->id)]);
} }
/**
* @inheritDoc
*/
public function livewirePaymentView(array $data): string
{
// Doesn't support, it's offsite payment method.
return '';
}
/**
* @inheritDoc
*/
public function paymentData(array $data): array
{
$this->paymentView($data);
return $data;
}
} }

View File

@ -18,13 +18,12 @@ use App\Models\GatewayType;
use App\Models\Payment; use App\Models\Payment;
use App\Models\PaymentType; use App\Models\PaymentType;
use App\Models\SystemLog; use App\Models\SystemLog;
use App\PaymentDrivers\Common\LivewireMethodInterface;
use App\PaymentDrivers\PayFastPaymentDriver; use App\PaymentDrivers\PayFastPaymentDriver;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Str; use Illuminate\Support\Str;
class CreditCard implements LivewireMethodInterface class CreditCard
{ {
public $payfast; public $payfast;
@ -159,9 +158,24 @@ class CreditCard implements LivewireMethodInterface
public function paymentView($data) public function paymentView($data)
{ {
$data = $this->paymentData($data); $payfast_data = [
'merchant_id' => $this->payfast->company_gateway->getConfigField('merchantId'),
'merchant_key' => $this->payfast->company_gateway->getConfigField('merchantKey'),
'return_url' => route('client.payments.index'),
'cancel_url' => route('client.payment_methods.index'),
'notify_url' => $this->payfast->genericWebhookUrl(),
'm_payment_id' => $data['payment_hash'],
'amount' => $data['amount_with_fee'],
'item_name' => 'purchase',
'item_description' => ctrans('texts.invoices').': '.collect($data['invoices'])->pluck('invoice_number'),
'passphrase' => $this->payfast->company_gateway->getConfigField('passphrase'),
];
return render('gateways.payfast.pay', array_merge($data)); $payfast_data['signature'] = $this->payfast->generateSignature($payfast_data);
$payfast_data['gateway'] = $this->payfast;
$payfast_data['payment_endpoint_url'] = $this->payfast->endpointUrl();
return render('gateways.payfast.pay', array_merge($data, $payfast_data));
} }
/* /*
@ -249,36 +263,4 @@ class CreditCard implements LivewireMethodInterface
throw new PaymentFailed('Failed to process the payment.', 500); throw new PaymentFailed('Failed to process the payment.', 500);
} }
/**
* @inheritDoc
*/
public function livewirePaymentView(array $data): string
{
return 'gateways.payfast.pay_livewire';
}
/**
* @inheritDoc
*/
public function paymentData(array $data): array
{
$payfast_data = [
'merchant_id' => $this->payfast->company_gateway->getConfigField('merchantId'),
'merchant_key' => $this->payfast->company_gateway->getConfigField('merchantKey'),
'return_url' => route('client.payments.index'),
'cancel_url' => route('client.payment_methods.index'),
'notify_url' => $this->payfast->genericWebhookUrl(),
'm_payment_id' => $data['payment_hash'],
'amount' => $data['amount_with_fee'],
'item_name' => 'purchase',
'item_description' => ctrans('texts.invoices').': '.collect($data['invoices'])->pluck('invoice_number'),
'passphrase' => $this->payfast->company_gateway->getConfigField('passphrase'),
];
$payfast_data['signature'] = $this->payfast->generateSignature($payfast_data);
$payfast_data['gateway'] = $this->payfast;
$payfast_data['payment_endpoint_url'] = $this->payfast->endpointUrl();
return array_merge($data, $payfast_data);
}
} }

Some files were not shown because too many files have changed in this diff Show More