1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-11 21:52:35 +01:00

Merge pull request #7805 from turbo124/v5-stable

v5.5.20
This commit is contained in:
David Bomba 2022-09-07 20:12:40 +10:00 committed by GitHub
commit 143e39c312
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
72 changed files with 675 additions and 683 deletions

View File

@ -1 +1 @@
5.5.19
5.5.20

View File

@ -76,7 +76,7 @@ class CheckData extends Command
/**
* @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
@ -118,8 +118,10 @@ class CheckData extends Command
$this->checkDuplicateRecurringInvoices();
$this->checkOauthSanity();
if(Ninja::isHosted())
if(Ninja::isHosted()){
$this->checkAccountStatuses();
$this->checkNinjaPortalUrls();
}
if (! $this->option('client_id')) {
$this->checkOAuth();
@ -505,12 +507,12 @@ class CheckData extends Command
$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;
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->save();
}
@ -582,12 +584,12 @@ class CheckData extends Command
if (round($total_invoice_payments, 2) != round($client->paid_to_date, 2)) {
$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;
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->save();
}
@ -618,7 +620,7 @@ class CheckData extends Command
if ((string)$total_paid != (string)($invoice->amount - $invoice->balance - $total_credit)) {
$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;
}
@ -666,11 +668,11 @@ class CheckData extends Command
$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')){
$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->save();
@ -704,7 +706,7 @@ class CheckData extends Command
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->save();
@ -758,13 +760,13 @@ class CheckData extends Command
$this->wrong_balances++;
$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;
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->save();
@ -796,14 +798,14 @@ class CheckData extends Command
if ($ledger && number_format($ledger->balance, 4) != number_format($client->balance, 4)) {
$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;
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->save();
@ -1003,4 +1005,31 @@ class CheckData extends Command
$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}");
}
});
}
}

View File

@ -189,7 +189,7 @@ class CreateSingleAccount extends Command
$this->createClient($company, $user);
}
CreateCompanyTaskStatuses::dispatchNow($company, $user);
(new CreateCompanyTaskStatuses($company, $user))->handle();
for ($x = 0; $x < $this->count; $x++) {
$client = $company->clients->random();

View File

@ -132,7 +132,8 @@ class DemoMode extends Command
'enabled_modules' => 32767,
'company_key' => 'KEY',
'enable_shop_api' => true,
'markdown_email_enabled' => false,
'markdown_email_enabled' => true,
'markdown_enabled' => false,
]);
$settings = $company->settings;

View File

@ -97,10 +97,6 @@ class SendRemindersCron extends Command
}
});
// SendReminders::dispatchNow();
// $this->webHookOverdueInvoices();
// $this->webHookExpiredQuotes();
}
private function calcLateFee($invoice, $template) :Invoice

View File

@ -727,7 +727,6 @@ class CompanySettings extends BaseSettings
*/
public static function defaults(): stdClass
{
$config = json_decode(config('ninja.settings'));
$data = (object) get_class_vars(self::class);

View File

@ -46,7 +46,7 @@ class CompanyFactory
$company->enabled_modules = config('ninja.enabled_modules'); //32767;//8191; //4095
$company->default_password_timeout = 1800000;
$company->markdown_email_enabled = false;
$company->markdown_email_enabled = true;
$company->markdown_enabled = false;
return $company;

View File

@ -46,7 +46,7 @@ class ContactRegisterController extends Controller
$t = app('translator');
$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)

View File

@ -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
// 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))))) {
$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) {
@ -900,9 +901,10 @@ class BaseController extends Controller
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_key_exists('path', $canvas_path_array)) ? $canvas_path_array['path'] : '';
$canvas_path = rtrim(str_replace("index.php", "", $canvas_path),'/');
$data = [];

View File

@ -131,7 +131,7 @@ class EmailController extends BaseController
if(Ninja::isHosted() && !$entity_obj->company->account->account_sms_verified)
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);
}

View File

@ -173,7 +173,7 @@ class PreviewPurchaseOrderController extends BaseController
}
//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);
}
@ -285,7 +285,7 @@ class PreviewPurchaseOrderController extends BaseController
return $pdf;
}
$file_path = PreviewPdf::dispatchNow($maker->getCompiledHTML(true), $company);
$file_path = (new PreviewPdf($maker->getCompiledHTML(true), $company))->handle();
if(Ninja::isHosted())
@ -363,7 +363,7 @@ class PreviewPurchaseOrderController extends BaseController
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->header('Content-Type', 'application/pdf');
@ -460,7 +460,7 @@ class PreviewPurchaseOrderController extends BaseController
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->header('Content-Type', 'application/pdf');

