From a224ec79b7fd4ba71a241d964a744c92a790b4f3 Mon Sep 17 00:00:00 2001 From: tomlebl Date: Mon, 29 Jul 2024 11:34:46 +0100 Subject: [PATCH] accounting minor improvements --- .../AccountsComponents/AccountsForm.jsx | 53 +++++++++++-------- .../AccountsComponents/infoModalCosting.jsx | 52 ++++++++++++++++++ 2 files changed, 84 insertions(+), 21 deletions(-) create mode 100644 nomad-front-end/src/components/AccountsComponents/infoModalCosting.jsx diff --git a/nomad-front-end/src/components/AccountsComponents/AccountsForm.jsx b/nomad-front-end/src/components/AccountsComponents/AccountsForm.jsx index da916ac..9a4fb43 100644 --- a/nomad-front-end/src/components/AccountsComponents/AccountsForm.jsx +++ b/nomad-front-end/src/components/AccountsComponents/AccountsForm.jsx @@ -1,6 +1,7 @@ import React, { useEffect } from 'react' import { Form, DatePicker, Button, Select, Tooltip, Radio, Modal, Space } from 'antd' import { CloseOutlined, QuestionOutlined } from '@ant-design/icons' +import infoModalConfig from './infoModalCosting' const { Option } = Select const { RangePicker } = DatePicker @@ -17,7 +18,12 @@ const AccountsForm = props => { )) - grpOptions = [ , ...grpOptions ] + grpOptions = [ + , + ...grpOptions + ] const radioOptions = ['Grants', 'Groups', 'Users'] @@ -31,29 +37,30 @@ const AccountsForm = props => { }) } - if (dateRange) { - values.dateRange = dateRange.map(date => date.format('YYYY-MM-DD')) - } + if (!dateRange) { + return Modal.confirm({ + title: 'Date range not defined', + content: ( +
+

If date range is not defined, the calculation can take very long time

+

Do you want to proceed?

+
+ ), + onOk() { + if (dateRange) { + values.dateRange = dateRange.map(date => date.format('YYYY-MM-DD')) + } - if (type !== 'Grants') { - props.getCosts(token, values) - } else { - props.getGrantsCosts(token, { dateRange: values.dateRange }) + if (type !== 'Grants') { + props.getCosts(token, values) + } else { + props.getGrantsCosts(token, { dateRange: values.dateRange }) + } + } + }) } } - const infoModalConfig = { - title: 'Accounting Calculations', - width: 800, - content: ( -
- Grants - Groups - Users -
- ) - } - return (
submitHandler(values)}> @@ -72,7 +79,11 @@ const AccountsForm = props => { /> - {grpOptions} diff --git a/nomad-front-end/src/components/AccountsComponents/infoModalCosting.jsx b/nomad-front-end/src/components/AccountsComponents/infoModalCosting.jsx new file mode 100644 index 0000000..ab109cd --- /dev/null +++ b/nomad-front-end/src/components/AccountsComponents/infoModalCosting.jsx @@ -0,0 +1,52 @@ +import React from 'react' +import { Alert } from 'antd' + +const infoModalConfig = { + title: 'Accounting Calculations', + width: 800, + content: ( +
+ You can switch between three types of accounting calculations +
+ Grants +
+

+ This calculation will work only if grants have been preset. In "Set Grants" table you can + assign either individual users or whole group to a grant. If you assign individual user and + his own group to two different grants, the experiments that were originated by the user will + be charged to the grant corresponding to the user and not to the one corresponding to the + whole group. +

+ +
+ Groups +
+

+ Groups calculation provides total sums of total experimental times (including overhead + times) and corresponding costs for groups. Costs are calculated using instrument costings + that are set in the costing table in the time of calculation. + +

+ Users +

+ Users calculation is similar to the previous one. A group can be selected from drop down + menu and total experimental times and costs are listed for individual users who were in the + group in the time of archiving of the experiments. If "--all--" option is selected the + calculation will be performed for all users who archived an experiment in the given period + of time. +

+ +
+ ) +} + +export default infoModalConfig