Skip to content

Commit 4f0322b

Browse files
authored
Merge pull request #5 from bannie2492/dev
clients / billing account pages bug fixes
2 parents a317f74 + a271f41 commit 4f0322b

17 files changed

+104
-62
lines changed

src/app/billing_account_resources/billingaccountresources.list.controller.js

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
var module = angular.module('supportAdminApp');
44

55
module.controller('billingaccount.BillingAccountResourcesListController', ['$scope', '$rootScope', '$log',
6-
'billingaccountresources.Constants', 'BillingAccountResourceService', 'Alert', '$timeout', '$stateParams', '$state',
7-
function ($scope, $rootScope, $log, constants, BillingAccountResourceService, $alert, $timeout, $stateParams, $state) {
6+
'billingaccountresources.Constants', 'BillingAccountResourceService', 'Alert', '$timeout', '$stateParams', '$state', 'UserService',
7+
function ($scope, $rootScope, $log, constants, BillingAccountResourceService, $alert, $timeout, $stateParams, $state, UserService) {
88

99
$scope.billingAccountId = $stateParams.accountId;
1010

@@ -44,7 +44,7 @@ module.controller('billingaccount.BillingAccountResourcesListController', ['$sco
4444
$scope.formSearch.setLoading(false);
4545
$scope.$broadcast('billingaccountresources.TableDataUpdated');
4646
}).catch(function (error) {
47-
$alert.error(error.error.message, $rootScope);
47+
$alert.error(error.error, $rootScope);
4848
$scope.formSearch.setLoading(false);
4949
});
5050
};
@@ -53,12 +53,19 @@ module.controller('billingaccount.BillingAccountResourcesListController', ['$sco
5353
* Delete the resource
5454
* @param {String} userId the id of resource
5555
*/
56-
$scope.deleteResource = function (userId) {
57-
BillingAccountResourceService.removeBillingAccountResource($scope.billingAccountId, userId).then(function () {
58-
$state.reload();
59-
}).catch(function (error) {
60-
$alert.error(error.error.message, $rootScope);
56+
$scope.deleteResource = function (user) {
57+
UserService.find({
58+
filter: 'handle=' + user.name
59+
}).then(function (data) {
60+
if (data && data.length) {
61+
BillingAccountResourceService.removeBillingAccountResource($scope.billingAccountId, data[0].id).then(function () {
62+
$state.reload();
63+
}).catch(function (error) {
64+
$alert.error(error.error, $rootScope);
65+
});
66+
}
6167
});
68+
6269
};
6370

6471
if ($stateParams.accountId) {

src/app/billing_account_resources/billingaccountresources.list.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<td>{{user.name}}</td>
3030
<td>{{user.status}}</td>
3131
<td>
32-
<a href="javascript:;" ng-click="deleteResource(user.id)">Delete</a>
32+
<a href="javascript:;" ng-click="deleteResource(user)">Delete</a>
3333
</td>
3434
</tr>
3535
</tbody>

src/app/billing_account_resources/billingaccountresources.new.controller.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ module.controller('billingaccount.NewBillingAccountResourceController', ['$scope
1818
$scope.processing = false;
1919
$state.go('index.billingaccountresources.list', { accountId: $scope.billingAccountId });
2020
}).catch(function (error) {
21-
$alert.error(error.error.message, $rootScope);
21+
$alert.error(error.error, $rootScope);
2222
$scope.processing = false;
2323
});
2424
};

src/app/billing_account_resources/billingaccountresources.service.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,16 @@ angular.module('supportAdminApp')
1818
status: error.status,
1919
error : error.data.result.content
2020
};
21+
} else if (error && error.data) {
22+
err = {
23+
status: error.status,
24+
error : error.data.message
25+
};
2126
}
2227
if(!err) {
2328
err = {
2429
status: error.status,
25-
error : error.statusText
30+
error : error.message
2631
};
2732
}
2833
deferred.reject(err);
@@ -51,7 +56,9 @@ angular.module('supportAdminApp')
5156
var deferred = $q.defer();
5257
$http({
5358
method: 'POST',
54-
data: entity,
59+
data: {
60+
userId: entity.userId
61+
},
5562
headers: {
5663
'Content-Type': 'application/json'
5764
},

src/app/billing_accounts/billingaccounts.edit.html

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</div>
1212
<div class="form-group col-md-6" ng-class="{'has-error': editAccountForm.customerNumber.$touched && editAccountForm.customerNumber.$invalid}">
1313
<label for="account-customer-number">Customer Number</label>
14-
<input id="account-customer-number" type="text" class="form-control" ng-model="account.customerNumber" name="customerNumber" required="required">
14+
<input id="account-customer-number" type="text" class="form-control" ng-model="account.companyId" name="customerNumber">
1515
</div>
1616
</div>
1717
<div class="row">
@@ -38,25 +38,23 @@
3838
<div class="form-group col-md-6" ng-class="{'has-error': editAccountForm.status.$touched && editAccountForm.status.$invalid}">
3939
<label for="account-status">Status</label>
4040
<select id="account-status" class="form-control" ng-model="account.status">
41-
<option value="inactive">In Active</option>
42-
<option value="active">Active</option>
43-
<option value="pending">Pending</option>
44-
<option value="disabled">Disabled</option>
41+
<option value="Active">Active</option>
42+
<option value="Inactive">In Active</option>
4543
</select>
4644
</div>
4745
<div class="form-group col-md-6" ng-class="{'has-error': editAccountForm.amount.$touched && editAccountForm.amount.$invalid}">
4846
<label for="account-amount">Amount</label>
49-
<input id="account-amount" type="number" class="form-control" ng-model="account.amount" name="amount" min="1" required="required">
47+
<input id="account-amount" type="number" class="form-control" ng-model="account.budgetAmount" name="amount" min="1">
5048
</div>
5149
</div>
5250
<div class="row">
5351
<div class="form-group col-md-6" ng-class="{'has-error': editAccountForm.poNumber.$touched && editAccountForm.poNumber.$invalid}">
5452
<label for="account-po">PO Number</label>
55-
<input id="account-po" type="number" class="form-control" ng-model="account.poNumber" name="poNumber" min="1" required="required">
53+
<input id="account-po" type="text" class="form-control" ng-model="account.poNumber" name="poNumber" required="required">
5654
</div>
5755
<div class="form-group col-md-6" ng-class="{'has-error': editAccountForm.subscriptionNumber.$touched && editAccountForm.subscriptionNumber.$invalid}">
5856
<label for="account-subscription-number">Subscription Number</label>
59-
<input id="account-subscription-number" type="number" class="form-control" ng-model="account.subscriptionNumber" name="subscriptionNumber" min="1" required="required">
57+
<input id="account-subscription-number" type="text" class="form-control" ng-model="account.subscriptionNumber" name="subscriptionNumber" min="1">
6058
</div>
6159
</div>
6260
<div class="row">
@@ -66,7 +64,7 @@
6664
</div>
6765
<div class="form-group col-md-6" ng-class="{'has-error': editAccountForm.paymentTerms.$touched && editAccountForm.paymentTerms.$invalid}">
6866
<label for="account-terms">Payment Terms</label>
69-
<input id="account-terms" type="textarea" class="form-control" ng-model="account.paymentTerms" name="paymentTerms" required="required">
67+
<input id="account-terms" type="textarea" class="form-control" ng-model="account.paymentTerms" name="paymentTerms">
7068
</div>
7169
</div>
7270
<div class="row">

src/app/billing_accounts/billingaccounts.list.controller.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ module.controller('billingaccount.BillingAccountsListController', ['$scope', '$r
4545
$scope.$broadcast('billingaccounts.TableDataUpdated');
4646
}).catch(function (error) {
4747
$scope.formSearch.setLoading(false);
48-
$alert.error(error.error.message, $rootScope);
48+
$alert.error(error.error, $rootScope);
4949
});
5050
};
5151

src/app/billing_accounts/billingaccounts.list.html

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,8 @@
2727
<label for="status">Status</label>
2828
<select id="status" class="form-control" ng-model="formSearch.criteria.status">
2929
<option value="" selected="selected"></option>
30-
<option value="active">Active</option>
31-
<option value="inactive">In Active</option>
32-
<option value="pending">Pending</option>
33-
<option value="disabled">Disabled</option>
30+
<option value="1">Active</option>
31+
<option value="0">In Active</option>
3432
</select>
3533
</div>
3634
</div>

src/app/billing_accounts/billingaccounts.new.controller.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module.controller('billingaccount.NewBillingAccountController', ['$scope', '$roo
77
function ($scope, $rootScope, $log, BillingAccountService, $alert, $state) {
88
$scope.processing = false;
99

10-
$scope.newAccount = { status: 'active' };
10+
$scope.newAccount = { status: 'Active' };
1111

1212
// date picker options
1313
$scope.endDateOptions = {
@@ -25,7 +25,7 @@ module.controller('billingaccount.NewBillingAccountController', ['$scope', '$roo
2525
$scope.processing = false;
2626
$state.go('index.billingaccounts.list');
2727
}).catch(function (error) {
28-
$alert.error(error.error.message, $rootScope);
28+
$alert.error(error.error, $rootScope);
2929
$scope.processing = false;
3030
});
3131
};

src/app/billing_accounts/billingaccounts.new.html

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</div>
1212
<div class="form-group col-md-6" ng-class="{'has-error': addAccountForm.customerNumber.$touched && addAccountForm.customerNumber.$invalid}">
1313
<label for="account-customer-number">Customer Number</label>
14-
<input id="account-customer-number" type="text" class="form-control" ng-model="newAccount.customerNumber" name="customerNumber" required="required">
14+
<input id="account-customer-number" type="text" class="form-control" ng-model="newAccount.companyId" name="customerNumber">
1515
</div>
1616
</div>
1717
<div class="row">
@@ -38,25 +38,23 @@
3838
<div class="form-group col-md-6" ng-class="{'has-error': addAccountForm.status.$touched && addAccountForm.status.$invalid}">
3939
<label for="account-status">Status</label>
4040
<select id="account-status" class="form-control" ng-model="newAccount.status">
41-
<option value="inactive">In Active</option>
42-
<option value="active">Active</option>
43-
<option value="pending">Pending</option>
44-
<option value="disabled">Disabled</option>
41+
<option value="Active">Active</option>
42+
<option value="Inactive">In Active</option>
4543
</select>
4644
</div>
4745
<div class="form-group col-md-6" ng-class="{'has-error': addAccountForm.amount.$touched && addAccountForm.amount.$invalid}">
4846
<label for="account-amount">Amount</label>
49-
<input id="account-amount" type="number" class="form-control" ng-model="newAccount.amount" name="amount" min="1" required="required">
47+
<input id="account-amount" type="number" class="form-control" ng-model="newAccount.budgetAmount" name="amount" min="1">
5048
</div>
5149
</div>
5250
<div class="row">
5351
<div class="form-group col-md-6" ng-class="{'has-error': addAccountForm.poNumber.$touched && addAccountForm.poNumber.$invalid}">
5452
<label for="account-po">PO Number</label>
55-
<input id="account-po" type="number" class="form-control" ng-model="newAccount.poNumber" name="poNumber" min="1" required="required">
53+
<input id="account-po" type="text" class="form-control" ng-model="newAccount.poNumber" name="poNumber" min="1" required="required">
5654
</div>
5755
<div class="form-group col-md-6" ng-class="{'has-error': addAccountForm.subscriptionNumber.$touched && addAccountForm.subscriptionNumber.$invalid}">
5856
<label for="account-subscription-number">Subscription Number</label>
59-
<input id="account-subscription-number" type="number" class="form-control" ng-model="newAccount.subscriptionNumber" name="subscriptionNumber" min="1" required="required">
57+
<input id="account-subscription-number" type="text" class="form-control" ng-model="newAccount.subscriptionNumber" name="subscriptionNumber" min="1">
6058
</div>
6159
</div>
6260
<div class="row">
@@ -66,7 +64,7 @@
6664
</div>
6765
<div class="form-group col-md-6" ng-class="{'has-error': addAccountForm.paymentTerms.$touched && addAccountForm.paymentTerms.$invalid}">
6866
<label for="account-terms">Payment Terms</label>
69-
<input id="account-terms" type="textarea" class="form-control" ng-model="newAccount.paymentTerms" name="paymentTerms" required="required">
67+
<input id="account-terms" type="textarea" class="form-control" ng-model="newAccount.paymentTerms" name="paymentTerms">
7068
</div>
7169
</div>
7270
<div class="row ">

src/app/billing_accounts/billingaccounts.service.js

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ angular.module('supportAdminApp')
55
function ($log, $q, $http, API_URL, API_VERSION_PATH) {
66
var BillingAccountService = { };
77

8+
function serialize(obj) {
9+
var result = [];
10+
for (var property in obj) {
11+
result.push(encodeURIComponent(property) + "=" + obj[property]);
12+
}
13+
return result.join("&");
14+
}
15+
816
/**
917
* Handle API response error
1018
* @param {Error} error the error as received in catch callback
@@ -18,11 +26,16 @@ angular.module('supportAdminApp')
1826
status: error.status,
1927
error : error.data.result.content
2028
};
29+
} else if (error && error.data) {
30+
err = {
31+
status: error.status,
32+
error : error.data.message
33+
};
2134
}
2235
if(!err) {
2336
err = {
2437
status: error.status,
25-
error : error.statusText
38+
error : error.message
2639
};
2740
}
2841
deferred.reject(err);
@@ -36,16 +49,25 @@ angular.module('supportAdminApp')
3649
* Search billing accounts
3750
*/
3851
BillingAccountService.search = function(criteria) {
52+
if (criteria.startDate && criteria.startDate.length) {
53+
criteria.startDate = criteria.startDate.substring(0,16) + 'Z';
54+
}
55+
if (criteria.endDate && criteria.endDate.length) {
56+
criteria.endDate = criteria.endDate.substring(0,16) + 'Z';
57+
}
3958
var deferred = $q.defer();
4059
var params = { };
4160
Object.keys(criteria).forEach(function (key) {
42-
if (criteria[key] && criteria[key] !== '') {
61+
if (criteria[key] && criteria[key] !== '' && key !== 'limit') {
4362
params[key] = criteria[key];
4463
}
4564
});
4665
$http({
4766
url: BillingAccountService.getBasePath() + '/billing-accounts',
48-
params: params
67+
params: {
68+
limit: criteria.limit,
69+
filter: serialize(params)
70+
}
4971
}).then(function (response) {
5072
deferred.resolve(response.data.result.content);
5173
}).catch(function (error) {
@@ -55,12 +77,19 @@ angular.module('supportAdminApp')
5577
}
5678

5779
BillingAccountService.createBillingAccount = function (entity) {
80+
var request = angular.copy(entity);
81+
request.startDate = request.startDate.substring(0,16) + 'Z';
82+
request.endDate = request.endDate.substring(0,16) + 'Z';
83+
if (request.paymentTerms) {
84+
request.paymentTerms = {
85+
id: parseInt(request.paymentTerms)
86+
};
87+
}
88+
delete request.customerNumber;
5889
var deferred = $q.defer();
5990
$http({
6091
method: 'POST',
61-
data: {
62-
param: entity
63-
},
92+
data: request,
6493
headers: {
6594
'Content-Type': 'application/json'
6695
},
@@ -74,12 +103,13 @@ angular.module('supportAdminApp')
74103
}
75104

76105
BillingAccountService.editBillingAccount = function (id, entity) {
106+
entity.paymentTerms = {
107+
id: 1
108+
};
77109
var deferred = $q.defer();
78110
$http({
79111
method: 'PATCH',
80-
data: {
81-
param: entity
82-
},
112+
data: entity,
83113
headers: {
84114
'Content-Type': 'application/json'
85115
},

0 commit comments

Comments
 (0)