View File

@ -210,7 +210,7 @@ class UserController extends BaseController
$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)));

View File

@ -108,8 +108,6 @@ class InvitationController extends Controller
$file_name = $invitation->purchase_order->numberFormatter().'.pdf';
// $file = CreateRawPdf::dispatchNow($invitation, $invitation->company->db);
$file = (new CreatePurchaseOrderPdf($invitation))->rawPdf();
$headers = ['Content-Type' => 'application/pdf'];

View File

@ -507,7 +507,7 @@ class BillingPortalPurchase extends Component
$mailer->settings = $this->subscription->company->settings;
$mailer->to_user = $contact;
NinjaMailerJob::dispatchNow($mailer);
NinjaMailerJob::dispatch($mailer);
$this->steps['passwordless_login_sent'] = true;
$this->passwordless_login_btn = false;

View File

@ -29,10 +29,10 @@ class NameWebsiteLogo extends Component
{
$this->fill([
'profile' => auth()->guard('contact')->user()->client,
'name' => auth()->guard('contact')->user()->client->present()->name,
'vat_number' => auth()->guard('contact')->user()->client->present()->vat_number,
'website' => auth()->guard('contact')->user()->client->present()->website,
'phone' => auth()->guard('contact')->user()->client->present()->phone,
'name' => auth()->guard('contact')->user()->client->present()->name(),
'vat_number' => auth()->guard('contact')->user()->client->vat_number ?: '',
'website' => auth()->guard('contact')->user()->client->website,
'phone' => auth()->guard('contact')->user()->client->present()->phone(),
'saved' => ctrans('texts.save'),
]);
}

View File

