mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Working on new pricing
This commit is contained in:
parent
cf3465b5e2
commit
86c08f3af5
@ -214,13 +214,6 @@ class AccountController extends BaseController
|
|||||||
return Redirect::to('view/' . $invitation->invitation_key);
|
return Redirect::to('view/' . $invitation->invitation_key);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// create a credit
|
|
||||||
$credit = $credit - $newPlan['price'];
|
|
||||||
if ($credit > 0) {
|
|
||||||
$client = $this->accountRepo->getNinjaClient($account, $credit);
|
|
||||||
$this->accountRepo->createNinjaCredit();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($plan != PLAN_FREE) {
|
if ($plan != PLAN_FREE) {
|
||||||
$company->plan_term = $term;
|
$company->plan_term = $term;
|
||||||
$company->plan_price = $newPlan['price'];
|
$company->plan_price = $newPlan['price'];
|
||||||
@ -235,131 +228,6 @@ class AccountController extends BaseController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
public function changePlan() {
|
|
||||||
$user = Auth::user();
|
|
||||||
$account = $user->account;
|
|
||||||
|
|
||||||
$plan = Input::get('plan');
|
|
||||||
$term = Input::get('plan_term');
|
|
||||||
|
|
||||||
$planDetails = $account->getPlanDetails(false, false);
|
|
||||||
|
|
||||||
$credit = 0;
|
|
||||||
if ($planDetails) {
|
|
||||||
if ($planDetails['plan'] == PLAN_PRO && $plan == PLAN_ENTERPRISE) {
|
|
||||||
// Upgrade from pro to enterprise
|
|
||||||
if($planDetails['term'] == PLAN_TERM_YEARLY && $term == PLAN_TERM_MONTHLY) {
|
|
||||||
// Upgrade to yearly for now; switch to monthly in a year
|
|
||||||
$pending_monthly = true;
|
|
||||||
$term = PLAN_TERM_YEARLY;
|
|
||||||
}
|
|
||||||
|
|
||||||
$new_plan = [
|
|
||||||
'plan' => PLAN_ENTERPRISE,
|
|
||||||
'term' => $term,
|
|
||||||
];
|
|
||||||
} elseif ($planDetails['plan'] == $plan) {
|
|
||||||
// Term switch
|
|
||||||
if ($planDetails['term'] == PLAN_TERM_YEARLY && $term == PLAN_TERM_MONTHLY) {
|
|
||||||
$pending_change = [
|
|
||||||
'plan' => $plan,
|
|
||||||
'term' => $term
|
|
||||||
];
|
|
||||||
} elseif ($planDetails['term'] == PLAN_TERM_MONTHLY && $term == PLAN_TERM_YEARLY
|
|
||||||
|| $planDetails['num_users'] != Input::get('num_users')) {
|
|
||||||
$new_plan = [
|
|
||||||
'plan' => $plan,
|
|
||||||
'term' => $term,
|
|
||||||
];
|
|
||||||
} else {
|
|
||||||
// Cancel the pending change
|
|
||||||
$account->company->pending_plan = null;
|
|
||||||
$account->company->pending_term = null;
|
|
||||||
$account->company->save();
|
|
||||||
Session::flash('message', trans('texts.updated_plan'));
|
|
||||||
}
|
|
||||||
} elseif (!empty($planDetails['started'])) {
|
|
||||||
// Downgrade
|
|
||||||
$refund_deadline = clone $planDetails['started'];
|
|
||||||
$refund_deadline->modify('+30 days');
|
|
||||||
|
|
||||||
if ($plan == PLAN_FREE && $refund_deadline >= date_create()) {
|
|
||||||
// Refund
|
|
||||||
$account->company->plan = null;
|
|
||||||
$account->company->plan_term = null;
|
|
||||||
$account->company->plan_started = null;
|
|
||||||
$account->company->plan_expires = null;
|
|
||||||
$account->company->plan_paid = null;
|
|
||||||
$account->company->pending_plan = null;
|
|
||||||
$account->company->pending_term = null;
|
|
||||||
|
|
||||||
if ($payment = $account->company->payment) {
|
|
||||||
$ninjaAccount = $this->accountRepo->getNinjaAccount();
|
|
||||||
$paymentDriver = $ninjaAccount->paymentDriver();
|
|
||||||
$paymentDriver->refundPayment($payment);
|
|
||||||
Session::flash('message', trans('texts.plan_refunded'));
|
|
||||||
\Log::info("Refunded Plan Payment: {$account->name} - {$user->email}");
|
|
||||||
} else {
|
|
||||||
Session::flash('message', trans('texts.updated_plan'));
|
|
||||||
}
|
|
||||||
|
|
||||||
$account->company->save();
|
|
||||||
|
|
||||||
} else {
|
|
||||||
$pending_change = [
|
|
||||||
'plan' => $plan,
|
|
||||||
'term' => $plan == PLAN_FREE ? null : $term,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($new_plan) && $new_plan['plan'] != PLAN_FREE) {
|
|
||||||
$time_used = $planDetails['paid']->diff(date_create());
|
|
||||||
$days_used = $time_used->days;
|
|
||||||
|
|
||||||
if ($time_used->invert) {
|
|
||||||
// They paid in advance
|
|
||||||
$days_used *= -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
$days_total = $planDetails['paid']->diff($planDetails['expires'])->days;
|
|
||||||
|
|
||||||
$percent_used = $days_used / $days_total;
|
|
||||||
$credit = $planDetails['plan_price'] * (1 - $percent_used);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$new_plan = [
|
|
||||||
'plan' => $plan,
|
|
||||||
'term' => $term,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($pending_change) && empty($new_plan)) {
|
|
||||||
$pending_change['num_users'] = Input::get('num_users');
|
|
||||||
$account->company->pending_plan = $pending_change['plan'];
|
|
||||||
$account->company->pending_term = $pending_change['term'];
|
|
||||||
$account->company->pending_num_users = $pending_change['num_users'];
|
|
||||||
$account->company->pending_plan_price = Utils::getPlanPrice($pending_change);
|
|
||||||
$account->company->save();
|
|
||||||
|
|
||||||
Session::flash('message', trans('texts.updated_plan'));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($new_plan) && $new_plan['plan'] != PLAN_FREE) {
|
|
||||||
$new_plan['num_users'] = 1;
|
|
||||||
if ($new_plan['plan'] == PLAN_ENTERPRISE) {
|
|
||||||
$new_plan['num_users'] = Input::get('num_users');
|
|
||||||
}
|
|
||||||
$new_plan['price'] = Utils::getPlanPrice($new_plan);
|
|
||||||
$invitation = $this->accountRepo->enablePlan($new_plan, $credit, !empty($pending_monthly));
|
|
||||||
return Redirect::to('view/'.$invitation->invitation_key);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Redirect::to('/settings/'.ACCOUNT_MANAGEMENT, 301);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $entityType
|
* @param $entityType
|
||||||
|
@ -2038,7 +2038,7 @@ $LANG = array(
|
|||||||
'buy_now_buttons_warning' => 'Note: client and invoice records are created even if the transaction isn\'t completed.',
|
'buy_now_buttons_warning' => 'Note: client and invoice records are created even if the transaction isn\'t completed.',
|
||||||
'buy_now_buttons_disabled' => 'This feature requires that a product is created and a payment gateway is configured.',
|
'buy_now_buttons_disabled' => 'This feature requires that a product is created and a payment gateway is configured.',
|
||||||
'enable_buy_now_buttons_help' => 'Enable support for buy now buttons',
|
'enable_buy_now_buttons_help' => 'Enable support for buy now buttons',
|
||||||
|
'changes_take_effect_immediately' => 'Note: changes take effect immediately',
|
||||||
);
|
);
|
||||||
|
|
||||||
return $LANG;
|
return $LANG;
|
||||||
|
@ -122,6 +122,11 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer" style="margin-top: 0px">
|
<div class="modal-footer" style="margin-top: 0px">
|
||||||
|
@if (Utils::isPro())
|
||||||
|
<div class="pull-left" style="padding-top: 8px;color:#888888">
|
||||||
|
{{ trans('texts.changes_take_effect_immediately') }}
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
<button type="button" class="btn btn-default" data-dismiss="modal">{{ trans('texts.go_back') }}</button>
|
<button type="button" class="btn btn-default" data-dismiss="modal">{{ trans('texts.go_back') }}</button>
|
||||||
@if ($planDetails && $planDetails['active'])
|
@if ($planDetails && $planDetails['active'])
|
||||||
<button type="button" class="btn btn-primary" id="changePlanButton" onclick="confirmChangePlan()">{{ trans('texts.plan_change') }}</button>
|
<button type="button" class="btn btn-primary" id="changePlanButton" onclick="confirmChangePlan()">{{ trans('texts.plan_change') }}</button>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user