Skip to content

Commit

Permalink
add account string calculated cols
Browse files Browse the repository at this point in the history
  • Loading branch information
katrina-cityofdetroit committed Jul 26, 2024
1 parent f415220 commit 7087d71
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
9 changes: 8 additions & 1 deletion src/js/views/05_overtime/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import NavButtons from '../../components/nav_buttons/nav_buttons.js';
import Subtitle from '../../components/header/header.js';
import Sidebar from '../../components/sidebar/sidebar.js';
import Table from '../../components/table/table.js';
import { Services } from '../../utils/data_utils/budget_data_handlers.js';
import { AccountString, Services } from '../../utils/data_utils/budget_data_handlers.js';
import Modal from '../../components/modal/modal.js';
import Form from '../../components/form/form.js';
import { unformatCurrency } from '../../utils/common_utils.js';
Expand Down Expand Up @@ -59,6 +59,9 @@ function assignClasses() {
{ title: 'Edit', className: 'edit'},
// calc columns
{ title: 'FICA Rate', className: 'fica', hide: true},
{ title: 'Account String', className: 'account-string', hide: true},
{ title: `Cost Center`, className: 'cc', hide: true },
{ title: 'Appropriation', className: 'approp', hide: true},
];

// assign cost classes
Expand Down Expand Up @@ -134,6 +137,10 @@ function handleSubmitNewRow(event){
// edit inputs from modal
responses['OT-wages'] = unformatCurrency(responses['OT-wages']);
responses['fica'] = 0.0765;
// create account string
responses['account-string'] = AccountString.build(responses['approp-name'], responses['cc-name']);
responses['approp'] = AccountString.getNumber(responses['approp-name']);
responses['cc'] = AccountString.getNumber(responses['cc-name']);

// make sure it's not an empty response
if (Object.values(responses)[0] != ''){
Expand Down
20 changes: 16 additions & 4 deletions src/js/views/06_nonpersonnel/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import Subtitle from "../../components/header/header.js";
import Tooltip from "../../components/tooltip/tooltip.js";
import Modal from "../../components/modal/modal.js";
import Form from "../../components/form/form.js";
import { ObjectCategories, Services } from "../../utils/data_utils/budget_data_handlers.js";
import { ObjectCategories, Services, AccountString } from "../../utils/data_utils/budget_data_handlers.js";
import { FundLookupTable } from "../../utils/data_utils/budget_data_handlers.js";
import { unformatCurrency } from "../../utils/common_utils.js";

const nonPersonnelColumns = [
{ title: 'FY26 Request', className: 'request', isCost: true },
Expand All @@ -22,9 +23,12 @@ const nonPersonnelColumns = [
// hidden columns used for calcs and info boxes
{ title: 'Appropriation Name', className: 'approp-name', hide: true },
{ title: 'Cost Center Name', className: 'cc-name', hide: true },
{ title : 'Contract End Date', className : 'contract-end', hide:true},
{ title: 'Appropriation', className: 'approp', hide: true },
{ title: 'Cost Center', className: 'cc', hide: true },
{ title: 'Contract End Date', className: 'contract-end', hide:true},
{ title: 'Amount Remaining on Contract', className: 'remaining', isCost: true , hide: true},
{ title: 'Object Name', className: 'object-name', hide: true},
{ title: 'Object', className: 'object', hide: true},
{ title: 'Vendor Name', className: 'vendor', hide: true},
{ title: 'Object Category', className: 'object-category', hide: true},
{ title: 'BPA/CPA Description', className: 'cpa-description', hide: true}
Expand Down Expand Up @@ -87,7 +91,8 @@ export function setUpForm() {
Form.NewField.dropdown('Appropriation:', 'approp-name', FundLookupTable.getApprops(), true);
Form.NewField.dropdown('Cost Center:', 'cc-name', FundLookupTable.getCostCenters(), true);
Form.NewField.dropdown('Object Category:', 'object-category', ObjectCategories.list, true);
Form.NewField.shortText('Object Number (if known):', 'object-number', true);
// TODO: maybe give dropdown based on selected obj category
Form.NewField.shortText('Object Number (if known):', 'object', false);
Form.NewField.dropdown('Service', 'service', Services.list(), true);
Form.NewField.longText('Describe your new request:', 'description', true);
Form.NewField.dropdown('Recurring or One-Time', 'recurring', ['Recurring', 'One-Time'], true);
Expand All @@ -104,14 +109,21 @@ function submitNewRow(event){
// edit inputs from modal
responses['avg-salary'] = unformatCurrency(responses['avg-salary']);
responses['fringe'] = parseFloat(responses['fringe']) / 100;
// create account string
responses['account-string'] = AccountString.build(responses['approp-name'], responses['cc-name'], responses['object']);
responses['approp'] = AccountString.getNumber(responses['approp-name']);
responses['cc'] = AccountString.getNumber(responses['cc-name']);
// TODO: build out lookup table from meta.obj tab from detail sheet?
responses['object-name'] = responses['object'];

// make sure it's not an empty response
if (Object.values(responses)[0] != ''){
// change page view
Modal.hide();
// add data to table
Table.Rows.add(responses);
Table.save();
initializePersonnelTable();
initializeNonpersonnelTable();

}

Expand Down

0 comments on commit 7087d71

Please sign in to comment.