Skip to content

Commit 8d9b555

Browse files
committed
add simple FiineAPI account check
1 parent dc16ec2 commit 8d9b555

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

coldfront/core/allocation/views.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,22 @@ def post(self, request, *args, **kwargs):
288288
allocation_obj.is_changeable = form_data.get('is_changeable')
289289
allocation_obj.status = form_data.get('status')
290290

291+
# check if corresponding Account for expense code exists
292+
if 'ifxbilling' in settings.INSTALLED_APPS:
293+
# pull up the person corresponding to the PI
294+
person = FiineAPI.readPerson(ifxid=allocation_obj.project.pi.ifxid)
295+
if allocation_obj not in [a.account.code for a in person.facility_accounts]:
296+
account = FiineAPI.listAccounts(code=allocation_obj.expense_code)[0]
297+
if not matched_fiineaccts:
298+
account = FiineAPI.createAccount(**account_data)
299+
300+
facility_account_dict = {
301+
'facility': 'Research Computing Storage',
302+
'account': { 'id': account.id },
303+
}
304+
person.facility_accounts.append(facility_account_dict)
305+
FiineAPI.updatePerson(ifxid=allocation_obj.project.pi.ifxid, **person.to_dict())
306+
291307
if 'approve' in action:
292308
err = None
293309
# ensure that Tier gets swapped out for storage volume

0 commit comments

Comments
 (0)