mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Merge branch 'v5-develop' into add-elestio
Signed-off-by: David Bomba <turbo124@gmail.com>
This commit is contained in:
commit
4eee3286f2
@ -52,6 +52,7 @@ All Pro and Enterprise features from the hosted app are included in the open-sou
|
||||
* [Cloudron](https://www.cloudron.io/store/com.invoiceninja.cloudronapp2.html)
|
||||
* [Softaculous](https://www.softaculous.com/apps/ecommerce/Invoice_Ninja)
|
||||
* [Elestio](https://elest.io/open-source/invoiceninja)
|
||||
* [YunoHost](https://apps.yunohost.org/app/invoiceninja5)
|
||||
|
||||
### Recommended Providers
|
||||
* [Stripe](https://stripe.com/)
|
||||
|
@ -1 +1 @@
|
||||
5.10.24
|
||||
5.10.26
|
@ -1169,7 +1169,7 @@ class CheckData extends Command
|
||||
->whereNull('exchange_rate')
|
||||
->orWhere('exchange_rate', 0)
|
||||
->cursor()
|
||||
->each(function ($expense){
|
||||
->each(function ($expense) {
|
||||
$expense->exchange_rate = 1;
|
||||
$expense->saveQuietly();
|
||||
|
||||
|
@ -516,9 +516,10 @@ class CompanySettings extends BaseSettings
|
||||
public $quote_late_fee_amount1 = 0;
|
||||
public $quote_late_fee_percent1 = 0;
|
||||
|
||||
|
||||
public string $payment_flow = 'default'; //smooth
|
||||
|
||||
public static $casts = [
|
||||
'payment_flow' => 'string',
|
||||
'enable_quote_reminder1' => 'bool',
|
||||
'quote_num_days_reminder1' => 'int',
|
||||
'quote_schedule_reminder1' => 'string',
|
||||
|
@ -131,7 +131,8 @@ class BaseRule implements RuleInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function shouldCalcTax(): bool {
|
||||
public function shouldCalcTax(): bool
|
||||
{
|
||||
return $this->should_calc_tax && $this->checkIfInvoiceLocked();
|
||||
}
|
||||
/**
|
||||
@ -404,8 +405,9 @@ class BaseRule implements RuleInterface
|
||||
{
|
||||
$lock_invoices = $this->client->getSetting('lock_invoices');
|
||||
|
||||
if($this->invoice instanceof RecurringInvoice)
|
||||
if($this->invoice instanceof RecurringInvoice) {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch ($lock_invoices) {
|
||||
case 'off':
|
||||
|
@ -241,8 +241,7 @@ class Rule extends BaseRule implements RuleInterface
|
||||
// nlog("tax exempt");
|
||||
$this->tax_rate = 0;
|
||||
$this->reduced_tax_rate = 0;
|
||||
} elseif($this->client_subregion != $this->client->company->tax_data->seller_subregion && in_array($this->client_subregion, $this->eu_country_codes) && $this->client->vat_number && $this->eu_business_tax_exempt) {
|
||||
// elseif($this->client_subregion != $this->client->company->tax_data->seller_subregion && in_array($this->client_subregion, $this->eu_country_codes) && $this->client->has_valid_vat_number && $this->eu_business_tax_exempt)
|
||||
} elseif($this->client_subregion != $this->client->company->tax_data->seller_subregion && in_array($this->client_subregion, $this->eu_country_codes) && $this->client->vat_number && $this->client->has_valid_vat_number && $this->eu_business_tax_exempt) {
|
||||
// nlog("euro zone and tax exempt");
|
||||
$this->tax_rate = 0;
|
||||
$this->reduced_tax_rate = 0;
|
||||
@ -252,8 +251,8 @@ class Rule extends BaseRule implements RuleInterface
|
||||
$this->reduced_tax_rate = 0;
|
||||
} elseif(!in_array($this->client_subregion, $this->eu_country_codes)) {
|
||||
$this->defaultForeign();
|
||||
} elseif(in_array($this->client_subregion, $this->eu_country_codes) && !$this->client->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) {
|
||||
} 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) {
|
||||
// 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->reduced_tax_rate = $this->client->company->tax_data->regions->EU->subregions->{$this->client->country->iso_3166_2}->reduced_tax_rate ?? 0;
|
||||
|
@ -48,8 +48,7 @@ class TaxModel
|
||||
public function migrate(): self
|
||||
{
|
||||
|
||||
if($this->version == 'alpha')
|
||||
{
|
||||
if($this->version == 'alpha') {
|
||||
$this->regions->EU->subregions->PL = new \stdClass();
|
||||
$this->regions->EU->subregions->PL->tax_rate = 23;
|
||||
$this->regions->EU->subregions->PL->tax_name = 'VAT';
|
||||
|
@ -11,7 +11,8 @@
|
||||
|
||||
namespace App\DataProviders;
|
||||
|
||||
final class CAProvinces {
|
||||
final class CAProvinces
|
||||
{
|
||||
/**
|
||||
* The provinces and territories of Canada
|
||||
*
|
||||
@ -39,7 +40,8 @@ final class CAProvinces {
|
||||
* @param string $abbreviation
|
||||
* @return string
|
||||
*/
|
||||
public static function getName($abbreviation) {
|
||||
public static function getName($abbreviation)
|
||||
{
|
||||
return self::$provinces[$abbreviation];
|
||||
}
|
||||
|
||||
@ -48,7 +50,8 @@ final class CAProvinces {
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function get() {
|
||||
public static function get()
|
||||
{
|
||||
return self::$provinces;
|
||||
}
|
||||
|
||||
@ -58,7 +61,8 @@ final class CAProvinces {
|
||||
* @param string $name
|
||||
* @return string
|
||||
*/
|
||||
public static function getAbbreviation($name) {
|
||||
public static function getAbbreviation($name)
|
||||
{
|
||||
return array_search(ucwords($name), self::$provinces);
|
||||
}
|
||||
}
|
||||
|
@ -130,7 +130,7 @@ class ActivityExport extends BaseExport
|
||||
$query->cursor()
|
||||
->each(function ($entity) {
|
||||
|
||||
/** @var \App\Models\Activity $entity */
|
||||
/** @var \App\Models\Activity $entity */
|
||||
|
||||
$this->buildRow($entity);
|
||||
});
|
||||
|
@ -1041,7 +1041,7 @@ class BaseExport
|
||||
|
||||
$recurring_filters = [];
|
||||
|
||||
if($this->company->getSetting('report_include_drafts')){
|
||||
if($this->company->getSetting('report_include_drafts')) {
|
||||
$recurring_filters[] = RecurringInvoice::STATUS_DRAFT;
|
||||
}
|
||||
|
||||
|
@ -133,7 +133,7 @@ class ClientExport extends BaseExport
|
||||
$query->where('is_deleted', 0);
|
||||
}
|
||||
|
||||
$query = $this->addDateRange($query,' clients');
|
||||
$query = $this->addDateRange($query, ' clients');
|
||||
|
||||
if($this->input['document_email_attachment'] ?? false) {
|
||||
$this->queueDocuments($query);
|
||||
@ -157,7 +157,7 @@ class ClientExport extends BaseExport
|
||||
$query->cursor()
|
||||
->each(function ($client) {
|
||||
|
||||
/** @var \App\Models\Client $client */
|
||||
/** @var \App\Models\Client $client */
|
||||
$this->csv->insertOne($this->buildRow($client));
|
||||
});
|
||||
|
||||
|
@ -101,7 +101,7 @@ class DocumentExport extends BaseExport
|
||||
|
||||
$query->cursor()
|
||||
->each(function ($entity) {
|
||||
/** @var mixed $entity */
|
||||
/** @var mixed $entity */
|
||||
$this->csv->insertOne($this->buildRow($entity));
|
||||
});
|
||||
|
||||
|
@ -269,8 +269,7 @@ class ExpenseExport extends BaseExport
|
||||
|
||||
if($expense->uses_inclusive_taxes) {
|
||||
$entity['expense.net_amount'] = round($expense->amount, $precision) - $total_tax_amount;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$entity['expense.net_amount'] = round($expense->amount, $precision);
|
||||
}
|
||||
|
||||
|
@ -115,7 +115,7 @@ class PaymentExport extends BaseExport
|
||||
$query->cursor()
|
||||
->each(function ($entity) {
|
||||
|
||||
/** @var \App\Models\Payment $entity */
|
||||
/** @var \App\Models\Payment $entity */
|
||||
$this->csv->insertOne($this->buildRow($entity));
|
||||
});
|
||||
|
||||
|
@ -106,8 +106,8 @@ class ProductExport extends BaseExport
|
||||
$query->cursor()
|
||||
->each(function ($entity) {
|
||||
|
||||
/** @var \App\Models\Product $entity */
|
||||
$this->csv->insertOne($this->buildRow($entity));
|
||||
/** @var \App\Models\Product $entity */
|
||||
$this->csv->insertOne($this->buildRow($entity));
|
||||
});
|
||||
|
||||
return $this->csv->toString();
|
||||
|
@ -122,8 +122,8 @@ class PurchaseOrderExport extends BaseExport
|
||||
$query->cursor()
|
||||
->each(function ($purchase_order) {
|
||||
|
||||
/** @var \App\Models\PurchaseOrder $purchase_order */
|
||||
$this->csv->insertOne($this->buildRow($purchase_order));
|
||||
/** @var \App\Models\PurchaseOrder $purchase_order */
|
||||
$this->csv->insertOne($this->buildRow($purchase_order));
|
||||
});
|
||||
|
||||
return $this->csv->toString();
|
||||
|
@ -102,14 +102,14 @@ class PurchaseOrderItemExport extends BaseExport
|
||||
$query->cursor()
|
||||
->each(function ($resource) {
|
||||
|
||||
/** @var \App\Models\PurchaseOrder $resource */
|
||||
$this->iterateItems($resource);
|
||||
/** @var \App\Models\PurchaseOrder $resource */
|
||||
$this->iterateItems($resource);
|
||||
|
||||
foreach($this->storage_array as $row) {
|
||||
$this->storage_item_array[] = $this->processItemMetaData($row, $resource);
|
||||
}
|
||||
foreach($this->storage_array as $row) {
|
||||
$this->storage_item_array[] = $this->processItemMetaData($row, $resource);
|
||||
}
|
||||
|
||||
$this->storage_array = [];
|
||||
$this->storage_array = [];
|
||||
|
||||
});
|
||||
|
||||
@ -130,8 +130,8 @@ class PurchaseOrderItemExport extends BaseExport
|
||||
$query->cursor()
|
||||
->each(function ($purchase_order) {
|
||||
|
||||
/** @var \App\Models\PurchaseOrder $purchase_order */
|
||||
$this->iterateItems($purchase_order);
|
||||
/** @var \App\Models\PurchaseOrder $purchase_order */
|
||||
$this->iterateItems($purchase_order);
|
||||
});
|
||||
|
||||
$this->csv->insertAll($this->storage_array);
|
||||
|
@ -107,8 +107,8 @@ class TaskExport extends BaseExport
|
||||
$query->cursor()
|
||||
->each(function ($entity) {
|
||||
|
||||
/** @var \App\Models\Task $entity*/
|
||||
$this->buildRow($entity);
|
||||
/** @var \App\Models\Task $entity*/
|
||||
$this->buildRow($entity);
|
||||
});
|
||||
|
||||
$this->csv->insertAll($this->storage_array);
|
||||
|
@ -110,8 +110,8 @@ class VendorExport extends BaseExport
|
||||
$query->cursor()
|
||||
->each(function ($vendor) {
|
||||
|
||||
/** @var \App\Models\Vendor $vendor */
|
||||
$this->csv->insertOne($this->buildRow($vendor));
|
||||
/** @var \App\Models\Vendor $vendor */
|
||||
$this->csv->insertOne($this->buildRow($vendor));
|
||||
});
|
||||
|
||||
return $this->csv->toString();
|
||||
|
@ -149,43 +149,43 @@ class RecurringExpenseToExpenseFactory
|
||||
}
|
||||
|
||||
// if (Str::contains($match, '|')) {
|
||||
$parts = explode('|', $match); // [ '[MONTH', 'MONTH+2]' ]
|
||||
$parts = explode('|', $match); // [ '[MONTH', 'MONTH+2]' ]
|
||||
|
||||
$left = substr($parts[0], 1); // 'MONTH'
|
||||
$right = substr($parts[1], 0, -1); // MONTH+2
|
||||
$left = substr($parts[0], 1); // 'MONTH'
|
||||
$right = substr($parts[1], 0, -1); // MONTH+2
|
||||
|
||||
// If left side is not part of replacements, skip.
|
||||
if (! array_key_exists($left, $replacements['ranges'])) {
|
||||
continue;
|
||||
}
|
||||
// If left side is not part of replacements, skip.
|
||||
if (! array_key_exists($left, $replacements['ranges'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$_left = Carbon::createFromDate(now()->year, now()->month)->translatedFormat('F Y');
|
||||
$_right = '';
|
||||
$_left = Carbon::createFromDate(now()->year, now()->month)->translatedFormat('F Y');
|
||||
$_right = '';
|
||||
|
||||
// If right side doesn't have any calculations, replace with raw ranges keyword.
|
||||
if (! Str::contains($right, ['-', '+', '/', '*'])) {
|
||||
$_right = Carbon::createFromDate(now()->year, now()->month)->translatedFormat('F Y');
|
||||
}
|
||||
// If right side doesn't have any calculations, replace with raw ranges keyword.
|
||||
if (! Str::contains($right, ['-', '+', '/', '*'])) {
|
||||
$_right = Carbon::createFromDate(now()->year, now()->month)->translatedFormat('F Y');
|
||||
}
|
||||
|
||||
// If right side contains one of math operations, calculate.
|
||||
if (Str::contains($right, ['+'])) {
|
||||
$operation = preg_match_all('/(?!^-)[+*\/-](\s?-)?/', $right, $_matches);
|
||||
// If right side contains one of math operations, calculate.
|
||||
if (Str::contains($right, ['+'])) {
|
||||
$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(
|
||||
sprintf('/%s/', preg_quote($match)),
|
||||
$replacement,
|
||||
$value,
|
||||
1
|
||||
);
|
||||
$value = preg_replace(
|
||||
sprintf('/%s/', preg_quote($match)),
|
||||
$replacement,
|
||||
$value,
|
||||
1
|
||||
);
|
||||
// }
|
||||
}
|
||||
|
||||
|
@ -105,7 +105,7 @@ class CreditFilters extends QueryFilters
|
||||
JSON_UNQUOTE(JSON_EXTRACT(line_items, '$[*].product_key'))
|
||||
), '$[*]')
|
||||
) LIKE ?", ['%'.$filter.'%']);
|
||||
// ->orWhereRaw("JSON_UNQUOTE(JSON_EXTRACT(line_items, '$[*].notes')) LIKE ?", ['%'.$filter.'%']);
|
||||
// ->orWhereRaw("JSON_UNQUOTE(JSON_EXTRACT(line_items, '$[*].notes')) LIKE ?", ['%'.$filter.'%']);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -162,8 +162,9 @@ class ExpenseFilters extends QueryFilters
|
||||
{
|
||||
$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;
|
||||
}
|
||||
|
||||
$categories_keys = $this->transformKeys($categories_exploded);
|
||||
|
||||
|
@ -132,7 +132,7 @@ class InvoiceFilters extends QueryFilters
|
||||
JSON_UNQUOTE(JSON_EXTRACT(line_items, '$[*].product_key'))
|
||||
), '$[*]')
|
||||
) LIKE ?", ['%'.$filter.'%']);
|
||||
// ->orWhereRaw("JSON_UNQUOTE(JSON_EXTRACT(line_items, '$[*].notes')) LIKE ?", ['%'.$filter.'%']);
|
||||
// ->orWhereRaw("JSON_UNQUOTE(JSON_EXTRACT(line_items, '$[*].notes')) LIKE ?", ['%'.$filter.'%']);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ class QuoteFilters extends QueryFilters
|
||||
JSON_UNQUOTE(JSON_EXTRACT(line_items, '$[*].product_key'))
|
||||
), '$[*]')
|
||||
) LIKE ?", ['%'.$filter.'%']);
|
||||
// ->orWhereRaw("JSON_UNQUOTE(JSON_EXTRACT(line_items, '$[*].notes')) LIKE ?", ['%'.$filter.'%']);
|
||||
// ->orWhereRaw("JSON_UNQUOTE(JSON_EXTRACT(line_items, '$[*].notes')) LIKE ?", ['%'.$filter.'%']);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ class RecurringInvoiceFilters extends QueryFilters
|
||||
JSON_UNQUOTE(JSON_EXTRACT(line_items, '$[*].product_key'))
|
||||
), '$[*]')
|
||||
) 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);
|
||||
}
|
||||
|
||||
if($sort_col[0] == 'status_id'){
|
||||
if($sort_col[0] == 'status_id') {
|
||||
return $this->builder->orderBy('status_id', $dir)->orderBy('last_sent_date', $dir);
|
||||
}
|
||||
|
||||
|
@ -254,17 +254,20 @@ class ActivityController extends BaseController
|
||||
$activity->client_id = $entity->client_id;
|
||||
$activity->project_id = $entity->project_id;
|
||||
$activity->vendor_id = $entity->vendor_id;
|
||||
// no break
|
||||
case Task::class:
|
||||
$activity->task_id = $entity->id;
|
||||
$activity->expense_id = $entity->id;
|
||||
$activity->client_id = $entity->client_id;
|
||||
$activity->project_id = $entity->project_id;
|
||||
$activity->vendor_id = $entity->vendor_id;
|
||||
// no break
|
||||
case Payment::class:
|
||||
$activity->payment_id = $entity->id;
|
||||
$activity->expense_id = $entity->id;
|
||||
$activity->client_id = $entity->client_id;
|
||||
$activity->project_id = $entity->project_id;
|
||||
// no break
|
||||
default:
|
||||
# code...
|
||||
break;
|
||||
|
@ -41,8 +41,9 @@ class ContactLoginController extends Controller
|
||||
$company = false;
|
||||
$account = false;
|
||||
|
||||
if($request->query('intended'))
|
||||
if($request->query('intended')) {
|
||||
$request->session()->put('url.intended', $request->query('intended'));
|
||||
}
|
||||
|
||||
if ($request->session()->has('company_key')) {
|
||||
MultiDB::findAndSetDbByCompanyKey($request->session()->get('company_key'));
|
||||
@ -142,8 +143,9 @@ class ContactLoginController extends Controller
|
||||
|
||||
$this->setRedirectPath();
|
||||
|
||||
if($intended)
|
||||
if($intended) {
|
||||
$this->redirectTo = $intended;
|
||||
}
|
||||
|
||||
return $request->wantsJson()
|
||||
? new JsonResponse([], 204)
|
||||
|
@ -934,7 +934,7 @@ class BaseController extends Controller
|
||||
} elseif (in_array($this->entity_type, [Design::class, GroupSetting::class, PaymentTerm::class, TaskStatus::class])) {
|
||||
// nlog($this->entity_type);
|
||||
} 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);
|
||||
});
|
||||
}
|
||||
@ -996,7 +996,7 @@ class BaseController extends Controller
|
||||
|
||||
if(request()->has('einvoice')) {
|
||||
|
||||
if(class_exists(Schema::class)){
|
||||
if(class_exists(Schema::class)) {
|
||||
$ro = new Schema();
|
||||
$response_data['einvoice_schema'] = $ro('Peppol');
|
||||
}
|
||||
|
@ -19,7 +19,6 @@ use Illuminate\Http\Request;
|
||||
*/
|
||||
class BrevoController extends BaseController
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ class InvitationController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
if(!auth()->guard('contact')->check()){
|
||||
if(!auth()->guard('contact')->check()) {
|
||||
$this->middleware('auth:contact');
|
||||
return redirect()->route('client.login', ['intended' => route('client.'.$entity.'.show', [$entity => $this->encodePrimaryKey($invitation->{$key}), 'silent' => $is_silent])]);
|
||||
}
|
||||
|
@ -62,6 +62,7 @@ class InvoiceController extends Controller
|
||||
|
||||
$invitation = $invoice->invitations()->where('client_contact_id', auth()->guard('contact')->user()->id)->first();
|
||||
|
||||
// @phpstan-ignore-next-line
|
||||
if ($invitation && auth()->guard('contact') && ! session()->get('is_silent') && ! $invitation->viewed_date) {
|
||||
$invitation->markViewed();
|
||||
|
||||
@ -77,13 +78,17 @@ class InvoiceController extends Controller
|
||||
'key' => $invitation ? $invitation->key : false,
|
||||
'hash' => $hash,
|
||||
'variables' => $variables,
|
||||
'invoices' => [$invoice->hashed_id],
|
||||
'db' => $invoice->company->db,
|
||||
];
|
||||
|
||||
if ($request->query('mode') === 'fullscreen') {
|
||||
return render('invoices.show-fullscreen', $data);
|
||||
}
|
||||
|
||||
return $this->render('invoices.show', $data);
|
||||
return auth()->guard('contact')->user()->client->getSetting('payment_flow') == 'default' ? $this->render('invoices.show', $data) : $this->render('invoices.show_smooth', $data);
|
||||
|
||||
// return $this->render('invoices.show_smooth', $data);
|
||||
}
|
||||
|
||||
public function showBlob($hash)
|
||||
@ -235,9 +240,12 @@ class InvoiceController extends Controller
|
||||
'hashed_ids' => $invoices->pluck('hashed_id'),
|
||||
'total' => $total,
|
||||
'variables' => $variables,
|
||||
'invitation' => $invitation,
|
||||
'db' => $invitation->company->db,
|
||||
];
|
||||
|
||||
return $this->render('invoices.payment', $data);
|
||||
// return $this->render('invoices.payment', $data);
|
||||
return auth()->guard('contact')->user()->client->getSetting('payment_flow') === 'default' ? $this->render('invoices.payment', $data) : $this->render('invoices.show_smooth_multi', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -126,7 +126,7 @@ class PaymentController extends Controller
|
||||
// if($payment_hash)
|
||||
$invoice = $payment_hash->fee_invoice;
|
||||
// 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);
|
||||
|
||||
|
135
app/Http/Controllers/ImportQuickbooksController.php
Normal file
135
app/Http/Controllers/ImportQuickbooksController.php
Normal file
@ -0,0 +1,135 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests\Quickbooks\AuthorizedQuickbooksRequest;
|
||||
use Closure;
|
||||
use App\Utils\Ninja;
|
||||
use App\Models\Company;
|
||||
use App\Libraries\MultiDB;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use App\Jobs\Import\QuickbooksIngest;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use App\Http\Requests\Quickbooks\AuthQuickbooksRequest;
|
||||
use App\Services\Import\Quickbooks\QuickbooksService;
|
||||
|
||||
class ImportQuickbooksController extends BaseController
|
||||
{
|
||||
private array $import_entities = [
|
||||
'client' => 'Customer',
|
||||
'invoice' => 'Invoice',
|
||||
'product' => 'Item',
|
||||
'payment' => 'Payment'
|
||||
];
|
||||
|
||||
public function onAuthorized(AuthorizedQuickbooksRequest $request)
|
||||
{
|
||||
|
||||
MultiDB::findAndSetDbByCompanyKey($request->getTokenContent()['company_key']);
|
||||
$company = $request->getCompany();
|
||||
$qb = new QuickbooksService($company);
|
||||
|
||||
$realm = $request->query('realmId');
|
||||
$access_token_object = $qb->getAuth()->accessToken($request->query('code'), $realm);
|
||||
nlog($access_token_object); //OAuth2AccessToken
|
||||
$company->quickbooks = $access_token_object;
|
||||
$company->save();
|
||||
|
||||
return response()->json(['message' => 'Success'], 200); //todo swapout for redirect to UI
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
*/
|
||||
public function authorizeQuickbooks(AuthQuickbooksRequest $request, string $token)
|
||||
{
|
||||
|
||||
MultiDB::findAndSetDbByCompanyKey($request->getTokenContent()['company_key']);
|
||||
$company = $request->getCompany();
|
||||
$qb = new QuickbooksService($company);
|
||||
|
||||
$authorizationUrl = $qb->getAuth()->getAuthorizationUrl();
|
||||
$state = $qb->getAuth()->getState();
|
||||
|
||||
Cache::put($state, $token, 190);
|
||||
|
||||
return redirect()->to($authorizationUrl);
|
||||
}
|
||||
|
||||
public function preimport(string $type, string $hash)
|
||||
{
|
||||
// Check for authorization otherwise
|
||||
// Create a reference
|
||||
$data = [
|
||||
'hash' => $hash,
|
||||
'type' => $type
|
||||
];
|
||||
$this->getData($data);
|
||||
}
|
||||
|
||||
protected function getData($data)
|
||||
{
|
||||
|
||||
$entity = $this->import_entities[$data['type']];
|
||||
$cache_name = "{$data['hash']}-{$data['type']}";
|
||||
// TODO: Get or put cache or DB?
|
||||
if(! Cache::has($cache_name)) {
|
||||
$contents = call_user_func([$this->service, "fetch{$entity}s"]);
|
||||
if($contents->isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Cache::put($cache_name, base64_encode($contents->toJson()), 600);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @OA\Post(
|
||||
* path="/api/v1/import_json",
|
||||
* operationId="getImportJson",
|
||||
* tags={"import"},
|
||||
* summary="Import data from the system",
|
||||
* description="Import data from the system",
|
||||
* @OA\Parameter(ref="#/components/parameters/X-Requested-With"),
|
||||
* @OA\Response(
|
||||
* response=200,
|
||||
* description="success",
|
||||
* @OA\Header(header="X-MINIMUM-CLIENT-VERSION", ref="#/components/headers/X-MINIMUM-CLIENT-VERSION"),
|
||||
* @OA\Header(header="X-RateLimit-Remaining", ref="#/components/headers/X-RateLimit-Remaining"),
|
||||
* @OA\Header(header="X-RateLimit-Limit", ref="#/components/headers/X-RateLimit-Limit"),
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=422,
|
||||
* description="Validation error",
|
||||
* @OA\JsonContent(ref="#/components/schemas/ValidationError"),
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response="default",
|
||||
* description="Unexpected Error",
|
||||
* @OA\JsonContent(ref="#/components/schemas/Error"),
|
||||
* ),
|
||||
* )
|
||||
*/
|
||||
public function import(Request $request)
|
||||
{
|
||||
// $hash = Str::random(32);
|
||||
// foreach($request->input('import_types') as $type) {
|
||||
// $this->preimport($type, $hash);
|
||||
// }
|
||||
// /** @var \App\Models\User $user */
|
||||
// // $user = auth()->user() ?? Auth::loginUsingId(60);
|
||||
// $data = ['import_types' => $request->input('import_types') ] + compact('hash');
|
||||
// if (Ninja::isHosted()) {
|
||||
// QuickbooksIngest::dispatch($data, $user->company());
|
||||
// } else {
|
||||
// QuickbooksIngest::dispatch($data, $user->company());
|
||||
// }
|
||||
|
||||
// return response()->json(['message' => 'Processing'], 200);
|
||||
}
|
||||
}
|
@ -503,7 +503,7 @@ class InvoiceController extends BaseController
|
||||
|
||||
$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']);
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,6 @@ use Illuminate\Http\Request;
|
||||
*/
|
||||
class MailgunWebhookController extends BaseController
|
||||
{
|
||||
|
||||
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'])) {
|
||||
ProcessMailgunWebhook::dispatch($request->all())->delay(rand(2,10));
|
||||
ProcessMailgunWebhook::dispatch($request->all())->delay(rand(2, 10));
|
||||
}
|
||||
|
||||
return response()->json(['message' => 'Success.'], 200);
|
||||
|
@ -22,7 +22,6 @@ use Illuminate\Support\Str;
|
||||
|
||||
class OneTimeTokenController extends BaseController
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
@ -19,7 +19,6 @@ use Illuminate\Http\Request;
|
||||
*/
|
||||
class PostMarkController extends BaseController
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
@ -297,8 +297,7 @@ class PreviewController extends BaseController
|
||||
->setTemplate($design_object)
|
||||
->mock();
|
||||
} catch(SyntaxError $e) {
|
||||
}
|
||||
catch(\Exception $e) {
|
||||
} catch(\Exception $e) {
|
||||
return response()->json(['message' => 'invalid data access', 'errors' => ['design.design.body' => $e->getMessage()]], 422);
|
||||
}
|
||||
|
||||
|
@ -181,8 +181,9 @@ class SelfUpdateController extends BaseController
|
||||
|
||||
public function checkVersion()
|
||||
{
|
||||
if(Ninja::isHosted())
|
||||
if(Ninja::isHosted()) {
|
||||
return '5.10.SaaS';
|
||||
}
|
||||
|
||||
return trim(file_get_contents(config('ninja.version_url')));
|
||||
}
|
||||
|
@ -11,23 +11,25 @@
|
||||
|
||||
namespace App\Http\Controllers\VendorPortal;
|
||||
|
||||
use App\Events\Misc\InvitationWasViewed;
|
||||
use App\Events\PurchaseOrder\PurchaseOrderWasAccepted;
|
||||
use App\Events\PurchaseOrder\PurchaseOrderWasViewed;
|
||||
use App\Utils\Ninja;
|
||||
use App\Models\Webhook;
|
||||
use Illuminate\View\View;
|
||||
use App\Models\PurchaseOrder;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use App\Utils\Traits\MakesDates;
|
||||
use App\Jobs\Entity\CreateRawPdf;
|
||||
use App\Jobs\Util\WebhookHandler;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\VendorPortal\PurchaseOrders\ProcessPurchaseOrdersInBulkRequest;
|
||||
use App\Jobs\Invoice\InjectSignature;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Contracts\View\Factory;
|
||||
use App\Models\PurchaseOrderInvitation;
|
||||
use App\Events\Misc\InvitationWasViewed;
|
||||
use App\Events\PurchaseOrder\PurchaseOrderWasViewed;
|
||||
use App\Events\PurchaseOrder\PurchaseOrderWasAccepted;
|
||||
use App\Http\Requests\VendorPortal\PurchaseOrders\ShowPurchaseOrderRequest;
|
||||
use App\Http\Requests\VendorPortal\PurchaseOrders\ShowPurchaseOrdersRequest;
|
||||
use App\Jobs\Entity\CreateRawPdf;
|
||||
use App\Jobs\Invoice\InjectSignature;
|
||||
use App\Models\PurchaseOrder;
|
||||
use App\Models\PurchaseOrderInvitation;
|
||||
use App\Utils\Ninja;
|
||||
use App\Utils\Traits\MakesDates;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use Illuminate\Contracts\View\Factory;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\View\View;
|
||||
use App\Http\Requests\VendorPortal\PurchaseOrders\ProcessPurchaseOrdersInBulkRequest;
|
||||
|
||||
class PurchaseOrderController extends Controller
|
||||
{
|
||||
@ -187,6 +189,9 @@ class PurchaseOrderController extends Controller
|
||||
}
|
||||
|
||||
event(new PurchaseOrderWasAccepted($purchase_order, auth()->guard('vendor')->user(), $purchase_order->company, Ninja::eventVars()));
|
||||
|
||||
WebhookHandler::dispatch(Webhook::EVENT_ACCEPTED_PURCHASE_ORDER, $purchase_order, $purchase_order->company, 'vendor')->delay(0);
|
||||
|
||||
});
|
||||
|
||||
if ($purchase_count_query->count() == 1) {
|
||||
|
@ -85,7 +85,10 @@ class ThrottleRequestsWithPredis extends \Illuminate\Routing\Middleware\Throttle
|
||||
protected function tooManyAttempts($key, $maxAttempts, $decaySeconds)
|
||||
{
|
||||
$limiter = new DurationLimiter(
|
||||
$this->getRedisConnection(), $key, $maxAttempts, $decaySeconds
|
||||
$this->getRedisConnection(),
|
||||
$key,
|
||||
$maxAttempts,
|
||||
$decaySeconds
|
||||
);
|
||||
|
||||
return tap(! $limiter->acquire(), function () use ($key, $limiter) {
|
||||
|
@ -68,11 +68,12 @@ class StoreNoteRequest extends Request
|
||||
|
||||
public function getEntity()
|
||||
{
|
||||
if(!$this->entity)
|
||||
if(!$this->entity) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$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);
|
||||
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,8 @@ class StoreBankTransactionRuleRequest extends Request
|
||||
'rules.*.value' => 'bail|required|nullable',
|
||||
'auto_convert' => 'bail|sometimes|bool',
|
||||
'matches_on_all' => 'bail|sometimes|bool',
|
||||
'applies_to' => 'bail|sometimes|string',
|
||||
'applies_to' => 'bail|sometimes|string|in:CREDIT,DEBIT',
|
||||
'on_credit_match' => 'bail|sometimes|in:create_payment,link_payment'
|
||||
];
|
||||
|
||||
$rules['category_id'] = 'bail|sometimes|nullable|exists:expense_categories,id,company_id,'.$user->company()->id.',is_deleted,0';
|
||||
|
@ -66,8 +66,7 @@ class ShowCalculatedFieldRequest extends Request
|
||||
$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());
|
||||
$input['start_date'] = $dates[0];
|
||||
$input['end_date'] = $dates[1];
|
||||
|
@ -40,8 +40,9 @@ class BulkInvoiceRequest extends Request
|
||||
/** @var \App\Models\User $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);
|
||||
}
|
||||
|
||||
\Illuminate\Support\Facades\Cache::put(($this->ip()."|".$this->input('action', 0)."|".$user->company()->company_key), true, 1);
|
||||
|
||||
|
@ -80,8 +80,9 @@ class StorePaymentRequest extends Request
|
||||
/** @var \App\Models\User $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);
|
||||
}
|
||||
|
||||
\Illuminate\Support\Facades\Cache::put(($this->ip()."|".$this->input('amount', 0)."|".$this->input('client_id', '')."|".$user->company()->company_key), true, 1);
|
||||
|
||||
|
69
app/Http/Requests/Quickbooks/AuthQuickbooksRequest.php
Normal file
69
app/Http/Requests/Quickbooks/AuthQuickbooksRequest.php
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2024. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://www.elastic.co/licensing/elastic-license
|
||||
*/
|
||||
|
||||
namespace App\Http\Requests\Quickbooks;
|
||||
|
||||
use App\Models\Company;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
|
||||
class AuthQuickbooksRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return is_array($this->getTokenContent());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve one-time token instance.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getTokenContent()
|
||||
{
|
||||
if ($this->state) {
|
||||
$this->token = $this->state;
|
||||
}
|
||||
|
||||
$data = Cache::get($this->token);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getContact(): ?User
|
||||
{
|
||||
return User::findOrFail($this->getTokenContent()['user_id']);
|
||||
}
|
||||
|
||||
public function getCompany(): ?Company
|
||||
{
|
||||
return Company::query()->where('company_key', $this->getTokenContent()['company_key'])->firstOrFail();
|
||||
}
|
||||
}
|
69
app/Http/Requests/Quickbooks/AuthorizedQuickbooksRequest.php
Normal file
69
app/Http/Requests/Quickbooks/AuthorizedQuickbooksRequest.php
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2024. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://www.elastic.co/licensing/elastic-license
|
||||
*/
|
||||
|
||||
namespace App\Http\Requests\Quickbooks;
|
||||
|
||||
use App\Models\Company;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
|
||||
class AuthorizedQuickbooksRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return is_array($this->getTokenContent());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'code' => 'required|string',
|
||||
'state' => 'required|string',
|
||||
'realmId' => 'required|string',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve one-time token instance.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getTokenContent()
|
||||
{
|
||||
$token = Cache::get($this->state);
|
||||
|
||||
$data = Cache::get($token);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getContact()
|
||||
{
|
||||
return User::findOrFail($this->getTokenContent()['user_id']);
|
||||
}
|
||||
|
||||
public function getCompany()
|
||||
{
|
||||
return Company::where('company_key', $this->getTokenContent()['company_key'])->firstOrFail();
|
||||
}
|
||||
}
|
@ -44,7 +44,7 @@ class StoreQuoteRequest extends Request
|
||||
|
||||
$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'))) {
|
||||
$rules['documents.*'] = $this->fileValidation();
|
||||
|
@ -17,7 +17,6 @@ use Illuminate\Auth\Access\AuthorizationException;
|
||||
|
||||
class GenericReportRequest extends Request
|
||||
{
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
|
@ -15,7 +15,6 @@ use App\Http\Requests\Request;
|
||||
|
||||
class DisconnectUserMailerRequest extends Request
|
||||
{
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
|
@ -77,8 +77,7 @@ class UpdateUserRequest extends Request
|
||||
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']);
|
||||
}
|
||||
|
||||
|
@ -34,8 +34,7 @@ class ValidClientScheme implements ValidationRule, ValidatorAwareRule
|
||||
public function validate(string $attribute, mixed $value, Closure $fail): void
|
||||
{
|
||||
|
||||
if(isset($value['Invoice']))
|
||||
{
|
||||
if(isset($value['Invoice'])) {
|
||||
$r = new EInvoice();
|
||||
$errors = $r->validateRequest($value['Invoice'], ClientLevel::class);
|
||||
|
||||
|
@ -24,7 +24,6 @@ use Illuminate\Contracts\Validation\ValidatorAwareRule;
|
||||
*/
|
||||
class ValidCompanyScheme implements ValidationRule, ValidatorAwareRule
|
||||
{
|
||||
|
||||
/**
|
||||
* The validator instance.
|
||||
*
|
||||
@ -35,8 +34,7 @@ class ValidCompanyScheme implements ValidationRule, ValidatorAwareRule
|
||||
public function validate(string $attribute, mixed $value, Closure $fail): void
|
||||
{
|
||||
|
||||
if(isset($value['Invoice']))
|
||||
{
|
||||
if(isset($value['Invoice'])) {
|
||||
$r = new EInvoice();
|
||||
$errors = $r->validateRequest($value['Invoice'], CompanyLevel::class);
|
||||
|
||||
|
@ -89,7 +89,7 @@ class ValidInvoicesRules implements Rule
|
||||
} elseif (floatval($invoice['amount']) > floatval($inv->balance)) {
|
||||
$this->error_msg = ctrans('texts.amount_greater_than_balance_v5');
|
||||
return false;
|
||||
} elseif($inv->is_deleted){
|
||||
} elseif($inv->is_deleted) {
|
||||
$this->error_msg = 'One or more invoices in this request have since been deleted';
|
||||
return false;
|
||||
}
|
||||
|
@ -42,8 +42,9 @@ class AccountComponent extends Component
|
||||
"authorization_type" => 'Online'
|
||||
];
|
||||
|
||||
public function __construct(public array $account) {
|
||||
$this->attributes = $this->newAttributeBag(Arr::only($this->account, $this->fields) );
|
||||
public function __construct(public array $account)
|
||||
{
|
||||
$this->attributes = $this->newAttributeBag(Arr::only($this->account, $this->fields));
|
||||
}
|
||||
|
||||
public function render()
|
||||
|
@ -34,21 +34,25 @@ class AddressComponent extends Component
|
||||
'country' => 'US'
|
||||
];
|
||||
|
||||
public function __construct(public array $address) {
|
||||
if(strlen($this->address['state']) > 2 ) {
|
||||
public function __construct(public array $address)
|
||||
{
|
||||
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->attributes = $this->newAttributeBag(
|
||||
Arr::only(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) );
|
||||
Arr::only(
|
||||
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
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -18,21 +18,20 @@ use App\Models\ClientContact;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\View\View;
|
||||
|
||||
|
||||
// Contact 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([
|
||||
'home_phone' =>$contact->client->phone,
|
||||
'home_phone' => $contact->client->phone,
|
||||
'custom_identifier' => $contact->client->client_hash,
|
||||
'name' =>$contact->client->name,
|
||||
'name' => $contact->client->name,
|
||||
'id' => null,
|
||||
] )->all();
|
||||
])->all();
|
||||
|
||||
$this->attributes = $this->newAttributeBag(Arr::only($contact, $this->fields) );
|
||||
$this->attributes = $this->newAttributeBag(Arr::only($contact, $this->fields));
|
||||
}
|
||||
|
||||
private $fields = [
|
||||
@ -53,6 +52,6 @@ class ContactComponent extends Component
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -137,9 +137,9 @@ class PortalComposer
|
||||
$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')) {
|
||||
$data[] = ['title' => ctrans('texts.plan'), 'url' => 'client.plan', 'icon' => 'credit-card'];
|
||||
$data[] = ['title' => ctrans('texts.plan'), 'url' => 'client.plan', 'icon' => 'credit-card'];
|
||||
// } 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')) {
|
||||
|
253
app/Import/Providers/Quickbooks.php
Normal file
253
app/Import/Providers/Quickbooks.php
Normal file
@ -0,0 +1,253 @@
|
||||
<?php
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2024. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://www.elastic.co/licensing/elastic-license
|
||||
*/
|
||||
|
||||
namespace App\Import\Providers;
|
||||
|
||||
use App\Models\Invoice;
|
||||
use App\Factory\ClientFactory;
|
||||
use App\Factory\InvoiceFactory;
|
||||
use App\Factory\PaymentFactory;
|
||||
use App\Factory\ProductFactory;
|
||||
use App\Import\ImportException;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use App\Repositories\ClientRepository;
|
||||
use App\Repositories\InvoiceRepository;
|
||||
use App\Repositories\PaymentRepository;
|
||||
use App\Repositories\ProductRepository;
|
||||
use App\Http\Requests\Client\StoreClientRequest;
|
||||
use App\Http\Requests\Invoice\StoreInvoiceRequest;
|
||||
use App\Http\Requests\Payment\StorePaymentRequest;
|
||||
use App\Http\Requests\Product\StoreProductRequest;
|
||||
use App\Import\Transformer\Quickbooks\ClientTransformer;
|
||||
use App\Import\Transformer\Quickbooks\InvoiceTransformer;
|
||||
use App\Import\Transformer\Quickbooks\PaymentTransformer;
|
||||
use App\Import\Transformer\Quickbooks\ProductTransformer;
|
||||
|
||||
class Quickbooks extends BaseImport
|
||||
{
|
||||
public array $entity_count = [];
|
||||
|
||||
public function import(string $entity)
|
||||
{
|
||||
if (
|
||||
in_array($entity, [
|
||||
'client',
|
||||
'invoice',
|
||||
'product',
|
||||
'payment',
|
||||
// 'vendor',
|
||||
// 'expense',
|
||||
])
|
||||
) {
|
||||
$this->{$entity}();
|
||||
}
|
||||
|
||||
//collate any errors
|
||||
|
||||
// $this->finalizeImport();
|
||||
}
|
||||
|
||||
public function client()
|
||||
{
|
||||
$entity_type = 'client';
|
||||
$data = $this->getData($entity_type);
|
||||
if (empty($data)) {
|
||||
$this->entity_count['clients'] = 0;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->request_name = StoreClientRequest::class;
|
||||
$this->repository_name = ClientRepository::class;
|
||||
$this->factory_name = ClientFactory::class;
|
||||
$this->repository = app()->make($this->repository_name);
|
||||
$this->repository->import_mode = true;
|
||||
$this->transformer = new ClientTransformer($this->company);
|
||||
$client_count = $this->ingest($data, $entity_type);
|
||||
$this->entity_count['clients'] = $client_count;
|
||||
}
|
||||
|
||||
public function product()
|
||||
{
|
||||
$entity_type = 'product';
|
||||
$data = $this->getData($entity_type);
|
||||
if (empty($data)) {
|
||||
$this->entity_count['products'] = 0;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->request_name = StoreProductRequest::class;
|
||||
$this->repository_name = ProductRepository::class;
|
||||
$this->factory_name = ProductFactory::class;
|
||||
$this->repository = app()->make($this->repository_name);
|
||||
$this->repository->import_mode = true;
|
||||
$this->transformer = new ProductTransformer($this->company);
|
||||
$count = $this->ingest($data, $entity_type);
|
||||
$this->entity_count['products'] = $count;
|
||||
}
|
||||
|
||||
public function getData($type)
|
||||
{
|
||||
|
||||
// get the data from cache? file? or api ?
|
||||
return json_decode(base64_decode(Cache::get("{$this->hash}-{$type}")), true);
|
||||
}
|
||||
|
||||
public function payment()
|
||||
{
|
||||
$entity_type = 'payment';
|
||||
$data = $this->getData($entity_type);
|
||||
if (empty($data)) {
|
||||
$this->entity_count['payments'] = 0;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->request_name = StorePaymentRequest::class;
|
||||
$this->repository_name = PaymentRepository::class;
|
||||
$this->factory_name = PaymentFactory::class;
|
||||
$this->repository = app()->make($this->repository_name);
|
||||
$this->repository->import_mode = true;
|
||||
$this->transformer = new PaymentTransformer($this->company);
|
||||
$count = $this->ingest($data, $entity_type);
|
||||
$this->entity_count['payments'] = $count;
|
||||
}
|
||||
|
||||
public function invoice()
|
||||
{
|
||||
//make sure we update and create products
|
||||
$initial_update_products_value = $this->company->update_products;
|
||||
$this->company->update_products = true;
|
||||
|
||||
$this->company->save();
|
||||
|
||||
$entity_type = 'invoice';
|
||||
$data = $this->getData($entity_type);
|
||||
|
||||
if (empty($data)) {
|
||||
$this->entity_count['invoices'] = 0;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->request_name = StoreInvoiceRequest::class;
|
||||
$this->repository_name = InvoiceRepository::class;
|
||||
$this->factory_name = InvoiceFactory::class;
|
||||
$this->repository = app()->make($this->repository_name);
|
||||
$this->repository->import_mode = true;
|
||||
$this->transformer = new InvoiceTransformer($this->company);
|
||||
$invoice_count = $this->ingestInvoices($data, '');
|
||||
$this->entity_count['invoices'] = $invoice_count;
|
||||
$this->company->update_products = $initial_update_products_value;
|
||||
$this->company->save();
|
||||
}
|
||||
|
||||
public function ingestInvoices($invoices, $invoice_number_key)
|
||||
{
|
||||
$count = 0;
|
||||
$invoice_transformer = $this->transformer;
|
||||
/** @var ClientRepository $client_repository */
|
||||
$client_repository = app()->make(ClientRepository::class);
|
||||
$client_repository->import_mode = true;
|
||||
$invoice_repository = new InvoiceRepository();
|
||||
$invoice_repository->import_mode = true;
|
||||
|
||||
foreach ($invoices as $raw_invoice) {
|
||||
if(!is_array($raw_invoice)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
$invoice_data = $invoice_transformer->transform($raw_invoice);
|
||||
$invoice_data['user_id'] = $this->company->owner()->id;
|
||||
$invoice_data['line_items'] = (array) $invoice_data['line_items'];
|
||||
$invoice_data['line_items'] = $this->cleanItems(
|
||||
$invoice_data['line_items'] ?? []
|
||||
);
|
||||
|
||||
if (
|
||||
empty($invoice_data['client_id']) &&
|
||||
! empty($invoice_data['client'])
|
||||
) {
|
||||
$client_data = $invoice_data['client'];
|
||||
$client_data['user_id'] = $this->getUserIDForRecord(
|
||||
$invoice_data
|
||||
);
|
||||
$client_repository->save(
|
||||
$client_data,
|
||||
$client = ClientFactory::create(
|
||||
$this->company->id,
|
||||
$client_data['user_id']
|
||||
)
|
||||
);
|
||||
$invoice_data['client_id'] = $client->id;
|
||||
unset($invoice_data['client']);
|
||||
}
|
||||
|
||||
$validator = $this->request_name::runFormRequest($invoice_data);
|
||||
if ($validator->fails()) {
|
||||
$this->error_array['invoice'][] = [
|
||||
'invoice' => $invoice_data,
|
||||
'error' => $validator->errors()->all(),
|
||||
];
|
||||
} else {
|
||||
if(!Invoice::where('number', $invoice_data['number'])->first()) {
|
||||
$invoice = InvoiceFactory::create(
|
||||
$this->company->id,
|
||||
$this->company->owner()->id
|
||||
);
|
||||
$invoice->mergeFillable(['partial','amount','balance','line_items']);
|
||||
if (! empty($invoice_data['status_id'])) {
|
||||
$invoice->status_id = $invoice_data['status_id'];
|
||||
}
|
||||
|
||||
$saveable_invoice_data = $invoice_data;
|
||||
if(array_key_exists('payments', $saveable_invoice_data)) {
|
||||
unset($saveable_invoice_data['payments']);
|
||||
}
|
||||
|
||||
$invoice->fill($saveable_invoice_data);
|
||||
$invoice->save();
|
||||
$count++;
|
||||
|
||||
}
|
||||
// $this->actionInvoiceStatus(
|
||||
// $invoice,
|
||||
// $invoice_data,
|
||||
// $invoice_repository
|
||||
// );
|
||||
}
|
||||
} catch (\Exception $ex) {
|
||||
if (\DB::connection(config('database.default'))->transactionLevel() > 0) {
|
||||
\DB::connection(config('database.default'))->rollBack();
|
||||
}
|
||||
|
||||
if ($ex instanceof ImportException) {
|
||||
$message = $ex->getMessage();
|
||||
} else {
|
||||
report($ex);
|
||||
$message = 'Unknown error ';
|
||||
nlog($ex->getMessage());
|
||||
nlog($raw_invoice);
|
||||
}
|
||||
|
||||
$this->error_array['invoice'][] = [
|
||||
'invoice' => $raw_invoice,
|
||||
'error' => $message,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return $count;
|
||||
}
|
||||
|
||||
}
|
@ -244,8 +244,7 @@ class Wave extends BaseImport implements ImportInterface
|
||||
if (empty($expense_data['vendor_id'])) {
|
||||
$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(
|
||||
['name' => isset($raw_expense['Vendor Name']) ? $raw_expense['Vendor Name'] : isset($raw_expense['Vendor'])],
|
||||
$vendor = VendorFactory::create(
|
||||
|
@ -119,8 +119,9 @@ class BaseTransformer
|
||||
{
|
||||
$code = array_key_exists($key, $data) ? $data[$key] : false;
|
||||
|
||||
if(!$code)
|
||||
if(!$code) {
|
||||
return $this->company->settings->currency_id;
|
||||
}
|
||||
|
||||
/** @var \Illuminate\Support\Collection<\App\Models\Currency> */
|
||||
$currencies = app('currencies');
|
||||
|
97
app/Import/Transformer/Quickbooks/ClientTransformer.php
Normal file
97
app/Import/Transformer/Quickbooks/ClientTransformer.php
Normal file
@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Invoice Ninja (https://clientninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://www.elastic.co/licensing/elastic-license
|
||||
*/
|
||||
|
||||
namespace App\Import\Transformer\Quickbooks;
|
||||
|
||||
use App\Import\Transformer\Quickbooks\CommonTrait;
|
||||
use App\Import\Transformer\BaseTransformer;
|
||||
use App\Models\Client as Model;
|
||||
use App\Models\ClientContact;
|
||||
use App\Import\ImportException;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* Class ClientTransformer.
|
||||
*/
|
||||
class ClientTransformer extends BaseTransformer
|
||||
{
|
||||
use CommonTrait {
|
||||
transform as preTransform;
|
||||
}
|
||||
|
||||
private $fillable = [
|
||||
'name' => 'CompanyName',
|
||||
'phone' => 'PrimaryPhone.FreeFormNumber',
|
||||
'country_id' => 'BillAddr.Country',
|
||||
'state' => 'BillAddr.CountrySubDivisionCode',
|
||||
'address1' => 'BillAddr.Line1',
|
||||
'city' => 'BillAddr.City',
|
||||
'postal_code' => 'BillAddr.PostalCode',
|
||||
'shipping_country_id' => 'ShipAddr.Country',
|
||||
'shipping_state' => 'ShipAddr.CountrySubDivisionCode',
|
||||
'shipping_address1' => 'ShipAddr.Line1',
|
||||
'shipping_city' => 'ShipAddr.City',
|
||||
'shipping_postal_code' => 'ShipAddr.PostalCode',
|
||||
'public_notes' => 'Notes'
|
||||
];
|
||||
|
||||
public function __construct($company)
|
||||
{
|
||||
parent::__construct($company);
|
||||
|
||||
$this->model = new Model();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Transforms a Customer array into a ClientContact model.
|
||||
*
|
||||
* @param array $data
|
||||
* @return array|bool
|
||||
*/
|
||||
public function transform($data)
|
||||
{
|
||||
$transformed_data = [];
|
||||
// Assuming 'customer_name' is equivalent to 'CompanyName'
|
||||
if (isset($data['CompanyName']) && $this->hasClient($data['CompanyName'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$transformed_data = $this->preTransform($data);
|
||||
$transformed_data['contacts'][0] = $this->getContacts($data)->toArray() + ['company_id' => $this->company->id ];
|
||||
|
||||
return $transformed_data;
|
||||
}
|
||||
|
||||
protected function getContacts($data)
|
||||
{
|
||||
return (new ClientContact())->fill([
|
||||
'first_name' => $this->getString($data, 'GivenName'),
|
||||
'last_name' => $this->getString($data, 'FamilyName'),
|
||||
'phone' => $this->getString($data, 'PrimaryPhone.FreeFormNumber'),
|
||||
'email' => $this->getString($data, 'PrimaryEmailAddr.Address'),
|
||||
'company_id' => $this->company->id
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
public function getShipAddrCountry($data, $field)
|
||||
{
|
||||
return is_null(($c = $this->getString($data, $field))) ? null : $this->getCountryId($c);
|
||||
}
|
||||
|
||||
public function getBillAddrCountry($data, $field)
|
||||
{
|
||||
return is_null(($c = $this->getString($data, $field))) ? null : $this->getCountryId($c);
|
||||
}
|
||||
|
||||
}
|
37
app/Import/Transformer/Quickbooks/CommonTrait.php
Normal file
37
app/Import/Transformer/Quickbooks/CommonTrait.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Import\Transformer\Quickbooks;
|
||||
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
trait CommonTrait
|
||||
{
|
||||
protected $model;
|
||||
|
||||
public function getString($data, $field)
|
||||
{
|
||||
return Arr::get($data, $field);
|
||||
}
|
||||
|
||||
public function getCreateTime($data, $field = null)
|
||||
{
|
||||
return $this->parseDateOrNull($data, 'MetaData.CreateTime');
|
||||
}
|
||||
|
||||
public function getLastUpdatedTime($data, $field = null)
|
||||
{
|
||||
return $this->parseDateOrNull($data, 'MetaData.LastUpdatedTime');
|
||||
}
|
||||
|
||||
public function transform($data)
|
||||
{
|
||||
$transformed = [];
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
return $this->model->fillable(array_keys($this->fillable))->fill($transformed)->toArray() + ['company_id' => $this->company->id ] ;
|
||||
}
|
||||
|
||||
}
|
200
app/Import/Transformer/Quickbooks/InvoiceTransformer.php
Normal file
200
app/Import/Transformer/Quickbooks/InvoiceTransformer.php
Normal file
@ -0,0 +1,200 @@
|
||||
<?php
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://www.elastic.co/licensing/elastic-license
|
||||
*/
|
||||
|
||||
namespace App\Import\Transformer\Quickbooks;
|
||||
|
||||
use App\Models\Invoice;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Str;
|
||||
use App\DataMapper\InvoiceItem;
|
||||
use App\Import\ImportException;
|
||||
use App\Models\Invoice as Model;
|
||||
use App\Import\Transformer\BaseTransformer;
|
||||
use App\Import\Transformer\Quickbooks\CommonTrait;
|
||||
use App\Import\Transformer\Quickbooks\ClientTransformer;
|
||||
|
||||
/**
|
||||
* Class InvoiceTransformer.
|
||||
*/
|
||||
class InvoiceTransformer extends BaseTransformer
|
||||
{
|
||||
use CommonTrait {
|
||||
transform as preTransform;
|
||||
}
|
||||
|
||||
private $fillable = [
|
||||
'amount' => "TotalAmt",
|
||||
'line_items' => "Line",
|
||||
'due_date' => "DueDate",
|
||||
'partial' => "Deposit",
|
||||
'balance' => "Balance",
|
||||
'private_notes' => "CustomerMemo",
|
||||
'public_notes' => "CustomerMemo",
|
||||
'number' => "DocNumber",
|
||||
'created_at' => "CreateTime",
|
||||
'updated_at' => "LastUpdatedTime",
|
||||
'payments' => 'LinkedTxn',
|
||||
'status_id' => 'InvoiceStatus',
|
||||
];
|
||||
|
||||
public function __construct($company)
|
||||
{
|
||||
parent::__construct($company);
|
||||
|
||||
$this->model = new Model();
|
||||
}
|
||||
|
||||
public function getInvoiceStatus($data)
|
||||
{
|
||||
return Invoice::STATUS_SENT;
|
||||
}
|
||||
|
||||
public function transform($data)
|
||||
{
|
||||
return $this->preTransform($data) + $this->getInvoiceClient($data);
|
||||
}
|
||||
|
||||
public function getTotalAmt($data)
|
||||
{
|
||||
return (float) $this->getString($data, 'TotalAmt');
|
||||
}
|
||||
|
||||
public function getLine($data)
|
||||
{
|
||||
return array_map(function ($item) {
|
||||
return [
|
||||
'description' => $this->getString($item, 'Description'),
|
||||
'product_key' => $this->getString($item, 'Description'),
|
||||
'quantity' => (int) $this->getString($item, 'SalesItemLineDetail.Qty'),
|
||||
'unit_price' => (float) $this->getString($item, 'SalesItemLineDetail.UnitPrice'),
|
||||
'line_total' => (float) $this->getString($item, 'Amount'),
|
||||
'cost' => (float) $this->getString($item, 'SalesItemLineDetail.UnitPrice'),
|
||||
'product_cost' => (float) $this->getString($item, 'SalesItemLineDetail.UnitPrice'),
|
||||
'tax_amount' => (float) $this->getString($item, 'TxnTaxDetail.TotalTax'),
|
||||
];
|
||||
}, array_filter($this->getString($data, 'Line'), function ($item) {
|
||||
return $this->getString($item, 'DetailType') !== 'SubTotalLineDetail';
|
||||
}));
|
||||
}
|
||||
|
||||
public function getInvoiceClient($data, $field = null)
|
||||
{
|
||||
/**
|
||||
* "CustomerRef": {
|
||||
"value": "23",
|
||||
"name": ""Barnett Design
|
||||
},
|
||||
"CustomerMemo": {
|
||||
"value": "Thank you for your business and have a great day!"
|
||||
},
|
||||
"BillAddr": {
|
||||
"Id": "58",
|
||||
"Line1": "Shara Barnett",
|
||||
"Line2": "Barnett Design",
|
||||
"Line3": "19 Main St.",
|
||||
"Line4": "Middlefield, CA 94303",
|
||||
"Lat": "37.4530553",
|
||||
"Long": "-122.1178261"
|
||||
},
|
||||
"ShipAddr": {
|
||||
"Id": "24",
|
||||
"Line1": "19 Main St.",
|
||||
"City": "Middlefield",
|
||||
"CountrySubDivisionCode": "CA",
|
||||
"PostalCode": "94303",
|
||||
"Lat": "37.445013",
|
||||
"Long": "-122.1391443"
|
||||
},"BillEmail": {
|
||||
"Address": "Design@intuit.com"
|
||||
},
|
||||
[
|
||||
'name' => 'CompanyName',
|
||||
'phone' => 'PrimaryPhone.FreeFormNumber',
|
||||
'country_id' => 'BillAddr.Country',
|
||||
'state' => 'BillAddr.CountrySubDivisionCode',
|
||||
'address1' => 'BillAddr.Line1',
|
||||
'city' => 'BillAddr.City',
|
||||
'postal_code' => 'BillAddr.PostalCode',
|
||||
'shipping_country_id' => 'ShipAddr.Country',
|
||||
'shipping_state' => 'ShipAddr.CountrySubDivisionCode',
|
||||
'shipping_address1' => 'ShipAddr.Line1',
|
||||
'shipping_city' => 'ShipAddr.City',
|
||||
'shipping_postal_code' => 'ShipAddr.PostalCode',
|
||||
'public_notes' => 'Notes'
|
||||
];
|
||||
|
||||
*/
|
||||
$bill_address = (object) $this->getString($data, 'BillAddr');
|
||||
$ship_address = $this->getString($data, 'ShipAddr');
|
||||
$customer = explode(" ", $this->getString($data, 'CustomerRef.name'));
|
||||
$customer = ['GivenName' => $customer[0], 'FamilyName' => $customer[1]];
|
||||
$has_company = property_exists($bill_address, 'Line4');
|
||||
$address = $has_company ? $bill_address->Line4 : $bill_address->Line3;
|
||||
$address_1 = substr($address, 0, stripos($address, ','));
|
||||
$address = array_filter([$address_1] + (explode(' ', substr($address, stripos($address, ",") + 1))));
|
||||
$client_id = null;
|
||||
$client =
|
||||
[
|
||||
"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 ],
|
||||
"ShipAddr" => $ship_address
|
||||
] + $customer + ['PrimaryEmailAddr' => ['Address' => $this->getString($data, 'BillEmail.Address') ]];
|
||||
if($this->hasClient($client['CompanyName'])) {
|
||||
$client_id = $this->getClient($client['CompanyName'], $this->getString($client, 'PrimaryEmailAddr.Address'));
|
||||
}
|
||||
|
||||
|
||||
return ['client' => (new ClientTransformer($this->company))->transform($client), 'client_id' => $client_id ];
|
||||
}
|
||||
|
||||
public function getDueDate($data)
|
||||
{
|
||||
return $this->parseDateOrNull($data, 'DueDate');
|
||||
}
|
||||
|
||||
public function getDeposit($data)
|
||||
{
|
||||
return (float) $this->getString($data, 'Deposit');
|
||||
}
|
||||
|
||||
public function getBalance($data)
|
||||
{
|
||||
return (float) $this->getString($data, 'Balance');
|
||||
}
|
||||
|
||||
public function getCustomerMemo($data)
|
||||
{
|
||||
return $this->getString($data, 'CustomerMemo.value');
|
||||
}
|
||||
|
||||
public function getDocNumber($data, $field = null)
|
||||
{
|
||||
return sprintf(
|
||||
"%s-%s",
|
||||
$this->getString($data, 'DocNumber'),
|
||||
$this->getString($data, 'Id.value')
|
||||
);
|
||||
}
|
||||
|
||||
public function getLinkedTxn($data)
|
||||
{
|
||||
$payments = $this->getString($data, 'LinkedTxn');
|
||||
if(empty($payments)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return [[
|
||||
'amount' => $this->getTotalAmt($data),
|
||||
'date' => $this->parseDateOrNull($data, 'TxnDate')
|
||||
]];
|
||||
|
||||
}
|
||||
}
|
106
app/Import/Transformer/Quickbooks/PaymentTransformer.php
Normal file
106
app/Import/Transformer/Quickbooks/PaymentTransformer.php
Normal file
@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Invoice Ninja (https://Paymentninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://www.elastic.co/licensing/elastic-license
|
||||
*/
|
||||
|
||||
namespace App\Import\Transformer\Quickbooks;
|
||||
|
||||
use App\Import\Transformer\Quickbooks\CommonTrait;
|
||||
use App\Import\Transformer\BaseTransformer;
|
||||
use App\Models\Payment as Model;
|
||||
use App\Import\ImportException;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Arr;
|
||||
use App\Models\Invoice;
|
||||
|
||||
/**
|
||||
*
|
||||
* Class PaymentTransformer.
|
||||
*/
|
||||
class PaymentTransformer extends BaseTransformer
|
||||
{
|
||||
use CommonTrait;
|
||||
|
||||
protected $fillable = [
|
||||
'number' => "PaymentRefNum",
|
||||
'amount' => "TotalAmt",
|
||||
"client_id" => "CustomerRef",
|
||||
"currency_id" => "CurrencyRef",
|
||||
'date' => "TxnDate",
|
||||
"invoices" => "Line",
|
||||
'private_notes' => "PrivateNote",
|
||||
'created_at' => "CreateTime",
|
||||
'updated_at' => "LastUpdatedTime"
|
||||
];
|
||||
|
||||
public function __construct($company)
|
||||
{
|
||||
parent::__construct($company);
|
||||
|
||||
$this->model = new Model();
|
||||
}
|
||||
|
||||
public function getTotalAmt($data, $field = null)
|
||||
{
|
||||
return (float) $this->getString($data, $field);
|
||||
}
|
||||
|
||||
public function getTxnDate($data, $field = null)
|
||||
{
|
||||
return $this->parseDateOrNull($data, $field);
|
||||
}
|
||||
|
||||
public function getCustomerRef($data, $field = null)
|
||||
{
|
||||
return $this->getClient($this->getString($data, 'CustomerRef.name'), null);
|
||||
}
|
||||
|
||||
public function getCurrencyRef($data, $field = null)
|
||||
{
|
||||
return $this->getCurrencyByCode($data['CurrencyRef'], 'value');
|
||||
}
|
||||
|
||||
public function getLine($data, $field = null)
|
||||
{
|
||||
$invoices = [];
|
||||
$invoice = $this->getString($data, 'Line.LinkedTxn.TxnType');
|
||||
if(is_null($invoice) || $invoice !== 'Invoice') {
|
||||
return $invoices;
|
||||
}
|
||||
if(is_null(($invoice_id = $this->getInvoiceId($this->getString($data, 'Line.LinkedTxn.TxnId.value'))))) {
|
||||
return $invoices;
|
||||
}
|
||||
|
||||
return [[
|
||||
'amount' => (float) $this->getString($data, 'Line.Amount'),
|
||||
'invoice_id' => $invoice_id
|
||||
]];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $invoice_number
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
public function getInvoiceId($invoice_number)
|
||||
{
|
||||
$invoice = Invoice::query()->where('company_id', $this->company->id)
|
||||
->where('is_deleted', false)
|
||||
->where(
|
||||
"number",
|
||||
"LIKE",
|
||||
"%-$invoice_number%",
|
||||
)
|
||||
->first();
|
||||
|
||||
return $invoice ? $invoice->id : null;
|
||||
}
|
||||
|
||||
}
|
61
app/Import/Transformer/Quickbooks/ProductTransformer.php
Normal file
61
app/Import/Transformer/Quickbooks/ProductTransformer.php
Normal file
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Invoice Ninja (https://Productninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://www.elastic.co/licensing/elastic-license
|
||||
*/
|
||||
|
||||
namespace App\Import\Transformer\Quickbooks;
|
||||
|
||||
use App\Import\Transformer\Quickbooks\CommonTrait;
|
||||
use App\Import\Transformer\BaseTransformer;
|
||||
use App\Models\Product as Model;
|
||||
use App\Import\ImportException;
|
||||
|
||||
/**
|
||||
* Class ProductTransformer.
|
||||
*/
|
||||
class ProductTransformer extends BaseTransformer
|
||||
{
|
||||
use CommonTrait;
|
||||
|
||||
protected $fillable = [
|
||||
'product_key' => 'Name',
|
||||
'notes' => 'Description',
|
||||
'cost' => 'PurchaseCost',
|
||||
'price' => 'UnitPrice',
|
||||
'quantity' => 'QtyOnHand',
|
||||
'in_stock_quantity' => 'QtyOnHand',
|
||||
'created_at' => 'CreateTime',
|
||||
'updated_at' => 'LastUpdatedTime',
|
||||
];
|
||||
|
||||
|
||||
public function __construct($company)
|
||||
{
|
||||
parent::__construct($company);
|
||||
|
||||
$this->model = new Model();
|
||||
}
|
||||
|
||||
public function getQtyOnHand($data, $field = null)
|
||||
{
|
||||
return (int) $this->getString($data, $field);
|
||||
}
|
||||
|
||||
public function getPurchaseCost($data, $field = null)
|
||||
{
|
||||
return (float) $this->getString($data, $field);
|
||||
}
|
||||
|
||||
|
||||
public function getUnitPrice($data, $field = null)
|
||||
{
|
||||
return (float) $this->getString($data, $field);
|
||||
}
|
||||
}
|
@ -38,12 +38,13 @@ class ExpenseTransformer extends BaseTransformer
|
||||
|
||||
$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'];
|
||||
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'];
|
||||
else
|
||||
} else {
|
||||
$public_notes = '';
|
||||
}
|
||||
|
||||
|
||||
$transformed = [
|
||||
|
@ -237,7 +237,7 @@ class MatchBankTransactions implements ShouldQueue
|
||||
|
||||
$amount = $this->bt->amount;
|
||||
|
||||
if ($_invoices->count() >0 && $this->checkPayable($_invoices)) {
|
||||
if ($_invoices->count() > 0 && $this->checkPayable($_invoices)) {
|
||||
$this->createPayment($_invoices, $amount);
|
||||
|
||||
$this->bts->push($this->bt->id);
|
||||
@ -387,7 +387,7 @@ class MatchBankTransactions implements ShouldQueue
|
||||
|
||||
$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']);
|
||||
}
|
||||
|
||||
|
@ -114,8 +114,7 @@ class RecurringExpensesCron
|
||||
$exchange_rate = new CurrencyApi();
|
||||
|
||||
$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;
|
||||
}
|
||||
|
||||
|
48
app/Jobs/Import/QuickbooksIngest.php
Normal file
48
app/Jobs/Import/QuickbooksIngest.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Import;
|
||||
|
||||
use App\Libraries\MultiDB;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use App\Import\Providers\Quickbooks;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
|
||||
class QuickbooksIngest implements ShouldQueue
|
||||
{
|
||||
use Dispatchable;
|
||||
use InteractsWithQueue;
|
||||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
protected $engine;
|
||||
protected $request;
|
||||
protected $company;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*/
|
||||
public function __construct(array $request, $company)
|
||||
{
|
||||
$this->company = $company;
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
MultiDB::setDb($this->company->db);
|
||||
set_time_limit(0);
|
||||
|
||||
$engine = new Quickbooks(['import_type' => 'client', 'hash' => $this->request['hash'] ], $this->company);
|
||||
foreach ($this->request['import_types'] as $entity) {
|
||||
$engine->import($entity);
|
||||
}
|
||||
|
||||
$engine->finalizeImport();
|
||||
}
|
||||
}
|
@ -298,7 +298,7 @@ class NinjaMailerJob implements ShouldQueue
|
||||
|
||||
/** Force free/trials onto specific mail driver */
|
||||
|
||||
if($this->mailer == 'default' && $this->company->account->isNewHostedAccount()) {
|
||||
if($this->nmo->settings->email_sending_method == 'default' && $this->company->account->isNewHostedAccount()) {
|
||||
$this->mailer = 'mailgun';
|
||||
$this->setHostedMailgunMailer();
|
||||
return $this;
|
||||
|
@ -48,12 +48,11 @@ class TaskAssigned implements ShouldQueue
|
||||
|
||||
$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->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->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->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->html_template = 'email.template.generic';
|
||||
$mo->to = [new Address($this->task->assigned_user->email, $this->task->assigned_user->present()->name())];
|
||||
|
@ -59,7 +59,6 @@ class Register extends Component
|
||||
|
||||
public function register(array $data)
|
||||
{
|
||||
|
||||
$service = new ClientRegisterService(
|
||||
company: $this->subscription->company,
|
||||
additional: $this->additional_fields,
|
||||
|
@ -363,10 +363,11 @@ class BillingPortalPurchase extends Component
|
||||
$method_values = array_column($this->methods, 'is_paypal');
|
||||
$is_paypal = in_array('1', $method_values);
|
||||
|
||||
if($is_paypal && !$this->steps['check_rff'])
|
||||
if($is_paypal && !$this->steps['check_rff']) {
|
||||
$this->rff();
|
||||
elseif(!$this->steps['check_rff'])
|
||||
} elseif(!$this->steps['check_rff']) {
|
||||
$this->steps['fetched_payment_methods'] = true;
|
||||
}
|
||||
|
||||
$this->heading_text = ctrans('texts.payment_methods');
|
||||
|
||||
|
@ -515,8 +515,7 @@ class BillingPortalPurchasev2 extends Component
|
||||
strlen($this->contact_email ?? '') == 0 ||
|
||||
strlen($this->client_city ?? '') == 0 ||
|
||||
strlen($this->client_postal_code ?? '') == 0
|
||||
)
|
||||
{
|
||||
) {
|
||||
$this->check_rff = true;
|
||||
}
|
||||
|
||||
|
287
app/Livewire/Flow2/InvoicePay.php
Normal file
287
app/Livewire/Flow2/InvoicePay.php
Normal file
@ -0,0 +1,287 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2024. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://www.elastic.co/licensing/elastic-license
|
||||
*/
|
||||
|
||||
namespace App\Livewire\Flow2;
|
||||
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Models\CompanyGateway;
|
||||
use App\Models\Invoice;
|
||||
use App\Utils\Number;
|
||||
use App\Utils\Traits\MakesDates;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use App\Utils\Traits\WithSecureContext;
|
||||
use Livewire\Attributes\Computed;
|
||||
use Livewire\Attributes\On;
|
||||
use Livewire\Component;
|
||||
|
||||
class InvoicePay extends Component
|
||||
{
|
||||
use MakesDates;
|
||||
use MakesHash;
|
||||
use WithSecureContext;
|
||||
|
||||
private $mappings = [
|
||||
'client_name' => 'name',
|
||||
'client_website' => 'website',
|
||||
'client_phone' => 'phone',
|
||||
|
||||
'client_address_line_1' => 'address1',
|
||||
'client_address_line_2' => 'address2',
|
||||
'client_city' => 'city',
|
||||
'client_state' => 'state',
|
||||
'client_postal_code' => 'postal_code',
|
||||
'client_country_id' => 'country_id',
|
||||
|
||||
'client_shipping_address_line_1' => 'shipping_address1',
|
||||
'client_shipping_address_line_2' => 'shipping_address2',
|
||||
'client_shipping_city' => 'shipping_city',
|
||||
'client_shipping_state' => 'shipping_state',
|
||||
'client_shipping_postal_code' => 'shipping_postal_code',
|
||||
'client_shipping_country_id' => 'shipping_country_id',
|
||||
|
||||
'client_custom_value1' => 'custom_value1',
|
||||
'client_custom_value2' => 'custom_value2',
|
||||
'client_custom_value3' => 'custom_value3',
|
||||
'client_custom_value4' => 'custom_value4',
|
||||
|
||||
'contact_first_name' => 'first_name',
|
||||
'contact_last_name' => 'last_name',
|
||||
'contact_email' => 'email',
|
||||
// 'contact_phone' => 'phone',
|
||||
];
|
||||
|
||||
public $client_address_array = [
|
||||
'address1',
|
||||
'address2',
|
||||
'city',
|
||||
'state',
|
||||
'postal_code',
|
||||
'country_id',
|
||||
'shipping_address1',
|
||||
'shipping_address2',
|
||||
'shipping_city',
|
||||
'shipping_state',
|
||||
'shipping_postal_code',
|
||||
'shipping_country_id',
|
||||
];
|
||||
|
||||
public $invitation_id;
|
||||
|
||||
public $invoices;
|
||||
|
||||
public $variables;
|
||||
|
||||
public $db;
|
||||
|
||||
public $settings;
|
||||
|
||||
public $terms_accepted = false;
|
||||
|
||||
public $signature_accepted = false;
|
||||
|
||||
public $payment_method_accepted = false;
|
||||
|
||||
public $under_over_payment = false;
|
||||
|
||||
public $required_fields = false;
|
||||
|
||||
#[On('update.context')]
|
||||
public function handleContext(string $property, $value): self
|
||||
{
|
||||
$this->setContext(property: $property, value: $value);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
#[On('terms-accepted')]
|
||||
public function termsAccepted()
|
||||
{
|
||||
nlog("Terms accepted");
|
||||
// $this->invite = \App\Models\InvoiceInvitation::withTrashed()->find($this->invitation_id)->withoutRelations();
|
||||
$this->terms_accepted = true;
|
||||
}
|
||||
|
||||
#[On('signature-captured')]
|
||||
public function signatureCaptured($base64)
|
||||
{
|
||||
nlog("signature captured");
|
||||
|
||||
$this->signature_accepted = true;
|
||||
$invite = \App\Models\InvoiceInvitation::withTrashed()->find($this->invitation_id);
|
||||
$invite->signature_base64 = $base64;
|
||||
$invite->signature_date = now()->addSeconds($invite->contact->client->timezone_offset());
|
||||
$this->setContext('signature', $base64); // $this->context['signature'] = $base64;
|
||||
$invite->save();
|
||||
|
||||
}
|
||||
|
||||
#[On('payable-amount')]
|
||||
public function payableAmount($payable_amount)
|
||||
{
|
||||
// $this->setContext('payable_invoices.0.amount', Number::parseFloat($payable_amount)); // $this->context['payable_invoices'][0]['amount'] = Number::parseFloat($payable_amount); //TODO DB: check parseFloat()
|
||||
$this->under_over_payment = false;
|
||||
}
|
||||
|
||||
#[On('payment-method-selected')]
|
||||
public function paymentMethodSelected($company_gateway_id, $gateway_type_id, $amount)
|
||||
{
|
||||
$this->setContext('company_gateway_id', $company_gateway_id);
|
||||
$this->setContext('gateway_type_id', $gateway_type_id);
|
||||
$this->setContext('amount', $amount);
|
||||
$this->setContext('pre_payment', false);
|
||||
$this->setContext('is_recurring', false);
|
||||
$this->setContext('invitation_id', $this->invitation_id);
|
||||
|
||||
$this->payment_method_accepted = true;
|
||||
|
||||
$company_gateway = CompanyGateway::query()->find($company_gateway_id);
|
||||
|
||||
$this->checkRequiredFields($company_gateway);
|
||||
}
|
||||
|
||||
#[On('required-fields')]
|
||||
public function requiredFieldsFilled()
|
||||
{
|
||||
$this->required_fields = false;
|
||||
}
|
||||
|
||||
private function checkRequiredFields(CompanyGateway $company_gateway)
|
||||
{
|
||||
|
||||
$fields = $company_gateway->driver()->getClientRequiredFields();
|
||||
|
||||
$this->setContext('fields', $fields); // $this->context['fields'] = $fields;
|
||||
|
||||
if ($company_gateway->always_show_required_fields) {
|
||||
return $this->required_fields = true;
|
||||
}
|
||||
|
||||
$contact = $this->getContext()['contact'];
|
||||
|
||||
foreach ($fields as $index => $field) {
|
||||
$_field = $this->mappings[$field['name']];
|
||||
|
||||
if (\Illuminate\Support\Str::startsWith($field['name'], 'client_')) {
|
||||
if (
|
||||
empty($contact->client->{$_field})
|
||||
|| is_null($contact->client->{$_field})
|
||||
) {
|
||||
|
||||
return $this->required_fields = true;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (\Illuminate\Support\Str::startsWith($field['name'], 'contact_')) {
|
||||
if (empty($contact->{$_field}) || is_null($contact->{$_field}) || str_contains($contact->{$_field}, '@example.com')) {
|
||||
return $this->required_fields = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->required_fields = false;
|
||||
|
||||
}
|
||||
|
||||
#[Computed()]
|
||||
public function component(): string
|
||||
{
|
||||
if (!$this->terms_accepted) {
|
||||
return Terms::class;
|
||||
}
|
||||
|
||||
if (!$this->signature_accepted) {
|
||||
return Signature::class;
|
||||
}
|
||||
|
||||
if ($this->under_over_payment) {
|
||||
return UnderOverPayment::class;
|
||||
}
|
||||
|
||||
if (!$this->payment_method_accepted) {
|
||||
return PaymentMethod::class;
|
||||
}
|
||||
|
||||
if ($this->required_fields) {
|
||||
return RequiredFields::class;
|
||||
}
|
||||
|
||||
return ProcessPayment::class;
|
||||
}
|
||||
|
||||
#[Computed()]
|
||||
public function componentUniqueId(): string
|
||||
{
|
||||
return "purchase-" . md5(microtime());
|
||||
}
|
||||
|
||||
public function mount()
|
||||
{
|
||||
$this->resetContext();
|
||||
|
||||
MultiDB::setDb($this->db);
|
||||
|
||||
// @phpstan-ignore-next-line
|
||||
$invite = \App\Models\InvoiceInvitation::with('contact.client', 'company')->withTrashed()->find($this->invitation_id);
|
||||
$client = $invite->contact->client;
|
||||
$settings = $client->getMergedSettings();
|
||||
$this->setContext('contact', $invite->contact); // $this->context['contact'] = $invite->contact;
|
||||
$this->setContext('settings', $settings); // $this->context['settings'] = $settings;
|
||||
$this->setContext('db', $this->db); // $this->context['db'] = $this->db;
|
||||
|
||||
nlog($this->invoices);
|
||||
|
||||
if(is_array($this->invoices)) {
|
||||
$this->invoices = Invoice::find($this->transformKeys($this->invoices));
|
||||
}
|
||||
|
||||
$invoices = $this->invoices->filter(function ($i) {
|
||||
$i = $i->service()
|
||||
->markSent()
|
||||
->removeUnpaidGatewayFees()
|
||||
->save();
|
||||
|
||||
return $i->isPayable();
|
||||
});
|
||||
|
||||
//under-over / payment
|
||||
|
||||
//required fields
|
||||
$this->terms_accepted = !$settings->show_accept_invoice_terms;
|
||||
$this->signature_accepted = !$settings->require_invoice_signature;
|
||||
$this->under_over_payment = $settings->client_portal_allow_over_payment || $settings->client_portal_allow_under_payment;
|
||||
$this->required_fields = false;
|
||||
|
||||
$this->setContext('variables', $this->variables); // $this->context['variables'] = $this->variables;
|
||||
$this->setContext('invoices', $invoices); // $this->context['invoices'] = $invoices;
|
||||
$this->setContext('settings', $settings); // $this->context['settings'] = $settings;
|
||||
$this->setContext('invitation', $invite); // $this->context['invitation'] = $invite;
|
||||
|
||||
$payable_invoices = $invoices->map(function ($i) {
|
||||
/** @var \App\Models\Invoice $i */
|
||||
return [
|
||||
'invoice_id' => $i->hashed_id,
|
||||
'amount' => $i->partial > 0 ? $i->partial : $i->balance,
|
||||
'formatted_amount' => Number::formatValue($i->partial > 0 ? $i->partial : $i->balance, $i->client->currency()),
|
||||
'number' => $i->number,
|
||||
'date' => $i->translateDate($i->date, $i->client->date_format(), $i->client->locale())
|
||||
];
|
||||
})->toArray();
|
||||
|
||||
$this->setContext('payable_invoices', $payable_invoices);
|
||||
}
|
||||
|
||||
public function render(): \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
{
|
||||
return render('flow2.invoice-pay');
|
||||
}
|
||||
}
|
47
app/Livewire/Flow2/InvoiceSummary.php
Normal file
47
app/Livewire/Flow2/InvoiceSummary.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2024. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://www.elastic.co/licensing/elastic-license
|
||||
*/
|
||||
|
||||
namespace App\Livewire\Flow2;
|
||||
|
||||
use App\Utils\Traits\WithSecureContext;
|
||||
use Livewire\Attributes\On;
|
||||
use Livewire\Component;
|
||||
|
||||
class InvoiceSummary extends Component
|
||||
{
|
||||
use WithSecureContext;
|
||||
|
||||
public $invoices;
|
||||
|
||||
public function mount()
|
||||
{
|
||||
//@TODO for a single invoice - show all details, for multi-invoices, only show the summaries
|
||||
$this->invoices = $this->getContext()['invoices']; // $this->context['invitation']->invoice;
|
||||
}
|
||||
|
||||
#[On(self::CONTEXT_UPDATE)]
|
||||
public function onContextUpdate(): void
|
||||
{
|
||||
// refactor logic for updating the price for eg if it changes with under/over pay
|
||||
|
||||
$this->invoices = $this->getContext()['invoices'];
|
||||
}
|
||||
|
||||
public function render(): \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
{
|
||||
return render('flow2.invoices-summary', [
|
||||
'invoice' => $this->invoices,
|
||||
'client' => $this->invoices->first()->client,
|
||||
]);
|
||||
|
||||
}
|
||||
}
|
78
app/Livewire/Flow2/PaymentMethod.php
Normal file
78
app/Livewire/Flow2/PaymentMethod.php
Normal file
@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2024. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://www.elastic.co/licensing/elastic-license
|
||||
*/
|
||||
|
||||
namespace App\Livewire\Flow2;
|
||||
|
||||
use App\Utils\Traits\WithSecureContext;
|
||||
use Livewire\Component;
|
||||
use App\Libraries\MultiDB;
|
||||
|
||||
class PaymentMethod extends Component
|
||||
{
|
||||
use WithSecureContext;
|
||||
|
||||
public $invoice;
|
||||
|
||||
public $variables;
|
||||
|
||||
public $methods = [];
|
||||
|
||||
public $isLoading = true;
|
||||
|
||||
public $amount = 0;
|
||||
|
||||
public function placeholder()
|
||||
{
|
||||
return <<<'HTML'
|
||||
<div class="flex items-center justify-center min-h-screen">
|
||||
<svg class="animate-spin h-10 w-10 text-gray-500" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
|
||||
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
|
||||
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
|
||||
</svg>
|
||||
</div>
|
||||
HTML;
|
||||
}
|
||||
|
||||
public function handleSelect(string $company_gateway_id, string $gateway_type_id, string $amount)
|
||||
{
|
||||
$this->isLoading = true;
|
||||
|
||||
$this->dispatch(
|
||||
event: 'payment-method-selected',
|
||||
company_gateway_id: $company_gateway_id,
|
||||
gateway_type_id: $gateway_type_id,
|
||||
amount: $amount,
|
||||
);
|
||||
}
|
||||
|
||||
public function mount()
|
||||
{
|
||||
$this->variables = $this->getContext()['variables'];
|
||||
$this->amount = array_sum(array_column($this->getContext()['payable_invoices'], 'amount'));
|
||||
|
||||
MultiDB::setDb($this->getContext()['db']);
|
||||
|
||||
$this->methods = $this->getContext()['invitation']->contact->client->service()->getPaymentMethods($this->amount);
|
||||
|
||||
if (count($this->methods) == 1) {
|
||||
$this->dispatch('singlePaymentMethodFound', company_gateway_id: $this->methods[0]['company_gateway_id'], gateway_type_id: $this->methods[0]['gateway_type_id'], amount: $this->amount);
|
||||
} else {
|
||||
$this->isLoading = false;
|
||||
$this->dispatch('loadingCompleted');
|
||||
}
|
||||
}
|
||||
|
||||
public function render(): \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
{
|
||||
return render('flow2.payment-method', ['methods' => $this->methods]);
|
||||
}
|
||||
}
|
86
app/Livewire/Flow2/ProcessPayment.php
Normal file
86
app/Livewire/Flow2/ProcessPayment.php
Normal file
@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2024. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://www.elastic.co/licensing/elastic-license
|
||||
*/
|
||||
|
||||
namespace App\Livewire\Flow2;
|
||||
|
||||
use App\Exceptions\PaymentFailed;
|
||||
use App\Utils\Traits\WithSecureContext;
|
||||
use Livewire\Component;
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Models\CompanyGateway;
|
||||
use App\Models\InvoiceInvitation;
|
||||
use App\Services\ClientPortal\LivewireInstantPayment;
|
||||
|
||||
class ProcessPayment extends Component
|
||||
{
|
||||
use WithSecureContext;
|
||||
|
||||
private ?string $payment_view;
|
||||
|
||||
private array $payment_data_payload = [];
|
||||
|
||||
public $isLoading = true;
|
||||
|
||||
public function mount()
|
||||
{
|
||||
|
||||
MultiDB::setDb($this->getContext()['db']);
|
||||
|
||||
$invitation = InvoiceInvitation::find($this->getContext()['invitation_id']);
|
||||
|
||||
$data = [
|
||||
'company_gateway_id' => $this->getContext()['company_gateway_id'],
|
||||
'payment_method_id' => $this->getContext()['gateway_type_id'],
|
||||
'payable_invoices' => $this->getContext()['payable_invoices'],
|
||||
'signature' => isset($this->getContext()['signature']) ? $this->getContext()['signature'] : false,
|
||||
'signature_ip' => isset($this->getContext()['signature_ip']) ? $this->getContext()['signature_ip'] : false,
|
||||
'pre_payment' => false,
|
||||
'frequency_id' => false,
|
||||
'remaining_cycles' => false,
|
||||
'is_recurring' => false,
|
||||
// 'hash' => false,
|
||||
];
|
||||
|
||||
$responder_data = (new LivewireInstantPayment($data))->run();
|
||||
|
||||
$company_gateway = CompanyGateway::find($this->getContext()['company_gateway_id']);
|
||||
|
||||
if (!$responder_data['success']) {
|
||||
throw new PaymentFailed($responder_data['error'], 400);
|
||||
}
|
||||
|
||||
$driver = $company_gateway
|
||||
->driver($invitation->contact->client)
|
||||
->setPaymentMethod($data['payment_method_id'])
|
||||
->setPaymentHash($responder_data['payload']['ph']);
|
||||
|
||||
$this->payment_data_payload = $driver->processPaymentViewData($responder_data['payload']);
|
||||
|
||||
$this->payment_view = $driver->livewirePaymentView(
|
||||
$this->payment_data_payload,
|
||||
);
|
||||
|
||||
$this->isLoading = false;
|
||||
|
||||
}
|
||||
|
||||
public function render(): \Illuminate\Contracts\View\Factory|string|\Illuminate\View\View
|
||||
{
|
||||
if ($this->isLoading) {
|
||||
return <<<'HTML'
|
||||
<template></template>
|
||||
HTML;
|
||||
}
|
||||
|
||||
return render($this->payment_view, $this->payment_data_payload);
|
||||
}
|
||||
}
|
136
app/Livewire/Flow2/RequiredFields.php
Normal file
136
app/Livewire/Flow2/RequiredFields.php
Normal file
@ -0,0 +1,136 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2024. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://www.elastic.co/licensing/elastic-license
|
||||
*/
|
||||
|
||||
namespace App\Livewire\Flow2;
|
||||
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Models\CompanyGateway;
|
||||
use App\Services\Client\RFFService;
|
||||
use App\Utils\Traits\WithSecureContext;
|
||||
use Livewire\Component;
|
||||
|
||||
class RequiredFields extends Component
|
||||
{
|
||||
use WithSecureContext;
|
||||
|
||||
public ?CompanyGateway $company_gateway;
|
||||
|
||||
public ?string $client_name;
|
||||
public ?string $contact_first_name;
|
||||
public ?string $contact_last_name;
|
||||
public ?string $contact_email;
|
||||
public ?string $client_phone;
|
||||
public ?string $client_address_line_1;
|
||||
public ?string $client_city;
|
||||
public ?string $client_state;
|
||||
public ?int $client_country_id;
|
||||
public ?string $client_postal_code;
|
||||
public ?string $client_shipping_address_line_1;
|
||||
public ?string $client_shipping_city;
|
||||
public ?string $client_shipping_state;
|
||||
public ?string $client_shipping_postal_code;
|
||||
public ?int $client_shipping_country_id;
|
||||
public ?string $client_custom_value1;
|
||||
public ?string $client_custom_value2;
|
||||
public ?string $client_custom_value3;
|
||||
public ?string $client_custom_value4;
|
||||
|
||||
/** @var array<int, string> */
|
||||
public array $fields = [];
|
||||
|
||||
public bool $is_loading = true;
|
||||
|
||||
public array $errors = [];
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
MultiDB::setDB(
|
||||
$this->getContext()['db'],
|
||||
);
|
||||
|
||||
$this->fields = $this->getContext()['fields'];
|
||||
|
||||
$this->company_gateway = CompanyGateway::withTrashed()
|
||||
->with('company')
|
||||
->find($this->getContext()['company_gateway_id']);
|
||||
|
||||
$contact = auth()->user();
|
||||
|
||||
$this->client_name = $contact->client->name;
|
||||
$this->contact_first_name = $contact->first_name;
|
||||
$this->contact_last_name = $contact->last_name;
|
||||
$this->contact_email = $contact->email;
|
||||
$this->client_phone = $contact->client->phone;
|
||||
$this->client_address_line_1 = $contact->client->address1;
|
||||
$this->client_city = $contact->client->city;
|
||||
$this->client_state = $contact->client->state;
|
||||
$this->client_country_id = $contact->client->country_id;
|
||||
$this->client_postal_code = $contact->client->postal_code;
|
||||
$this->client_shipping_address_line_1 = $contact->client->shipping_address1;
|
||||
$this->client_shipping_city = $contact->client->shipping_city;
|
||||
$this->client_shipping_state = $contact->client->shipping_state;
|
||||
$this->client_shipping_postal_code = $contact->client->shipping_postal_code;
|
||||
$this->client_shipping_country_id = $contact->client->shipping_country_id;
|
||||
$this->client_custom_value1 = $contact->client->custom_value1;
|
||||
$this->client_custom_value2 = $contact->client->custom_value2;
|
||||
$this->client_custom_value3 = $contact->client->custom_value3;
|
||||
$this->client_custom_value4 = $contact->client->custom_value4;
|
||||
|
||||
$rff = new RFFService(
|
||||
fields: $this->getContext()['fields'],
|
||||
database: $this->getContext()['db'],
|
||||
company_gateway_id: $this->company_gateway->id,
|
||||
);
|
||||
|
||||
/** @var \App\Models\ClientContact $contact */
|
||||
$rff->check($contact);
|
||||
|
||||
if ($rff->unfilled_fields === 0) {
|
||||
$this->dispatch('required-fields');
|
||||
}
|
||||
|
||||
if ($rff->unfilled_fields > 0) {
|
||||
$this->is_loading = false;
|
||||
}
|
||||
}
|
||||
|
||||
public function handleSubmit(array $data)
|
||||
{
|
||||
$this->errors = [];
|
||||
$this->is_loading = true;
|
||||
|
||||
$rff = new RFFService(
|
||||
fields: $this->fields,
|
||||
database: $this->getContext()['db'],
|
||||
company_gateway_id: $this->company_gateway->id,
|
||||
);
|
||||
|
||||
$contact = auth()->user();
|
||||
|
||||
/** @var \App\Models\ClientContact $contact */
|
||||
$errors = $rff->handleSubmit($data, $contact, return_errors: true, callback: function () {
|
||||
$this->dispatch('required-fields');
|
||||
});
|
||||
|
||||
if (is_array($errors) && count($errors)) {
|
||||
$this->errors = $errors;
|
||||
$this->is_loading = false;
|
||||
}
|
||||
}
|
||||
|
||||
public function render(): \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
{
|
||||
return render('flow2.required-fields', [
|
||||
'contact' => $this->getContext()['contact'],
|
||||
]);
|
||||
}
|
||||
}
|
23
app/Livewire/Flow2/Signature.php
Normal file
23
app/Livewire/Flow2/Signature.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2024. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://www.elastic.co/licensing/elastic-license
|
||||
*/
|
||||
|
||||
namespace App\Livewire\Flow2;
|
||||
|
||||
use Livewire\Component;
|
||||
|
||||
class Signature extends Component
|
||||
{
|
||||
public function render()
|
||||
{
|
||||
return render('components.livewire.signature');
|
||||
}
|
||||
}
|
36
app/Livewire/Flow2/Terms.php
Normal file
36
app/Livewire/Flow2/Terms.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2024. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://www.elastic.co/licensing/elastic-license
|
||||
*/
|
||||
|
||||
namespace App\Livewire\Flow2;
|
||||
|
||||
use App\Utils\Traits\WithSecureContext;
|
||||
use Livewire\Component;
|
||||
|
||||
class Terms extends Component
|
||||
{
|
||||
use WithSecureContext;
|
||||
|
||||
public $invoice;
|
||||
|
||||
public $variables;
|
||||
|
||||
public function mount()
|
||||
{
|
||||
$this->invoice = $this->getContext()['invoices']->first();
|
||||
$this->variables = $this->getContext()['variables'];
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return render('components.livewire.terms');
|
||||
}
|
||||
}
|
76
app/Livewire/Flow2/UnderOverPayment.php
Normal file
76
app/Livewire/Flow2/UnderOverPayment.php
Normal file
@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2024. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://www.elastic.co/licensing/elastic-license
|
||||
*/
|
||||
|
||||
namespace App\Livewire\Flow2;
|
||||
|
||||
use App\Utils\Number;
|
||||
use App\Utils\Traits\WithSecureContext;
|
||||
use Livewire\Component;
|
||||
|
||||
class UnderOverPayment extends Component
|
||||
{
|
||||
use WithSecureContext;
|
||||
|
||||
public $payableAmount;
|
||||
|
||||
public $currency;
|
||||
|
||||
public $invoice_amount;
|
||||
|
||||
public $errors = '';
|
||||
|
||||
public $payableInvoices = [];
|
||||
|
||||
public function mount()
|
||||
{
|
||||
|
||||
$this->invoice_amount = array_sum(array_column($this->getContext()['payable_invoices'], 'amount'));
|
||||
$this->currency = $this->getContext()['invitation']->contact->client->currency();
|
||||
$this->payableInvoices = $this->getContext()['payable_invoices'];
|
||||
}
|
||||
|
||||
public function checkValue(array $payableInvoices)
|
||||
{
|
||||
$this->errors = '';
|
||||
|
||||
$settings = $this->getContext()['settings'];
|
||||
|
||||
foreach($payableInvoices as $key => $invoice) {
|
||||
$payableInvoices[$key]['amount'] = Number::parseFloat($invoice['formatted_amount']);
|
||||
}
|
||||
|
||||
$input_amount = collect($payableInvoices)->sum('amount');
|
||||
|
||||
if($settings->client_portal_allow_under_payment && $settings->client_portal_under_payment_minimum != 0) {
|
||||
if($input_amount <= $settings->client_portal_under_payment_minimum) {
|
||||
// return error message under payment too low.
|
||||
$this->errors = ctrans('texts.minimum_required_payment', ['amount' => $settings->client_portal_under_payment_minimum]);
|
||||
$this->dispatch('errorMessageUpdate', errors: $this->errors);
|
||||
}
|
||||
}
|
||||
|
||||
if(!$settings->client_portal_allow_over_payment && ($input_amount > $this->invoice_amount)) {
|
||||
$this->errors = ctrans('texts.over_payments_disabled');
|
||||
$this->dispatch('errorMessageUpdate', errors: $this->errors);
|
||||
}
|
||||
|
||||
if(!$this->errors) {
|
||||
$this->setContext('payable_invoices', $payableInvoices);
|
||||
$this->dispatch('payable-amount', payable_amount: $input_amount);
|
||||
}
|
||||
}
|
||||
|
||||
public function render(): \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
{
|
||||
return render('flow2.under-over-payments');
|
||||
}
|
||||
}
|
@ -197,8 +197,8 @@ class RequiredClientInfo extends Component
|
||||
|
||||
MultiDB::setDb($this->db);
|
||||
$contact = ClientContact::withTrashed()->with(['client' => function ($query) {
|
||||
$query->without('gateway_tokens', 'documents', 'contacts.company', 'contacts'); // Exclude 'grandchildren' relation of 'client'
|
||||
}])->find($this->contact_id);
|
||||
$query->without('gateway_tokens', 'documents', 'contacts.company', 'contacts'); // Exclude 'grandchildren' relation of 'client'
|
||||
}])->find($this->contact_id);
|
||||
|
||||
$this->company_gateway = CompanyGateway::withTrashed()->with('company')->find($this->company_gateway_id);
|
||||
$company = $this->company_gateway->company;
|
||||
|
@ -26,7 +26,7 @@ class TemplateEmail extends Mailable
|
||||
|
||||
|
||||
/** @var \App\Models\Client $client */
|
||||
private $client;
|
||||
private $client;
|
||||
|
||||
/** @var \App\Models\ClientContact | \App\Models\VendorContact $contact */
|
||||
private $contact;
|
||||
@ -65,7 +65,7 @@ class TemplateEmail extends Mailable
|
||||
}
|
||||
|
||||
$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) {
|
||||
$link_string .= "<li>{$link}</li>";
|
||||
}
|
||||
|
@ -449,8 +449,9 @@ class Activity extends StaticModel
|
||||
$replacements['created_at'] = $this->created_at ?? '';
|
||||
$replacements['ip'] = $this->ip ?? '';
|
||||
|
||||
if($this->activity_type_id == 141)
|
||||
if($this->activity_type_id == 141) {
|
||||
$replacements = $this->harvestNoteEntities($replacements);
|
||||
}
|
||||
|
||||
return $replacements;
|
||||
|
||||
@ -472,12 +473,12 @@ class Activity extends StaticModel
|
||||
|
||||
];
|
||||
|
||||
foreach($entities as $entity)
|
||||
{
|
||||
foreach($entities as $entity) {
|
||||
$entity_key = substr($entity, 1);
|
||||
|
||||
if($this?->{$entity_key})
|
||||
if($this?->{$entity_key}) {
|
||||
$replacements = array_merge($replacements, $this->matchVar($entity));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -374,10 +374,9 @@ class BaseModel extends Model
|
||||
|
||||
$files->push($company_docs);
|
||||
|
||||
try{
|
||||
try {
|
||||
$pdf = (new PdfMerge($files->flatten()->toArray()))->run();
|
||||
}
|
||||
catch(\Exception $e){
|
||||
} catch(\Exception $e) {
|
||||
nlog("Exception:: BaseModel:: PdfMerge::" . $e->getMessage());
|
||||
}
|
||||
|
||||
|
@ -118,6 +118,7 @@ use Laracasts\Presenter\PresentableTrait;
|
||||
* @property string|null $smtp_port
|
||||
* @property string|null $smtp_encryption
|
||||
* @property string|null $smtp_local_domain
|
||||
* @property object|null $quickbooks
|
||||
* @property boolean $smtp_verify_peer
|
||||
* @property-read \App\Models\Account $account
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Activity> $activities
|
||||
@ -373,6 +374,7 @@ class Company extends BaseModel
|
||||
'ip',
|
||||
'smtp_username',
|
||||
'smtp_password',
|
||||
'quickbooks',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
@ -390,6 +392,7 @@ class Company extends BaseModel
|
||||
'smtp_username' => 'encrypted',
|
||||
'smtp_password' => 'encrypted',
|
||||
'e_invoice' => 'object',
|
||||
'quickbooks' => 'object',
|
||||
];
|
||||
|
||||
protected $with = [];
|
||||
|
@ -106,8 +106,8 @@ class Gateway extends StaticModel
|
||||
} elseif ($this->id == 62) {
|
||||
$link = 'https://docs.btcpayserver.org/InvoiceNinja/';
|
||||
} elseif ($this->id == 63) {
|
||||
$link = 'https://rotessa.com';
|
||||
}
|
||||
$link = 'https://rotessa.com';
|
||||
}
|
||||
|
||||
return $link;
|
||||
}
|
||||
@ -226,15 +226,15 @@ class Gateway extends StaticModel
|
||||
return [
|
||||
GatewayType::CRYPTO => ['refund' => true, 'token_billing' => false, 'webhooks' => ['confirmed', 'paid_out', 'failed', 'fulfilled']],
|
||||
]; //BTCPay
|
||||
case 63:
|
||||
return [
|
||||
GatewayType::BANK_TRANSFER => [
|
||||
'refund' => false,
|
||||
'token_billing' => true,
|
||||
'webhooks' => [],
|
||||
],
|
||||
GatewayType::ACSS => ['refund' => false, 'token_billing' => true, 'webhooks' => []]
|
||||
]; // Rotessa
|
||||
case 63:
|
||||
return [
|
||||
GatewayType::BANK_TRANSFER => [
|
||||
'refund' => false,
|
||||
'token_billing' => true,
|
||||
'webhooks' => [],
|
||||
],
|
||||
GatewayType::ACSS => ['refund' => false, 'token_billing' => true, 'webhooks' => []]
|
||||
]; // Rotessa
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
|
@ -431,9 +431,9 @@ class Invoice extends BaseModel
|
||||
|
||||
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;
|
||||
elseif ($this->status_id == self::STATUS_DRAFT && $this->is_deleted == false) {
|
||||
} elseif ($this->status_id == self::STATUS_DRAFT && $this->is_deleted == false) {
|
||||
return true;
|
||||
} elseif ($this->status_id == self::STATUS_SENT && $this->is_deleted == false) {
|
||||
return true;
|
||||
|
@ -28,6 +28,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
* @property string|null $transaction_reference
|
||||
* @property int|null $product_id
|
||||
* @property int|null $recurring_invoice_id
|
||||
* @property int|null $e_invoice_quota
|
||||
* @property-read \App\Models\RecurringInvoice $recurring_invoice
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|StaticModel company()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|StaticModel exclude($columns)
|
||||
|
@ -408,21 +408,21 @@ class Quote extends BaseModel
|
||||
$client->getSetting('quote_num_days_reminder1')
|
||||
) && ! $this->reminder1_sent) {
|
||||
return 'reminder1';
|
||||
// } elseif ($this->inReminderWindow(
|
||||
// $client->getSetting('schedule_reminder2'),
|
||||
// $client->getSetting('num_days_reminder2')
|
||||
// ) && ! $this->reminder2_sent) {
|
||||
// return 'reminder2';
|
||||
// } elseif ($this->inReminderWindow(
|
||||
// $client->getSetting('schedule_reminder3'),
|
||||
// $client->getSetting('num_days_reminder3')
|
||||
// ) && ! $this->reminder3_sent) {
|
||||
// return 'reminder3';
|
||||
// } elseif ($this->checkEndlessReminder(
|
||||
// $this->reminder_last_sent,
|
||||
// $client->getSetting('endless_reminder_frequency_id')
|
||||
// )) {
|
||||
// return 'endless_reminder';
|
||||
// } elseif ($this->inReminderWindow(
|
||||
// $client->getSetting('schedule_reminder2'),
|
||||
// $client->getSetting('num_days_reminder2')
|
||||
// ) && ! $this->reminder2_sent) {
|
||||
// return 'reminder2';
|
||||
// } elseif ($this->inReminderWindow(
|
||||
// $client->getSetting('schedule_reminder3'),
|
||||
// $client->getSetting('num_days_reminder3')
|
||||
// ) && ! $this->reminder3_sent) {
|
||||
// return 'reminder3';
|
||||
// } elseif ($this->checkEndlessReminder(
|
||||
// $this->reminder_last_sent,
|
||||
// $client->getSetting('endless_reminder_frequency_id')
|
||||
// )) {
|
||||
// return 'endless_reminder';
|
||||
} else {
|
||||
return $entity_string;
|
||||
}
|
||||
@ -435,8 +435,9 @@ class Quote extends BaseModel
|
||||
*/
|
||||
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 true;
|
||||
|
||||
|
@ -296,8 +296,7 @@ class Task extends BaseModel
|
||||
$client_currency = $this->client->getSetting('currency_id');
|
||||
$company_currency = $this->company->getSetting('currency_id');
|
||||
|
||||
if($client_currency != $company_currency)
|
||||
{
|
||||
if($client_currency != $company_currency) {
|
||||
$converter = new CurrencyApi();
|
||||
return $converter->convert($this->taskValue(), $client_currency, $company_currency);
|
||||
}
|
||||
@ -308,7 +307,7 @@ class Task extends BaseModel
|
||||
|
||||
public function taskValue(): float
|
||||
{
|
||||
return round(($this->calcDuration() / 3600) * $this->getRate(),2);
|
||||
return round(($this->calcDuration() / 3600) * $this->getRate(), 2);
|
||||
}
|
||||
|
||||
public function processLogs()
|
||||
@ -374,8 +373,9 @@ class Task extends BaseModel
|
||||
|
||||
public function assignedCompanyUser()
|
||||
{
|
||||
if(!$this->assigned_user_id)
|
||||
if(!$this->assigned_user_id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return CompanyUser::where('company_id', $this->company_id)->where('user_id', $this->assigned_user_id)->first();
|
||||
}
|
||||
|
@ -176,7 +176,10 @@ class Webhook extends BaseModel
|
||||
|
||||
public const EVENT_REMIND_QUOTE = 64;
|
||||
|
||||
public const EVENT_ACCEPTED_PURCHASE_ORDER = 65;
|
||||
|
||||
public static $valid_events = [
|
||||
self::EVENT_ACCEPTED_PURCHASE_ORDER,
|
||||
self::EVENT_REMIND_QUOTE,
|
||||
self::EVENT_CREATE_PURCHASE_ORDER,
|
||||
self::EVENT_UPDATE_PURCHASE_ORDER,
|
||||
|
@ -66,7 +66,7 @@ class EmailQuotaNotification extends Notification
|
||||
{
|
||||
$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_email = $owner->email ?? 'No Owner Email Found';
|
||||
|
||||
|
30
app/PaymentDrivers/Common/LivewireMethodInterface.php
Normal file
30
app/PaymentDrivers/Common/LivewireMethodInterface.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2024. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://www.elastic.co/licensing/elastic-license
|
||||
*/
|
||||
|
||||
namespace App\PaymentDrivers\Common;
|
||||
|
||||
interface LivewireMethodInterface
|
||||
{
|
||||
/**
|
||||
* Payment page for the gateway method.
|
||||
*
|
||||
* @param array $data
|
||||
*/
|
||||
public function livewirePaymentView(array $data): string;
|
||||
|
||||
/**
|
||||
* Payment data for the gateway method.
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
public function paymentData(array $data): array;
|
||||
}
|
261
app/PaymentDrivers/PayPalExpressPaymentDriver.php
Normal file
261
app/PaymentDrivers/PayPalExpressPaymentDriver.php
Normal file
@ -0,0 +1,261 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2024. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://www.elastic.co/licensing/elastic-license
|
||||
*/
|
||||
|
||||
namespace App\PaymentDrivers;
|
||||
|
||||
use App\Exceptions\PaymentFailed;
|
||||
use App\Jobs\Util\SystemLogger;
|
||||
use App\Models\GatewayType;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\PaymentType;
|
||||
use App\Models\SystemLog;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use Omnipay\Common\Item;
|
||||
use Omnipay\Omnipay;
|
||||
|
||||
class PayPalExpressPaymentDriver extends BaseDriver
|
||||
{
|
||||
use MakesHash;
|
||||
|
||||
public $token_billing = false;
|
||||
|
||||
public $can_authorise_credit_card = false;
|
||||
|
||||
private $omnipay_gateway;
|
||||
|
||||
private float $fee = 0;
|
||||
|
||||
public const SYSTEM_LOG_TYPE = SystemLog::TYPE_PAYPAL;
|
||||
|
||||
public function gatewayTypes()
|
||||
{
|
||||
return [
|
||||
GatewayType::PAYPAL,
|
||||
];
|
||||
}
|
||||
|
||||
public function init()
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize Omnipay PayPal_Express gateway.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function initializeOmnipayGateway(): void
|
||||
{
|
||||
$this->omnipay_gateway = Omnipay::create(
|
||||
$this->company_gateway->gateway->provider
|
||||
);
|
||||
|
||||
$this->omnipay_gateway->initialize((array) $this->company_gateway->getConfig());
|
||||
}
|
||||
|
||||
public function setPaymentMethod($payment_method_id)
|
||||
{
|
||||
// PayPal doesn't have multiple ways of paying.
|
||||
// There's just one, off-site redirect.
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function authorizeView($payment_method)
|
||||
{
|
||||
// PayPal doesn't support direct authorization.
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function authorizeResponse($request)
|
||||
{
|
||||
// PayPal doesn't support direct authorization.
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function processPaymentView($data)
|
||||
{
|
||||
$this->initializeOmnipayGateway();
|
||||
|
||||
$this->payment_hash->data = array_merge((array) $this->payment_hash->data, ['amount' => $data['total']['amount_with_fee']]);
|
||||
$this->payment_hash->save();
|
||||
|
||||
$response = $this->omnipay_gateway
|
||||
->purchase($this->generatePaymentDetails($data))
|
||||
->setItems($this->generatePaymentItems($data))
|
||||
->send();
|
||||
|
||||
if ($response->isRedirect()) {
|
||||
return redirect($response->getRedirectUrl());
|
||||
}
|
||||
|
||||
// $this->sendFailureMail($response->getMessage() ?: '');
|
||||
|
||||
$message = [
|
||||
'server_response' => $response->getMessage(),
|
||||
'data' => $this->payment_hash->data,
|
||||
];
|
||||
|
||||
SystemLogger::dispatch(
|
||||
$message,
|
||||
SystemLog::CATEGORY_GATEWAY_RESPONSE,
|
||||
SystemLog::EVENT_GATEWAY_FAILURE,
|
||||
SystemLog::TYPE_PAYPAL,
|
||||
$this->client,
|
||||
$this->client->company,
|
||||
);
|
||||
|
||||
throw new PaymentFailed($response->getMessage(), $response->getCode());
|
||||
}
|
||||
|
||||
public function processPaymentResponse($request)
|
||||
{
|
||||
$this->initializeOmnipayGateway();
|
||||
|
||||
$response = $this->omnipay_gateway
|
||||
->completePurchase(['amount' => $this->payment_hash->data->amount, 'currency' => $this->client->getCurrencyCode()])
|
||||
->send();
|
||||
|
||||
if ($response->isCancelled() && $this->client->getSetting('enable_client_portal')) {
|
||||
return redirect()->route('client.invoices.index')->with('warning', ctrans('texts.status_cancelled'));
|
||||
} elseif($response->isCancelled() && !$this->client->getSetting('enable_client_portal')) {
|
||||
redirect()->route('client.invoices.show', ['invoice' => $this->payment_hash->fee_invoice])->with('warning', ctrans('texts.status_cancelled'));
|
||||
}
|
||||
|
||||
if ($response->isSuccessful()) {
|
||||
$data = [
|
||||
'payment_method' => $response->getData()['TOKEN'],
|
||||
'payment_type' => PaymentType::PAYPAL,
|
||||
'amount' => $this->payment_hash->data->amount,
|
||||
'transaction_reference' => $response->getTransactionReference(),
|
||||
'gateway_type_id' => GatewayType::PAYPAL,
|
||||
];
|
||||
|
||||
$payment = $this->createPayment($data, \App\Models\Payment::STATUS_COMPLETED);
|
||||
|
||||
SystemLogger::dispatch(
|
||||
['response' => (array) $response->getData(), 'data' => $data],
|
||||
SystemLog::CATEGORY_GATEWAY_RESPONSE,
|
||||
SystemLog::EVENT_GATEWAY_SUCCESS,
|
||||
SystemLog::TYPE_PAYPAL,
|
||||
$this->client,
|
||||
$this->client->company,
|
||||
);
|
||||
|
||||
return redirect()->route('client.payments.show', ['payment' => $this->encodePrimaryKey($payment->id)]);
|
||||
}
|
||||
|
||||
if (! $response->isSuccessful()) {
|
||||
$data = $response->getData();
|
||||
|
||||
$this->sendFailureMail($response->getMessage() ?: '');
|
||||
|
||||
$message = [
|
||||
'server_response' => $data['L_LONGMESSAGE0'],
|
||||
'data' => $this->payment_hash->data,
|
||||
];
|
||||
|
||||
SystemLogger::dispatch(
|
||||
$message,
|
||||
SystemLog::CATEGORY_GATEWAY_RESPONSE,
|
||||
SystemLog::EVENT_GATEWAY_FAILURE,
|
||||
SystemLog::TYPE_PAYPAL,
|
||||
$this->client,
|
||||
$this->client->company,
|
||||
);
|
||||
|
||||
throw new PaymentFailed($response->getMessage(), $response->getCode());
|
||||
}
|
||||
}
|
||||
|
||||
public function generatePaymentDetails(array $data)
|
||||
{
|
||||
$_invoice = collect($this->payment_hash->data->invoices)->first();
|
||||
$invoice = Invoice::withTrashed()->find($this->decodePrimaryKey($_invoice->invoice_id));
|
||||
|
||||
// $this->fee = $this->feeCalc($invoice, $data['total']['amount_with_fee']);
|
||||
|
||||
return [
|
||||
'currency' => $this->client->getCurrencyCode(),
|
||||
'transactionType' => 'Purchase',
|
||||
'clientIp' => request()->getClientIp(),
|
||||
// 'amount' => round(($data['total']['amount_with_fee'] + $this->fee),2),
|
||||
'amount' => round($data['total']['amount_with_fee'], 2),
|
||||
'returnUrl' => route('client.payments.response', [
|
||||
'company_gateway_id' => $this->company_gateway->id,
|
||||
'payment_hash' => $this->payment_hash->hash,
|
||||
'payment_method_id' => GatewayType::PAYPAL,
|
||||
]),
|
||||
'cancelUrl' => $this->client->company->domain()."/client/invoices/{$invoice->hashed_id}",
|
||||
'description' => implode(',', collect($this->payment_hash->data->invoices)
|
||||
->map(function ($invoice) {
|
||||
return sprintf('%s: %s', ctrans('texts.invoice_number'), $invoice->invoice_number);
|
||||
})->toArray()),
|
||||
'transactionId' => $this->payment_hash->hash.'-'.time(),
|
||||
'ButtonSource' => 'InvoiceNinja_SP',
|
||||
'solutionType' => 'Sole',
|
||||
'no_shipping' => $this->company_gateway->require_shipping_address ? 0 : 1,
|
||||
];
|
||||
}
|
||||
|
||||
public function generatePaymentItems(array $data)
|
||||
{
|
||||
$_invoice = collect($this->payment_hash->data->invoices)->first();
|
||||
$invoice = Invoice::withTrashed()->find($this->decodePrimaryKey($_invoice->invoice_id));
|
||||
|
||||
$items = [];
|
||||
|
||||
$items[] = new Item([
|
||||
'name' => ' ',
|
||||
'description' => ctrans('texts.invoice_number').'# '.$invoice->number,
|
||||
'price' => $data['total']['amount_with_fee'],
|
||||
'quantity' => 1,
|
||||
]);
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
private function feeCalc($invoice, $invoice_total)
|
||||
{
|
||||
$invoice->service()->removeUnpaidGatewayFees();
|
||||
$invoice = $invoice->fresh();
|
||||
|
||||
$balance = floatval($invoice->balance);
|
||||
|
||||
$_updated_invoice = $invoice->service()->addGatewayFee($this->company_gateway, GatewayType::PAYPAL, $invoice_total)->save();
|
||||
|
||||
if (floatval($_updated_invoice->balance) > $balance) {
|
||||
$fee = floatval($_updated_invoice->balance) - $balance;
|
||||
|
||||
$this->payment_hash->fee_total = $fee;
|
||||
$this->payment_hash->save();
|
||||
|
||||
return $fee;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function livewirePaymentView(array $data): string
|
||||
{
|
||||
$this->processPaymentView($data);
|
||||
|
||||
return ''; // Gateway is offsite.
|
||||
}
|
||||
|
||||
public function processPaymentViewData(array $data): array
|
||||
{
|
||||
return $data;
|
||||
}
|
||||
}
|
@ -536,7 +536,7 @@ class EventServiceProvider extends ServiceProvider
|
||||
QuoteWasRestored::class => [
|
||||
QuoteRestoredActivity::class,
|
||||
],
|
||||
QuoteReminderWasEmailed::class =>[
|
||||
QuoteReminderWasEmailed::class => [
|
||||
QuoteReminderEmailActivity::class,
|
||||
// QuoteEmailedNotification::class,
|
||||
],
|
||||
|
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories\Import\Quickbooks\Contracts;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
interface RepositoryInterface
|
||||
{
|
||||
public function get(int $max = 100): Collection;
|
||||
public function all(): Collection;
|
||||
public function count(): int;
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user