mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-12 06:02:39 +01:00
Merge branch 'v5-develop' into v5-stable
This commit is contained in:
commit
b2c3151923
@ -1 +1 @@
|
|||||||
5.5.19
|
5.5.20
|
@ -76,7 +76,7 @@ class CheckData extends Command
|
|||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $signature = 'ninja:check-data {--database=} {--fix=} {--client_id=} {--vendor_id=} {--paid_to_date=} {--client_balance=} {--ledger_balance=} {--balance_status=}';
|
protected $signature = 'ninja:check-data {--database=} {--fix=} {--portal_url=} {--client_id=} {--vendor_id=} {--paid_to_date=} {--client_balance=} {--ledger_balance=} {--balance_status=}';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
@ -118,8 +118,10 @@ class CheckData extends Command
|
|||||||
$this->checkDuplicateRecurringInvoices();
|
$this->checkDuplicateRecurringInvoices();
|
||||||
$this->checkOauthSanity();
|
$this->checkOauthSanity();
|
||||||
|
|
||||||
if(Ninja::isHosted())
|
if(Ninja::isHosted()){
|
||||||
$this->checkAccountStatuses();
|
$this->checkAccountStatuses();
|
||||||
|
$this->checkNinjaPortalUrls();
|
||||||
|
}
|
||||||
|
|
||||||
if (! $this->option('client_id')) {
|
if (! $this->option('client_id')) {
|
||||||
$this->checkOAuth();
|
$this->checkOAuth();
|
||||||
@ -505,12 +507,12 @@ class CheckData extends Command
|
|||||||
|
|
||||||
$this->wrong_paid_to_dates++;
|
$this->wrong_paid_to_dates++;
|
||||||
|
|
||||||
$this->logMessage($client->present()->name.' id = # '.$client->id." - Client Paid To Date = {$client->paid_to_date} != Invoice Payments = {$total_paid_to_date} - {$_client->payments_applied} + {$credits_used_for_payments[0]->credit_payment}");
|
$this->logMessage($client->present()->name().' id = # '.$client->id." - Client Paid To Date = {$client->paid_to_date} != Invoice Payments = {$total_paid_to_date} - {$_client->payments_applied} + {$credits_used_for_payments[0]->credit_payment}");
|
||||||
|
|
||||||
$this->isValid = false;
|
$this->isValid = false;
|
||||||
|
|
||||||
if($this->option('paid_to_date')){
|
if($this->option('paid_to_date')){
|
||||||
$this->logMessage("# {$client->id} " . $client->present()->name.' - '.$client->number." Fixing {$client->paid_to_date} to {$total_paid_to_date}");
|
$this->logMessage("# {$client->id} " . $client->present()->name().' - '.$client->number." Fixing {$client->paid_to_date} to {$total_paid_to_date}");
|
||||||
$client->paid_to_date = $total_paid_to_date;
|
$client->paid_to_date = $total_paid_to_date;
|
||||||
$client->save();
|
$client->save();
|
||||||
}
|
}
|
||||||
@ -582,12 +584,12 @@ class CheckData extends Command
|
|||||||
if (round($total_invoice_payments, 2) != round($client->paid_to_date, 2)) {
|
if (round($total_invoice_payments, 2) != round($client->paid_to_date, 2)) {
|
||||||
$this->wrong_paid_to_dates++;
|
$this->wrong_paid_to_dates++;
|
||||||
|
|
||||||
$this->logMessage($client->present()->name.' id = # '.$client->id." - Paid to date does not match Client Paid To Date = {$client->paid_to_date} - Invoice Payments = {$total_invoice_payments}");
|
$this->logMessage($client->present()->name().' id = # '.$client->id." - Paid to date does not match Client Paid To Date = {$client->paid_to_date} - Invoice Payments = {$total_invoice_payments}");
|
||||||
|
|
||||||
$this->isValid = false;
|
$this->isValid = false;
|
||||||
|
|
||||||
if($this->option('paid_to_date')){
|
if($this->option('paid_to_date')){
|
||||||
$this->logMessage("# {$client->id} " . $client->present()->name.' - '.$client->number." Fixing {$client->paid_to_date} to {$total_invoice_payments}");
|
$this->logMessage("# {$client->id} " . $client->present()->name().' - '.$client->number." Fixing {$client->paid_to_date} to {$total_invoice_payments}");
|
||||||
$client->paid_to_date = $total_invoice_payments;
|
$client->paid_to_date = $total_invoice_payments;
|
||||||
$client->save();
|
$client->save();
|
||||||
}
|
}
|
||||||
@ -618,7 +620,7 @@ class CheckData extends Command
|
|||||||
if ((string)$total_paid != (string)($invoice->amount - $invoice->balance - $total_credit)) {
|
if ((string)$total_paid != (string)($invoice->amount - $invoice->balance - $total_credit)) {
|
||||||
$this->wrong_balances++;
|
$this->wrong_balances++;
|
||||||
|
|
||||||
$this->logMessage($client->present()->name.' - '.$client->id." - Total Paid = {$total_paid} != Calculated Total = {$calculated_paid_amount}");
|
$this->logMessage($client->present()->name().' - '.$client->id." - Total Paid = {$total_paid} != Calculated Total = {$calculated_paid_amount}");
|
||||||
|
|
||||||
$this->isValid = false;
|
$this->isValid = false;
|
||||||
}
|
}
|
||||||
@ -666,11 +668,11 @@ class CheckData extends Command
|
|||||||
|
|
||||||
$client_object = Client::withTrashed()->find($client['client_id']);
|
$client_object = Client::withTrashed()->find($client['client_id']);
|
||||||
|
|
||||||
$this->logMessage($client_object->present()->name.' - '.$client_object->id." - calculated client balances do not match Invoice Balances = ". $client['invoice_balance'] ." - Client Balance = ".rtrim($client['client_balance'], '0'));
|
$this->logMessage($client_object->present()->name().' - '.$client_object->id." - calculated client balances do not match Invoice Balances = ". $client['invoice_balance'] ." - Client Balance = ".rtrim($client['client_balance'], '0'));
|
||||||
|
|
||||||
if($this->option('client_balance')){
|
if($this->option('client_balance')){
|
||||||
|
|
||||||
$this->logMessage("# {$client_object->id} " . $client_object->present()->name.' - '.$client_object->number." Fixing {$client_object->balance} to " . $client['invoice_balance']);
|
$this->logMessage("# {$client_object->id} " . $client_object->present()->name().' - '.$client_object->number." Fixing {$client_object->balance} to " . $client['invoice_balance']);
|
||||||
$client_object->balance = $client['invoice_balance'];
|
$client_object->balance = $client['invoice_balance'];
|
||||||
$client_object->save();
|
$client_object->save();
|
||||||
|
|
||||||
@ -704,7 +706,7 @@ class CheckData extends Command
|
|||||||
|
|
||||||
if($this->option('client_balance')){
|
if($this->option('client_balance')){
|
||||||
|
|
||||||
$this->logMessage("# {$client->id} " . $client->present()->name.' - '.$client->number." Fixing {$client->balance} to 0");
|
$this->logMessage("# {$client->id} " . $client->present()->name().' - '.$client->number." Fixing {$client->balance} to 0");
|
||||||
|
|
||||||
$client->balance = 0;
|
$client->balance = 0;
|
||||||
$client->save();
|
$client->save();
|
||||||
@ -758,13 +760,13 @@ class CheckData extends Command
|
|||||||
$this->wrong_balances++;
|
$this->wrong_balances++;
|
||||||
$ledger_balance = $ledger ? $ledger->balance : 0;
|
$ledger_balance = $ledger ? $ledger->balance : 0;
|
||||||
|
|
||||||
$this->logMessage("# {$client->id} " . $client->present()->name.' - '.$client->number." - Balance Failure - Invoice Balances = {$invoice_balance} Client Balance = {$client->balance} Ledger Balance = {$ledger_balance}");
|
$this->logMessage("# {$client->id} " . $client->present()->name().' - '.$client->number." - Balance Failure - Invoice Balances = {$invoice_balance} Client Balance = {$client->balance} Ledger Balance = {$ledger_balance}");
|
||||||
|
|
||||||
$this->isValid = false;
|
$this->isValid = false;
|
||||||
|
|
||||||
if($this->option('client_balance')){
|
if($this->option('client_balance')){
|
||||||
|
|
||||||
$this->logMessage("# {$client->id} " . $client->present()->name.' - '.$client->number." Fixing {$client->balance} to {$invoice_balance}");
|
$this->logMessage("# {$client->id} " . $client->present()->name().' - '.$client->number." Fixing {$client->balance} to {$invoice_balance}");
|
||||||
$client->balance = $invoice_balance;
|
$client->balance = $invoice_balance;
|
||||||
$client->save();
|
$client->save();
|
||||||
|
|
||||||
@ -796,14 +798,14 @@ class CheckData extends Command
|
|||||||
|
|
||||||
if ($ledger && number_format($ledger->balance, 4) != number_format($client->balance, 4)) {
|
if ($ledger && number_format($ledger->balance, 4) != number_format($client->balance, 4)) {
|
||||||
$this->wrong_balances++;
|
$this->wrong_balances++;
|
||||||
$this->logMessage("# {$client->id} " . $client->present()->name.' - '.$client->number." - Balance Failure - Client Balance = {$client->balance} Ledger Balance = {$ledger->balance}");
|
$this->logMessage("# {$client->id} " . $client->present()->name().' - '.$client->number." - Balance Failure - Client Balance = {$client->balance} Ledger Balance = {$ledger->balance}");
|
||||||
|
|
||||||
$this->isValid = false;
|
$this->isValid = false;
|
||||||
|
|
||||||
|
|
||||||
if($this->option('ledger_balance')){
|
if($this->option('ledger_balance')){
|
||||||
|
|
||||||
$this->logMessage("# {$client->id} " . $client->present()->name.' - '.$client->number." Fixing {$client->balance} to {$invoice_balance}");
|
$this->logMessage("# {$client->id} " . $client->present()->name().' - '.$client->number." Fixing {$client->balance} to {$invoice_balance}");
|
||||||
$client->balance = $invoice_balance;
|
$client->balance = $invoice_balance;
|
||||||
$client->save();
|
$client->save();
|
||||||
|
|
||||||
@ -1003,4 +1005,31 @@ class CheckData extends Command
|
|||||||
$this->logMessage($this->wrong_paid_status." wrong invoices with bad balance state");
|
$this->logMessage($this->wrong_paid_status." wrong invoices with bad balance state");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function checkNinjaPortalUrls()
|
||||||
|
{
|
||||||
|
|
||||||
|
$wrong_count = CompanyUser::where('is_owner',1)->where('ninja_portal_url', '')->count();
|
||||||
|
|
||||||
|
$this->logMessage("Missing ninja portal Urls = {$wrong_count}");
|
||||||
|
|
||||||
|
if(!$this->option('portal_url'))
|
||||||
|
return;
|
||||||
|
|
||||||
|
CompanyUser::where('is_owner',1)->where('ninja_portal_url', '')->cursor()->each(function ($cu){
|
||||||
|
|
||||||
|
$cc = ClientContact::on('db-ninja-01')->where('company_id', config('ninja.ninja_default_company_id'))->where('email', $cu->user->email)->first();
|
||||||
|
|
||||||
|
if($cc){
|
||||||
|
$ninja_portal_url = "https://invoiceninja.invoicing.co/client/ninja/{$cc->contact_key}/{$cu->company->company_key}";
|
||||||
|
|
||||||
|
$cu->ninja_portal_url = $ninja_portal_url;
|
||||||
|
$cu->save();
|
||||||
|
|
||||||
|
$this->logMessage("Fixing - {$ninja_portal_url}");
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
@ -189,7 +189,7 @@ class CreateSingleAccount extends Command
|
|||||||
$this->createClient($company, $user);
|
$this->createClient($company, $user);
|
||||||
}
|
}
|
||||||
|
|
||||||
CreateCompanyTaskStatuses::dispatchNow($company, $user);
|
(new CreateCompanyTaskStatuses($company, $user))->handle();
|
||||||
|
|
||||||
for ($x = 0; $x < $this->count; $x++) {
|
for ($x = 0; $x < $this->count; $x++) {
|
||||||
$client = $company->clients->random();
|
$client = $company->clients->random();
|
||||||
|
@ -132,7 +132,8 @@ class DemoMode extends Command
|
|||||||
'enabled_modules' => 32767,
|
'enabled_modules' => 32767,
|
||||||
'company_key' => 'KEY',
|
'company_key' => 'KEY',
|
||||||
'enable_shop_api' => true,
|
'enable_shop_api' => true,
|
||||||
'markdown_email_enabled' => false,
|
'markdown_email_enabled' => true,
|
||||||
|
'markdown_enabled' => false,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$settings = $company->settings;
|
$settings = $company->settings;
|
||||||
|
@ -97,10 +97,6 @@ class SendRemindersCron extends Command
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// SendReminders::dispatchNow();
|
|
||||||
|
|
||||||
// $this->webHookOverdueInvoices();
|
|
||||||
// $this->webHookExpiredQuotes();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function calcLateFee($invoice, $template) :Invoice
|
private function calcLateFee($invoice, $template) :Invoice
|
||||||
|
@ -727,7 +727,6 @@ class CompanySettings extends BaseSettings
|
|||||||
*/
|
*/
|
||||||
public static function defaults(): stdClass
|
public static function defaults(): stdClass
|
||||||
{
|
{
|
||||||
$config = json_decode(config('ninja.settings'));
|
|
||||||
|
|
||||||
$data = (object) get_class_vars(self::class);
|
$data = (object) get_class_vars(self::class);
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ class CompanyFactory
|
|||||||
|
|
||||||
$company->enabled_modules = config('ninja.enabled_modules'); //32767;//8191; //4095
|
$company->enabled_modules = config('ninja.enabled_modules'); //32767;//8191; //4095
|
||||||
$company->default_password_timeout = 1800000;
|
$company->default_password_timeout = 1800000;
|
||||||
$company->markdown_email_enabled = false;
|
$company->markdown_email_enabled = true;
|
||||||
$company->markdown_enabled = false;
|
$company->markdown_enabled = false;
|
||||||
|
|
||||||
return $company;
|
return $company;
|
||||||
|
@ -46,7 +46,7 @@ class ContactRegisterController extends Controller
|
|||||||
$t = app('translator');
|
$t = app('translator');
|
||||||
$t->replace(Ninja::transformTranslations($company->settings));
|
$t->replace(Ninja::transformTranslations($company->settings));
|
||||||
|
|
||||||
return render('auth.register', ['register_company' => $company, 'account' => $company->account]);
|
return render('auth.register', ['register_company' => $company, 'account' => $company->account, 'submitsForm' => false]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function register(RegisterRequest $request)
|
public function register(RegisterRequest $request)
|
||||||
|
@ -773,7 +773,8 @@ class BaseController extends Controller
|
|||||||
// 10-01-2022 need to ensure we snake case properly here to ensure permissions work as expected
|
// 10-01-2022 need to ensure we snake case properly here to ensure permissions work as expected
|
||||||
// 28-03-2022 this is definitely correct here, do not append _ to the view, it resolved correctly when snake cased
|
// 28-03-2022 this is definitely correct here, do not append _ to the view, it resolved correctly when snake cased
|
||||||
if (auth()->user() && ! auth()->user()->hasPermission('view'.lcfirst(class_basename(Str::snake($this->entity_type))))) {
|
if (auth()->user() && ! auth()->user()->hasPermission('view'.lcfirst(class_basename(Str::snake($this->entity_type))))) {
|
||||||
$query->where('user_id', '=', auth()->user()->id);
|
//03-09-2022
|
||||||
|
$query->where('user_id', '=', auth()->user()->id)->orWhere('assigned_user_id', auth()->user()->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request()->has('updated_at') && request()->input('updated_at') > 0) {
|
if (request()->has('updated_at') && request()->input('updated_at') > 0) {
|
||||||
@ -900,9 +901,10 @@ class BaseController extends Controller
|
|||||||
return redirect('/')->with(['signup' => 'true']);
|
return redirect('/')->with(['signup' => 'true']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 06-09-2022 - parse the path if loaded in a subdirectory for canvaskit resolution
|
||||||
$canvas_path_array = parse_url(config('ninja.app_url'));
|
$canvas_path_array = parse_url(config('ninja.app_url'));
|
||||||
|
|
||||||
$canvas_path = (array_key_exists('path', $canvas_path_array)) ? $canvas_path_array['path'] : '';
|
$canvas_path = (array_key_exists('path', $canvas_path_array)) ? $canvas_path_array['path'] : '';
|
||||||
|
$canvas_path = rtrim(str_replace("index.php", "", $canvas_path),'/');
|
||||||
|
|
||||||
$data = [];
|
$data = [];
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ class EmailController extends BaseController
|
|||||||
if(Ninja::isHosted() && !$entity_obj->company->account->account_sms_verified)
|
if(Ninja::isHosted() && !$entity_obj->company->account->account_sms_verified)
|
||||||
return response(['message' => 'Please verify your account to send emails.'], 400);
|
return response(['message' => 'Please verify your account to send emails.'], 400);
|
||||||
|
|
||||||
if($entity == 'purchaseOrder' || $template == 'purchase_order'){
|
if($entity == 'purchaseOrder' || $entity == 'purchase_order' || $template == 'purchase_order'){
|
||||||
return $this->sendPurchaseOrder($entity_obj, $data);
|
return $this->sendPurchaseOrder($entity_obj, $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,7 +173,7 @@ class PreviewPurchaseOrderController extends BaseController
|
|||||||
}
|
}
|
||||||
|
|
||||||
//else
|
//else
|
||||||
$file_path = PreviewPdf::dispatchNow($maker->getCompiledHTML(true), auth()->user()->company());
|
$file_path = (new PreviewPdf($maker->getCompiledHTML(true), auth()->user()->company()))->handle();
|
||||||
|
|
||||||
return response()->download($file_path, basename($file_path), ['Cache-Control:' => 'no-cache'])->deleteFileAfterSend(true);
|
return response()->download($file_path, basename($file_path), ['Cache-Control:' => 'no-cache'])->deleteFileAfterSend(true);
|
||||||
}
|
}
|
||||||
@ -285,7 +285,7 @@ class PreviewPurchaseOrderController extends BaseController
|
|||||||
return $pdf;
|
return $pdf;
|
||||||
}
|
}
|
||||||
|
|
||||||
$file_path = PreviewPdf::dispatchNow($maker->getCompiledHTML(true), $company);
|
$file_path = (new PreviewPdf($maker->getCompiledHTML(true), $company))->handle();
|
||||||
|
|
||||||
|
|
||||||
if(Ninja::isHosted())
|
if(Ninja::isHosted())
|
||||||
@ -363,7 +363,7 @@ class PreviewPurchaseOrderController extends BaseController
|
|||||||
return $pdf;
|
return $pdf;
|
||||||
}
|
}
|
||||||
|
|
||||||
$file_path = PreviewPdf::dispatchNow($maker->getCompiledHTML(true), auth()->user()->company());
|
$file_path = (new PreviewPdf($maker->getCompiledHTML(true), auth()->user()->company()))->handle();
|
||||||
|
|
||||||
$response = Response::make($file_path, 200);
|
$response = Response::make($file_path, 200);
|
||||||
$response->header('Content-Type', 'application/pdf');
|
$response->header('Content-Type', 'application/pdf');
|
||||||
@ -460,7 +460,7 @@ class PreviewPurchaseOrderController extends BaseController
|
|||||||
return $pdf;
|
return $pdf;
|
||||||
}
|
}
|
||||||
|
|
||||||
$file_path = PreviewPdf::dispatchNow($maker->getCompiledHTML(true), auth()->user()->company());
|
$file_path = (new PreviewPdf($maker->getCompiledHTML(true), auth()->user()->company()))->handle();
|
||||||
|
|
||||||
$response = Response::make($file_path, 200);
|
$response = Response::make($file_path, 200);
|
||||||
$response->header('Content-Type', 'application/pdf');
|
$response->header('Content-Type', 'application/pdf');
|
||||||
|
@ -210,7 +210,7 @@ class UserController extends BaseController
|
|||||||
|
|
||||||
$user_agent = request()->input('token_name') ?: request()->server('HTTP_USER_AGENT');
|
$user_agent = request()->input('token_name') ?: request()->server('HTTP_USER_AGENT');
|
||||||
|
|
||||||
$ct = CreateCompanyToken::dispatchNow($company, $user, $user_agent);
|
$ct = (new CreateCompanyToken($company, $user, $user_agent))->handle();
|
||||||
|
|
||||||
event(new UserWasCreated($user, auth()->user(), $company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
|
event(new UserWasCreated($user, auth()->user(), $company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
|
||||||
|
|
||||||
|
@ -108,8 +108,6 @@ class InvitationController extends Controller
|
|||||||
|
|
||||||
$file_name = $invitation->purchase_order->numberFormatter().'.pdf';
|
$file_name = $invitation->purchase_order->numberFormatter().'.pdf';
|
||||||
|
|
||||||
// $file = CreateRawPdf::dispatchNow($invitation, $invitation->company->db);
|
|
||||||
|
|
||||||
$file = (new CreatePurchaseOrderPdf($invitation))->rawPdf();
|
$file = (new CreatePurchaseOrderPdf($invitation))->rawPdf();
|
||||||
|
|
||||||
$headers = ['Content-Type' => 'application/pdf'];
|
$headers = ['Content-Type' => 'application/pdf'];
|
||||||
|
@ -507,7 +507,7 @@ class BillingPortalPurchase extends Component
|
|||||||
$mailer->settings = $this->subscription->company->settings;
|
$mailer->settings = $this->subscription->company->settings;
|
||||||
$mailer->to_user = $contact;
|
$mailer->to_user = $contact;
|
||||||
|
|
||||||
NinjaMailerJob::dispatchNow($mailer);
|
NinjaMailerJob::dispatch($mailer);
|
||||||
|
|
||||||
$this->steps['passwordless_login_sent'] = true;
|
$this->steps['passwordless_login_sent'] = true;
|
||||||
$this->passwordless_login_btn = false;
|
$this->passwordless_login_btn = false;
|
||||||
|
@ -29,10 +29,10 @@ class NameWebsiteLogo extends Component
|
|||||||
{
|
{
|
||||||
$this->fill([
|
$this->fill([
|
||||||
'profile' => auth()->guard('contact')->user()->client,
|
'profile' => auth()->guard('contact')->user()->client,
|
||||||
'name' => auth()->guard('contact')->user()->client->present()->name,
|
'name' => auth()->guard('contact')->user()->client->present()->name(),
|
||||||
'vat_number' => auth()->guard('contact')->user()->client->present()->vat_number,
|
'vat_number' => auth()->guard('contact')->user()->client->vat_number ?: '',
|
||||||
'website' => auth()->guard('contact')->user()->client->present()->website,
|
'website' => auth()->guard('contact')->user()->client->website,
|
||||||
'phone' => auth()->guard('contact')->user()->client->present()->phone,
|
'phone' => auth()->guard('contact')->user()->client->present()->phone(),
|
||||||
'saved' => ctrans('texts.save'),
|
'saved' => ctrans('texts.save'),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ class ContactRegister
|
|||||||
{
|
{
|
||||||
$domain_name = $request->getHost();
|
$domain_name = $request->getHost();
|
||||||
|
|
||||||
|
/* Hosted */
|
||||||
if (strpos($domain_name, 'invoicing.co') !== false) {
|
if (strpos($domain_name, 'invoicing.co') !== false) {
|
||||||
$subdomain = explode('.', $domain_name)[0];
|
$subdomain = explode('.', $domain_name)[0];
|
||||||
|
|
||||||
@ -42,6 +43,7 @@ class ContactRegister
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Hosted */
|
||||||
if (Ninja::isHosted()) {
|
if (Ninja::isHosted()) {
|
||||||
$query = [
|
$query = [
|
||||||
'portal_domain' => $request->getSchemeAndHttpHost(),
|
'portal_domain' => $request->getSchemeAndHttpHost(),
|
||||||
|
@ -65,7 +65,7 @@ class StoreClientRequest extends Request
|
|||||||
/* Ensure we have a client name, and that all emails are unique*/
|
/* Ensure we have a client name, and that all emails are unique*/
|
||||||
//$rules['name'] = 'required|min:1';
|
//$rules['name'] = 'required|min:1';
|
||||||
$rules['settings'] = new ValidClientGroupSettingsRule();
|
$rules['settings'] = new ValidClientGroupSettingsRule();
|
||||||
$rules['contacts'] = 'array';
|
$rules['contacts'] = 'bail|array';
|
||||||
$rules['contacts.*.email'] = 'bail|nullable|distinct|sometimes|email';
|
$rules['contacts.*.email'] = 'bail|nullable|distinct|sometimes|email';
|
||||||
$rules['contacts.*.password'] = [
|
$rules['contacts.*.password'] = [
|
||||||
'bail',
|
'bail',
|
||||||
|
@ -1,4 +1,13 @@
|
|||||||
<?php
|
<?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\Http\Requests\ClientPortal;
|
namespace App\Http\Requests\ClientPortal;
|
||||||
|
|
||||||
@ -7,6 +16,7 @@ use App\Models\Account;
|
|||||||
use App\Models\Company;
|
use App\Models\Company;
|
||||||
use App\Utils\Ninja;
|
use App\Utils\Ninja;
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
class RegisterRequest extends FormRequest
|
class RegisterRequest extends FormRequest
|
||||||
{
|
{
|
||||||
@ -31,13 +41,13 @@ class RegisterRequest extends FormRequest
|
|||||||
|
|
||||||
foreach ($this->company()->client_registration_fields as $field) {
|
foreach ($this->company()->client_registration_fields as $field) {
|
||||||
if ($field['required']) {
|
if ($field['required']) {
|
||||||
$rules[$field['key']] = ['required'];
|
$rules[$field['key']] = ['bail','required'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($rules as $field => $properties) {
|
foreach ($rules as $field => $properties) {
|
||||||
if ($field === 'email') {
|
if ($field === 'email') {
|
||||||
$rules[$field] = array_merge($rules[$field], ['email:rfc,dns', 'max:255']);
|
$rules[$field] = array_merge($rules[$field], ['email:rfc,dns', 'max:255', Rule::unique('client_contacts')->where('company_id', $this->company()->id)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($field === 'current_password') {
|
if ($field === 'current_password') {
|
||||||
|
@ -43,7 +43,7 @@ class StorePaymentRequest extends Request
|
|||||||
$invoices_total = 0;
|
$invoices_total = 0;
|
||||||
$credits_total = 0;
|
$credits_total = 0;
|
||||||
|
|
||||||
if (isset($input['client_id'])) {
|
if (isset($input['client_id']) && is_string($input['client_id']) ) {
|
||||||
$input['client_id'] = $this->decodePrimaryKey($input['client_id']);
|
$input['client_id'] = $this->decodePrimaryKey($input['client_id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,7 +53,9 @@ class StorePaymentRequest extends Request
|
|||||||
|
|
||||||
if (isset($input['invoices']) && is_array($input['invoices']) !== false) {
|
if (isset($input['invoices']) && is_array($input['invoices']) !== false) {
|
||||||
foreach ($input['invoices'] as $key => $value) {
|
foreach ($input['invoices'] as $key => $value) {
|
||||||
$input['invoices'][$key]['invoice_id'] = $this->decodePrimaryKey($value['invoice_id']);
|
|
||||||
|
if(is_string($value['invoice_id']))
|
||||||
|
$input['invoices'][$key]['invoice_id'] = $this->decodePrimaryKey($value['invoice_id']);
|
||||||
|
|
||||||
if (array_key_exists('amount', $value)) {
|
if (array_key_exists('amount', $value)) {
|
||||||
$invoices_total += $value['amount'];
|
$invoices_total += $value['amount'];
|
||||||
@ -97,7 +99,8 @@ class StorePaymentRequest extends Request
|
|||||||
{
|
{
|
||||||
$rules = [
|
$rules = [
|
||||||
'amount' => ['numeric', 'bail', new PaymentAmountsBalanceRule(), new ValidCreditsPresentRule($this->all())],
|
'amount' => ['numeric', 'bail', new PaymentAmountsBalanceRule(), new ValidCreditsPresentRule($this->all())],
|
||||||
'client_id' => 'bail|required|exists:clients,id',
|
// 'client_id' => 'bail|required|exists:clients,id',
|
||||||
|
'client_id' => 'bail|required|exists:clients,id,company_id,'.auth()->user()->company()->id.',is_deleted,0',
|
||||||
'invoices.*.invoice_id' => 'bail|required|distinct|exists:invoices,id',
|
'invoices.*.invoice_id' => 'bail|required|distinct|exists:invoices,id',
|
||||||
'invoices.*.amount' => 'bail|required',
|
'invoices.*.amount' => 'bail|required',
|
||||||
'invoices.*.invoice_id' => new ValidInvoicesRules($this->all()),
|
'invoices.*.invoice_id' => new ValidInvoicesRules($this->all()),
|
||||||
|
@ -85,7 +85,9 @@ class BaseTransformer
|
|||||||
|
|
||||||
$client_name_search = Client::where('company_id', $this->company->id)
|
$client_name_search = Client::where('company_id', $this->company->id)
|
||||||
->where('is_deleted', false)
|
->where('is_deleted', false)
|
||||||
->where('name', $client_name);
|
->whereRaw("LOWER(REPLACE(`name`, ' ' ,'')) = ?", [
|
||||||
|
strtolower(str_replace(' ', '', $client_name)),
|
||||||
|
]);
|
||||||
|
|
||||||
if ($client_name_search->count() >= 1) {
|
if ($client_name_search->count() >= 1) {
|
||||||
return $client_name_search->first()->id;
|
return $client_name_search->first()->id;
|
||||||
|
@ -288,7 +288,7 @@ class CompanyImport implements ShouldQueue
|
|||||||
$nmo->company = $_company;
|
$nmo->company = $_company;
|
||||||
$nmo->settings = $_company->settings;
|
$nmo->settings = $_company->settings;
|
||||||
$nmo->to_user = $_company->owner();
|
$nmo->to_user = $_company->owner();
|
||||||
NinjaMailerJob::dispatchNow($nmo);
|
NinjaMailerJob::dispatch($nmo);
|
||||||
|
|
||||||
}
|
}
|
||||||
catch(\Exception $e){
|
catch(\Exception $e){
|
||||||
@ -1644,7 +1644,7 @@ class CompanyImport implements ShouldQueue
|
|||||||
$nmo->company = $this->company;
|
$nmo->company = $this->company;
|
||||||
$nmo->settings = $this->company->settings;
|
$nmo->settings = $this->company->settings;
|
||||||
$nmo->to_user = $this->company->owner();
|
$nmo->to_user = $this->company->owner();
|
||||||
NinjaMailerJob::dispatchNow($nmo);
|
NinjaMailerJob::dispatch($nmo);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -64,7 +64,8 @@ class CreateCompany
|
|||||||
$company->custom_fields = new \stdClass;
|
$company->custom_fields = new \stdClass;
|
||||||
$company->default_password_timeout = 1800000;
|
$company->default_password_timeout = 1800000;
|
||||||
$company->client_registration_fields = ClientRegistrationFields::generate();
|
$company->client_registration_fields = ClientRegistrationFields::generate();
|
||||||
$company->markdown_email_enabled = false;
|
$company->markdown_email_enabled = true;
|
||||||
|
$company->markdown_enabled = false;
|
||||||
|
|
||||||
if (Ninja::isHosted()) {
|
if (Ninja::isHosted()) {
|
||||||
$company->subdomain = MultiDB::randomSubdomainGenerator();
|
$company->subdomain = MultiDB::randomSubdomainGenerator();
|
||||||
|
@ -52,8 +52,6 @@ class CheckCompanyData implements ShouldQueue
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute the job.
|
* Execute the job.
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
@ -110,7 +108,7 @@ class CheckCompanyData implements ShouldQueue
|
|||||||
if ($ledger && number_format($invoice_balance, 4) != number_format($client->balance, 4)) {
|
if ($ledger && number_format($invoice_balance, 4) != number_format($client->balance, 4)) {
|
||||||
$wrong_balances++;
|
$wrong_balances++;
|
||||||
|
|
||||||
$this->company_data[] = "# {$client->id} ".$client->present()->name.' - '.$client->number." - Balance Failure - Invoice Balances = {$invoice_balance} Client Balance = {$client->balance} Ledger Balance = {$ledger->balance} ";
|
$this->company_data[] = "# {$client->id} ".$client->present()->name().' - '.$client->number." - Balance Failure - Invoice Balances = {$invoice_balance} Client Balance = {$client->balance} Ledger Balance = {$ledger->balance} ";
|
||||||
|
|
||||||
$this->is_valid = false;
|
$this->is_valid = false;
|
||||||
}
|
}
|
||||||
@ -136,7 +134,7 @@ class CheckCompanyData implements ShouldQueue
|
|||||||
if ((string) $total_paid != (string) ($invoice->amount - $invoice->balance - $total_credit)) {
|
if ((string) $total_paid != (string) ($invoice->amount - $invoice->balance - $total_credit)) {
|
||||||
$wrong_balances++;
|
$wrong_balances++;
|
||||||
|
|
||||||
$this->company_data[] = $client->present()->name.' - '.$client->id." - Total Amount = {$total_amount} != Calculated Total = {$calculated_paid_amount} - Total Refund = {$total_refund} Total credit = {$total_credit}";
|
$this->company_data[] = $client->present()->name().' - '.$client->id." - Total Amount = {$total_amount} != Calculated Total = {$calculated_paid_amount} - Total Refund = {$total_refund} Total credit = {$total_credit}";
|
||||||
|
|
||||||
$this->is_valid = false;
|
$this->is_valid = false;
|
||||||
}
|
}
|
||||||
@ -175,7 +173,7 @@ class CheckCompanyData implements ShouldQueue
|
|||||||
if (round($total_invoice_payments, 2) != round($client->paid_to_date, 2)) {
|
if (round($total_invoice_payments, 2) != round($client->paid_to_date, 2)) {
|
||||||
$wrong_paid_to_dates++;
|
$wrong_paid_to_dates++;
|
||||||
|
|
||||||
$this->company_data[] = $client->present()->name.'id = # '.$client->id." - Paid to date does not match Client Paid To Date = {$client->paid_to_date} - Invoice Payments = {$total_invoice_payments}";
|
$this->company_data[] = $client->present()->name().'id = # '.$client->id." - Paid to date does not match Client Paid To Date = {$client->paid_to_date} - Invoice Payments = {$total_invoice_payments}";
|
||||||
|
|
||||||
$this->is_valid = false;
|
$this->is_valid = false;
|
||||||
}
|
}
|
||||||
@ -204,7 +202,7 @@ class CheckCompanyData implements ShouldQueue
|
|||||||
if ($ledger && (string) $invoice_balance != (string) $client->balance) {
|
if ($ledger && (string) $invoice_balance != (string) $client->balance) {
|
||||||
$wrong_paid_to_dates++;
|
$wrong_paid_to_dates++;
|
||||||
|
|
||||||
$this->company_data[] = $client->present()->name.' - '.$client->id." - calculated client balances do not match {$invoice_balance} - ".rtrim($client->balance, '0').'';
|
$this->company_data[] = $client->present()->name().' - '.$client->id." - calculated client balances do not match {$invoice_balance} - ".rtrim($client->balance, '0').'';
|
||||||
|
|
||||||
$this->is_valid = false;
|
$this->is_valid = false;
|
||||||
}
|
}
|
||||||
|
@ -252,7 +252,7 @@ class Import implements ShouldQueue
|
|||||||
$this->setInitialCompanyLedgerBalances();
|
$this->setInitialCompanyLedgerBalances();
|
||||||
|
|
||||||
// $this->fixClientBalances();
|
// $this->fixClientBalances();
|
||||||
$check_data = CheckCompanyData::dispatchNow($this->company, md5(time()));
|
$check_data = (new CheckCompanyData($this->company, md5(time())))->handle();
|
||||||
|
|
||||||
// if(Ninja::isHosted() && array_key_exists('ninja_tokens', $data))
|
// if(Ninja::isHosted() && array_key_exists('ninja_tokens', $data))
|
||||||
$this->processNinjaTokens($data['ninja_tokens']);
|
$this->processNinjaTokens($data['ninja_tokens']);
|
||||||
@ -591,7 +591,7 @@ class Import implements ShouldQueue
|
|||||||
|
|
||||||
$user_agent = array_key_exists('token_name', $resource) ?: request()->server('HTTP_USER_AGENT');
|
$user_agent = array_key_exists('token_name', $resource) ?: request()->server('HTTP_USER_AGENT');
|
||||||
|
|
||||||
CreateCompanyToken::dispatchNow($this->company, $user, $user_agent);
|
(new CreateCompanyToken($this->company, $user, $user_agent))->handle();
|
||||||
|
|
||||||
$key = "users_{$resource['id']}";
|
$key = "users_{$resource['id']}";
|
||||||
|
|
||||||
@ -1899,7 +1899,7 @@ class Import implements ShouldQueue
|
|||||||
if(Ninja::isHosted()){
|
if(Ninja::isHosted()){
|
||||||
|
|
||||||
try{
|
try{
|
||||||
\Modules\Admin\Jobs\Account\NinjaUser::dispatchNow($data, $this->company);
|
\Modules\Admin\Jobs\Account\NinjaUser::dispatch($data, $this->company);
|
||||||
}
|
}
|
||||||
catch(\Exception $e){
|
catch(\Exception $e){
|
||||||
nlog($e->getMessage());
|
nlog($e->getMessage());
|
||||||
|
@ -112,7 +112,7 @@ class ClientPaymentFailureObject
|
|||||||
'invoice' => $this->invoices->first()->number,
|
'invoice' => $this->invoices->first()->number,
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
'greeting' => ctrans('texts.email_salutation', ['name' => $this->client->present()->name]),
|
'greeting' => ctrans('texts.email_salutation', ['name' => $this->client->present()->name()]),
|
||||||
'content' => ctrans('texts.client_payment_failure_body', ['invoice' => implode(',', $this->invoices->pluck('number')->toArray()), 'amount' => $this->getAmount()]),
|
'content' => ctrans('texts.client_payment_failure_body', ['invoice' => implode(',', $this->invoices->pluck('number')->toArray()), 'amount' => $this->getAmount()]),
|
||||||
'signature' => $signature,
|
'signature' => $signature,
|
||||||
'logo' => $this->company->present()->logo(),
|
'logo' => $this->company->present()->logo(),
|
||||||
|
@ -70,8 +70,13 @@ class SupportMessageSent extends Mailable
|
|||||||
$trial = $account->isTrial() ? 'T' : '';
|
$trial = $account->isTrial() ? 'T' : '';
|
||||||
$plan = str_replace('_', ' ', $plan);
|
$plan = str_replace('_', ' ', $plan);
|
||||||
|
|
||||||
|
$plan_status = '';
|
||||||
|
|
||||||
|
if(Carbon::parse($account->plan_expires)->lt(now()))
|
||||||
|
$plan_status = 'Plan Expired';
|
||||||
|
|
||||||
if (Ninja::isHosted()) {
|
if (Ninja::isHosted()) {
|
||||||
$subject = "{$priority}Hosted-{$db}-{$is_large}{$platform}{$migrated}{$trial} :: {$plan} :: ".date('M jS, g:ia');
|
$subject = "{$priority}Hosted-{$db}-{$is_large}{$platform}{$migrated}{$trial} :: {$plan} :: {$plan_status} ".date('M jS, g:ia');
|
||||||
} else {
|
} else {
|
||||||
$subject = "{$priority}Self Hosted :: {$plan} :: {$is_large}{$platform}{$migrated} :: ".date('M jS, g:ia');
|
$subject = "{$priority}Self Hosted :: {$plan} :: {$is_large}{$platform}{$migrated} :: ".date('M jS, g:ia');
|
||||||
}
|
}
|
||||||
|
@ -212,14 +212,14 @@ class PurchaseOrder extends BaseModel
|
|||||||
return Storage::disk(config('filesystems.default'))->{$type}($file_path);
|
return Storage::disk(config('filesystems.default'))->{$type}($file_path);
|
||||||
}
|
}
|
||||||
elseif(Ninja::isHosted() && $portal){
|
elseif(Ninja::isHosted() && $portal){
|
||||||
$file_path = CreatePurchaseOrderPdf::dispatchNow($invitation,config('filesystems.default'));
|
$file_path = (new CreatePurchaseOrderPdf($invitation,config('filesystems.default')))->handle();
|
||||||
return Storage::disk(config('filesystems.default'))->{$type}($file_path);
|
return Storage::disk(config('filesystems.default'))->{$type}($file_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Storage::disk('public')->exists($file_path))
|
if(Storage::disk('public')->exists($file_path))
|
||||||
return Storage::disk('public')->{$type}($file_path);
|
return Storage::disk('public')->{$type}($file_path);
|
||||||
|
|
||||||
$file_path = CreatePurchaseOrderPdf::dispatchNow($invitation);
|
$file_path = (new CreatePurchaseOrderPdf($invitation))->handle();
|
||||||
return Storage::disk('public')->{$type}($file_path);
|
return Storage::disk('public')->{$type}($file_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,17 +110,17 @@ class BraintreePaymentDriver extends BaseDriver
|
|||||||
}
|
}
|
||||||
|
|
||||||
$result = $this->gateway->customer()->create([
|
$result = $this->gateway->customer()->create([
|
||||||
'firstName' => $this->client->present()->name,
|
'firstName' => $this->client->present()->name(),
|
||||||
'email' => $this->client->present()->email,
|
'email' => $this->client->present()->email(),
|
||||||
'phone' => $this->client->present()->phone,
|
'phone' => $this->client->present()->phone(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if ($result->success) {
|
if ($result->success) {
|
||||||
$address = $this->gateway->address()->create([
|
$address = $this->gateway->address()->create([
|
||||||
'customerId' => $result->customer->id,
|
'customerId' => $result->customer->id,
|
||||||
'firstName' => $this->client->present()->name,
|
'firstName' => $this->client->present()->name(),
|
||||||
'streetAddress' => $this->client->address1,
|
'streetAddress' => $this->client->address1 ?: '',
|
||||||
'postalCode' => $this->client->postal_code,
|
'postalCode' => $this->client->postal_code ?: '',
|
||||||
'countryCodeAlpha2' => $this->client->country ? $this->client->country->iso_3166_2 : '',
|
'countryCodeAlpha2' => $this->client->country ? $this->client->country->iso_3166_2 : '',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ class CreditCard implements MethodInterface
|
|||||||
$client->addressLines = [$this->square_driver->client->address1 ?: '', $this->square_driver->client->address2 ?: ''];
|
$client->addressLines = [$this->square_driver->client->address1 ?: '', $this->square_driver->client->address2 ?: ''];
|
||||||
$client->givenName = $this->square_driver->client->present()->first_name();
|
$client->givenName = $this->square_driver->client->present()->first_name();
|
||||||
$client->familyName = $this->square_driver->client->present()->last_name();
|
$client->familyName = $this->square_driver->client->present()->last_name();
|
||||||
$client->email = $this->square_driver->client->present()->email;
|
$client->email = $this->square_driver->client->present()->email();
|
||||||
$client->phone = $this->square_driver->client->phone;
|
$client->phone = $this->square_driver->client->phone;
|
||||||
$client->city = $this->square_driver->client->city;
|
$client->city = $this->square_driver->client->city;
|
||||||
$client->region = $this->square_driver->client->state;
|
$client->region = $this->square_driver->client->state;
|
||||||
|
@ -28,10 +28,21 @@ class ClientContactRepository extends BaseRepository
|
|||||||
|
|
||||||
public function save(array $data, Client $client) : void
|
public function save(array $data, Client $client) : void
|
||||||
{
|
{
|
||||||
if (isset($data['contacts'])) {
|
//06-09-2022 sometimes users pass a contact object instead of a nested array, this sequence handles this scenario
|
||||||
|
if (isset($data['contacts']) && (count($data['contacts']) !== count($data['contacts'], COUNT_RECURSIVE))) {
|
||||||
|
|
||||||
$contacts = collect($data['contacts']);
|
$contacts = collect($data['contacts']);
|
||||||
} else {
|
|
||||||
|
} elseif(isset($data['contacts'])){
|
||||||
|
|
||||||
|
$temp_array[] = $data['contacts'];
|
||||||
|
$contacts = collect($temp_array);
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
$contacts = collect();
|
$contacts = collect();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$client->contacts->pluck('id')->diff($contacts->pluck('id'))->each(function ($contact) {
|
$client->contacts->pluck('id')->diff($contacts->pluck('id'))->each(function ($contact) {
|
||||||
@ -45,6 +56,7 @@ class ClientContactRepository extends BaseRepository
|
|||||||
|
|
||||||
/* Set first record to primary - always */
|
/* Set first record to primary - always */
|
||||||
$contacts = $contacts->sortByDesc('is_primary')->map(function ($contact) {
|
$contacts = $contacts->sortByDesc('is_primary')->map(function ($contact) {
|
||||||
|
|
||||||
$contact['is_primary'] = $this->is_primary;
|
$contact['is_primary'] = $this->is_primary;
|
||||||
$this->is_primary = false;
|
$this->is_primary = false;
|
||||||
|
|
||||||
|
@ -84,23 +84,23 @@ class PaymentRepository extends BaseRepository {
|
|||||||
$data['amount'] = array_sum(array_column($data['invoices'], 'amount'));
|
$data['amount'] = array_sum(array_column($data['invoices'], 'amount'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// $client->service()->updatePaidToDate($data['amount'])->save();
|
$client->service()->updatePaidToDate($data['amount'])->save();
|
||||||
$client->paid_to_date += $data['amount'];
|
// $client->paid_to_date += $data['amount'];
|
||||||
$client->save();
|
$client->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
else{
|
else{
|
||||||
//this fixes an edge case with unapplied payments
|
//this fixes an edge case with unapplied payments
|
||||||
// $client->service()->updatePaidToDate($data['amount'])->save();
|
$client->service()->updatePaidToDate($data['amount'])->save();
|
||||||
$client->paid_to_date += $data['amount'];
|
// $client->paid_to_date += $data['amount'];
|
||||||
$client->save();
|
$client->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array_key_exists('credits', $data) && is_array($data['credits']) && count($data['credits']) > 0) {
|
if (array_key_exists('credits', $data) && is_array($data['credits']) && count($data['credits']) > 0) {
|
||||||
$_credit_totals = array_sum(array_column($data['credits'], 'amount'));
|
$_credit_totals = array_sum(array_column($data['credits'], 'amount'));
|
||||||
|
|
||||||
// $client->service()->updatePaidToDate($_credit_totals)->save();
|
$client->service()->updatePaidToDate($_credit_totals)->save();
|
||||||
$client->paid_to_date += $_credit_totals;
|
// $client->paid_to_date += $_credit_totals;
|
||||||
$client->save();
|
$client->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
namespace App\Services\Client;
|
namespace App\Services\Client;
|
||||||
|
|
||||||
use App\Models\Client;
|
use App\Models\Client;
|
||||||
|
use App\Models\Credit;
|
||||||
use App\Services\Client\Merge;
|
use App\Services\Client\Merge;
|
||||||
use App\Services\Client\PaymentMethod;
|
use App\Services\Client\PaymentMethod;
|
||||||
use App\Utils\Number;
|
use App\Utils\Number;
|
||||||
@ -28,14 +29,47 @@ class ClientService
|
|||||||
|
|
||||||
public function updateBalance(float $amount)
|
public function updateBalance(float $amount)
|
||||||
{
|
{
|
||||||
$this->client->balance += $amount;
|
// $this->client->balance += $amount;
|
||||||
|
|
||||||
|
\DB::connection(config('database.default'))->transaction(function () use($amount) {
|
||||||
|
|
||||||
|
$this->client = Client::where('id', $this->client->id)->lockForUpdate()->first();
|
||||||
|
$this->client->balance += $amount;
|
||||||
|
$this->client->save();
|
||||||
|
|
||||||
|
}, 2);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updateBalanceAndPaidToDate(float $balance, float $paid_to_date)
|
||||||
|
{
|
||||||
|
// $this->client->balance += $amount;
|
||||||
|
// $this->client->paid_to_date += $amount;
|
||||||
|
|
||||||
|
\DB::connection(config('database.default'))->transaction(function () use($balance, $paid_to_date) {
|
||||||
|
|
||||||
|
$this->client = Client::where('id', $this->client->id)->lockForUpdate()->first();
|
||||||
|
$this->client->balance += $balance;
|
||||||
|
$this->client->paid_to_date += $paid_to_date;
|
||||||
|
$this->client->save();
|
||||||
|
|
||||||
|
}, 2);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updatePaidToDate(float $amount)
|
public function updatePaidToDate(float $amount)
|
||||||
{
|
{
|
||||||
$this->client->paid_to_date += $amount;
|
// $this->client->paid_to_date += $amount;
|
||||||
|
|
||||||
|
\DB::connection(config('database.default'))->transaction(function () use($amount) {
|
||||||
|
|
||||||
|
$this->client = Client::where('id', $this->client->id)->lockForUpdate()->first();
|
||||||
|
$this->client->paid_to_date += $amount;
|
||||||
|
$this->client->save();
|
||||||
|
|
||||||
|
}, 2);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@ -49,7 +83,7 @@ class ClientService
|
|||||||
|
|
||||||
public function getCreditBalance() :float
|
public function getCreditBalance() :float
|
||||||
{
|
{
|
||||||
$credits = $this->client->credits()
|
$credits = Credit::where('client_id', $this->client->id)
|
||||||
->where('is_deleted', false)
|
->where('is_deleted', false)
|
||||||
->where('balance', '>', 0)
|
->where('balance', '>', 0)
|
||||||
->where(function ($query) {
|
->where(function ($query) {
|
||||||
@ -63,7 +97,7 @@ class ClientService
|
|||||||
|
|
||||||
public function getCredits()
|
public function getCredits()
|
||||||
{
|
{
|
||||||
return $this->client->credits()
|
return Credit::where('client_id', $this->client->id)
|
||||||
->where('is_deleted', false)
|
->where('is_deleted', false)
|
||||||
->where('balance', '>', 0)
|
->where('balance', '>', 0)
|
||||||
->where(function ($query) {
|
->where(function ($query) {
|
||||||
|
@ -59,7 +59,7 @@ class ApplyNumber extends AbstractService
|
|||||||
} catch (QueryException $e) {
|
} catch (QueryException $e) {
|
||||||
$x++;
|
$x++;
|
||||||
|
|
||||||
if ($x > 10) {
|
if ($x > 50) {
|
||||||
$this->completed = false;
|
$this->completed = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ class ApplyNumber extends AbstractService
|
|||||||
|
|
||||||
$x++;
|
$x++;
|
||||||
|
|
||||||
if($x>10)
|
if($x>50)
|
||||||
$this->completed = false;
|
$this->completed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +88,6 @@ class ApplyPayment extends AbstractService
|
|||||||
|
|
||||||
$this->invoice
|
$this->invoice
|
||||||
->client
|
->client
|
||||||
->fresh()
|
|
||||||
->service()
|
->service()
|
||||||
->updateBalance($amount_paid)
|
->updateBalance($amount_paid)
|
||||||
->save();
|
->save();
|
||||||
|
@ -43,7 +43,7 @@ class ApplyPaymentAmount extends AbstractService
|
|||||||
public function run()
|
public function run()
|
||||||
{
|
{
|
||||||
if ($this->invoice->status_id == Invoice::STATUS_DRAFT) {
|
if ($this->invoice->status_id == Invoice::STATUS_DRAFT) {
|
||||||
$this->invoice->service()->markSent()->save();
|
$this->invoice = $this->invoice->service()->markSent()->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*Don't double pay*/
|
/*Don't double pay*/
|
||||||
@ -88,10 +88,8 @@ class ApplyPaymentAmount extends AbstractService
|
|||||||
|
|
||||||
$this->invoice
|
$this->invoice
|
||||||
->client
|
->client
|
||||||
->fresh()
|
|
||||||
->service()
|
->service()
|
||||||
->updateBalance($payment->amount * -1)
|
->updateBalanceAndPaidToDate($payment->amount * -1, $payment->amount)
|
||||||
->updatePaidToDate($payment->amount)
|
|
||||||
->save();
|
->save();
|
||||||
|
|
||||||
|
|
||||||
|
@ -35,6 +35,9 @@ class AutoBillInvoice extends AbstractService
|
|||||||
|
|
||||||
protected $db;
|
protected $db;
|
||||||
|
|
||||||
|
/*Specific variable for partial payments */
|
||||||
|
private bool $is_partial_amount = false;
|
||||||
|
|
||||||
public function __construct(Invoice $invoice, $db)
|
public function __construct(Invoice $invoice, $db)
|
||||||
{
|
{
|
||||||
$this->invoice = $invoice;
|
$this->invoice = $invoice;
|
||||||
@ -46,7 +49,8 @@ class AutoBillInvoice extends AbstractService
|
|||||||
{
|
{
|
||||||
MultiDB::setDb($this->db);
|
MultiDB::setDb($this->db);
|
||||||
|
|
||||||
$this->client = $this->invoice->client->fresh();
|
/* Harvest Client*/
|
||||||
|
$this->client = $this->invoice->client;
|
||||||
|
|
||||||
$is_partial = false;
|
$is_partial = false;
|
||||||
|
|
||||||
@ -68,6 +72,10 @@ class AutoBillInvoice extends AbstractService
|
|||||||
$this->applyCreditPayment();
|
$this->applyCreditPayment();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//If this returns true, it means a partial invoice amount was paid as a credit and there is no further balance payable
|
||||||
|
if($this->is_partial_amount && $this->invoice->partial == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
$amount = 0;
|
$amount = 0;
|
||||||
|
|
||||||
/* Determine $amount */
|
/* Determine $amount */
|
||||||
@ -169,9 +177,9 @@ class AutoBillInvoice extends AbstractService
|
|||||||
$payment->invoices()->attach($this->invoice->id, ['amount' => $amount]);
|
$payment->invoices()->attach($this->invoice->id, ['amount' => $amount]);
|
||||||
|
|
||||||
$this->invoice
|
$this->invoice
|
||||||
->service()
|
->service()
|
||||||
->setStatus(Invoice::STATUS_PAID)
|
->setCalculatedStatus()
|
||||||
->save();
|
->save();
|
||||||
|
|
||||||
foreach ($this->used_credit as $credit) {
|
foreach ($this->used_credit as $credit) {
|
||||||
$current_credit = Credit::find($credit['credit_id']);
|
$current_credit = Credit::find($credit['credit_id']);
|
||||||
@ -191,18 +199,18 @@ class AutoBillInvoice extends AbstractService
|
|||||||
->updatePaymentBalance($amount * -1)
|
->updatePaymentBalance($amount * -1)
|
||||||
->save();
|
->save();
|
||||||
|
|
||||||
$client = $this->invoice->client->fresh();
|
$this->invoice
|
||||||
|
->client
|
||||||
$client->service()
|
->service()
|
||||||
->updateBalance($amount * -1)
|
->updateBalanceAndPaidToDate($amount * -1, $amount)
|
||||||
->updatePaidToDate($amount)
|
// ->updateBalance($amount * -1)
|
||||||
->adjustCreditBalance($amount * -1)
|
// ->updatePaidToDate($amount)
|
||||||
->save();
|
->adjustCreditBalance($amount * -1)
|
||||||
|
->save();
|
||||||
|
|
||||||
$this->invoice->ledger() //09-03-2022
|
$this->invoice->ledger() //09-03-2022
|
||||||
// ->updateInvoiceBalance($amount * -1, "Invoice {$this->invoice->number} payment using Credit {$current_credit->number}")
|
->updateCreditBalance($amount * -1, "Credit {$current_credit->number} used to pay down Invoice {$this->invoice->number}")
|
||||||
->updateCreditBalance($amount * -1, "Credit {$current_credit->number} used to pay down Invoice {$this->invoice->number}")
|
->save();
|
||||||
->save();
|
|
||||||
|
|
||||||
event('eloquent.created: App\Models\Payment', $payment);
|
event('eloquent.created: App\Models\Payment', $payment);
|
||||||
event(new PaymentWasCreated($payment, $payment->company, Ninja::eventVars()));
|
event(new PaymentWasCreated($payment, $payment->company, Ninja::eventVars()));
|
||||||
@ -221,11 +229,11 @@ class AutoBillInvoice extends AbstractService
|
|||||||
*/
|
*/
|
||||||
private function applyCreditPayment()
|
private function applyCreditPayment()
|
||||||
{
|
{
|
||||||
$available_credits = $this->client
|
$available_credits = Credit::where('client_id', $this->client->id)
|
||||||
->credits
|
|
||||||
->where('is_deleted', false)
|
->where('is_deleted', false)
|
||||||
->where('balance', '>', 0)
|
->where('balance', '>', 0)
|
||||||
->sortBy('created_at');
|
->orderBy('created_at')
|
||||||
|
->get();
|
||||||
|
|
||||||
$available_credit_balance = $available_credits->sum('balance');
|
$available_credit_balance = $available_credits->sum('balance');
|
||||||
|
|
||||||
@ -235,16 +243,14 @@ class AutoBillInvoice extends AbstractService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$is_partial_amount = false;
|
|
||||||
|
|
||||||
if ($this->invoice->partial > 0) {
|
if ($this->invoice->partial > 0) {
|
||||||
$is_partial_amount = true;
|
$this->is_partial_amount = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->used_credit = [];
|
$this->used_credit = [];
|
||||||
|
|
||||||
foreach ($available_credits as $key => $credit) {
|
foreach ($available_credits as $key => $credit) {
|
||||||
if ($is_partial_amount) {
|
if ($this->is_partial_amount) {
|
||||||
|
|
||||||
//more credit than needed
|
//more credit than needed
|
||||||
if ($credit->balance > $this->invoice->partial) {
|
if ($credit->balance > $this->invoice->partial) {
|
||||||
@ -260,6 +266,7 @@ class AutoBillInvoice extends AbstractService
|
|||||||
$this->invoice->partial -= $credit->balance;
|
$this->invoice->partial -= $credit->balance;
|
||||||
$this->invoice->balance -= $credit->balance;
|
$this->invoice->balance -= $credit->balance;
|
||||||
$this->invoice->paid_to_date += $credit->balance;
|
$this->invoice->paid_to_date += $credit->balance;
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
@ -276,6 +283,7 @@ class AutoBillInvoice extends AbstractService
|
|||||||
$this->used_credit[$key]['amount'] = $credit->balance;
|
$this->used_credit[$key]['amount'] = $credit->balance;
|
||||||
$this->invoice->balance -= $credit->balance;
|
$this->invoice->balance -= $credit->balance;
|
||||||
$this->invoice->paid_to_date += $credit->balance;
|
$this->invoice->paid_to_date += $credit->balance;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,8 +45,7 @@ class MarkInvoiceDeleted extends AbstractService
|
|||||||
->setAdjustmentAmount()
|
->setAdjustmentAmount()
|
||||||
->deletePaymentables()
|
->deletePaymentables()
|
||||||
->adjustPayments()
|
->adjustPayments()
|
||||||
->adjustPaidToDate()
|
->adjustPaidToDateAndBalance()
|
||||||
->adjustBalance()
|
|
||||||
->adjustLedger();
|
->adjustLedger();
|
||||||
|
|
||||||
$transaction = [
|
$transaction = [
|
||||||
@ -70,21 +69,29 @@ class MarkInvoiceDeleted extends AbstractService
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function adjustPaidToDate()
|
private function adjustPaidToDateAndBalance()
|
||||||
{
|
{
|
||||||
$client = $this->invoice->client->fresh();
|
// $client = $this->invoice->client->fresh();
|
||||||
$client->paid_to_date += $this->adjustment_amount * -1;
|
// $client->paid_to_date += $this->adjustment_amount * -1;
|
||||||
$client->save();
|
// $client->balance += $this->balance_adjustment * -1;
|
||||||
// $this->invoice->client->service()->updatePaidToDate($this->adjustment_amount * -1)->save(); //reduces the paid to date by the payment totals
|
// $client->save();
|
||||||
|
|
||||||
|
// 06-09-2022
|
||||||
|
$this->invoice
|
||||||
|
->client
|
||||||
|
->service()
|
||||||
|
->updateBalanceAndPaidToDate($this->balance_adjustment * -1, $this->adjustment_amount * -1)
|
||||||
|
->save(); //reduces the paid to date by the payment totals
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @deprecated
|
||||||
private function adjustBalance()
|
private function adjustBalance()
|
||||||
{
|
{
|
||||||
$client = $this->invoice->client->fresh();
|
// $client = $this->invoice->client->fresh();
|
||||||
$client->balance += $this->balance_adjustment * -1;
|
// $client->balance += $this->balance_adjustment * -1;
|
||||||
$client->save();
|
// $client->save();
|
||||||
|
|
||||||
// $this->invoice->client->service()->updateBalance($this->balance_adjustment * -1)->save(); //reduces the client balance by the invoice amount.
|
// $this->invoice->client->service()->updateBalance($this->balance_adjustment * -1)->save(); //reduces the client balance by the invoice amount.
|
||||||
|
|
||||||
|
@ -34,6 +34,8 @@ class MarkPaid extends AbstractService
|
|||||||
|
|
||||||
private $invoice;
|
private $invoice;
|
||||||
|
|
||||||
|
private $payable_balance;
|
||||||
|
|
||||||
public function __construct(Invoice $invoice)
|
public function __construct(Invoice $invoice)
|
||||||
{
|
{
|
||||||
$this->invoice = $invoice;
|
$this->invoice = $invoice;
|
||||||
@ -48,20 +50,20 @@ class MarkPaid extends AbstractService
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($this->invoice->status_id == Invoice::STATUS_DRAFT) {
|
if ($this->invoice->status_id == Invoice::STATUS_DRAFT) {
|
||||||
$this->invoice->service()->markSent()->save();
|
$this->invoice = $this->invoice->service()->markSent()->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
$payable_balance = $this->invoice->balance;
|
\DB::connection(config('database.default'))->transaction(function () {
|
||||||
|
|
||||||
\DB::connection(config('database.default'))->transaction(function () use($payable_balance) {
|
|
||||||
|
|
||||||
$this->invoice = Invoice::where('id', $this->invoice->id)->lockForUpdate()->first();
|
$this->invoice = Invoice::where('id', $this->invoice->id)->lockForUpdate()->first();
|
||||||
|
|
||||||
|
$this->payable_balance = $this->invoice->balance;
|
||||||
|
|
||||||
$this->invoice
|
$this->invoice
|
||||||
->service()
|
->service()
|
||||||
->setExchangeRate()
|
->setExchangeRate()
|
||||||
->updateBalance($payable_balance * -1)
|
->updateBalance($this->payable_balance * -1)
|
||||||
->updatePaidToDate($payable_balance)
|
->updatePaidToDate($this->payable_balance)
|
||||||
->setStatus(Invoice::STATUS_PAID)
|
->setStatus(Invoice::STATUS_PAID)
|
||||||
->save();
|
->save();
|
||||||
|
|
||||||
@ -70,8 +72,8 @@ class MarkPaid extends AbstractService
|
|||||||
/* Create Payment */
|
/* Create Payment */
|
||||||
$payment = PaymentFactory::create($this->invoice->company_id, $this->invoice->user_id);
|
$payment = PaymentFactory::create($this->invoice->company_id, $this->invoice->user_id);
|
||||||
|
|
||||||
$payment->amount = $payable_balance;
|
$payment->amount = $this->payable_balance;
|
||||||
$payment->applied = $payable_balance;
|
$payment->applied = $this->payable_balance;
|
||||||
$payment->status_id = Payment::STATUS_COMPLETED;
|
$payment->status_id = Payment::STATUS_COMPLETED;
|
||||||
$payment->client_id = $this->invoice->client_id;
|
$payment->client_id = $this->invoice->client_id;
|
||||||
$payment->transaction_reference = ctrans('texts.manual_entry');
|
$payment->transaction_reference = ctrans('texts.manual_entry');
|
||||||
@ -99,21 +101,13 @@ class MarkPaid extends AbstractService
|
|||||||
|
|
||||||
/* Create a payment relationship to the invoice entity */
|
/* Create a payment relationship to the invoice entity */
|
||||||
$payment->invoices()->attach($this->invoice->id, [
|
$payment->invoices()->attach($this->invoice->id, [
|
||||||
'amount' => $payable_balance,
|
'amount' => $this->payable_balance,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
event('eloquent.created: App\Models\Payment', $payment);
|
event('eloquent.created: App\Models\Payment', $payment);
|
||||||
|
|
||||||
$this->invoice->next_send_date = null;
|
$this->invoice->next_send_date = null;
|
||||||
|
|
||||||
// $this->invoice
|
|
||||||
// ->service()
|
|
||||||
// ->setExchangeRate()
|
|
||||||
// ->updateBalance($payment->amount * -1)
|
|
||||||
// ->updatePaidToDate($payment->amount)
|
|
||||||
// ->setStatus(Invoice::STATUS_PAID)
|
|
||||||
// ->save();
|
|
||||||
|
|
||||||
$this->invoice
|
$this->invoice
|
||||||
->service()
|
->service()
|
||||||
->applyNumber()
|
->applyNumber()
|
||||||
@ -121,16 +115,14 @@ class MarkPaid extends AbstractService
|
|||||||
->save();
|
->save();
|
||||||
|
|
||||||
$payment->ledger()
|
$payment->ledger()
|
||||||
->updatePaymentBalance($payable_balance * -1);
|
->updatePaymentBalance($this->payable_balance * -1);
|
||||||
|
|
||||||
\DB::connection(config('database.default'))->transaction(function () use ($payment) {
|
//06-09-2022
|
||||||
|
$this->invoice
|
||||||
/* Get the last record for the client and set the current balance*/
|
->client
|
||||||
$client = Client::withTrashed()->where('id', $this->invoice->client_id)->lockForUpdate()->first();
|
->service()
|
||||||
$client->paid_to_date += $payment->amount;
|
->updateBalanceAndPaidToDate($payment->amount*-1, $payment->amount)
|
||||||
$client->balance -= $payment->amount;
|
->save();
|
||||||
$client->save();
|
|
||||||
}, 1);
|
|
||||||
|
|
||||||
$this->invoice = $this->invoice
|
$this->invoice = $this->invoice
|
||||||
->service()
|
->service()
|
||||||
|
@ -62,15 +62,7 @@ class MarkSent extends AbstractService
|
|||||||
->save();
|
->save();
|
||||||
|
|
||||||
/*Adjust client balance*/
|
/*Adjust client balance*/
|
||||||
|
$this->invoice->client->service()->updateBalance($adjustment)->save();
|
||||||
\DB::connection(config('database.default'))->transaction(function () use ($adjustment) {
|
|
||||||
|
|
||||||
/* Get the last record for the client and set the current balance*/
|
|
||||||
$client = Client::withTrashed()->where('id', $this->client->id)->lockForUpdate()->first();
|
|
||||||
$client->balance += $adjustment;
|
|
||||||
$client->save();
|
|
||||||
|
|
||||||
}, 1);
|
|
||||||
|
|
||||||
$this->invoice->markInvitationsSent();
|
$this->invoice->markInvitationsSent();
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ class ApplyNumber extends AbstractService
|
|||||||
} catch (QueryException $e) {
|
} catch (QueryException $e) {
|
||||||
$x++;
|
$x++;
|
||||||
|
|
||||||
if ($x > 10) {
|
if ($x > 50) {
|
||||||
$this->completed = false;
|
$this->completed = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,9 +90,12 @@ class DeletePayment
|
|||||||
->updateInvoiceBalance($net_deletable, "Adjusting invoice {$paymentable_invoice->number} due to deletion of Payment {$this->payment->number}")
|
->updateInvoiceBalance($net_deletable, "Adjusting invoice {$paymentable_invoice->number} due to deletion of Payment {$this->payment->number}")
|
||||||
->save();
|
->save();
|
||||||
|
|
||||||
$client = $client->service()
|
$client = $this->payment
|
||||||
->updateBalance($net_deletable)
|
->client
|
||||||
->save();
|
->fresh()
|
||||||
|
->service()
|
||||||
|
->updateBalance($net_deletable)
|
||||||
|
->save();
|
||||||
|
|
||||||
if ($paymentable_invoice->balance == $paymentable_invoice->amount) {
|
if ($paymentable_invoice->balance == $paymentable_invoice->amount) {
|
||||||
$paymentable_invoice->service()->setStatus(Invoice::STATUS_SENT)->save();
|
$paymentable_invoice->service()->setStatus(Invoice::STATUS_SENT)->save();
|
||||||
|
@ -55,15 +55,12 @@ class RefundPayment
|
|||||||
public function run()
|
public function run()
|
||||||
{
|
{
|
||||||
$this->payment = $this->calculateTotalRefund() //sets amount for the refund (needed if we are refunding multiple invoices in one payment)
|
$this->payment = $this->calculateTotalRefund() //sets amount for the refund (needed if we are refunding multiple invoices in one payment)
|
||||||
->setStatus() //sets status of payment
|
->setStatus() //sets status of payment
|
||||||
//->reversePayment()
|
->updateCreditables() //return the credits first
|
||||||
//->buildCreditNote() //generate the credit note
|
->updatePaymentables() //update the paymentable items
|
||||||
//->buildCreditLineItems() //generate the credit note items
|
->adjustInvoices()
|
||||||
->updateCreditables() //return the credits first
|
->processGatewayRefund() //process the gateway refund if needed
|
||||||
->updatePaymentables() //update the paymentable items
|
->save();
|
||||||
->adjustInvoices()
|
|
||||||
->processGatewayRefund() //process the gateway refund if needed
|
|
||||||
->save();
|
|
||||||
|
|
||||||
if (array_key_exists('email_receipt', $this->refund_data) && $this->refund_data['email_receipt'] == 'true') {
|
if (array_key_exists('email_receipt', $this->refund_data) && $this->refund_data['email_receipt'] == 'true') {
|
||||||
$contact = $this->payment->client->contacts()->whereNotNull('email')->first();
|
$contact = $this->payment->client->contacts()->whereNotNull('email')->first();
|
||||||
@ -251,7 +248,6 @@ class RefundPayment
|
|||||||
*/
|
*/
|
||||||
private function adjustInvoices()
|
private function adjustInvoices()
|
||||||
{
|
{
|
||||||
$adjustment_amount = 0;
|
|
||||||
|
|
||||||
if (isset($this->refund_data['invoices']) && count($this->refund_data['invoices']) > 0) {
|
if (isset($this->refund_data['invoices']) && count($this->refund_data['invoices']) > 0) {
|
||||||
foreach ($this->refund_data['invoices'] as $refunded_invoice) {
|
foreach ($this->refund_data['invoices'] as $refunded_invoice) {
|
||||||
@ -266,7 +262,9 @@ class RefundPayment
|
|||||||
->updatePaidToDate($refunded_invoice['amount'] * -1)
|
->updatePaidToDate($refunded_invoice['amount'] * -1)
|
||||||
->save();
|
->save();
|
||||||
|
|
||||||
$invoice->ledger()->updateInvoiceBalance($refunded_invoice['amount'], "Refund of payment # {$this->payment->number}")->save();
|
$invoice->ledger()
|
||||||
|
->updateInvoiceBalance($refunded_invoice['amount'], "Refund of payment # {$this->payment->number}")
|
||||||
|
->save();
|
||||||
|
|
||||||
if ($invoice->amount == $invoice->balance) {
|
if ($invoice->amount == $invoice->balance) {
|
||||||
$invoice->service()->setStatus(Invoice::STATUS_SENT);
|
$invoice->service()->setStatus(Invoice::STATUS_SENT);
|
||||||
@ -276,10 +274,15 @@ class RefundPayment
|
|||||||
|
|
||||||
$invoice->saveQuietly();
|
$invoice->saveQuietly();
|
||||||
|
|
||||||
$client = $invoice->client;
|
//06-09-2022
|
||||||
$adjustment_amount += $refunded_invoice['amount'];
|
$client = $invoice->client
|
||||||
$client->balance += $refunded_invoice['amount'];
|
->service()
|
||||||
$client->save();
|
->updateBalance($refunded_invoice['amount'])
|
||||||
|
->save();
|
||||||
|
|
||||||
|
// $client = $invoice->client;
|
||||||
|
// $client->balance += $refunded_invoice['amount'];
|
||||||
|
// $client->save();
|
||||||
|
|
||||||
$transaction = [
|
$transaction = [
|
||||||
'invoice' => $invoice->transaction_event(),
|
'invoice' => $invoice->transaction_event(),
|
||||||
@ -350,75 +353,4 @@ class RefundPayment
|
|||||||
return $this->payment;
|
return $this->payment;
|
||||||
}
|
}
|
||||||
|
|
||||||
// public function updateCreditNoteBalance()
|
|
||||||
// {
|
|
||||||
// $this->credit_note->balance -= $this->total_refund;
|
|
||||||
// $this->credit_note->status_id = Credit::STATUS_APPLIED;
|
|
||||||
|
|
||||||
// $this->credit_note->balance === 0
|
|
||||||
// ? $this->credit_note->status_id = Credit::STATUS_APPLIED
|
|
||||||
// : $this->credit_note->status_id = Credit::STATUS_PARTIAL;
|
|
||||||
|
|
||||||
// $this->credit_note->save();
|
|
||||||
|
|
||||||
// return $this;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// private function buildCreditNote()
|
|
||||||
// {
|
|
||||||
// $this->credit_note = CreditFactory::create($this->payment->company_id, $this->payment->user_id);
|
|
||||||
// $this->credit_note->assigned_user_id = isset($this->payment->assigned_user_id) ?: null;
|
|
||||||
// $this->credit_note->date = $this->refund_data['date'];
|
|
||||||
// $this->credit_note->status_id = Credit::STATUS_SENT;
|
|
||||||
// $this->credit_note->client_id = $this->payment->client->id;
|
|
||||||
// $this->credit_note->amount = $this->total_refund;
|
|
||||||
// $this->credit_note->balance = $this->total_refund;
|
|
||||||
|
|
||||||
// $this->credit_note->save();
|
|
||||||
// $this->credit_note->number = $this->payment->client->getNextCreditNumber($this->payment->client);
|
|
||||||
// $this->credit_note->save();
|
|
||||||
|
|
||||||
// return $this;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// private function buildCreditLineItems()
|
|
||||||
// {
|
|
||||||
// $ledger_string = '';
|
|
||||||
|
|
||||||
// if (isset($this->refund_data['invoices']) && count($this->refund_data['invoices']) > 0) {
|
|
||||||
// foreach ($this->refund_data['invoices'] as $invoice) {
|
|
||||||
|
|
||||||
// $inv = Invoice::find($invoice['invoice_id']);
|
|
||||||
|
|
||||||
// $credit_line_item = InvoiceItemFactory::create();
|
|
||||||
// $credit_line_item->quantity = 1;
|
|
||||||
// $credit_line_item->cost = $invoice['amount'];
|
|
||||||
// $credit_line_item->product_key = ctrans('texts.invoice');
|
|
||||||
// $credit_line_item->notes = ctrans('texts.refund_body', ['amount' => $invoice['amount'], 'invoice_number' => $inv->number]);
|
|
||||||
// $credit_line_item->line_total = $invoice['amount'];
|
|
||||||
// $credit_line_item->date = $this->refund_data['date'];
|
|
||||||
|
|
||||||
// $ledger_string .= $credit_line_item->notes . ' ';
|
|
||||||
|
|
||||||
// $line_items[] = $credit_line_item;
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
|
|
||||||
// $credit_line_item = InvoiceItemFactory::create();
|
|
||||||
// $credit_line_item->quantity = 1;
|
|
||||||
// $credit_line_item->cost = $this->refund_data['amount'];
|
|
||||||
// $credit_line_item->product_key = ctrans('texts.credit');
|
|
||||||
// $credit_line_item->notes = ctrans('texts.credit_created_by', ['transaction_reference' => $this->payment->number]);
|
|
||||||
// $credit_line_item->line_total = $this->refund_data['amount'];
|
|
||||||
// $credit_line_item->date = $this->refund_data['date'];
|
|
||||||
|
|
||||||
// $line_items = [];
|
|
||||||
// $line_items[] = $credit_line_item;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// $this->credit_note->line_items = $line_items;
|
|
||||||
// $this->credit_note->save();
|
|
||||||
|
|
||||||
// return $this;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
@ -62,15 +62,17 @@ class UpdateInvoicePayment
|
|||||||
$paid_amount = $paid_invoice->amount;
|
$paid_amount = $paid_invoice->amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
\DB::connection(config('database.default'))->transaction(function () use($client, $paid_amount){
|
$client->service()->updateBalanceAndPaidToDate($paid_amount*-1, $paid_amount);
|
||||||
|
|
||||||
|
// \DB::connection(config('database.default'))->transaction(function () use($client, $paid_amount){
|
||||||
|
|
||||||
$update_client = Client::withTrashed()->where('id', $client->id)->lockForUpdate()->first();
|
// $update_client = Client::withTrashed()->where('id', $client->id)->lockForUpdate()->first();
|
||||||
|
|
||||||
$update_client->paid_to_date += $paid_amount;
|
// $update_client->paid_to_date += $paid_amount;
|
||||||
$update_client->balance -= $paid_amount;
|
// $update_client->balance -= $paid_amount;
|
||||||
$update_client->save();
|
// $update_client->save();
|
||||||
|
|
||||||
}, 1);
|
// }, 1);
|
||||||
|
|
||||||
/* Need to determine here is we have an OVER payment - if YES only apply the max invoice amount */
|
/* Need to determine here is we have an OVER payment - if YES only apply the max invoice amount */
|
||||||
if($paid_amount > $invoice->partial && $paid_amount > $invoice->balance)
|
if($paid_amount > $invoice->partial && $paid_amount > $invoice->balance)
|
||||||
|
@ -104,7 +104,7 @@ class PurchaseOrderService
|
|||||||
if($force){
|
if($force){
|
||||||
|
|
||||||
$this->purchase_order->invitations->each(function ($invitation) {
|
$this->purchase_order->invitations->each(function ($invitation) {
|
||||||
CreatePurchaseOrderPdf::dispatchNow($invitation);
|
(new CreatePurchaseOrderPdf($invitation))->handle();
|
||||||
});
|
});
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -67,7 +67,7 @@ class ApplyNumber
|
|||||||
} catch (QueryException $e) {
|
} catch (QueryException $e) {
|
||||||
$x++;
|
$x++;
|
||||||
|
|
||||||
if ($x > 10) {
|
if ($x > 50) {
|
||||||
$this->completed = false;
|
$this->completed = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,7 @@ class RecurringService
|
|||||||
|
|
||||||
$this->recurring_entity->invitations->each(function ($invitation){
|
$this->recurring_entity->invitations->each(function ($invitation){
|
||||||
|
|
||||||
UnlinkFile::dispatchNow(config('filesystems.default'), $this->recurring_entity->client->recurring_invoice_filepath($invitation) . $this->recurring_entity->numberFormatter().'.pdf');
|
(new UnlinkFile(config('filesystems.default'), $this->recurring_entity->client->recurring_invoice_filepath($invitation) . $this->recurring_entity->numberFormatter().'.pdf'))->handle();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ class TemplateEngine
|
|||||||
|
|
||||||
private function setSettingsObject()
|
private function setSettingsObject()
|
||||||
{
|
{
|
||||||
if($this->entity == 'purchaseOrder'){
|
if($this->entity == 'purchaseOrder' || $this->entity == 'purchase_order'){
|
||||||
$this->settings_entity = auth()->user()->company();
|
$this->settings_entity = auth()->user()->company();
|
||||||
$this->settings = $this->settings_entity->settings;
|
$this->settings = $this->settings_entity->settings;
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,7 @@ trait Refundable
|
|||||||
/**
|
/**
|
||||||
* Entry point for processing of refunds.
|
* Entry point for processing of refunds.
|
||||||
* @param array $data
|
* @param array $data
|
||||||
|
* @deprecated ???? 06-09-2022
|
||||||
* @return Refundable
|
* @return Refundable
|
||||||
* @throws PaymentRefundFailed
|
* @throws PaymentRefundFailed
|
||||||
*/
|
*/
|
||||||
|
@ -33,6 +33,9 @@ trait SavesDocuments
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!is_array($document_array))
|
||||||
|
return;
|
||||||
|
|
||||||
foreach ($document_array as $document) {
|
foreach ($document_array as $document) {
|
||||||
$document = (new UploadFile(
|
$document = (new UploadFile(
|
||||||
$document,
|
$document,
|
||||||
|
@ -94,7 +94,7 @@
|
|||||||
"wepay/php-sdk": "^0.3"
|
"wepay/php-sdk": "^0.3"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"php": "^7.4|^8.0",
|
"php": "^8.1",
|
||||||
"barryvdh/laravel-debugbar": "^3.6",
|
"barryvdh/laravel-debugbar": "^3.6",
|
||||||
"beyondcode/laravel-query-detector": "^1.6",
|
"beyondcode/laravel-query-detector": "^1.6",
|
||||||
"brianium/paratest": "^6.1",
|
"brianium/paratest": "^6.1",
|
||||||
|
694
composer.lock
generated
694
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@ -14,8 +14,8 @@ return [
|
|||||||
'require_https' => env('REQUIRE_HTTPS', true),
|
'require_https' => env('REQUIRE_HTTPS', true),
|
||||||
'app_url' => rtrim(env('APP_URL', ''), '/'),
|
'app_url' => rtrim(env('APP_URL', ''), '/'),
|
||||||
'app_domain' => env('APP_DOMAIN', 'invoicing.co'),
|
'app_domain' => env('APP_DOMAIN', 'invoicing.co'),
|
||||||
'app_version' => '5.5.19',
|
'app_version' => '5.5.20',
|
||||||
'app_tag' => '5.5.19',
|
'app_tag' => '5.5.20',
|
||||||
'minimum_client_version' => '5.0.16',
|
'minimum_client_version' => '5.0.16',
|
||||||
'terms_version' => '1.0.1',
|
'terms_version' => '1.0.1',
|
||||||
'api_secret' => env('API_SECRET', ''),
|
'api_secret' => env('API_SECRET', ''),
|
||||||
|
@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
\Illuminate\Support\Facades\Artisan::call('ninja:design-update');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
};
|
@ -68,5 +68,40 @@ class LanguageSeeder extends Seeder
|
|||||||
Language::create($language);
|
Language::create($language);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!Language::find(33)) {
|
||||||
|
|
||||||
|
$serbian = ['id' => 33, 'name' => 'Serbian', 'locale' => 'sr'];
|
||||||
|
Language::create($serbian);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!Language::find(34)) {
|
||||||
|
|
||||||
|
$slovak = ['id' => 34, 'name' => 'Slovak', 'locale' => 'sk'];
|
||||||
|
Language::create($slovak);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!Language::find(35)) {
|
||||||
|
|
||||||
|
$estonia = ['id' => 35, 'name' => 'Estonian', 'locale' => 'et'];
|
||||||
|
Language::create($estonia);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!Language::find(36)) {
|
||||||
|
|
||||||
|
$bulgarian = ['id' => 36, 'name' => 'Bulgarian', 'locale' => 'bg'];
|
||||||
|
Language::create($bulgarian);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!Language::find(37)) {
|
||||||
|
|
||||||
|
$hebrew = ['id' => 37, 'name' => 'Hebrew', 'locale' => 'he'];
|
||||||
|
Language::create($hebrew);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4770,6 +4770,13 @@ $LANG = array(
|
|||||||
'archive_purchase_order' => 'Archive Purchase Order',
|
'archive_purchase_order' => 'Archive Purchase Order',
|
||||||
'restore_purchase_order' => 'Restore Purchase Order',
|
'restore_purchase_order' => 'Restore Purchase Order',
|
||||||
'delete_purchase_order' => 'Delete Purchase Order',
|
'delete_purchase_order' => 'Delete Purchase Order',
|
||||||
|
'connect' => 'Connect',
|
||||||
|
'mark_paid_payment_email' => 'Mark Paid Payment Email',
|
||||||
|
'convert_to_project' => 'Convert to Project',
|
||||||
|
'client_email' => 'Client Email',
|
||||||
|
'invoice_task_project' => 'Invoice Task Project',
|
||||||
|
'invoice_task_project_help' => 'Add the project to the invoice line items',
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return $LANG;
|
return $LANG;
|
||||||
|
2
public/css/app.css
vendored
2
public/css/app.css
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -14,7 +14,7 @@
|
|||||||
"/js/clients/payments/checkout-credit-card.js": "/js/clients/payments/checkout-credit-card.js?id=4bd34a0b160f6f29b3096d870ac4d308",
|
"/js/clients/payments/checkout-credit-card.js": "/js/clients/payments/checkout-credit-card.js?id=4bd34a0b160f6f29b3096d870ac4d308",
|
||||||
"/js/clients/quotes/action-selectors.js": "/js/clients/quotes/action-selectors.js?id=6fb63bae43d077b5061f4dadfe8dffc8",
|
"/js/clients/quotes/action-selectors.js": "/js/clients/quotes/action-selectors.js?id=6fb63bae43d077b5061f4dadfe8dffc8",
|
||||||
"/js/clients/quotes/approve.js": "/js/clients/quotes/approve.js?id=cdc76607aaf0b47a5a4e554e4177713d",
|
"/js/clients/quotes/approve.js": "/js/clients/quotes/approve.js?id=cdc76607aaf0b47a5a4e554e4177713d",
|
||||||
"/js/clients/payments/stripe-credit-card.js": "/js/clients/payments/stripe-credit-card.js?id=62871ea440059c401bdc9458a41cfa3f",
|
"/js/clients/payments/stripe-credit-card.js": "/js/clients/payments/stripe-credit-card.js?id=809de47258a681f0ffebe787dd6a9a93",
|
||||||
"/js/setup/setup.js": "/js/setup/setup.js?id=87367cce4927b42a92defdbae7a64711",
|
"/js/setup/setup.js": "/js/setup/setup.js?id=87367cce4927b42a92defdbae7a64711",
|
||||||
"/js/clients/payments/card-js.min.js": "/js/clients/payments/card-js.min.js?id=8ce33c3deae058ad314fb8357e5be63b",
|
"/js/clients/payments/card-js.min.js": "/js/clients/payments/card-js.min.js?id=8ce33c3deae058ad314fb8357e5be63b",
|
||||||
"/js/clients/shared/pdf.js": "/js/clients/shared/pdf.js?id=be5307abc990bb44f2f92628103b1d98",
|
"/js/clients/shared/pdf.js": "/js/clients/shared/pdf.js?id=be5307abc990bb44f2f92628103b1d98",
|
||||||
@ -42,7 +42,7 @@
|
|||||||
"/js/clients/payments/stripe-przelewy24.js": "/js/clients/payments/stripe-przelewy24.js?id=3d53d2f7d0291d9f92cf7414dd2d351c",
|
"/js/clients/payments/stripe-przelewy24.js": "/js/clients/payments/stripe-przelewy24.js?id=3d53d2f7d0291d9f92cf7414dd2d351c",
|
||||||
"/js/clients/payments/stripe-browserpay.js": "/js/clients/payments/stripe-browserpay.js?id=db71055862995fd6ae21becfc587a3de",
|
"/js/clients/payments/stripe-browserpay.js": "/js/clients/payments/stripe-browserpay.js?id=db71055862995fd6ae21becfc587a3de",
|
||||||
"/js/clients/payments/stripe-fpx.js": "/js/clients/payments/stripe-fpx.js?id=914a6846ad1e5584635e7430fef76875",
|
"/js/clients/payments/stripe-fpx.js": "/js/clients/payments/stripe-fpx.js?id=914a6846ad1e5584635e7430fef76875",
|
||||||
"/css/app.css": "/css/app.css?id=9cae1171423003d13f5880afe40d3ede",
|
"/css/app.css": "/css/app.css?id=ba50afdf2f898ddd8e59ebc5bde6c144",
|
||||||
"/css/card-js.min.css": "/css/card-js.min.css?id=62afeb675235451543ada60afcedcb7c",
|
"/css/card-js.min.css": "/css/card-js.min.css?id=62afeb675235451543ada60afcedcb7c",
|
||||||
"/vendor/clipboard.min.js": "/vendor/clipboard.min.js?id=15f52a1ee547f2bdd46e56747332ca2d"
|
"/vendor/clipboard.min.js": "/vendor/clipboard.min.js?id=15f52a1ee547f2bdd46e56747332ca2d"
|
||||||
}
|
}
|
||||||
|
@ -150,7 +150,7 @@ class StripeCreditCard {
|
|||||||
})
|
})
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
if (result.error) {
|
if (result.error) {
|
||||||
return this.handleFailure(result);
|
return this.handleFailure(result.error.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.handleSuccessfulAuthorization(result);
|
return this.handleSuccessfulAuthorization(result);
|
||||||
|
@ -325,12 +325,12 @@
|
|||||||
<div class="hero-section">
|
<div class="hero-section">
|
||||||
<div class="hero-contact-section">
|
<div class="hero-contact-section">
|
||||||
<div class="client-details">
|
<div class="client-details">
|
||||||
<span class="client-details-to-label">$from_label:</span>
|
<span class="client-details-to-label">$to_label:</span>
|
||||||
<div id="client-details"></div>
|
<div id="client-details"></div>
|
||||||
<div id="vendor-details"></div>
|
<div id="vendor-details"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="company-details">
|
<div class="company-details">
|
||||||
<span class="client-details-to-label">$to_label:</span>
|
<span class="client-details-to-label">$from_label:</span>
|
||||||
<div class="company-details-wrapper">
|
<div class="company-details-wrapper">
|
||||||
<div id="company-details"></div>
|
<div id="company-details"></div>
|
||||||
<div id="company-address"></div>
|
<div id="company-address"></div>
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
@section('meta_title', ctrans('texts.register'))
|
@section('meta_title', ctrans('texts.register'))
|
||||||
|
|
||||||
@section('body')
|
@section('body')
|
||||||
|
|
||||||
<div class="grid lg:grid-cols-12 py-8">
|
<div class="grid lg:grid-cols-12 py-8">
|
||||||
<div class="col-span-12 lg:col-span-8 lg:col-start-3 xl:col-span-6 xl:col-start-4 px-6">
|
<div class="col-span-12 lg:col-span-8 lg:col-start-3 xl:col-span-6 xl:col-start-4 px-6">
|
||||||
<div class="flex justify-center">
|
<div class="flex justify-center">
|
||||||
@ -10,7 +11,7 @@
|
|||||||
<h1 class="text-center text-3xl mt-8">{{ ctrans('texts.register') }}</h1>
|
<h1 class="text-center text-3xl mt-8">{{ ctrans('texts.register') }}</h1>
|
||||||
<p class="block text-center text-gray-600">{{ ctrans('texts.register_label') }}</p>
|
<p class="block text-center text-gray-600">{{ ctrans('texts.register_label') }}</p>
|
||||||
|
|
||||||
<form action="{{ route('client.register', request()->route('company_key')) }}" method="POST" x-data="{ more: false }">
|
<form action="{{ route('client.register', request()->route('company_key')) }}" method="POST" x-data="{more: false, busy: false, isSubmitted: false}" x-on:submit="isSubmitted = true">
|
||||||
@if($register_company)
|
@if($register_company)
|
||||||
<input type="hidden" name="company_key" value="{{ $register_company->company_key }}">
|
<input type="hidden" name="company_key" value="{{ $register_company->company_key }}">
|
||||||
@endif
|
@endif
|
||||||
@ -40,19 +41,19 @@
|
|||||||
class="input w-full"
|
class="input w-full"
|
||||||
type="email"
|
type="email"
|
||||||
name="{{ $field['key'] }}"
|
name="{{ $field['key'] }}"
|
||||||
value=""
|
value="{{ old($field['key']) }}"
|
||||||
{{ $field['required'] ? 'required' : '' }} />
|
/>
|
||||||
@elseif($field['key'] === 'password')
|
@elseif($field['key'] === 'password')
|
||||||
<input
|
<input
|
||||||
id="{{ $field['key'] }}"
|
id="{{ $field['key'] }}"
|
||||||
class="input w-full"
|
class="input w-full"
|
||||||
type="password"
|
type="password"
|
||||||
name="{{ $field['key'] }}"
|
name="{{ $field['key'] }}"
|
||||||
{{ $field['required'] ? 'required' : '' }} />
|
/>
|
||||||
@elseif($field['key'] === 'country_id')
|
@elseif($field['key'] === 'country_id')
|
||||||
<select
|
<select
|
||||||
id="shipping_country"
|
id="shipping_country"
|
||||||
class="input w-full form-select"
|
class="input w-full form-select bg-white"
|
||||||
name="country_id">
|
name="country_id">
|
||||||
<option value="none"></option>
|
<option value="none"></option>
|
||||||
@foreach(App\Utils\TranslationHelper::getCountries() as $country)
|
@foreach(App\Utils\TranslationHelper::getCountries() as $country)
|
||||||
@ -69,7 +70,7 @@
|
|||||||
class="input w-full"
|
class="input w-full"
|
||||||
name="{{ $field['key'] }}"
|
name="{{ $field['key'] }}"
|
||||||
value="{{ old($field['key']) }}"
|
value="{{ old($field['key']) }}"
|
||||||
{{ $field['required'] ? 'required' : '' }} />
|
/>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
@error($field['key'])
|
@error($field['key'])
|
||||||
@ -98,7 +99,7 @@
|
|||||||
type="password"
|
type="password"
|
||||||
class="input w-full"
|
class="input w-full"
|
||||||
name="password_confirmation"
|
name="password_confirmation"
|
||||||
{{ $field['required'] ? 'required' : '' }} />
|
/>
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
@endif
|
@endif
|
||||||
@ -124,7 +125,8 @@
|
|||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<button class="button button-primary bg-blue-600">{{ ctrans('texts.register') }}</button>
|
<button class="button button-primary bg-blue-600" :disabled={{ $submitsForm == 'true' ? 'isSubmitted' : 'busy'}} x-on:click="busy = true">{{ ctrans('texts.register')}}</button>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
@if(!array_key_exists('filled', $field))
|
@if(!array_key_exists('filled', $field))
|
||||||
@component('portal.ninja2020.components.general.card-element', ['title' => $field['label']])
|
@component('portal.ninja2020.components.general.card-element', ['title' => $field['label']])
|
||||||
@if($field['name'] == 'client_country_id' || $field['name'] == 'client_shipping_country_id')
|
@if($field['name'] == 'client_country_id' || $field['name'] == 'client_shipping_country_id')
|
||||||
<select id="client_country" class="input w-full form-select" name="{{ $field['name'] }}" wire:model.lazy="{{ str_replace(["client_","_line_","contact_"], ["client.","","contact."], $field['name']) }}">
|
<select id="client_country" class="input w-full form-select bg-white" name="{{ $field['name'] }}" wire:model.lazy="{{ str_replace(["client_","_line_","contact_"], ["client.","","contact."], $field['name']) }}">
|
||||||
<option value="none"></option>
|
<option value="none"></option>
|
||||||
|
|
||||||
@foreach($countries as $country)
|
@foreach($countries as $country)
|
||||||
|
@ -55,7 +55,7 @@
|
|||||||
@endcomponent
|
@endcomponent
|
||||||
|
|
||||||
@component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.country')])
|
@component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.country')])
|
||||||
<select name="countries" id="country" name="country" class="form-select input w-full" required>
|
<select name="countries" id="country" name="country" class="form-select input w-full bg-white" required>
|
||||||
@foreach($countries as $country)
|
@foreach($countries as $country)
|
||||||
<option value="{{ $country->iso_3166_2 }}" {{$country->iso_3166_2 == 'US' ? "selected" : ""}}>{{ $country->iso_3166_2 }} ({{ $country->name }})</option>
|
<option value="{{ $country->iso_3166_2 }}" {{$country->iso_3166_2 == 'US' ? "selected" : ""}}>{{ $country->iso_3166_2 }} ({{ $country->name }})</option>
|
||||||
@endforeach
|
@endforeach
|
||||||
|
@ -47,7 +47,7 @@
|
|||||||
@endcomponent
|
@endcomponent
|
||||||
|
|
||||||
@component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.country')])
|
@component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.country')])
|
||||||
<select name="countries" id="country" class="form-select input w-full">
|
<select name="countries" id="country" class="form-select input w-full bg-white">
|
||||||
<option disabled selected></option>
|
<option disabled selected></option>
|
||||||
@foreach($countries as $country)
|
@foreach($countries as $country)
|
||||||
@if($country->iso_3166_2 == 'US')
|
@if($country->iso_3166_2 == 'US')
|
||||||
|
@ -45,7 +45,7 @@
|
|||||||
@endcomponent
|
@endcomponent
|
||||||
|
|
||||||
@component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.country')])
|
@component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.country')])
|
||||||
<select name="countries" id="country" class="form-select input w-full" required>
|
<select name="countries" id="country" class="form-select input w-full bg-white" required>
|
||||||
@foreach($countries as $country)
|
@foreach($countries as $country)
|
||||||
<option value="{{ $country->iso_3166_2 }}">{{ $country->iso_3166_2 }} ({{ $country->name }})</option>
|
<option value="{{ $country->iso_3166_2 }}">{{ $country->iso_3166_2 }} ({{ $country->name }})</option>
|
||||||
@endforeach
|
@endforeach
|
||||||
|
@ -45,7 +45,7 @@
|
|||||||
@endcomponent
|
@endcomponent
|
||||||
|
|
||||||
@component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.country')])
|
@component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.country')])
|
||||||
<select name="countries" id="country" class="form-select input w-full" required>
|
<select name="countries" id="country" class="form-select input w-full bg-white" required>
|
||||||
@foreach($countries as $country)
|
@foreach($countries as $country)
|
||||||
<option value="{{ $country->iso_3166_2 }}">{{ $country->iso_3166_2 }} ({{ $country->name }})</option>
|
<option value="{{ $country->iso_3166_2 }}">{{ $country->iso_3166_2 }} ({{ $country->name }})</option>
|
||||||
@endforeach
|
@endforeach
|
||||||
|
@ -45,7 +45,7 @@
|
|||||||
@endcomponent
|
@endcomponent
|
||||||
|
|
||||||
@component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.country')])
|
@component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.country')])
|
||||||
<select name="countries" id="country" class="form-select input w-full" required>
|
<select name="countries" id="country" class="form-select input w-full bg-white" required>
|
||||||
@foreach($countries as $country)
|
@foreach($countries as $country)
|
||||||
<option value="{{ $country->iso_3166_2 }}">{{ $country->iso_3166_2 }} ({{ $country->name }})</option>
|
<option value="{{ $country->iso_3166_2 }}">{{ $country->iso_3166_2 }} ({{ $country->name }})</option>
|
||||||
@endforeach
|
@endforeach
|
||||||
|
@ -57,7 +57,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="col-span-6 sm:col-span-2">
|
<div class="col-span-6 sm:col-span-2">
|
||||||
<label for="country" class="input-label">@lang('texts.country')</label>
|
<label for="country" class="input-label">@lang('texts.country')</label>
|
||||||
<select id="country" class="input w-full form-select {{ in_array('billing_country', (array) session('missing_required_fields')) ? 'border border-red-400' : '' }}" wire:model.defer="country_id">
|
<select id="country" class="input w-full form-select bg-white {{ in_array('billing_country', (array) session('missing_required_fields')) ? 'border border-red-400' : '' }}" wire:model.defer="country_id">
|
||||||
<option value="none"></option>
|
<option value="none"></option>
|
||||||
@foreach($countries as $country)
|
@foreach($countries as $country)
|
||||||
<option value="{{ $country->id }}">
|
<option value="{{ $country->id }}">
|
||||||
|
@ -58,7 +58,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="col-span-4 sm:col-span-2">
|
<div class="col-span-4 sm:col-span-2">
|
||||||
<label for="shipping_country" class="input-label">@lang('texts.shipping_country')</label>
|
<label for="shipping_country" class="input-label">@lang('texts.shipping_country')</label>
|
||||||
<select id="shipping_country" class="input w-full form-select" wire:model.defer="shipping_country_id">
|
<select id="shipping_country" class="input w-full form-select bg-white" wire:model.defer="shipping_country_id">
|
||||||
<option value="none"></option>
|
<option value="none"></option>
|
||||||
@foreach($countries as $country)
|
@foreach($countries as $country)
|
||||||
<option value="{{ $country->id }}">
|
<option value="{{ $country->id }}">
|
||||||
|
@ -46,6 +46,7 @@ Route::group(['middleware' => ['auth:vendor', 'vendor_locale', 'domain_db'], 'pr
|
|||||||
|
|
||||||
Route::post('documents/download_multiple', [App\Http\Controllers\VendorPortal\DocumentController::class, 'downloadMultiple'])->name('documents.download_multiple');
|
Route::post('documents/download_multiple', [App\Http\Controllers\VendorPortal\DocumentController::class, 'downloadMultiple'])->name('documents.download_multiple');
|
||||||
Route::get('documents/{document}/download', [App\Http\Controllers\VendorPortal\DocumentController::class, 'download'])->name('documents.download');
|
Route::get('documents/{document}/download', [App\Http\Controllers\VendorPortal\DocumentController::class, 'download'])->name('documents.download');
|
||||||
|
Route::get('documents/{document}/download_pdf', [App\Http\Controllers\VendorPortal\DocumentController::class, 'download'])->name('documents.download_pdf');
|
||||||
Route::resource('documents', App\Http\Controllers\VendorPortal\DocumentController::class)->only(['index', 'show']);
|
Route::resource('documents', App\Http\Controllers\VendorPortal\DocumentController::class)->only(['index', 'show']);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -258,7 +258,7 @@ class DeleteInvoiceTest extends TestCase
|
|||||||
$invoice = $invoice->service()->markPaid()->save();
|
$invoice = $invoice->service()->markPaid()->save();
|
||||||
|
|
||||||
$this->assertEquals(0, $invoice->balance);
|
$this->assertEquals(0, $invoice->balance);
|
||||||
$this->assertEquals(0, $invoice->client->balance);
|
$this->assertEquals(0, $invoice->client->fresh()->balance);
|
||||||
$this->assertEquals(20, $invoice->client->paid_to_date);
|
$this->assertEquals(20, $invoice->client->paid_to_date);
|
||||||
|
|
||||||
//partially refund payment
|
//partially refund payment
|
||||||
|
Loading…
Reference in New Issue
Block a user