From 978d8af20b4760c6e296595d8c584a26a2615f43 Mon Sep 17 00:00:00 2001 From: farhantock Date: Sun, 19 May 2024 01:51:10 +0700 Subject: [PATCH] feat(project): add new field income yearly and value contract --- .../CreatedProyek/DialogFormProyek.js | 143 +++++++++------ src/views/SimproV2/CreatedProyek/index.js | 166 ++++++++++-------- 2 files changed, 179 insertions(+), 130 deletions(-) diff --git a/src/views/SimproV2/CreatedProyek/DialogFormProyek.js b/src/views/SimproV2/CreatedProyek/DialogFormProyek.js index 42d265a..08772fb 100644 --- a/src/views/SimproV2/CreatedProyek/DialogFormProyek.js +++ b/src/views/SimproV2/CreatedProyek/DialogFormProyek.js @@ -6,7 +6,7 @@ import axios from "../../../const/interceptorApi"; import moment from "moment"; import { CKEditor } from '@ckeditor/ckeditor5-react'; import ClassicEditor from '@ckeditor/ckeditor5-build-classic'; -import {NotificationManager} from "react-notifications"; +import { NotificationManager } from "react-notifications"; import "antd/dist/antd.css"; import { formatNumber } from "../../../const/CustomFunc"; import { @@ -33,9 +33,9 @@ const DialogFormProyek = ({ dataPM, projectImage, company_id, - role_name, - token, - companyList + role_name, + token, + companyList }) => { const HEADER = { headers: { @@ -50,6 +50,8 @@ const DialogFormProyek = ({ const [late, setLateConsequence] = useState(""); const [assumtion, setAssumtion] = useState(""); const [biaya, setBiaya] = useState(""); + const [valueProyek, setValueProyek] = useState(""); + const [incomeYearly, setIncomeYearly] = useState(""); const [typeProject, setTypeproject] = useState(null); const [phaseProject, setPhaseProject] = useState(null); const [divisiProject, setDivisiProject] = useState(null); @@ -67,10 +69,9 @@ const DialogFormProyek = ({ const [scompany_id, setCompanyId] = useState(null); const [step, setStep] = useState(1); const [currencyList, setCurrencyList] = useState(null); - const [currency, setCurrency] = useState(""); // merge of code | symbol | name - const [currencyCode, setCurrencyCode] = useState(""); - const [currencySymbol, setCurrencySymbol] = useState("IDR|Rp|Indonesian rupiah"); - const [currencyName, setCurrencyName] = useState(""); + const [currencyCode, setCurrencyCode] = useState("IDR"); + const [currencySymbol, setCurrencySymbol] = useState("Rp"); + const [currencyName, setCurrencyName] = useState("Indonesian rupiah"); const [objectives, setObjectives] = useState(""); const [projectIsConsideredSuccessful, setProjectIsConsideredSuccessful] = useState(""); const [participants, setParticipants] = useState([]); @@ -104,6 +105,8 @@ const DialogFormProyek = ({ setLateConsequence(val.late_consequence ? val.late_consequence : ""); setAssumtion(val.assumtion ? val.assumtion : ""); setBiaya(val.rencana_biaya ? formatNumber(val.rencana_biaya) : ""); + setValueProyek(val.value_proyek ? formatNumber(val.value_proyek) : ""); + setIncomeYearly(val.income_year ? formatNumber(val.income_year) : ""); setTypeproject(val.type_proyek_id); setPhaseProject(val.phase_id); setDivisiProject(val.divisi_id); @@ -115,7 +118,7 @@ const DialogFormProyek = ({ setProjectDuration(val.durasi_proyek); setInvestor(val.investor); setCompany(val.company); - setCompanyId(val.company_id) + setCompanyId(val.company_id) setFinance(val.finance); setObjectives(val.project_objectives ? val.project_objectives : ""); setTestingEnv(val.testing_environment); @@ -207,11 +210,10 @@ const DialogFormProyek = ({ setDivisiProject(null); setProjectStructureOrg(null); setCompany(""); - setCompanyId(null) - setCurrency(""); - setCurrencyCode(""); - setCurrencySymbol("IDR|Rp|Indonesian rupiah"); - setCurrencyName(""); + setCompanyId(null) + setCurrencyCode("IDR"); + setCurrencySymbol("Rp"); + setCurrencyName("Indonesian rupiah"); setObjectives(""); setImage(""); setProjectIsConsideredSuccessful(""); @@ -278,7 +280,9 @@ const DialogFormProyek = ({ currency_symbol: currencySymbol, currency_code: currencyCode, currency_name: currencyName, - company_id: role_name !== "Super Admin" ? parseInt(company_id) : parseInt(scompany_id) + company_id: role_name !== "Super Admin" ? parseInt(company_id) : parseInt(scompany_id), + value_proyek: valueProyek, + income_year: incomeYearly }; data.projectCharter = { checklist, issue, potentialRisks, participants, milestones, approval }; data.imageStructureOrg = organization ? organization : null; @@ -309,7 +313,9 @@ const DialogFormProyek = ({ currency_symbol: currencySymbol, currency_code: currencyCode, currency_name: currencyName, - company_id: role_name !== "Super Admin" ? parseInt(company_id) : parseInt(scompany_id) + company_id: role_name !== "Super Admin" ? parseInt(company_id) : parseInt(scompany_id), + value_proyek: valueProyek, + income_year: incomeYearly }; data.projectCharter = { checklist, issue, potentialRisks, participants, milestones, approval }; data.imageStructureOrg = organization ? organization : null; @@ -328,7 +334,7 @@ const DialogFormProyek = ({ setTypeproject(val); }; - const onChangeCompanyProject = (val) => { + const onChangeCompanyProject = (val) => { setCompanyId(val); }; @@ -381,6 +387,8 @@ const DialogFormProyek = ({ setCurrencyName(curr[2]); }; + console.log(currencyCode, currencySymbol, currencyName); + const handleDatePickerStart = (date, dateString) => { setStartDate(date); }; @@ -410,7 +418,7 @@ const DialogFormProyek = ({ alert("End Date cannot be empty!"); return false; } - if (role_name === 'Super Admin' && !scompany_id || scompany_id === "") { + if (role_name === 'Super Admin' && !scompany_id || scompany_id === "") { alert("Company data cannot be empty!"); return false; } @@ -422,7 +430,7 @@ const DialogFormProyek = ({ alert("Currency Symbol cannot be empty!"); return false; } - if (!divisiProject || divisiProject === "") { + if (!divisiProject || divisiProject === "") { alert("Division cannot be empty!"); return false; } @@ -768,31 +776,31 @@ const DialogFormProyek = ({ - { - role_name === 'Super Admin' && ( - - - - - - - ) - } + { + role_name === 'Super Admin' && ( + + + + + + + ) + } @@ -803,10 +811,10 @@ const DialogFormProyek = ({ /> - + @@ -824,14 +832,41 @@ const DialogFormProyek = ({ setBiaya(formatNumber(e.target.value))} + value={valueProyek} + onChange={(e) => setValueProyek(formatNumber(e.target.value))} /> - + + + + + setIncomeYearly(formatNumber(e.target.value))} + /> + + + + + + + + setBiaya(formatNumber(e.target.value))} + /> + + + - + ); }); - } else if (checklist.length < 1) { + } else if (checklist?.length == 0) { return (
- + {step === 1 ? idTask diff --git a/src/views/SimproV2/CreatedProyek/index.js b/src/views/SimproV2/CreatedProyek/index.js index b98e356..62c4bc5 100644 --- a/src/views/SimproV2/CreatedProyek/index.js +++ b/src/views/SimproV2/CreatedProyek/index.js @@ -70,11 +70,11 @@ import DialogInitDocument from "./DialogInitDocument"; import DialogGantt from "./DialogGantt"; import DialogHierarchy from "./DialogHierarchy"; import { - formatNumber, - formatRupiah, - formatThousand, - renderFormatRupiah, - checkActMenup, + formatNumber, + formatRupiah, + formatThousand, + renderFormatRupiah, + checkActMenup, } from "../../../const/CustomFunc"; // import DialogAsignHr from './AsignHrProject'; import AssignHrProject from "./AsignHrProject"; @@ -91,7 +91,7 @@ const url = ""; const format = "DD-MM-YYYY"; const CreatedProyek = ({ params, ...props }) => { - let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name = '', hierarchy = [], user_name = '', configApp={}; + let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name = '', hierarchy = [], user_name = '', configApp = {}; if (props && props.role_id && props.user_id) { role_id = props.role_id; user_id = props.user_id; @@ -208,10 +208,10 @@ const CreatedProyek = ({ params, ...props }) => { }, [openDialogProyek]); useEffect(() => { - if(role_name === 'Super Admin') { + if (role_name === 'Super Admin') { getDataProyekCompany(); } - },[]) + }, []) useEffect(() => { if (parseInt(role_id) === 44) { @@ -245,7 +245,7 @@ const CreatedProyek = ({ params, ...props }) => { "joins": [], "orders": { "columns": ["id"], "ascending": false } } - if(role_name !== 'Super Admin') { + if (role_name !== 'Super Admin') { payload.columns.push( { "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" } ) @@ -266,7 +266,7 @@ const CreatedProyek = ({ params, ...props }) => { "joins": [], "orders": { "columns": ["id"], "ascending": false } } - if(role_name !== 'Super Admin') { + if (role_name !== 'Super Admin') { payload.columns.push( { "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" } ) @@ -287,7 +287,7 @@ const CreatedProyek = ({ params, ...props }) => { "joins": [], "orders": { "columns": ["id"], "ascending": false } } - if(role_name !== 'Super Admin') { + if (role_name !== 'Super Admin') { payload.columns.push( { "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" } ) @@ -310,7 +310,7 @@ const CreatedProyek = ({ params, ...props }) => { "joins": [], "orders": { "columns": ["id"], "ascending": false } } - if(role_name !== 'Super Admin') { + if (role_name !== 'Super Admin') { payload.columns.push( { "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" } ) @@ -414,9 +414,10 @@ const CreatedProyek = ({ params, ...props }) => { "currency_symbol", "mulai_proyek", "akhir_proyek", + "value_proyek", + "income_year", "company_id", "deleted_at", - "value_proyek", "deleted_by_id" ], joins: [ @@ -440,7 +441,7 @@ const CreatedProyek = ({ params, ...props }) => { { name: "company_id", logic_operator: "like", value: parseInt(company_id), operator: "AND" } ); } - if (role_name !== 'Super Admin' && all_project === 'false' || role_name !== 'Super Admin' && all_project === 'null') { + if (role_name !== 'Super Admin' && all_project === 'false' || role_name !== 'Super Admin' && all_project === 'null') { payload.columns.push( { name: "created_by_id", logic_operator: "IN", value: [JSON.parse(hierarchy)], operator: "AND" } ); @@ -1429,7 +1430,7 @@ const CreatedProyek = ({ params, ...props }) => { { name: "company_id", logic_operator: "like", value: parseInt(company_id), operator: "AND" } ); } - if (role_name !== 'Super Admin' && all_project === 'false' || role_name !== 'Super Admin' && all_project === 'null') { + if (role_name !== 'Super Admin' && all_project === 'false' || role_name !== 'Super Admin' && all_project === 'null') { payload.columns.push( { name: "created_by_id", logic_operator: "IN", value: [JSON.parse(hierarchy)], operator: "AND" } ); @@ -1489,7 +1490,7 @@ const CreatedProyek = ({ params, ...props }) => { const handleExportPdf = async () => { const doc = new jsPDF(); let headers = [ - [role_name === 'Super Admin' ? "Company" : null, "Project Name", "Budget", "Project Type", "PM", "Time Project"], + [role_name === 'Super Admin' ? "Company" : null, "Project Name", "Nilai Kontrak", "Pendapatan Pertahun", "Anggaran Biaya", "Project Type", "PM", "Time Project"], ]; const payload = { @@ -1544,7 +1545,7 @@ const CreatedProyek = ({ params, ...props }) => { { name: "company_id", logic_operator: "like", value: parseInt(company_id), operator: "AND" } ); } - if (role_name !== 'Super Admin' && all_project === 'false' || role_name !== 'Super Admin' && all_project === 'null') { + if (role_name !== 'Super Admin' && all_project === 'false' || role_name !== 'Super Admin' && all_project === 'null') { payload.columns.push( { name: "created_by_id", logic_operator: "IN", value: [JSON.parse(hierarchy)], operator: "AND" } ); @@ -1621,7 +1622,7 @@ const CreatedProyek = ({ params, ...props }) => { - Project Charter + Indentitas Proyek
handleOpenDokumen(text)}> @@ -1697,18 +1698,18 @@ const CreatedProyek = ({ params, ...props }) => { <> {dataVersionGantt.slice(0, 8).map((res) => ( + isLogin, + token, + role_id, + user_id, + role_name, + company_id: text.company_id, + dataViewStartDate, + companyName: (role_name === 'Super Admin' ? text.join_third_company_name : JSON.parse(configApp).company_name) + } + }}>
@@ -1762,6 +1763,7 @@ const CreatedProyek = ({ params, ...props }) => { title: "Action", dataIndex: "", key: "x", + width: 70, render: (text, record) => parseInt(role_id) == 44 ? ( <> @@ -1785,40 +1787,40 @@ const CreatedProyek = ({ params, ...props }) => { trigger="click" > { - checkActMenup(location.pathname, 'read') ? - - : - null - } + checkActMenup(location.pathname, 'read') ? + + : + null + } { - checkActMenup(location.pathname, 'update') ? - - {text.join_second_is_multiLocation == true ? ( - - ) : ( - - )} - - : - null - } + {text.join_second_is_multiLocation == true ? ( + + ) : ( + + )} + + : + null + } ), }, @@ -1831,13 +1833,25 @@ const CreatedProyek = ({ params, ...props }) => { {record.join_third_company_name} ) }] : []), - { title: "Project Name", dataIndex: "nama", key: "nama" }, + { title: "Project Name", dataIndex: "nama", key: "nama", width: 200 }, + { + title: "Pendapatan Pertahun", dataIndex: "income_year", + key: "income_year", + render: (text, record) => { + const incomeYear = text ?? '-'; + return record.currency_symbol + ? `${record.currency_symbol} ${formatThousand(incomeYear)}` + : `${formatThousand(incomeYear)}`; + }, + }, { - title: "Nilai Kontrak", - dataIndex: "value_proyek", + title: "Nilai Kontrak", dataIndex: "value_proyek", key: "value_proyek", render: (text, record) => { - return "Rp " + (record.value_proyek == null ? 0 : record.value_proyek); + const valueProyek = text ?? '-'; + return record.currency_symbol + ? `${record.currency_symbol} ${formatThousand(valueProyek)}` + : `${formatThousand(valueProyek)}`; }, }, { @@ -2200,18 +2214,18 @@ const CreatedProyek = ({ params, ...props }) => { {parseInt(role_id) == 44 ? null : ( // role kustomer - { - checkActMenup(location.pathname, 'create') ? - - : - null - } + { + checkActMenup(location.pathname, 'create') ? + + : + null + } )}