Skip to content

Commit

Permalink
Billing PDF modifications and bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Harin329 committed Jul 26, 2023
1 parent a090ccc commit 7dc1606
Show file tree
Hide file tree
Showing 13 changed files with 48 additions and 19 deletions.
1 change: 1 addition & 0 deletions backend/src/controllers/costCentreController.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export default class CostCentreController {
const costCenterData = {
cost_center_id: req.body.cost_center_id,
cost_center_name: req.body.cost_center_name,
cost_center_client_name: req.body.cost_center_client_name,
cost_center_investigator: req.body.cost_center_investigator,
cost_center_contact: req.body.cost_center_contact,
cost_center_email: req.body.cost_center_email,
Expand Down
3 changes: 2 additions & 1 deletion backend/src/models/costCentre.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,11 @@ export class CostCentre {

insertCostCentre(newCostCentre, result) {
con.query(
"CALL save_cost_center(?, ?, ?, ?, ?, ?, ?)",
"CALL save_cost_center(?, ?, ?, ?, ?, ?, ?, ?)",
[
newCostCentre.cost_center_id,
newCostCentre.cost_center_name,
newCostCentre.cost_center_client_name,
newCostCentre.cost_center_investigator,
newCostCentre.cost_center_contact,
newCostCentre.cost_center_email,
Expand Down
1 change: 1 addition & 0 deletions database/init/cost_centers.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ BEGIN
CREATE TABLE `cost_centers` (
cost_center_id VARCHAR(50) NOT NULL,
cost_center_name VARCHAR(50),
cost_center_client_name VARCHAR(255),
cost_center_investigator VARCHAR(255),
cost_center_contact VARCHAR(255),
cost_center_email VARCHAR(255),
Expand Down
6 changes: 4 additions & 2 deletions database/procedures/billableProc.sql
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,12 @@ END $$
CREATE PROCEDURE `load_billable` ()

BEGIN
SELECT billable.*, u.username, o.organization_name, t.task_id, st.fk_task_id, st.subtask_id, t.task_state, st.subtask_state FROM billable
SELECT billable.*, u.username, o.organization_name, p.project_name, t.task_id, st.fk_task_id, st.subtask_id, t.task_state, st.subtask_state FROM billable
LEFT JOIN tasks t on t.task_uuid = billable.task_uuid
LEFT JOIN subtasks st on st.subtask_uuid = billable.task_uuid
LEFT JOIN users u on u.user_id = billable.created_by
LEFT JOIN organizations o on o.organization_id = u.fk_organization_id
LEFT JOIN projects p on p.project_id = billable.fk_project_id
WHERE billable.billed = 0
AND (t.task_state != "archived" OR t.task_state IS NULL)
AND (st.subtask_state != "archived" OR st.subtask_state IS NULL);
Expand All @@ -100,13 +101,14 @@ CREATE PROCEDURE `load_billable_with_filter` (
)

BEGIN
SELECT billable.*, u.username, o.organization_name, t.task_id, st.fk_task_id, st.subtask_id, t.task_state, st.subtask_state FROM billable
SELECT billable.*, u.username, o.organization_name, p.project_name, t.task_id, st.fk_task_id, st.subtask_id, t.task_state, st.subtask_state FROM billable
LEFT JOIN tasks t on t.task_uuid = billable.task_uuid
LEFT JOIN subtasks st on st.subtask_uuid = billable.task_uuid
LEFT JOIN costcenter_assignments ca on ca.fk_project_id = billable.fk_project_id
LEFT JOIN project_assignments pa on pa.fk_project_id = billable.fk_project_id
LEFT JOIN users u on u.user_id = billable.created_by
LEFT JOIN organizations o on o.organization_id = u.fk_organization_id
LEFT JOIN projects p on p.project_id = billable.fk_project_id
WHERE (name = _service_name OR _service_name IS NULL OR _service_name = '')
AND (ca.fk_cost_center_id = _costcenter_id OR _costcenter_id IS NULL OR _costcenter_id = '')
AND (billable.fk_project_id = _project_id OR _project_id IS NULL OR _project_id = '')
Expand Down
4 changes: 4 additions & 0 deletions database/procedures/costCenterProc.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ DELIMITER $$
CREATE PROCEDURE `save_cost_center` (
IN `_cost_center_id` VARCHAR(50),
IN `_cost_center_name` VARCHAR(50),
IN `_cost_center_client_name` VARCHAR(255),
IN `_cost_center_investigator` VARCHAR(255),
IN `_cost_center_contact` VARCHAR(255),
IN `_cost_center_email` VARCHAR(255),
Expand All @@ -18,6 +19,7 @@ CREATE PROCEDURE `save_cost_center` (
INSERT INTO `cost_centers` (
`cost_center_id`,
`cost_center_name`,
`cost_center_client_name`,
`cost_center_investigator`,
`cost_center_contact`,
`cost_center_email`,
Expand All @@ -28,6 +30,7 @@ VALUES
(
`_cost_center_id`,
`_cost_center_name`,
`_cost_center_client_name`,
`_cost_center_investigator`,
`_cost_center_contact`,
`_cost_center_email`,
Expand All @@ -36,6 +39,7 @@ VALUES
) ON DUPLICATE KEY UPDATE
cost_centers.cost_center_id=_cost_center_id,
cost_centers.cost_center_name=_cost_center_name,
cost_centers.cost_center_client_name=_cost_center_client_name,
cost_centers.cost_center_investigator=_cost_center_investigator,
cost_centers.cost_center_contact=_cost_center_contact,
cost_centers.cost_center_email=_cost_center_email,
Expand Down
10 changes: 9 additions & 1 deletion frontend/src/components/CostCenterTable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@ const CostCenterTable = () => {
dataIndex: "cost_center_name",
key: "cost_center_name",
editable: true,
width: "20%",
width: "15%",
},
{
title: "Client Name",
dataIndex: "cost_center_client_name",
key: "cost_center_client_name",
editable: true,
width: "10%",
},
{
title: "Principal Investigator",
Expand Down Expand Up @@ -114,6 +121,7 @@ const CostCenterTable = () => {
const newData = {
cost_center_id: uuid(),
cost_center_name: "New Cost Center",
cost_center_client_name: "New Client",
cost_center_investigator: "New Investigator",
cost_center_contact: "New Contact",
cost_center_email: "New Email",
Expand Down
15 changes: 7 additions & 8 deletions frontend/src/components/GenerateInvoice/InvoiceTemplate/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,11 @@ const InvoiceTemplate = ({ customer, costcenterMap, invoicNum }) => {
<div className="header-table-section header-item">
<p className="header-table-title">Billed to: </p>
<p className="header-table-content">
Client Name: {customer.cost_center_name}
<br />
Client Address: {customer.cost_center_address}<br />
Contact: {customer.cost_center_contact}<br />
Department: {customer.cost_center_type}<br />
Worktag/Email: {customer.cost_center_email}<br />
Client Name: {customer.cost_center_client_name}<br />
Address/Department: {customer.cost_center_address}<br />
Billing Contact: {customer.cost_center_contact}<br />
Email: {customer.cost_center_email}<br />
Cost Center/Worktag: {customer.cost_center_name}<br />
</p>
</div>
<div className="header-table-section">
Expand All @@ -74,6 +73,7 @@ const InvoiceTemplate = ({ customer, costcenterMap, invoicNum }) => {
<p className="header-table-title">Project Details: </p>
<p className="header-table-content">
Project ID: {customer.fk_project_id}<br />
Project Name: {customer.project_name}<br />
Principal Investigator: {customer.cost_center_investigator}<br />
</p>
</div>
Expand All @@ -87,7 +87,7 @@ const InvoiceTemplate = ({ customer, costcenterMap, invoicNum }) => {
return costcenterMap[billable.fk_project_id] === customer.cost_center_id
})} />

<label htmlFor="notes">All MAPcore invoices should be deposited to EABJ / PM009455</label>
<label htmlFor="notes"><br/><br/>All MAPcore invoices should be deposited to EABJ / PM009455</label>

<div>
<div className="signer-form">
Expand Down Expand Up @@ -155,7 +155,6 @@ function InvoiceDetails({ billingData }) {
</tr>

{billingData.map((invoiceItem, index) => {
console.log(invoiceItem);
return (
<tr className="item" key={invoiceItem.billable_id}>
<td>
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/InvoiceTable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ const InvoiceTable = () => {
},
{
title: "Project",
dataIndex: "fk_project_id",
key: "fk_project_id",
dataIndex: "project_name",
key: "project_name",
editable: false,
},
{
Expand Down
1 change: 1 addition & 0 deletions frontend/src/redux/api/costcenterApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export const postCostCenterApi = async (payload) => {
var data = JSON.stringify({
cost_center_id: payload.cost_center_id,
cost_center_name: payload.cost_center_name,
cost_center_client_name: payload.cost_center_client_name,
cost_center_investigator: payload.cost_center_investigator,
cost_center_contact: payload.cost_center_contact,
cost_center_email: payload.cost_center_email,
Expand Down
10 changes: 9 additions & 1 deletion frontend/src/redux/saga/costCenterSaga.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,15 @@ import { loadProjectSaga } from "./projectSaga";

export function* loadCostCenterSaga() {
const costCenterList = yield call(getCostcenterApi);
yield put({ type: SET_COSTCENTER, payload: costCenterList.data });
const ccd = costCenterList.data;
const costCenterData = ccd.map((costCenter) => {
return {
...costCenter,
cost_center_investigator: costCenter.cost_center_investigator ?? "New Investigator",
cost_center_client_name: costCenter.cost_center_client_name ?? "New Client",
}
})
yield put({ type: SET_COSTCENTER, payload: costCenterData });
}

export function* updateProjectAssignment({ payload }) {
Expand Down
6 changes: 5 additions & 1 deletion frontend/src/screens/invoice/invoice-preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ function InvoicePreview() {
const billableProject = invoice.fk_project_id;
const billableProjectFilter = projectList.find((project) => project.project_id === billableProject);
const billableCostCenterList = billableProjectFilter.costcenter;
const costcenter = billableCostCenterList[0] ?? "No Cost Center";
const cc = billableCostCenterList[0] ?? "No Cost Center";
const costcenter = {
...cc,
project_name: invoice.project_name,
}
if (customers.filter((customer) => customer.cost_center_id === costcenter.cost_center_id).length === 0) {
customers.push(costcenter);
}
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/screens/login-form/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function LoginForm({ from }) {
dispatch({
type: AUTHENTICATE_USER,
payload: {
email: email,
email: email.toLowerCase(),
password: password,
},
});
Expand All @@ -44,7 +44,7 @@ function LoginForm({ from }) {
dispatch({
type: REQUEST_RESET,
payload: {
email: email,
email: email.toLowerCase(),
},
});
};
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/screens/signup-form/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function SignUpForm() {
user_id: uuid(),
fk_organization_id: null,
username: firstName + " " + lastName,
email: email,
email: email.toLowerCase(),
employee: false,
password: password,
navTo: () => navigate("/"),
Expand Down

0 comments on commit 7dc1606

Please sign in to comment.