1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-20 10:13:31 +00:00

org settings and billing

This commit is contained in:
Kyle Spearrin
2017-04-06 16:52:25 -04:00
parent 7591843220
commit 80e4d2329a
8 changed files with 249 additions and 9 deletions

View File

@@ -1,6 +1,72 @@
angular
.module('bit.organization')
.controller('organizationBillingController', function ($scope) {
.controller('organizationBillingController', function ($scope, apiService, $state) {
$scope.charges = [];
$scope.paymentSource = null;
$scope.plan = null;
$scope.subscription = null;
$scope.loading = true;
$scope.$on('$viewContentLoaded', function () {
apiService.organizations.getBilling({ id: $state.params.orgId }, function (org) {
$scope.loading = false;
$scope.plan = {
name: org.Plan,
type: org.PlanType,
maxUsers: org.MaxUsers
};
$scope.subscription = {
trialEndDate: org.Subscription.TrialEndDate,
nextBillDate: org.Subscription.NextBillDate,
cancelNext: org.Subscription.CancelAtNextBillDate,
status: org.Subscription.Status
};
if (org.Subscription.Items) {
$scope.subscription.items = [];
for (var i = 0; i < org.Subscription.Items.length; i++) {
$scope.subscription.items.push({
amount: org.Subscription.Items[i].Amount,
name: org.Subscription.Items[i].Name,
interval: org.Subscription.Items[i].Interval,
qty: org.Subscription.Items[i].Quantity
});
}
}
if (org.PaymentSource) {
$scope.paymentSource = {
type: org.PaymentSource.Type,
description: org.PaymentSource.Description,
cardBrand: org.PaymentSource.CardBrand
};
}
var charges = [];
for (var i = 0; i < org.Charges.length; i++) {
charges.push({
date: org.Charges[i].CreatedDate,
paymentSource: org.Charges[i].PaymentSource ? org.Charges[i].PaymentSource.Description : '-',
amount: org.Charges[i].Amount,
status: org.Charges[i].Status,
failureMessage: org.Charges[i].FailureMessage,
refunded: org.Charges[i].Refunded,
partiallyRefunded: org.Charges[i].PartiallyRefunded,
refundedAmount: org.Charges[i].RefundedAmount
});
}
$scope.charges = charges;
});
});
$scope.changePayment = function () {
};
$scope.cancel = function () {
};
});