diff --git a/app/DataMapper/ClientRegistrationFields.php b/app/DataMapper/ClientRegistrationFields.php index 5e6397267dfe..505e40742490 100644 --- a/app/DataMapper/ClientRegistrationFields.php +++ b/app/DataMapper/ClientRegistrationFields.php @@ -93,6 +93,10 @@ class ClientRegistrationFields 'key' => 'vat_number', 'required' => false, ], + [ + 'key' => 'currency_id', + 'required' => false, + ], ]; return $data; diff --git a/app/Http/Controllers/Auth/ContactRegisterController.php b/app/Http/Controllers/Auth/ContactRegisterController.php index db7fc1e0c7bb..8efb6647ea66 100644 --- a/app/Http/Controllers/Auth/ContactRegisterController.php +++ b/app/Http/Controllers/Auth/ContactRegisterController.php @@ -58,7 +58,7 @@ class ContactRegisterController extends Controller Auth::guard('contact')->loginUsingId($client_contact->id, true); - return redirect()->route('client.dashboard'); + return redirect()->intended('client.dashboard'); } private function getClient(array $data) @@ -66,7 +66,15 @@ class ContactRegisterController extends Controller $client = ClientFactory::create($data['company']->id, $data['company']->owner()->id); $client->fill($data); + $client->save(); + + if(isset($data['currency_id'])) { + $settings = $client->settings; + $settings->currency_id = isset($data['currency_id']) ? $data['currency_id'] : $data['company']->settings->currency_id; + $client->settings = $settings; + } + $client->number = $this->getNextClientNumber($client); $client->save(); diff --git a/app/Http/Controllers/ClientPortal/SubscriptionPurchaseController.php b/app/Http/Controllers/ClientPortal/SubscriptionPurchaseController.php index fb569df26c3d..04354e228220 100644 --- a/app/Http/Controllers/ClientPortal/SubscriptionPurchaseController.php +++ b/app/Http/Controllers/ClientPortal/SubscriptionPurchaseController.php @@ -53,6 +53,16 @@ class SubscriptionPurchaseController extends Controller $this->setLocale($request->query('locale')); } + if(!auth()->guard('contact')->check() && $subscription->registration_required && $subscription->company->client_can_register) { + + session()->put('url.intended', route('client.subscription.upgrade',['subscription' => $subscription->hashed_id])); + + return redirect()->route('client.register', ['company_key' => $subscription->company->company_key]); + } + elseif(!auth()->guard('contact')->check() && $subscription->registration_required && ! $subscription->company->client_can_register) { + return render('generic.subscription_blocked', ['account' => $subscription->company->account, 'company' => $subscription->company]); + } + return view('billing-portal.purchasev2', [ 'subscription' => $subscription, 'hash' => Str::uuid()->toString(), diff --git a/app/Http/Livewire/BillingPortalPurchasev2.php b/app/Http/Livewire/BillingPortalPurchasev2.php index 429c45aeff36..3be67e4858e0 100644 --- a/app/Http/Livewire/BillingPortalPurchasev2.php +++ b/app/Http/Livewire/BillingPortalPurchasev2.php @@ -158,6 +158,13 @@ class BillingPortalPurchasev2 extends Component { MultiDB::setDb($this->company->db); + if(auth()->guard('contact')->check()){ + $this->email = auth()->guard('contact')->user()->email; + $this->contact = auth()->guard('contact')->user(); + $this->authenticated = true; + $this->payment_started = true; + } + $this->discount = 0; $this->sub_total = 0; $this->float_amount_total = 0; diff --git a/database/factories/ProductFactory.php b/database/factories/ProductFactory.php index ecba3066cd16..7f8f25833838 100644 --- a/database/factories/ProductFactory.php +++ b/database/factories/ProductFactory.php @@ -29,14 +29,8 @@ class ProductFactory extends Factory 'cost' => $this->faker->numberBetween(1, 1000), 'price' => $this->faker->numberBetween(1, 1000), 'quantity' => $this->faker->numberBetween(1, 100), - // 'tax_name1' => 'GST', - // 'tax_rate1' => 10, - // 'tax_name2' => 'VAT', - // 'tax_rate2' => 17.5, - // 'tax_name3' => 'THIRDTAX', - // 'tax_rate3' => 5, - 'custom_value1' => $this->faker->text(20), - 'custom_value2' => $this->faker->text(20), + 'custom_value1' => 'https://picsum.photos/200', + 'custom_value2' => rand(0,100), 'custom_value3' => $this->faker->text(20), 'custom_value4' => $this->faker->text(20), 'is_deleted' => false, diff --git a/lang/en/texts.php b/lang/en/texts.php index 04d4e52a2605..50c56a5b8ebe 100644 --- a/lang/en/texts.php +++ b/lang/en/texts.php @@ -4910,6 +4910,8 @@ $LANG = array( 'notification_purchase_order_created_subject' => 'Purchase Order :purchase_order was created for :vendor', 'notification_purchase_order_sent_subject' => 'Purchase Order :purchase_order was sent to :vendor', 'notification_purchase_order_sent' => 'The following vendor :vendor was emailed Purchase Order :purchase_order for :amount.', + 'subscription_blocked' => 'This product is a restricted item, please contact the vendor for further information.', + 'subscription_blocked_title' => 'Product not available.', ); return $LANG; diff --git a/resources/views/portal/ninja2020/auth/register.blade.php b/resources/views/portal/ninja2020/auth/register.blade.php index 84e2c0f2a94e..47ecc899edc6 100644 --- a/resources/views/portal/ninja2020/auth/register.blade.php +++ b/resources/views/portal/ninja2020/auth/register.blade.php @@ -5,9 +5,17 @@
{{ ctrans('texts.register_label') }}
@@ -54,6 +62,18 @@ type="password" name="{{ $field['key'] }}" /> + @elseif($field['key'] === 'currency_id') + @elseif($field['key'] === 'country_id')