@ -21,6 +21,7 @@ class ContactRegister
{
$domain_name = $request->getHost();
/* Hosted */
if (strpos($domain_name, 'invoicing.co') !== false) {
$subdomain = explode('.', $domain_name)[0];
@ -42,6 +43,7 @@ class ContactRegister
}
}
/* Hosted */
if (Ninja::isHosted()) {
$query = [
'portal_domain' => $request->getSchemeAndHttpHost(),

View File

@ -65,7 +65,7 @@ class StoreClientRequest extends Request
/* Ensure we have a client name, and that all emails are unique*/
//$rules['name'] = 'required|min:1';
$rules['settings'] = new ValidClientGroupSettingsRule();
$rules['contacts'] = 'array';
$rules['contacts'] = 'bail|array';
$rules['contacts.*.email'] = 'bail|nullable|distinct|sometimes|email';
$rules['contacts.*.password'] = [
'bail',

View File

@ -1,4 +1,13 @@
<?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;
@ -7,6 +16,7 @@ use App\Models\Account;
use App\Models\Company;
use App\Utils\Ninja;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class RegisterRequest extends FormRequest
{
@ -31,13 +41,13 @@ class RegisterRequest extends FormRequest
foreach ($this->company()->client_registration_fields as $field) {
if ($field['required']) {
$rules[$field['key']] = ['required'];
$rules[$field['key']] = ['bail','required'];
}
}
foreach ($rules as $field => $properties) {
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') {

View File

@ -43,7 +43,7 @@ class StorePaymentRequest extends Request
$invoices_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']);
}
@ -53,7 +53,9 @@ class StorePaymentRequest extends Request
if (isset($input['invoices']) && is_array($input['invoices']) !== false) {
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)) {
$invoices_total += $value['amount'];
@ -97,7 +99,8 @@ class StorePaymentRequest extends Request
{
$rules = [
'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.*.amount' => 'bail|required',
'invoices.*.invoice_id' => new ValidInvoicesRules($this->all()),

View File

@ -85,7 +85,9 @@ class BaseTransformer
$client_name_search = Client::where('company_id', $this->company->id)
->where('is_deleted', false)
->where('name', $client_name);
->whereRaw("LOWER(REPLACE(`name`, ' ' ,'')) = ?", [
strtolower(str_replace(' ', '', $client_name)),
]);
if ($client_name_search->count() >= 1) {
return $client_name_search->first()->id;

View File

@ -288,7 +288,7 @@ class CompanyImport implements ShouldQueue
$nmo->company = $_company;
$nmo->settings = $_company->settings;
$nmo->to_user = $_company->owner();
NinjaMailerJob::dispatchNow($nmo);
NinjaMailerJob::dispatch($nmo);
}
catch(\Exception $e){
@ -1644,7 +1644,7 @@ class CompanyImport implements ShouldQueue
$nmo->company = $this->company;
$nmo->settings = $this->company->settings;
$nmo->to_user = $this->company->owner();
NinjaMailerJob::dispatchNow($nmo);
NinjaMailerJob::dispatch($nmo);
}
}

View File

@ -64,7 +64,8 @@ class CreateCompany
$company->custom_fields = new \stdClass;
$company->default_password_timeout = 1800000;
$company->client_registration_fields = ClientRegistrationFields::generate();
$company->markdown_email_enabled = false;
$company->markdown_email_enabled = true;
$company->markdown_enabled = false;
if (Ninja::isHosted()) {
$company->subdomain = MultiDB::randomSubdomainGenerator();

View File

@ -52,8 +52,6 @@ class CheckCompanyData implements ShouldQueue
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
@ -110,7 +108,7 @@ class CheckCompanyData implements ShouldQueue
if ($ledger && number_format($invoice_balance, 4) != number_format($client->balance, 4)) {
$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;
}
@ -136,7 +134,7 @@ class CheckCompanyData implements ShouldQueue
if ((string) $total_paid != (string) ($invoice->amount - $invoice->balance - $total_credit)) {
$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;
}
@ -175,7 +173,7 @@ class CheckCompanyData implements ShouldQueue
if (round($total_invoice_payments, 2) != round($client->paid_to_date, 2)) {
$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;
}
@ -204,7 +202,7 @@ class CheckCompanyData implements ShouldQueue
if ($ledger && (string) $invoice_balance != (string) $client->balance) {
$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;
}

View File

@ -252,7 +252,7 @@ class Import implements ShouldQueue
$this->setInitialCompanyLedgerBalances();
// $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))
$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');
CreateCompanyToken::dispatchNow($this->company, $user, $user_agent);
(new CreateCompanyToken($this->company, $user, $user_agent))->handle();
$key = "users_{$resource['id']}";
@ -1899,7 +1899,7 @@ class Import implements ShouldQueue
if(Ninja::isHosted()){
try{
\Modules\Admin\Jobs\Account\NinjaUser::dispatchNow($data, $this->company);
\Modules\Admin\Jobs\Account\NinjaUser::dispatch($data, $this->company);
}
catch(\Exception $e){
nlog($e->getMessage());

View File

@ -112,7 +112,7 @@ class ClientPaymentFailureObject
'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()]),
'signature' => $signature,
'logo' => $this->company->present()->logo(),

View File

@ -70,8 +70,13 @@ class SupportMessageSent extends Mailable
$trial = $account->isTrial() ? 'T' : '';
$plan = str_replace('_', ' ', $plan);
$plan_status = '';
if(Carbon::parse($account->plan_expires)->lt(now()))
$plan_status = 'Plan Expired';
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 {
$subject = "{$priority}Self Hosted :: {$plan} :: {$is_large}{$platform}{$migrated} :: ".date('M jS, g:ia');
}

View File

@ -212,14 +212,14 @@ class PurchaseOrder extends BaseModel
return Storage::disk(config('filesystems.default'))->{$type}($file_path);
}
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);
}
if(Storage::disk('public')->exists($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);
}

View File

@ -110,17 +110,17 @@ class BraintreePaymentDriver extends BaseDriver
}
$result = $this->gateway->customer()->create([
'firstName' => $this->client->present()->name,
'email' => $this->client->present()->email,
'phone' => $this->client->present()->phone,
'firstName' => $this->client->present()->name(),
'email' => $this->client->present()->email(),
'phone' => $this->client->present()->phone(),
]);
if ($result->success) {
$address = $this->gateway->address()->create([
'customerId' => $result->customer->id,
'firstName' => $this->client->present()->name,
'streetAddress' => $this->client->address1,
'postalCode' => $this->client->postal_code,
'firstName' => $this->client->present()->name(),
'streetAddress' => $this->client->address1 ?: '',
'postalCode' => $this->client->postal_code ?: '',
'countryCodeAlpha2' => $this->client->country ? $this->client->country->iso_3166_2 : '',
]);

View File

@ -81,7 +81,7 @@ class CreditCard implements MethodInterface
$client->addressLines = [$this->square_driver->client->address1 ?: '', $this->square_driver->client->address2 ?: ''];
$client->givenName = $this->square_driver->client->present()->first_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->city = $this->square_driver->client->city;
$client->region = $this->square_driver->client->state;

View File

@ -28,10 +28,21 @@ class ClientContactRepository extends BaseRepository
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']);
} else {
} elseif(isset($data['contacts'])){
$temp_array[] = $data['contacts'];
$contacts = collect($temp_array);
}
else {
$contacts = collect();
}
$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 */
$contacts = $contacts->sortByDesc('is_primary')->map(function ($contact) {
$contact['is_primary'] = $this->is_primary;
$this->is_primary = false;

View File

@ -84,23 +84,23 @@ class PaymentRepository extends BaseRepository {
$data['amount'] = array_sum(array_column($data['invoices'], 'amount'));
}
// $client->service()->updatePaidToDate($data['amount'])->save();
$client->paid_to_date += $data['amount'];
$client->service()->updatePaidToDate($data['amount'])->save();
// $client->paid_to_date += $data['amount'];
$client->save();
}
else{
//this fixes an edge case with unapplied payments
// $client->service()->updatePaidToDate($data['amount'])->save();
$client->paid_to_date += $data['amount'];
$client->service()->updatePaidToDate($data['amount'])->save();
// $client->paid_to_date += $data['amount'];
$client->save();
}
if (array_key_exists('credits', $data) && is_array($data['credits']) && count($data['credits']) > 0) {
$_credit_totals = array_sum(array_column($data['credits'], 'amount'));
// $client->service()->updatePaidToDate($_credit_totals)->save();
$client->paid_to_date += $_credit_totals;
$client->service()->updatePaidToDate($_credit_totals)->save();
// $client->paid_to_date += $_credit_totals;
$client->save();
}

View File

@ -12,6 +12,7 @@
namespace App\Services\Client;
use App\Models\Client;
use App\Models\Credit;
use App\Services\Client\Merge;
use App\Services\Client\PaymentMethod;
use App\Utils\Number;
@ -28,14 +29,47 @@ class ClientService
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;
}
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;
}
@ -49,7 +83,7 @@ class ClientService
public function getCreditBalance() :float
{
$credits = $this->client->credits()
$credits = Credit::where('client_id', $this->client->id)
->where('is_deleted', false)
->where('balance', '>', 0)
->where(function ($query) {
@ -63,7 +97,7 @@ class ClientService
public function getCredits()
{
return $this->client->credits()
return Credit::where('client_id', $this->client->id)
->where('is_deleted', false)
->where('balance', '>', 0)
->where(function ($query) {

View File

@ -59,7 +59,7 @@ class ApplyNumber extends AbstractService
} catch (QueryException $e) {
$x++;
if ($x > 10) {
if ($x > 50) {
$this->completed = false;
}
}

View File

@ -77,7 +77,7 @@ class ApplyNumber extends AbstractService
$x++;
if($x>10)
if($x>50)
$this->completed = false;
}

View File

@ -88,7 +88,6 @@ class ApplyPayment extends AbstractService
$this->invoice
->client
->fresh()
->service()
->updateBalance($amount_paid)
->save();

View File

@ -43,7 +43,7 @@ class ApplyPaymentAmount extends AbstractService
public function run()
{
if ($this->invoice->status_id == Invoice::STATUS_DRAFT) {
$this->invoice->service()->markSent()->save();
$this->invoice = $this->invoice->service()->markSent()->save();
}
/*Don't double pay*/
@ -88,10 +88,8 @@ class ApplyPaymentAmount extends AbstractService
$this->invoice
->client
->fresh()
->service()
->updateBalance($payment->amount * -1)
->updatePaidToDate($payment->amount)
->updateBalanceAndPaidToDate($payment->amount * -1, $payment->amount)
->save();

View File

@ -35,6 +35,9 @@ class AutoBillInvoice extends AbstractService
protected $db;
/*Specific variable for partial payments */
private bool $is_partial_amount = false;
public function __construct(Invoice $invoice, $db)
{
$this->invoice = $invoice;
@ -46,7 +49,8 @@ class AutoBillInvoice extends AbstractService
{
MultiDB::setDb($this->db);
$this->client = $this->invoice->client->fresh();
/* Harvest Client*/
$this->client = $this->invoice->client;
$is_partial = false;
@ -68,6 +72,10 @@ class AutoBillInvoice extends AbstractService
$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;
/* Determine $amount */
@ -169,9 +177,9 @@ class AutoBillInvoice extends AbstractService
$payment->invoices()->attach($this->invoice->id, ['amount' => $amount]);
$this->invoice
->service()
->setStatus(Invoice::STATUS_PAID)
->save();
->service()
->setCalculatedStatus()
->save();
foreach ($this->used_credit as $credit) {
$current_credit = Credit::find($credit['credit_id']);
@ -191,18 +199,18 @@ class AutoBillInvoice extends AbstractService
->updatePaymentBalance($amount * -1)
->save();
$client = $this->invoice->client->fresh();
$client->service()
->updateBalance($amount * -1)
->updatePaidToDate($amount)
->adjustCreditBalance($amount * -1)
->save();
$this->invoice
->client
->service()
->updateBalanceAndPaidToDate($amount * -1, $amount)
// ->updateBalance($amount * -1)
// ->updatePaidToDate($amount)
->adjustCreditBalance($amount * -1)
->save();
$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}")
->save();
->updateCreditBalance($amount * -1, "Credit {$current_credit->number} used to pay down Invoice {$this->invoice->number}")
->save();
event('eloquent.created: App\Models\Payment', $payment);
event(new PaymentWasCreated($payment, $payment->company, Ninja::eventVars()));
@ -221,11 +229,11 @@ class AutoBillInvoice extends AbstractService
*/
private function applyCreditPayment()
{
$available_credits = $this->client
->credits
$available_credits = Credit::where('client_id', $this->client->id)
->where('is_deleted', false)
->where('balance', '>', 0)
->sortBy('created_at');
->orderBy('created_at')
->get();
$available_credit_balance = $available_credits->sum('balance');
@ -235,16 +243,14 @@ class AutoBillInvoice extends AbstractService
return;
}
$is_partial_amount = false;
if ($this->invoice->partial > 0) {
$is_partial_amount = true;
$this->is_partial_amount = true;
}
$this->used_credit = [];
foreach ($available_credits as $key => $credit) {
if ($is_partial_amount) {
if ($this->is_partial_amount) {
//more credit than needed
if ($credit->balance > $this->invoice->partial) {
@ -260,6 +266,7 @@ class AutoBillInvoice extends AbstractService
$this->invoice->partial -= $credit->balance;
$this->invoice->balance -= $credit->balance;
$this->invoice->paid_to_date += $credit->balance;
}
} else {
@ -276,6 +283,7 @@ class AutoBillInvoice extends AbstractService
$this->used_credit[$key]['amount'] = $credit->balance;
$this->invoice->balance -= $credit->balance;
$this->invoice->paid_to_date += $credit->balance;
}
}
}

View File

@ -45,8 +45,7 @@ class MarkInvoiceDeleted extends AbstractService
->setAdjustmentAmount()
->deletePaymentables()
->adjustPayments()
->adjustPaidToDate()
->adjustBalance()
->adjustPaidToDateAndBalance()
->adjustLedger();
$transaction = [
@ -70,21 +69,29 @@ class MarkInvoiceDeleted extends AbstractService
return $this;
}
private function adjustPaidToDate()
private function adjustPaidToDateAndBalance()
{
$client = $this->invoice->client->fresh();
$client->paid_to_date += $this->adjustment_amount * -1;
$client->save();
// $this->invoice->client->service()->updatePaidToDate($this->adjustment_amount * -1)->save(); //reduces the paid to date by the payment totals
// $client = $this->invoice->client->fresh();
// $client->paid_to_date += $this->adjustment_amount * -1;
// $client->balance += $this->balance_adjustment * -1;
// $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;
}
// @deprecated
private function adjustBalance()
{
$client = $this->invoice->client->fresh();
$client->balance += $this->balance_adjustment * -1;
$client->save();
// $client = $this->invoice->client->fresh();
// $client->balance += $this->balance_adjustment * -1;
// $client->save();
// $this->invoice->client->service()->updateBalance($this->balance_adjustment * -1)->save(); //reduces the client balance by the invoice amount.

View File

@ -34,6 +34,8 @@ class MarkPaid extends AbstractService
private $invoice;
private $payable_balance;
public function __construct(Invoice $invoice)
{
$this->invoice = $invoice;
@ -48,20 +50,20 @@ class MarkPaid extends AbstractService
}
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 () use($payable_balance) {
\DB::connection(config('database.default'))->transaction(function () {
$this->invoice = Invoice::where('id', $this->invoice->id)->lockForUpdate()->first();
$this->payable_balance = $this->invoice->balance;
$this->invoice
->service()
->setExchangeRate()
->updateBalance($payable_balance * -1)
->updatePaidToDate($payable_balance)
->updateBalance($this->payable_balance * -1)
->updatePaidToDate($this->payable_balance)
->setStatus(Invoice::STATUS_PAID)
->save();
@ -70,8 +72,8 @@ class MarkPaid extends AbstractService
/* Create Payment */
$payment = PaymentFactory::create($this->invoice->company_id, $this->invoice->user_id);
$payment->amount = $payable_balance;
$payment->applied = $payable_balance;
$payment->amount = $this->payable_balance;
$payment->applied = $this->payable_balance;
$payment->status_id = Payment::STATUS_COMPLETED;
$payment->client_id = $this->invoice->client_id;
$payment->transaction_reference = ctrans('texts.manual_entry');
@ -99,21 +101,13 @@ class MarkPaid extends AbstractService
/* Create a payment relationship to the invoice entity */
$payment->invoices()->attach($this->invoice->id, [
'amount' => $payable_balance,
'amount' => $this->payable_balance,
]);
event('eloquent.created: App\Models\Payment', $payment);
$this->invoice->next_send_date = null;
// $this->invoice
// ->service()
// ->setExchangeRate()
// ->updateBalance($payment->amount * -1)
// ->updatePaidToDate($payment->amount)
// ->setStatus(Invoice::STATUS_PAID)
// ->save();
$this->invoice
->service()
->applyNumber()
@ -121,16 +115,14 @@ class MarkPaid extends AbstractService
->save();
$payment->ledger()
->updatePaymentBalance($payable_balance * -1);
->updatePaymentBalance($this->payable_balance * -1);
\DB::connection(config('database.default'))->transaction(function () use ($payment) {
/* Get the last record for the client and set the current balance*/
$client = Client::withTrashed()->where('id', $this->invoice->client_id)->lockForUpdate()->first();
$client->paid_to_date += $payment->amount;
$client->balance -= $payment->amount;
$client->save();
}, 1);
//06-09-2022
$this->invoice
->client
->service()
->updateBalanceAndPaidToDate($payment->amount*-1, $payment->amount)
->save();
$this->invoice = $this->invoice
->service()

View File

@ -62,15 +62,7 @@ class MarkSent extends AbstractService
->save();
/*Adjust client balance*/
\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->client->service()->updateBalance($adjustment)->save();
$this->invoice->markInvitationsSent();

View File

@ -56,7 +56,7 @@ class ApplyNumber extends AbstractService
} catch (QueryException $e) {
$x++;
if ($x > 10) {
if ($x > 50) {
$this->completed = false;
}
}

View File

@ -90,9 +90,12 @@ class DeletePayment
->updateInvoiceBalance($net_deletable, "Adjusting invoice {$paymentable_invoice->number} due to deletion of Payment {$this->payment->number}")
->save();
$client = $client->service()
->updateBalance($net_deletable)
->save();
$client = $this->payment
->client
->fresh()
->service()
->updateBalance($net_deletable)
->save();
if ($paymentable_invoice->balance == $paymentable_invoice->amount) {
$paymentable_invoice->service()->setStatus(Invoice::STATUS_SENT)->save();

View File

@ -55,15 +55,12 @@ class RefundPayment
public function run()
{
$this->payment = $this->calculateTotalRefund() //sets amount for the refund (needed if we are refunding multiple invoices in one payment)
->setStatus() //sets status of payment
//->reversePayment()
//->buildCreditNote() //generate the credit note
//->buildCreditLineItems() //generate the credit note items
->updateCreditables() //return the credits first
->updatePaymentables() //update the paymentable items
->adjustInvoices()
->processGatewayRefund() //process the gateway refund if needed
->save();
->setStatus() //sets status of payment
->updateCreditables() //return the credits first
->updatePaymentables() //update the paymentable items
->adjustInvoices()
->processGatewayRefund() //process the gateway refund if needed
->save();
if (array_key_exists('email_receipt', $this->refund_data) && $this->refund_data['email_receipt'] == 'true') {
$contact = $this->payment->client->contacts()->whereNotNull('email')->first();
@ -251,7 +248,6 @@ class RefundPayment
*/
private function adjustInvoices()
{
$adjustment_amount = 0;
if (isset($this->refund_data['invoices']) && count($this->refund_data['invoices']) > 0) {
foreach ($this->refund_data['invoices'] as $refunded_invoice) {
@ -266,7 +262,9 @@ class RefundPayment
->updatePaidToDate($refunded_invoice['amount'] * -1)
->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) {
$invoice->service()->setStatus(Invoice::STATUS_SENT);
@ -276,10 +274,15 @@ class RefundPayment
$invoice->saveQuietly();
$client = $invoice->client;
$adjustment_amount += $refunded_invoice['amount'];
$client->balance += $refunded_invoice['amount'];
$client->save();
//06-09-2022
$client = $invoice->client
->service()
->updateBalance($refunded_invoice['amount'])
->save();
// $client = $invoice->client;
// $client->balance += $refunded_invoice['amount'];
// $client->save();
$transaction = [
'invoice' => $invoice->transaction_event(),
@ -350,75 +353,4 @@ class RefundPayment
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;
// }
}

View File

@ -62,15 +62,17 @@ class UpdateInvoicePayment
$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->balance -= $paid_amount;
$update_client->save();
// $update_client->paid_to_date += $paid_amount;
// $update_client->balance -= $paid_amount;
// $update_client->save();
}, 1);
// }, 1);
/* 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)

View File

@ -104,7 +104,7 @@ class PurchaseOrderService
if($force){
$this->purchase_order->invitations->each(function ($invitation) {
CreatePurchaseOrderPdf::dispatchNow($invitation);
(new CreatePurchaseOrderPdf($invitation))->handle();
});
return $this;

View File

@ -67,7 +67,7 @@ class ApplyNumber
} catch (QueryException $e) {
$x++;
if ($x > 10) {
if ($x > 50) {
$this->completed = false;
}
}

View File

@ -88,7 +88,7 @@ class RecurringService
$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();
});

View File

@ -107,7 +107,7 @@ class TemplateEngine
private function setSettingsObject()
{
if($this->entity == 'purchaseOrder'){
if($this->entity == 'purchaseOrder' || $this->entity == 'purchase_order'){
$this->settings_entity = auth()->user()->company();
$this->settings = $this->settings_entity->settings;
}

View File

@ -28,6 +28,7 @@ trait Refundable
/**
* Entry point for processing of refunds.
* @param array $data
* @deprecated ???? 06-09-2022
* @return Refundable
* @throws PaymentRefundFailed
*/

View File

@ -33,6 +33,9 @@ trait SavesDocuments
return false;
}
if(!is_array($document_array))
return;
foreach ($document_array as $document) {
$document = (new UploadFile(
$document,

View File

@ -94,7 +94,7 @@
"wepay/php-sdk": "^0.3"
},
"require-dev": {
"php": "^7.4|^8.0",
"php": "^8.1",
"barryvdh/laravel-debugbar": "^3.6",
"beyondcode/laravel-query-detector": "^1.6",
"brianium/paratest": "^6.1",

694
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -14,8 +14,8 @@ return [
'require_https' => env('REQUIRE_HTTPS', true),
'app_url' => rtrim(env('APP_URL', ''), '/'),
'app_domain' => env('APP_DOMAIN', 'invoicing.co'),
'app_version' => '5.5.19',
'app_tag' => '5.5.19',
'app_version' => '5.5.20',
'app_tag' => '5.5.20',
'minimum_client_version' => '5.0.16',
'terms_version' => '1.0.1',
'api_secret' => env('API_SECRET', ''),

View File

@ -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()
{
//
}
};

View File

@ -68,5 +68,40 @@ class LanguageSeeder extends Seeder
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);
}
}
}

View File

@ -4770,6 +4770,13 @@ $LANG = array(
'archive_purchase_order' => 'Archive Purchase Order',
'restore_purchase_order' => 'Restore 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;

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

View File

@ -14,7 +14,7 @@
"/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/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/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",
@ -42,7 +42,7 @@
"/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-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",
"/vendor/clipboard.min.js": "/vendor/clipboard.min.js?id=15f52a1ee547f2bdd46e56747332ca2d"
}

View File

@ -150,7 +150,7 @@ class StripeCreditCard {
})
.then((result) => {
if (result.error) {
return this.handleFailure(result);
return this.handleFailure(result.error.message);
}
return this.handleSuccessfulAuthorization(result);

View File

@ -325,12 +325,12 @@
<div class="hero-section">
<div class="hero-contact-section">
<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="vendor-details"></div>
</div>
<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 id="company-details"></div>
<div id="company-address"></div>

View File

@ -2,6 +2,7 @@
@section('meta_title', ctrans('texts.register'))
@section('body')
<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="flex justify-center">
@ -10,7 +11,7 @@
<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>
<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)
<input type="hidden" name="company_key" value="{{ $register_company->company_key }}">
@endif
@ -40,19 +41,19 @@
class="input w-full"
type="email"
name="{{ $field['key'] }}"
value=""
{{ $field['required'] ? 'required' : '' }} />
value="{{ old($field['key']) }}"
/>
@elseif($field['key'] === 'password')
<input
id="{{ $field['key'] }}"
class="input w-full"
type="password"
name="{{ $field['key'] }}"
{{ $field['required'] ? 'required' : '' }} />
/>
@elseif($field['key'] === 'country_id')
<select
id="shipping_country"
class="input w-full form-select"
class="input w-full form-select bg-white"
name="country_id">
<option value="none"></option>
@foreach(App\Utils\TranslationHelper::getCountries() as $country)
@ -69,7 +70,7 @@
class="input w-full"
name="{{ $field['key'] }}"
value="{{ old($field['key']) }}"
{{ $field['required'] ? 'required' : '' }} />
/>
@endif
@error($field['key'])
@ -98,7 +99,7 @@
type="password"
class="input w-full"
name="password_confirmation"
{{ $field['required'] ? 'required' : '' }} />
/>
</div>
@endif
@endif
@ -124,7 +125,8 @@
</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>
</form>
</div>

View File

@ -15,7 +15,7 @@
@if(!array_key_exists('filled', $field))
@component('portal.ninja2020.components.general.card-element', ['title' => $field['label']])
@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>
@foreach($countries as $country)

View File

@ -55,7 +55,7 @@
@endcomponent
@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)
<option value="{{ $country->iso_3166_2 }}" {{$country->iso_3166_2 == 'US' ? "selected" : ""}}>{{ $country->iso_3166_2 }} ({{ $country->name }})</option>
@endforeach

View File

@ -47,7 +47,7 @@
@endcomponent
@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>
@foreach($countries as $country)
@if($country->iso_3166_2 == 'US')

View File

@ -45,7 +45,7 @@
@endcomponent
@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)
<option value="{{ $country->iso_3166_2 }}">{{ $country->iso_3166_2 }} ({{ $country->name }})</option>
@endforeach

View File

@ -45,7 +45,7 @@
@endcomponent
@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)
<option value="{{ $country->iso_3166_2 }}">{{ $country->iso_3166_2 }} ({{ $country->name }})</option>
@endforeach

View File

@ -45,7 +45,7 @@
@endcomponent
@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)
<option value="{{ $country->iso_3166_2 }}">{{ $country->iso_3166_2 }} ({{ $country->name }})</option>
@endforeach

View File

@ -57,7 +57,7 @@
</div>
<div class="col-span-6 sm:col-span-2">
<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>
@foreach($countries as $country)
<option value="{{ $country->id }}">

View File

@ -58,7 +58,7 @@
</div>
<div class="col-span-4 sm:col-span-2">
<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>
@foreach($countries as $country)
<option value="{{ $country->id }}">

View File

@ -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::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']);
});

View File

@ -258,7 +258,7 @@ class DeleteInvoiceTest extends TestCase
$invoice = $invoice->service()->markPaid()->save();
$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);
//partially refund payment