Commit fb267e58 authored by Deni Rinaldi's avatar Deni Rinaldi

Merge branch 'master' of http://103.44.149.204/d.arizona/tia-dev into deni-

parents f629a31f ef68e97c
...@@ -226,7 +226,7 @@ export default class CorporateAnnualTarget extends Component { ...@@ -226,7 +226,7 @@ export default class CorporateAnnualTarget extends Component {
} }
} }
}) })
// // console.log(dataTable) // console.log(dataTable)
this.setState({ dataTable, loading: false, dataReal: res, editable: true, dataCustomerPrs, dataInternalBsn }, () => { this.setState({ dataTable, loading: false, dataReal: res, editable: true, dataCustomerPrs, dataInternalBsn }, () => {
// // console.log(dataCustomerPrs) // // console.log(dataCustomerPrs)
}) })
...@@ -1271,7 +1271,11 @@ export default class CorporateAnnualTarget extends Component { ...@@ -1271,7 +1271,11 @@ export default class CorporateAnnualTarget extends Component {
if (idParent !== null) { if (idParent !== null) {
let indexsss = dataTable2.findIndex((val) => val[1] == idParent) let indexsss = dataTable2.findIndex((val) => val[1] == idParent)
if (dataTable2[indexsss][6] == 'FINANCIAL PERSPECTIVE') { if (dataTable2[indexsss][6] == 'FINANCIAL PERSPECTIVE') {
return true if (tableMeta.rowData[0] == 3) {
return false
} else {
return true
}
} else { } else {
return false return false
} }
...@@ -1744,11 +1748,11 @@ export default class CorporateAnnualTarget extends Component { ...@@ -1744,11 +1748,11 @@ export default class CorporateAnnualTarget extends Component {
control={ control={
<NumberFormat <NumberFormat
thousandSeparator={true} thousandSeparator={true}
style={{ color: "#5198ea", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} style={{ color: "black", fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text" type="text"
placeholder="" placeholder=""
value={Number(value).toFixed(1)} value={Number(value).toFixed(1)}
disabled={this.props.isApprover ? true : ((this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted') ? false : true)} disabled={true}
decimalScale={1} decimalScale={1}
onBlur={(event) => { onBlur={(event) => {
// updateValue(event.target.value) // updateValue(event.target.value)
......
...@@ -1122,6 +1122,7 @@ export default class MonthlyReport extends Component { ...@@ -1122,6 +1122,7 @@ export default class MonthlyReport extends Component {
periode={this.state.periode.periode} periode={this.state.periode.periode}
monthlyReportId={this.state.monthlyReportId} monthlyReportId={this.state.monthlyReportId}
month={this.state.month} month={this.state.month}
saveToMonthlyReport={this.saveToMonthlyReport.bind(this)}
onClickClose={() => this.setState({ visibleFAM: false, visibleMonthlyReport: true })} onClickClose={() => this.setState({ visibleFAM: false, visibleMonthlyReport: true })}
/> />
)} )}
......
...@@ -520,9 +520,11 @@ export default class BalanceSheetMR extends Component { ...@@ -520,9 +520,11 @@ export default class BalanceSheetMR extends Component {
if (String(item).includes('#')) { if (String(item).includes('#')) {
if (String(item).includes('[M-1]')) { if (String(item).includes('[M-1]')) {
let tst = String(item).replace('[M-1]', '') let tst = String(item).replace('[M-1]', '')
let indexID = dataTable2.findIndex((val) => val[21] == tst) // let indexID = dataTable2.findIndex((val) => val[21] == tst)
let data = tableMeta.rowData[20]
let indexID = data.findIndex((val) => val.item_formula == String(`@${item}`))
if (indexID !== -1) { if (indexID !== -1) {
let valuezz = dataTable2[indexID][9] let valuezz = data[indexID].value
anjay.push(valuezz == "" ? 0 : valuezz) anjay.push(valuezz == "" ? 0 : valuezz)
} }
} else { } else {
...@@ -584,9 +586,11 @@ export default class BalanceSheetMR extends Component { ...@@ -584,9 +586,11 @@ export default class BalanceSheetMR extends Component {
let totalPrio = 0 let totalPrio = 0
let optPrio = "" let optPrio = ""
let prio = false let prio = false
let optPrev = ""
anjay2.map((item, index) => { anjay2.map((item, index) => {
if (Array.isArray(item)) { if (Array.isArray(item)) {
prio = true prio = true
optPrev = opt
item.map((items, indexs) => { item.map((items, indexs) => {
if (items == "+") { if (items == "+") {
optPrio = "tambah" optPrio = "tambah"
...@@ -628,7 +632,17 @@ export default class BalanceSheetMR extends Component { ...@@ -628,7 +632,17 @@ export default class BalanceSheetMR extends Component {
if (item == "+") { if (item == "+") {
opt = "tambah" opt = "tambah"
if (prio) { if (prio) {
total = Number(Number(totalPrio) + Number(total)) if (optPrev == "tambah") {
total = Number(total) + Number(totalPrio)
} else if (optPrev == "kurang") {
total = Number(total) - Number(totalPrio)
} else if (optPrev == "kali") {
total = Number(total) * Number(totalPrio)
} else if (optPrev == "bagi") {
total = Number(total) / Number(totalPrio) == NaN ? 0 : Number(total) / Number(totalPrio)
} else {
total += Number(totalPrio)
}
prio = false prio = false
totalPrio = 0 totalPrio = 0
optPrio = "" optPrio = ""
...@@ -636,7 +650,17 @@ export default class BalanceSheetMR extends Component { ...@@ -636,7 +650,17 @@ export default class BalanceSheetMR extends Component {
} else if (item == "-") { } else if (item == "-") {
opt = "kurang" opt = "kurang"
if (prio) { if (prio) {
total = Number(Number(totalPrio) + Number(total)) if (optPrev == "tambah") {
total = Number(total) + Number(totalPrio)
} else if (optPrev == "kurang") {
total = Number(total) - Number(totalPrio)
} else if (optPrev == "kali") {
total = Number(total) * Number(totalPrio)
} else if (optPrev == "bagi") {
total = Number(total) / Number(totalPrio) == NaN ? 0 : Number(total) / Number(totalPrio)
} else {
total += Number(totalPrio)
}
prio = false prio = false
totalPrio = 0 totalPrio = 0
optPrio = "" optPrio = ""
...@@ -644,7 +668,17 @@ export default class BalanceSheetMR extends Component { ...@@ -644,7 +668,17 @@ export default class BalanceSheetMR extends Component {
} else if (item == "*") { } else if (item == "*") {
opt = "kali" opt = "kali"
if (prio) { if (prio) {
total = Number(Number(totalPrio) + Number(total)) if (optPrev == "tambah") {
total = Number(total) + Number(totalPrio)
} else if (optPrev == "kurang") {
total = Number(total) - Number(totalPrio)
} else if (optPrev == "kali") {
total = Number(total) * Number(totalPrio)
} else if (optPrev == "bagi") {
total = Number(total) / Number(totalPrio) == NaN ? 0 : Number(total) / Number(totalPrio)
} else {
total += Number(totalPrio)
}
prio = false prio = false
totalPrio = 0 totalPrio = 0
optPrio = "" optPrio = ""
...@@ -652,7 +686,17 @@ export default class BalanceSheetMR extends Component { ...@@ -652,7 +686,17 @@ export default class BalanceSheetMR extends Component {
} else if (item == "/") { } else if (item == "/") {
opt = "bagi" opt = "bagi"
if (prio) { if (prio) {
total = Number(Number(totalPrio) + Number(total)) if (optPrev == "tambah") {
total = Number(total) + Number(totalPrio)
} else if (optPrev == "kurang") {
total = Number(total) - Number(totalPrio)
} else if (optPrev == "kali") {
total = Number(total) * Number(totalPrio)
} else if (optPrev == "bagi") {
total = Number(total) / Number(totalPrio) == NaN ? 0 : Number(total) / Number(totalPrio)
} else {
total += Number(totalPrio)
}
prio = false prio = false
totalPrio = 0 totalPrio = 0
optPrio = "" optPrio = ""
......
...@@ -90,6 +90,7 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -90,6 +90,7 @@ export default class FixedAssetsMovementMR extends Component {
item.fixed_asset_movement.act_vs_mb_percent === "" ? "0.0" : item.fixed_asset_movement.act_vs_mb_percent, item.fixed_asset_movement.act_vs_mb_percent === "" ? "0.0" : item.fixed_asset_movement.act_vs_mb_percent,
item.fixed_asset_movement.act_vs_rb_amount === "" ? "0.0" : item.fixed_asset_movement.act_vs_rb_amount, item.fixed_asset_movement.act_vs_rb_amount === "" ? "0.0" : item.fixed_asset_movement.act_vs_rb_amount,
item.fixed_asset_movement.act_vs_rb_percent === "" ? "0.0" : item.fixed_asset_movement.act_vs_rb_percent, item.fixed_asset_movement.act_vs_rb_percent === "" ? "0.0" : item.fixed_asset_movement.act_vs_rb_percent,
item.fixed_asset_movement.actual_formula,
item.order item.order
]) ])
} }
...@@ -119,6 +120,7 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -119,6 +120,7 @@ export default class FixedAssetsMovementMR extends Component {
item.fixed_asset_movement.act_vs_mb_percent === "" ? "0.0" : item.fixed_asset_movement.act_vs_mb_percent, item.fixed_asset_movement.act_vs_mb_percent === "" ? "0.0" : item.fixed_asset_movement.act_vs_mb_percent,
item.fixed_asset_movement.act_vs_rb_amount === "" ? "0.0" : item.fixed_asset_movement.act_vs_rb_amount, item.fixed_asset_movement.act_vs_rb_amount === "" ? "0.0" : item.fixed_asset_movement.act_vs_rb_amount,
item.fixed_asset_movement.act_vs_rb_percent === "" ? "0.0" : item.fixed_asset_movement.act_vs_rb_percent, item.fixed_asset_movement.act_vs_rb_percent === "" ? "0.0" : item.fixed_asset_movement.act_vs_rb_percent,
item.fixed_asset_movement.actual_formula,
item.order item.order
]) ])
if (item.children !== null) { if (item.children !== null) {
...@@ -162,13 +164,14 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -162,13 +164,14 @@ export default class FixedAssetsMovementMR extends Component {
} }
} }
// url donlot data minta ama arfin
async downloadAllData() { async downloadAllData() {
let url = `https://tia.eksad.com/tia-reporting-dev/public/transaction/monthly_report/fam/export_monthly_report?monthly_report_id=${this.props.monthlyReportId}&&report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&revision=${this.props.revision}&&months=${this.props.month.month_id}` let url = `https://tia.eksad.com/tia-reporting-dev/public/transaction/monthly_report/fam/export_monthly_report?monthly_report_id=${this.props.monthlyReportId}&&report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&revision=${this.props.revision}&&months=${this.props.month.month_id}`
console.log(url); console.log(url);
let res = await fetch( let res = await fetch(
`https://tia.eksad.com/tia-reporting-dev/public/transaction/monthly_report/fam/export_monthly_report?monthly_report_id=${this.props.monthlyReportId === null ? "" : this.props.monthlyReportId}&&report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&revision=${this.props.revision}&&months=${this.props.month.month_id}` `https://tia.eksad.com/tia-reporting-dev/public/transaction/monthly_report/fam/export_monthly_report?monthly_report_id=${this.props.monthlyReportId === null ? "" : this.props.monthlyReportId}&&report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&revision=${this.props.revision}&&months=${this.props.month.month_id}`
) )
res = await res.blob()
this.setState({ loading: false })
if (res.size > 0) { if (res.size > 0) {
let url = window.URL.createObjectURL(res); let url = window.URL.createObjectURL(res);
let a = document.createElement('a'); let a = document.createElement('a');
...@@ -181,13 +184,11 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -181,13 +184,11 @@ export default class FixedAssetsMovementMR extends Component {
fileHandler = (event) => { fileHandler = (event) => {
let fileObj = event let fileObj = event
ExcelRenderer(fileObj, (err, resp) => { ExcelRenderer(fileObj, (err, resp) => {
// console.log(resp)
if (err) { if (err) {
console.log(err); console.log(err);
} }
else { else {
let isi = resp.rows.slice(3) let isi = resp.rows.slice(3)
// console.log(resp.rows[2]);
let payload = [] let payload = []
let reg = /^[-+]?(?:[0-9]+,)*[0-9]+(?:\.[0-9]+)?$/; let reg = /^[-+]?(?:[0-9]+,)*[0-9]+(?:\.[0-9]+)?$/;
isi.map((i, index) => { isi.map((i, index) => {
...@@ -196,16 +197,7 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -196,16 +197,7 @@ export default class FixedAssetsMovementMR extends Component {
orders: i[0] === undefined ? "" : String(i[0]).trim(), orders: i[0] === undefined ? "" : String(i[0]).trim(),
item_report_id: i[1] === undefined ? "" : String(i[1]).trim(), item_report_id: i[1] === undefined ? "" : String(i[1]).trim(),
item_report: i[2] === undefined ? "" : String(i[2]).trim(), item_report: i[2] === undefined ? "" : String(i[2]).trim(),
mtd_actual: i[3] === undefined ? "0" : reg.test(String(i[2])) === false ? "0" : String(i[3]).trim(), mtd_actual: i[3] === undefined ? "0" : reg.test(String(i[3])) === false ? "0" : String(i[3]).trim(),
mtd_mb: "",
mtd_rb: "",
act_previous_month: "",
act_vs_prev_month_amount: "",
act_vs_prev_month_percent: "",
act_vs_mb_amount: "",
act_vs_mb_percent: "",
act_vs_rb_amount: "",
act_vs_rb_percent: ""
}) })
} }
}) })
...@@ -216,18 +208,17 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -216,18 +208,17 @@ export default class FixedAssetsMovementMR extends Component {
months: this.props.month.month_id, months: this.props.month.month_id,
fixed_asset_movement: payload fixed_asset_movement: payload
} }
console.log(body) // console.log(body)
this.setState({ payload: body, judul: resp.rows[1][0], judulColumn: resp.rows[2] }) this.setState({ payload: body, judul: resp.rows[1][0], judulColumn: resp.rows[2] })
} }
}); });
} }
// cek upload error network mulu..
checkUpload() { checkUpload() {
api.create().checkUploadMonthlyReportFAM(this.state.payload).then(response => { api.create().checkUploadMonthlyReportFAM(this.state.payload).then(response => {
// console.log(JSON.stringify(this.state.payload)); // console.log(JSON.stringify(this.state.payload));
console.log(this.state.payload) // console.log(this.state.payload)
console.log(response) // console.log(response)
if (response.data) { if (response.data) {
if (response.data.status === 'success') { if (response.data.status === 'success') {
this.setState({ visibleUpload: false, loading: true, visibleFAMMR: false }) this.setState({ visibleUpload: false, loading: true, visibleFAMMR: false })
...@@ -242,26 +233,27 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -242,26 +233,27 @@ export default class FixedAssetsMovementMR extends Component {
item.mtd_mb, item.mtd_mb,
item.mtd_rb, item.mtd_rb,
item.mtd_actual, item.mtd_actual,
"", item.act_previous_month,
"", item.act_vs_prev_month_amount,
"", item.act_vs_prev_month_percent,
"", item.act_vs_mb_amount,
"", item.act_vs_mb_percent,
"", item.act_vs_rb_amount,
"", item.act_vs_rb_percent,
item.actual_formula,
item.order, item.order,
item.error item.error
] ]
}) })
console.log(dataTable) // console.log(dataTable)
this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false, editable: true, saveDraft: true }, () => { this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false, editable: true }, () => {
this.state.dataTable.map(item => { this.state.dataTable.map(item => {
if (item[17].length > 0) { if (item[18].length > 0) {
console.log('masuk') console.log('masuk')
this.setState({ buttonError: true, errorPreview: true, editable: true, saveDraft: true }) this.setState({ buttonError: true, errorPreview: true, editable: true })
} }
}) })
console.log(this.state.dataTable); // console.log(this.state.dataTable);
}) })
} }
} }
...@@ -274,16 +266,16 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -274,16 +266,16 @@ export default class FixedAssetsMovementMR extends Component {
data.push({ data.push({
item_report_id: i[1], item_report_id: i[1],
item_report: String(i[5]).trim(), item_report: String(i[5]).trim(),
master_budget: String(Number(i[6]).toFixed(1)), mtd_mb: i[0] === 5 || i[0] === 6 ? String(Number(i[6]).toFixed(1)) : i[0] === 3 && i[6] === "" ? "0.0" : String(Number(i[6]).toFixed(1)),
rolling_budget: String(Number(i[7]).toFixed(1)), mtd_rb: i[0] === 5 || i[0] === 6 ? String(Number(i[7]).toFixed(1)) : i[0] === 3 && i[7] === "" ? "0.0" : String(Number(i[7]).toFixed(1)),
actual: String(Number(i[8]).toFixed(1)), mtd_actual: i[0] === 5 || i[0] === 6 ? String(Number(i[8]).toFixed(1)) : i[0] === 3 && i[8] === "" ? "0.0" : String(Number(i[8]).toFixed(1)),
actual_previous_month: String(Number(i[9]).toFixed(1)), act_previous_month: i[0] === 5 || i[0] === 6 ? String(Number(i[9]).toFixed(1)) : i[0] === 3 && i[9] === "" ? "0.0" : String(Number(i[9]).toFixed(1)),
amount_act_vs_previous_month: String(Number(i[10]).toFixed(1)), act_vs_prev_month_amount: i[0] === 5 || i[0] === 6 ? String(Number(i[10]).toFixed(1)) : i[0] === 3 && i[10] === "" ? "0.0" : String(Number(i[10]).toFixed(1)),
percent_act_vs_previous_month: String(Number(i[11]).toFixed(1)), act_vs_prev_month_percent: i[0] === 5 || i[0] === 6 ? String(Number(i[11]).toFixed(1)) : i[0] === 3 && i[11] === "" ? "0.0" : String(Number(i[11]).toFixed(1)),
amount_act_vs_mb: String(Number(i[12]).toFixed(1)), act_vs_mb_amount: i[0] === 5 || i[0] === 6 ? String(Number(i[12]).toFixed(1)) : i[0] === 3 && i[12] === "" ? "0.0" : String(Number(i[12]).toFixed(1)),
percent_act_vs_mb: String(Number(i[13]).toFixed(1)), act_vs_mb_percent: i[0] === 5 || i[0] === 6 ? String(Number(i[13]).toFixed(1)) : i[0] === 3 && i[13] === "" ? "0.0" : String(Number(i[13]).toFixed(1)),
amount_act_vs_rb: String(Number(i[14]).toFixed(1)), act_vs_rb_amount: i[0] === 5 || i[0] === 6 ? String(Number(i[14]).toFixed(1)) : i[0] === 3 && i[14] === "" ? "0.0" : String(Number(i[14]).toFixed(1)),
percent_act_vs_rb: String(Number(i[15]).toFixed(1)), act_vs_rb_percent: i[0] === 5 || i[0] === 6 ? String(Number(i[15]).toFixed(1)) : i[0] === 3 && i[15] === "" ? "0.0" : String(Number(i[15]).toFixed(1)),
}) })
}) })
let body = { let body = {
...@@ -299,23 +291,18 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -299,23 +291,18 @@ export default class FixedAssetsMovementMR extends Component {
api.create('UPLOAD').uploadMonthlyReportFAM(body).then(response => { api.create('UPLOAD').uploadMonthlyReportFAM(body).then(response => {
console.log(response); console.log(response);
if (response.data) { if (response.data) {
if (response.ok) { if (response.data.status === "success") {
if (response.data.status === "success") { this.props.onClickClose()
this.props.onClickClose() // this.props.getReport()
this.props.getReport()
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
if (response.data.message.includes("Someone Logged In")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
// alert(response.data.status)
}
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error', loading: false }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
if (response.data.message.includes("Someone Logged In")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false }) this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
...@@ -351,6 +338,8 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -351,6 +338,8 @@ export default class FixedAssetsMovementMR extends Component {
"months": this.props.month.month_id, "months": this.props.month.month_id,
"fixed_asset_movement": data "fixed_asset_movement": data
} }
// console.log(JSON.stringify(payload));
api.create('UPLOAD').createMonthlyReportFAM(payload).then(response => { api.create('UPLOAD').createMonthlyReportFAM(payload).then(response => {
console.log(response); console.log(response);
if (response.data) { if (response.data) {
...@@ -376,118 +365,246 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -376,118 +365,246 @@ export default class FixedAssetsMovementMR extends Component {
render() { render() {
let dataTable2 = this.state.dataTable let dataTable2 = this.state.dataTable
const handleChange = (value, tableMeta, type) => {
console.log(dataTable2); const handleValueFormula = (tableMeta, colIdx) => {
console.log(tableMeta); // loading = true
let val = String(value).split(",").join("") // console.log(tableMeta);
if (type === "actual") { // "@44[M-1]#BS"
dataTable2[tableMeta.rowIndex][8] = Number(val).toFixed(1) let splitFormula = String(tableMeta.rowData[3]).split(/([()@])/)
} else { let baru = []
console.log(val); let anjay = []
let indexParent = dataTable2.findIndex((val) => val[1] === dataTable2[tableMeta.rowIndex][2]) // console.log(splitFormula);
console.log(indexParent); splitFormula.map((item, index) => {
if (indexParent > 0) { let items = String(item).substr(Number(String(item).length) - 1, 1)
// console.log(indexParent) let subForm = String(item).substr(0, Number(String(item).length) - 1)
dataTable2[tableMeta.rowIndex][9] = Number(val).toFixed(1) // console.log(item);
let jagain = Number(dataTable2[indexParent][8]).toFixed(1) // console.log(items);
dataTable2[indexParent][9] = jagain === undefined ? (0 + Number(val)).toFixed(1) : Number(Number(jagain) + Number(val)).toFixed(1) // console.log(subForm);
// if (tableMeta.rowData[5] === 'Cash & Bank Balance') {
// console.log(value); let re = /^[a-zA-Z0-9_]+$/;
// console.log(a); if (item !== "") {
// console.log(jagain); if (items == ']') {
// console.log(dataTable2[indexParent]); baru.push(String(item))
// } } else if (!re.test(items)) {
} else { baru.push(subForm)
dataTable2[tableMeta.rowIndex][8] = Number(val).toFixed(1) baru.push(items)
} } else {
} baru.push(String(item))
} }
// handleValue(tableMeta, 2)
const handleValue = (data, type) => {
// console.log(data, type);
let total = 0
dataTable2.map((item, index) => {
if (data.rowData[1] === item[2]) {
let itemVal = item[data.columnIndex + type].value !== undefined ? Number(item[data.columnIndex + type].value) : Number(item[data.columnIndex + type])
total = item[data.columnIndex + type] === undefined ? Number(total) + 0 : Number(total) + itemVal
} }
}) })
let indexParent = dataTable2.findIndex((val) => val[1] === dataTable2[data.rowIndex][2])
let a = dataTable2[data.rowIndex][data.columnIndex + type] = Number(total).toFixed(1)
// console.log(indexParent);
return a
}
const handleFormula = (data, tableMeta, type) => {
let arrayFormula = tableMeta.rowData[3].match(/[a-zA-Z]+|[0-9]+|[-!$%^&*()_+|~=`{}\[\]:";'<>?,.\/]+(?:\.[0-9]+@|)/g)
let arrayJumlah = []
let tambahan = false
let opet = ""
arrayFormula.map((item, indexs) => { // console.log(baru);
if (item == 'X') {
tambahan = true baru.map((item, index) => {
} else if (item == '-' || item == '+' || item == '/' || item == '*') { if (item == '-' || item == '+' || item == '/' || item == '*' || item == '(' || item == ')') {
arrayJumlah.push(item) anjay.push(item)
} else { } else {
let index = dataTable2.findIndex((val) => val[22] == item) if (String(item).includes('#')) {
if (tambahan) { if (String(item).includes('[M-1]')) {
if (item == '-' || item == '+' || item == '/' || item == '*') { let tst = String(item).replace('[M-1]', '')
opet = item let indexID = dataTable2.findIndex((val) => val[17] == tst)
// console.log(indexID);
if (indexID !== -1) {
let valuezz = dataTable2[indexID][8]
anjay.push(valuezz == "" ? 0 : valuezz)
}
} else { } else {
arrayJumlah.push(opet == '' ? Number(item) : Number(String(opet + String(item)))) let data = tableMeta.rowData[16]
tambahan = false let indexID = data.findIndex((val) => val.item_formula == String(`@${item}`))
opet = "" if (indexID !== -1) {
let valuezz = data[indexID].value
anjay.push(valuezz == "" ? 0 : valuezz)
}
} }
} else { } else {
if (index != -1) { if (String(item).includes('[M-1]')) {
arrayJumlah.push(dataTable2[index][tableMeta.columnIndex + type]) let tst = String(item).replace('[M-1]', '')
let indexID = dataTable2.findIndex((val) => val[17] == tst)
if (indexID !== -1) {
let valuezz = dataTable2[indexID][8]
anjay.push(valuezz == "" ? 0 : valuezz)
}
} else {
let indexID = dataTable2.findIndex((val) => val[17] == item)
if (indexID !== -1) {
let valuezz = dataTable2[indexID][colIdx]
if (item == dataTable2[tableMeta.rowIndex][28]) {
anjay.push(0)
} else {
anjay.push(valuezz == "" ? 0 : valuezz)
}
} else {
if (item === '(-1)') {
anjay.push(-1)
}
}
} }
} }
} }
}) })
let array = arrayJumlah let anjay2 = []
let kurung = false
let item1 = []
anjay.map((item, index) => {
if (item == "(") {
kurung = true
} else if (item == ")") {
kurung = false
anjay2.push(item1)
item1 = []
} else {
if (kurung) {
item1.push(item)
} else {
anjay2.push(item)
}
}
})
let total = 0 let total = 0
let opt = "" let opt = ""
let totalPrio = 0
let optPrio = ""
let prio = false
anjay2.map((item, index) => {
if (Array.isArray(item)) {
prio = true
item.map((items, indexs) => {
if (items == "+") {
optPrio = "tambah"
} else if (items == "-") {
optPrio = "kurang"
} else if (items == "*") {
optPrio = "kali"
} else if (items == "/") {
optPrio = "bagi"
} else {
if (optPrio == "tambah") {
totalPrio = Number(totalPrio) + Number(items)
} else if (optPrio == "kurang") {
totalPrio = Number(totalPrio) - Number(items)
} else if (optPrio == "kali") {
totalPrio = Number(totalPrio) * Number(items)
} else if (optPrio == "bagi") {
totalPrio = Number(totalPrio) / Number(items) == NaN ? 0 : Number(totalPrio) / Number(items)
} else {
totalPrio += Number(items)
}
}
})
array.map((item, index) => { if (index == anjay2.length - 1) {
if (item == "+") { if (opt == "tambah") {
opt = "tambah" total = Number(total) + Number(totalPrio)
} else if (item == "-") { } else if (opt == "kurang") {
opt = "kurang" total = Number(total) - Number(totalPrio)
} else if (item == "*") { } else if (opt == "kali") {
opt = "kali" total = Number(total) * Number(totalPrio)
} else if (item == "/") { } else if (opt == "bagi") {
opt = "bagi" total = Number(total) / Number(totalPrio) == NaN ? 0 : Number(total) / Number(totalPrio)
} else {
total += Number(totalPrio)
}
}
} else { } else {
if (opt == "tambah") { if (item == "+") {
total = Number(total) + Number(item) opt = "tambah"
} else if (opt == "kurang") { if (prio) {
total = Number(total) - Number(item) total = Number(Number(totalPrio) + Number(total))
} else if (opt == "kali") { prio = false
total = Number(total) * Number(item) totalPrio = 0
// if (tableMeta.rowData[22] === 3) { optPrio = ""
// console.log(dataTable2[tableMeta.rowIndex]); }
// console.log(total); } else if (item == "-") {
// console.log(item); opt = "kurang"
// console.log(arrayJumlah); if (prio) {
// } total = Number(Number(totalPrio) + Number(total))
} else if (opt == "bagi") { prio = false
total = R.equals((Number(total) / Number(item)), NaN) ? '0' : Number(total) / Number(item) totalPrio = 0
optPrio = ""
}
} else if (item == "*") {
opt = "kali"
if (prio) {
total = Number(Number(totalPrio) + Number(total))
prio = false
totalPrio = 0
optPrio = ""
}
} else if (item == "/") {
opt = "bagi"
if (prio) {
total = Number(Number(totalPrio) + Number(total))
prio = false
totalPrio = 0
optPrio = ""
}
} else { } else {
total += Number(item) if (opt == "tambah") {
total = Number(total) + Number(item)
} else if (opt == "kurang") {
total = Number(total) - Number(item)
} else if (opt == "kali") {
total = Number(total) * Number(item)
} else if (opt == "bagi") {
total = Number(total) / Number(item) == NaN ? 0 : Number(total) / Number(item)
} else {
total += Number(item)
}
} }
} }
}) })
total = R.equals(total, NaN) ? "0.0" : total
// // // total = R.equals(total, NaN) ? "0.0" : total
// // // console.log(dataTable2[tableMeta.rowIndex][22])
// // // console.log(tableMeta.rowData[5])
// // if (tableMeta.rowData[5] == "1.5 Other non-current assets") {
// // if (forecast !== undefined) {
// // if (String(tableMeta.rowData[5]) == "Depreciation & amortisation") {
// console.log(splitFormula)
// console.log(baru)
// console.log(anjay)
// console.log(anjay2)
// console.log(total)
// // console.log(dataTable2[tableMeta.rowIndex])
// // }
// // }
let a = dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = Number(total) // if (dataTable2[tableMeta.rowIndex][colIdx].value == undefined) {
dataTable2[tableMeta.rowIndex][colIdx] = total
// } else {
// dataTable2[tableMeta.rowIndex][column].value = total
// }
// loading = false
return total
}
const handleChange = (value, tableMeta, type) => {
dataTable2[tableMeta.rowIndex][type] = value
// console.log(dataTable2[tableMeta.rowIndex][type]);
// console.log(value);
}
const handleValue = (data, type) => {
// console.log(data, type);
let total = 0
dataTable2.map((item, index) => {
if (data.rowData[1] === item[2]) {
let itemVal = item[data.columnIndex + type].value !== undefined ? Number(item[data.columnIndex + type].value) : Number(item[data.columnIndex + type])
total = item[data.columnIndex + type] === undefined ? Number(total) + 0 : Number(total) + itemVal
}
})
let indexParent = dataTable2.findIndex((val) => val[1] === dataTable2[data.rowIndex][2])
let a = dataTable2[data.rowIndex][data.columnIndex + type] = Number(total).toFixed(1)
// console.log(indexParent);
return a return a
} }
const handleVariance = (tableMeta, dex, type) => { const handleVariance = (tableMeta, dex, type) => {
let total = 0 let total = 0
if (dex === 1) { if (dex === 1) {
...@@ -505,18 +622,27 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -505,18 +622,27 @@ export default class FixedAssetsMovementMR extends Component {
const handleVariancePercent = (tableMeta, dex, type) => { const handleVariancePercent = (tableMeta, dex, type) => {
let total = 0 let total = 0
// if (tableMeta.rowData[5] === "Disposal (negative value)") {
// console.log(dataTable2);
// console.log(tableMeta);
// }
// value={Number(handleVariancePercent(tableMeta, 1, 3)).toFixed(1)}
// dataTable2[5][11]
if (dex === 1) { if (dex === 1) {
// total = Number(dataTable2[tableMeta.rowIndex][13]) / Number(dataTable2[tableMeta.rowIndex][12]) total = R.equals((Number(dataTable2[tableMeta.rowIndex][10]) / Number(dataTable2[tableMeta.rowIndex][9])), NaN) ? '0' : R.equals((Number(dataTable2[tableMeta.rowIndex][10]) / Number(dataTable2[tableMeta.rowIndex][9])), Infinity) ? "0" : R.equals((Number(dataTable2[tableMeta.rowIndex][10]) / Number(dataTable2[tableMeta.rowIndex][9])), -Infinity) ? "0" : Number(dataTable2[tableMeta.rowIndex][10]) / Number(dataTable2[tableMeta.rowIndex][9])
total = R.equals((Number(dataTable2[tableMeta.rowIndex][13]) / Number(dataTable2[tableMeta.rowIndex][12])), NaN) ? '0' : R.equals((Number(dataTable2[tableMeta.rowIndex][13]) / Number(dataTable2[tableMeta.rowIndex][12])), Infinity) ? '0' : Number(dataTable2[tableMeta.rowIndex][13]) / Number(dataTable2[tableMeta.rowIndex][12])
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = Number(total).toFixed(1) dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = Number(total).toFixed(1)
// if (tableMeta.rowData[5] === "Cash and cash equivalent") {
// console.log(total);
// console.log(Number(dataTable2[tableMeta.rowIndex][11]) / Number(dataTable2[tableMeta.rowIndex][10]));
// console.log(dataTable2[tableMeta.rowIndex]);
// }
} else if (dex === 2) { } else if (dex === 2) {
// total = Number(dataTable2[tableMeta.rowIndex][15]) / Number(dataTable2[tableMeta.rowIndex][8]) total = R.equals((Number(dataTable2[tableMeta.rowIndex][12]) / Number(dataTable2[tableMeta.rowIndex][6])), NaN) ? '0' : R.equals((Number(dataTable2[tableMeta.rowIndex][12]) / Number(dataTable2[tableMeta.rowIndex][6])), Infinity) ? "0" : R.equals((Number(dataTable2[tableMeta.rowIndex][12]) / Number(dataTable2[tableMeta.rowIndex][6])), -Infinity) ? "0" : Number(dataTable2[tableMeta.rowIndex][12]) / Number(dataTable2[tableMeta.rowIndex][6])
total = R.equals((Number(dataTable2[tableMeta.rowIndex][15]) / Number(dataTable2[tableMeta.rowIndex][8])), NaN) ? '0' : R.equals((Number(dataTable2[tableMeta.rowIndex][15]) / Number(dataTable2[tableMeta.rowIndex][8])), Infinity) ? '0' : Number(dataTable2[tableMeta.rowIndex][15]) / Number(dataTable2[tableMeta.rowIndex][8])
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = Number(total).toFixed(1) dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = Number(total).toFixed(1)
} else if (dex === 3) { } else if (dex === 3) {
// total = Number(dataTable2[tableMeta.rowIndex][17]) / Number(dataTable2[tableMeta.rowIndex][9]) total = R.equals((Number(dataTable2[tableMeta.rowIndex][14]) / Number(dataTable2[tableMeta.rowIndex][7])), NaN) ? '0' : R.equals((Number(dataTable2[tableMeta.rowIndex][14]) / Number(dataTable2[tableMeta.rowIndex][7])), Infinity) ? "0" : R.equals((Number(dataTable2[tableMeta.rowIndex][14]) / Number(dataTable2[tableMeta.rowIndex][7])), -Infinity) ? "0" : Number(dataTable2[tableMeta.rowIndex][14]) / Number(dataTable2[tableMeta.rowIndex][7])
total = R.equals((Number(dataTable2[tableMeta.rowIndex][17]) / Number(dataTable2[tableMeta.rowIndex][9])), NaN) ? '0' : R.equals((Number(dataTable2[tableMeta.rowIndex][17]) / Number(dataTable2[tableMeta.rowIndex][9])), Infinity) ? '0' : Number(dataTable2[tableMeta.rowIndex][17]) / Number(dataTable2[tableMeta.rowIndex][9])
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = Number(total).toFixed(1) dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = Number(total).toFixed(1)
// console.log(total);
} }
return total return total
} }
...@@ -621,8 +747,18 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -621,8 +747,18 @@ export default class FixedAssetsMovementMR extends Component {
<div style={{ textAlign: 'right', width: 90 }}> <div style={{ textAlign: 'right', width: 90 }}>
{ {
tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 4 ? tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 4 ?
null : null :
tableMeta.rowData[0] === 3 ? tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 ?
<span style={{ fontSize: 12, textAlign: 'right' }}>
<NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 90, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={Number(handleValueFormula(tableMeta, 6)).toFixed(1)}
/>
</span> :
<div style={{ flex: 1 }}> <div style={{ flex: 1 }}>
<FormControlLabel <FormControlLabel
style={{ margin: 0 }} style={{ margin: 0 }}
...@@ -634,34 +770,11 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -634,34 +770,11 @@ export default class FixedAssetsMovementMR extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={Number(tableMeta.rowData[6]).toFixed(1)} value={Number(value).toFixed(1)}
/> />
} }
/> />
</div> : </div>
tableMeta.rowData[0] === 5 ?
<span style={{ fontSize: 12, textAlign: 'right' }}>
<NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 90, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={Number(handleFormula(value, tableMeta, 0)).toFixed(1)}
/>
</span> :
tableMeta.rowData[0] === 6 ?
<span style={{ fontSize: 12, textAlign: 'right' }}>
<NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 90, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={Number(handleFormula(value, tableMeta, 0)).toFixed(1)}
/>
</span> :
null
} }
</div> </div>
</div> </div>
...@@ -678,27 +791,25 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -678,27 +791,25 @@ export default class FixedAssetsMovementMR extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={Number(handleFormula(value, tableMeta, 1)).toFixed(1)} value={Number(handleValueFormula(tableMeta, 7)).toFixed(1)}
/> />
</span> : </span> :
tableMeta.rowData[0] === 3 ? <div style={{ flex: 1 }}>
<div style={{ flex: 1 }}> <FormControlLabel
<FormControlLabel style={{ margin: 0 }}
style={{ margin: 0 }} value={value}
value={value} control={
control={ <NumberFormat
<NumberFormat thousandSeparator={true}
thousandSeparator={true} style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 90, backgroundColor: 'transparent' }}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 90, backgroundColor: 'transparent' }} type="text"
type="text" placeholder=""
placeholder="" disabled={true}
disabled={true} value={Number(value).toFixed(1)}
value={Number(tableMeta.rowData[7]).toFixed(1)} />
/> }
} />
/> </div>
</div> :
null
} }
</div> </div>
</div> </div>
...@@ -721,13 +832,13 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -721,13 +832,13 @@ export default class FixedAssetsMovementMR extends Component {
disabled={false} disabled={false}
value={Number(tableMeta.rowData[8]).toFixed(1)} value={Number(tableMeta.rowData[8]).toFixed(1)}
onBlur={(event) => { onBlur={(event) => {
handleChange(event.target.value, tableMeta) handleChange(event.target.value, tableMeta, 8)
}} }}
/> />
} }
/> />
</div> : </div> :
tableMeta.rowData[0] === 5 ? tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 ?
<span style={{ fontSize: 12, textAlign: 'right' }}> <span style={{ fontSize: 12, textAlign: 'right' }}>
<NumberFormat <NumberFormat
thousandSeparator={true} thousandSeparator={true}
...@@ -735,22 +846,25 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -735,22 +846,25 @@ export default class FixedAssetsMovementMR extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
// value={Number(handleValue(tableMeta, 2)).toFixed(1)} value={Number(handleValueFormula(tableMeta, 8)).toFixed(1)}
value={Number(handleFormula(value, tableMeta, 2)).toFixed(1)}
/> />
</span> : </span> :
tableMeta.rowData[0] === 6 ? <div style={{ flex: 1 }}>
<span style={{ fontSize: 12, textAlign: 'right' }}> <FormControlLabel
<NumberFormat style={{ margin: 0 }}
thousandSeparator={true} value={value}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} control={
type="text" <NumberFormat
placeholder="" thousandSeparator={true}
disabled={true} style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
value={Number(handleFormula(value, tableMeta, 2)).toFixed(1)} type="text"
/> placeholder=""
</span> : disabled={true}
null value={Number(value).toFixed(1)}
/>
}
/>
</div>
} }
</div> </div>
</div> </div>
...@@ -773,19 +887,18 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -773,19 +887,18 @@ export default class FixedAssetsMovementMR extends Component {
<div style={{ textAlign: 'right', width: 90 }}> <div style={{ textAlign: 'right', width: 90 }}>
{ {
tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 4 ? tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 4 ?
null : null :
tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 ? tableMeta.rowData[0] === 5 || tableMeta.rowData[0] === 6 ?
<span style={{ fontSize: 12, textAlign: 'right' }}> <span style={{ fontSize: 12, textAlign: 'right' }}>
<NumberFormat <NumberFormat
thousandSeparator={true} thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 90, backgroundColor: 'transparent' }} style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={Number(handleValue(tableMeta, 0)).toFixed(1)} value={Number(handleValueFormula(tableMeta, 9)).toFixed(1)}
/> />
</span> : </span> :
tableMeta.rowData[0] === 3 ?
<div style={{ flex: 1 }}> <div style={{ flex: 1 }}>
<FormControlLabel <FormControlLabel
style={{ margin: 0 }} style={{ margin: 0 }}
...@@ -793,7 +906,7 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -793,7 +906,7 @@ export default class FixedAssetsMovementMR extends Component {
control={ control={
<NumberFormat <NumberFormat
thousandSeparator={true} thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 90, backgroundColor: 'transparent' }} style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
...@@ -801,8 +914,7 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -801,8 +914,7 @@ export default class FixedAssetsMovementMR extends Component {
/> />
} }
/> />
</div> : </div>
null
} }
</div> </div>
) )
...@@ -815,41 +927,41 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -815,41 +927,41 @@ export default class FixedAssetsMovementMR extends Component {
<th style={{ ...style2, backgroundColor: '#1c71b8', color: '#fff', fontSize: 13, fontWeight: 1, width: 150, borderRight: "1px solid rgb(255, 255, 255)" }} > <th style={{ ...style2, backgroundColor: '#1c71b8', color: '#fff', fontSize: 13, fontWeight: 1, width: 150, borderRight: "1px solid rgb(255, 255, 255)" }} >
<div style={{ borderLeft: "1px #fff solid", textAlign: 'center', fontSize: 12, fontWeight: 'bold', padding: 5, height: 45, display: 'flex', justifyContent: 'center', alignItems: 'center' }}>{columnMeta.name}</div> <div style={{ borderLeft: "1px #fff solid", textAlign: 'center', fontSize: 12, fontWeight: 'bold', padding: 5, height: 45, display: 'flex', justifyContent: 'center', alignItems: 'center' }}>{columnMeta.name}</div>
<div className="grid grid-3x" style={{ ...style2, backgroundColor: '#1c71b8', color: '#fff', fontSize: 12, fontWeight: 'bold', position: "sticky" }}> <div className="grid grid-3x" style={{ ...style2, backgroundColor: '#1c71b8', color: '#fff', fontSize: 12, fontWeight: 'bold', position: "sticky" }}>
<div className="column-1" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, border: '1px #fff solid', backgroundColor: '#37b5e6' }}> <div className="column-1" style={{ placeSelf: 'center', textAlign: 'center', border: '1px #fff solid', backgroundColor: '#37b5e6', borderBottom: '1px solid #37b5e6' }}>
<div style={{ borderBottom: '1px #fff solid', backgroundColor: '#37b5e6' }}> <div style={{ borderBottom: '1px #fff solid', padding: 2.5, backgroundColor: '#37b5e6' }}>
<span>{"Act vs Previous Month"}</span> <span>{"Act vs Previous Month"}</span>
</div> </div>
<div className="grid grid-2x"> <div className="grid grid-2x">
<div className="column-1" style={{ borderRight: '1px #fff solid', backgroundColor: '#37b5e6' }}> <div className="column-1" style={{ borderRight: '1px #fff solid', padding: 2.5, backgroundColor: '#37b5e6' }}>
<span>{"Amount"}</span> <span>{"Amount"}</span>
</div> </div>
<div className="column-2" style={{ borderLeft: '1px #fff solid', backgroundColor: '#37b5e6' }}> <div className="column-2" style={{ padding: 2.5, backgroundColor: '#37b5e6' }}>
<span>{"%"}</span> <span>{"%"}</span>
</div> </div>
</div> </div>
</div> </div>
<div className="column-2" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, border: '1px #fff solid', backgroundColor: '#07a7d0' }}> <div className="column-2" style={{ placeSelf: 'center', textAlign: 'center', border: '1px #fff solid', backgroundColor: '#07a7d0', borderBottom: '1px solid #37b5e6' }}>
<div style={{ borderBottom: '1px #fff solid' }}> <div style={{ borderBottom: '1px #fff solid', padding: 2.5, backgroundColor: '#37b5e6' }}>
<span>{"Act vs MB"}</span> <span>{"Act vs MB"}</span>
</div> </div>
<div className="grid grid-2x"> <div className="grid grid-2x">
<div className="column-1" style={{ borderRight: '1px #fff solid' }}> <div className="column-1" style={{ borderRight: '1px #fff solid', padding: 2.5, backgroundColor: '#37b5e6' }}>
<span>{"Amount"}</span> <span>{"Amount"}</span>
</div> </div>
<div className="column-2" style={{ borderLeft: '1px #fff solid' }}> <div className="column-2" style={{ padding: 2.5, backgroundColor: '#37b5e6' }}>
<span>{"%"}</span> <span>{"%"}</span>
</div> </div>
</div> </div>
</div> </div>
<div className="column-3" style={{ placeSelf: 'center', textAlign: 'center', padding: 5, border: '1px #fff solid', backgroundColor: '#07a7d0' }}> <div className="column-3" style={{ placeSelf: 'center', textAlign: 'center', border: '1px #fff solid', backgroundColor: '#07a7d0', borderBottom: '1px solid #37b5e6' }}>
<div style={{ borderBottom: '1px #fff solid' }}> <div style={{ borderBottom: '1px #fff solid', padding: 2.5, backgroundColor: '#37b5e6' }}>
<span>{"Act vs RB"}</span> <span>{"Act vs RB"}</span>
</div> </div>
<div className="grid grid-2x"> <div className="grid grid-2x">
<div className="column-1" style={{ borderRight: '1px #fff solid' }}> <div className="column-1" style={{ borderRight: '1px #fff solid', padding: 2.5, backgroundColor: '#37b5e6' }}>
<span>{"Amount"}</span> <span>{"Amount"}</span>
</div> </div>
<div className="column-2" style={{ borderLeft: '1px #fff solid' }}> <div className="column-2" style={{ padding: 2.5, backgroundColor: '#37b5e6' }}>
<span>{"%"}</span> <span>{"%"}</span>
</div> </div>
</div> </div>
...@@ -857,18 +969,22 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -857,18 +969,22 @@ export default class FixedAssetsMovementMR extends Component {
</div> </div>
</th> </th>
), ),
setCellProps: () => ({ style2 }), setCellProps: () => ({
style: {
paddingLeft: 0,
paddingRight: 10
}
}),
customBodyRender: (val, tableMeta, updateValue) => { customBodyRender: (val, tableMeta, updateValue) => {
// console.log(tableMeta); // console.log(tableMeta);
return ( return (
<div> <div>
<div className="grid grid-3x content-center"> <div className="grid grid-3x content-center">
<div className="col-1"> <div className="column-1">
<div className="grid grid-2x content-center"> <div className="grid grid-2x content-center">
<div className="col-1"> <div className="column-1">
<div style={{ textAlign: 'right', width: 90 }}> <div style={{ textAlign: 'right', width: 120 }}>
{ {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 4 ?
null : null :
<div style={{ flex: 1 }}> <div style={{ flex: 1 }}>
<FormControlLabel <FormControlLabel
...@@ -889,11 +1005,10 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -889,11 +1005,10 @@ export default class FixedAssetsMovementMR extends Component {
} }
</div> </div>
</div> </div>
<div className="col-2"> <div className="column-2">
<div style={{ textAlign: 'right', width: 90 }}> <div style={{ textAlign: 'right', width: 120 }}>
{ {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 4 ? null :
null :
<div style={{ flex: 1 }}> <div style={{ flex: 1 }}>
<FormControlLabel <FormControlLabel
style={{ margin: 0 }} style={{ margin: 0 }}
...@@ -904,8 +1019,9 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -904,8 +1019,9 @@ export default class FixedAssetsMovementMR extends Component {
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text" type="text"
placeholder="" placeholder=""
suffix={'%'}
disabled={true} disabled={true}
value={Number(handleVariance(tableMeta, 1, 2)).toFixed(1)} value={Number(handleVariancePercent(tableMeta, 1, 3)).toFixed(1)}
/> />
} }
/> />
...@@ -915,12 +1031,11 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -915,12 +1031,11 @@ export default class FixedAssetsMovementMR extends Component {
</div> </div>
</div> </div>
</div> </div>
<div className="col-2"> <div className="column-2">
<div className="grid grid-2x content-center"> <div className="grid grid-2x content-center">
<div className="col-1"> <div className="column-1">
<div style={{ textAlign: 'right', width: 90 }}> <div style={{ textAlign: 'right', width: 120 }}>
{ {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 4 ?
null : null :
<div style={{ flex: 1 }}> <div style={{ flex: 1 }}>
<FormControlLabel <FormControlLabel
...@@ -933,7 +1048,7 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -933,7 +1048,7 @@ export default class FixedAssetsMovementMR extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={Number(handleVariance(tableMeta, 1, 2)).toFixed(1)} value={Number(handleVariance(tableMeta, 2, 4)).toFixed(1)}
/> />
} }
/> />
...@@ -941,11 +1056,10 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -941,11 +1056,10 @@ export default class FixedAssetsMovementMR extends Component {
} }
</div> </div>
</div> </div>
<div className="col-2"> <div className="column-2">
<div style={{ textAlign: 'right', width: 90 }}> <div style={{ textAlign: 'right', width: 120 }}>
{ {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 4 ? null :
null :
<div style={{ flex: 1 }}> <div style={{ flex: 1 }}>
<FormControlLabel <FormControlLabel
style={{ margin: 0 }} style={{ margin: 0 }}
...@@ -957,7 +1071,8 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -957,7 +1071,8 @@ export default class FixedAssetsMovementMR extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={Number(handleVariance(tableMeta, 1, 2)).toFixed(1)} suffix={'%'}
value={Number(handleVariancePercent(tableMeta, 2, 5)).toFixed(1)}
/> />
} }
/> />
...@@ -967,12 +1082,11 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -967,12 +1082,11 @@ export default class FixedAssetsMovementMR extends Component {
</div> </div>
</div> </div>
</div> </div>
<div className="col-3"> <div className="column-3">
<div className="grid grid-2x content-center"> <div className="grid grid-2x content-center">
<div className="col-1"> <div className="column-1">
<div style={{ textAlign: 'right', width: 90 }}> <div style={{ textAlign: 'right', width: 120 }}>
{ {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 4 ?
null : null :
<div style={{ flex: 1 }}> <div style={{ flex: 1 }}>
<FormControlLabel <FormControlLabel
...@@ -985,7 +1099,7 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -985,7 +1099,7 @@ export default class FixedAssetsMovementMR extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={Number(handleVariance(tableMeta, 1, 2)).toFixed(1)} value={Number(handleVariance(tableMeta, 3, 6)).toFixed(1)}
/> />
} }
/> />
...@@ -993,11 +1107,10 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -993,11 +1107,10 @@ export default class FixedAssetsMovementMR extends Component {
} }
</div> </div>
</div> </div>
<div className="col-2"> <div className="column-2">
<div style={{ textAlign: 'right', width: 90 }}> <div style={{ textAlign: 'right', width: 120 }}>
{ {tableMeta.rowData[0] === 4 || tableMeta.rowData[0] === 1 ?
tableMeta.rowData[0] === 1 || tableMeta.rowData[0] === 4 ? null :
null :
<div style={{ flex: 1 }}> <div style={{ flex: 1 }}>
<FormControlLabel <FormControlLabel
style={{ margin: 0 }} style={{ margin: 0 }}
...@@ -1009,7 +1122,8 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -1009,7 +1122,8 @@ export default class FixedAssetsMovementMR extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={Number(handleVariance(tableMeta, 1, 2)).toFixed(1)} suffix={'%'}
value={Number(handleVariancePercent(tableMeta, 3, 7)).toFixed(1)}
/> />
} }
/> />
...@@ -1064,6 +1178,11 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -1064,6 +1178,11 @@ export default class FixedAssetsMovementMR extends Component {
options: { options: {
display: false display: false
} }
}, {
name: "",
options: {
display: false
}
}] }]
const loadingComponent = ( const loadingComponent = (
...@@ -1079,6 +1198,7 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -1079,6 +1198,7 @@ export default class FixedAssetsMovementMR extends Component {
return ( return (
<div style={{ height: this.props.height, backgroundColor: '#f8f8f8', marginBottom: 100, minHeight: 1000 }}> <div style={{ height: this.props.height, backgroundColor: '#f8f8f8', marginBottom: 100, minHeight: 1000 }}>
{this.state.loading && loadingComponent}
<div className={"main-color"} style={{ height: 78, flex: 1, display: 'flex', alignItems: 'center', paddingLeft: 20 }}> <div className={"main-color"} style={{ height: 78, flex: 1, display: 'flex', alignItems: 'center', paddingLeft: 20 }}>
<Typography style={{ fontSize: '16px', color: 'white' }}>Monthly Report</Typography> <Typography style={{ fontSize: '16px', color: 'white' }}>Monthly Report</Typography>
</div> </div>
...@@ -1154,16 +1274,17 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -1154,16 +1274,17 @@ export default class FixedAssetsMovementMR extends Component {
</div> </div>
<div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}> <div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
{this.state.loading && loadingComponent} {!this.state.loading && (
<MuiThemeProvider theme={getMuiTheme()}> <MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable <MUIDataTable
data={dataTable2} data={dataTable2}
columns={columns} columns={columns}
options={options} options={options}
/> />
</MuiThemeProvider> </MuiThemeProvider>
)}
</div> </div>
{/* <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 20 }}>Last Updated by : {this.state.updateBy}</Typography> */} <Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 20 }}>Last Updated by : {this.state.updateBy}</Typography>
</div> </div>
<div className="grid grid-2x" style={{ marginTop: 20 }}> <div className="grid grid-2x" style={{ marginTop: 20 }}>
<div className="col-1"> <div className="col-1">
...@@ -1225,7 +1346,7 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -1225,7 +1346,7 @@ export default class FixedAssetsMovementMR extends Component {
onClick={() => onClick={() =>
this.state.editable === true ? this.state.editable === true ?
null : null :
this.state.handleTekTekTek == 1 ? null : this.state.handleTekTekTek === 1 ? null :
this.setState({ handleTekTekTek: 1 }, () => { this.setState({ handleTekTekTek: 1 }, () => {
this.backToMonthlyReport('draft') this.backToMonthlyReport('draft')
}) })
...@@ -1242,7 +1363,7 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -1242,7 +1363,7 @@ export default class FixedAssetsMovementMR extends Component {
this.state.buttonError ? this.state.buttonError ?
this.setState({ alert: true, messageAlert: 'Data is not complete !', tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: 'Data is not complete !', tipeAlert: 'warning' })
: :
this.state.handleTekTekTek == 1 ? null : this.state.handleTekTekTek === 1 ? null :
this.setState({ handleTekTekTek: 1 }, () => { this.setState({ handleTekTekTek: 1 }, () => {
this.backToMonthlyReport('submitted') this.backToMonthlyReport('submitted')
})} })}
...@@ -1275,14 +1396,15 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -1275,14 +1396,15 @@ export default class FixedAssetsMovementMR extends Component {
</div> </div>
<div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}> <div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
{this.state.loading && loadingComponent} {!this.state.loading && (
<MuiThemeProvider theme={getMuiTheme()}> <MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable <MUIDataTable
data={dataTable2} data={dataTable2}
columns={columns} columns={columns}
options={options} options={options}
/> />
</MuiThemeProvider> </MuiThemeProvider>
)}
</div> </div>
</div> </div>
<div className="grid grid-2x" style={{ marginTop: 20 }}> <div className="grid grid-2x" style={{ marginTop: 20 }}>
...@@ -1337,15 +1459,15 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -1337,15 +1459,15 @@ export default class FixedAssetsMovementMR extends Component {
type="button" type="button"
style={{ style={{
backgroundColor: 'transparent', backgroundColor: 'transparent',
cursor: this.state.editable !== true ? 'pointer' : 'default', cursor: this.state.saveDraft !== true ? 'pointer' : 'default',
borderColor: 'transparent', borderColor: 'transparent',
outline: 'none', outline: 'none',
marginRight: 20 marginRight: 20
}} }}
onClick={() => onClick={() =>
this.state.editable === true ? this.state.saveDraft === true ?
null : null :
this.state.handleTekTekTek == 1 ? null : this.state.handleTekTekTek === 1 ? null :
this.setState({ handleTekTekTek: 1 }, () => { this.setState({ handleTekTekTek: 1 }, () => {
this.uploadFAMMR('draft') this.uploadFAMMR('draft')
}) })
...@@ -1362,7 +1484,7 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -1362,7 +1484,7 @@ export default class FixedAssetsMovementMR extends Component {
this.state.buttonError ? this.state.buttonError ?
this.setState({ alert: true, messageAlert: 'Data is not complete !', tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: 'Data is not complete !', tipeAlert: 'warning' })
: :
this.state.handleTekTekTek == 1 ? null : this.state.handleTekTekTek === 1 ? null :
this.setState({ handleTekTekTek: 1 }, () => { this.setState({ handleTekTekTek: 1 }, () => {
this.uploadFAMMR('submitted') this.uploadFAMMR('submitted')
})} })}
......
import { createMuiTheme, FormControlLabel, Input, MuiThemeProvider, Paper, TableCell, Tooltip, Typography, withStyles } from '@material-ui/core'; import { createMuiTheme, FormControlLabel, Input, MuiThemeProvider, Paper, Snackbar, TableCell, Tooltip, Typography, withStyles } from '@material-ui/core';
import MUIDataTable from 'mui-datatables'; import MUIDataTable from 'mui-datatables';
import React, { Component } from 'react'; import React, { Component } from 'react';
import NumberFormat from 'react-number-format'; import NumberFormat from 'react-number-format';
...@@ -8,6 +8,9 @@ import api from '../../api'; ...@@ -8,6 +8,9 @@ import api from '../../api';
import * as R from 'ramda'; import * as R from 'ramda';
import Images from '../../assets/Images'; import Images from '../../assets/Images';
import Constant from '../../library/Constant'; import Constant from '../../library/Constant';
import { ExcelRenderer } from 'react-excel-renderer';
import UploadFile from "../../library/Upload";
import { Alert } from '@material-ui/lab';
const LightTooltip = withStyles((theme) => ({ const LightTooltip = withStyles((theme) => ({
tooltip: { tooltip: {
...@@ -42,6 +45,7 @@ export default class OperatingIndicatorMR extends Component { ...@@ -42,6 +45,7 @@ export default class OperatingIndicatorMR extends Component {
this.state = { this.state = {
dataTable: [], dataTable: [],
loading: true, loading: true,
visibleOI: true,
minValue: 0, minValue: 0,
maxValue: 0 maxValue: 0
} }
...@@ -86,21 +90,17 @@ export default class OperatingIndicatorMR extends Component { ...@@ -86,21 +90,17 @@ export default class OperatingIndicatorMR extends Component {
} }
getItemHierarki() { getItemHierarki() {
let payload = {
"report_id": this.props.report_id,
"revision": Number(this.props.revision),
"periode": this.props.periode,
"company_id": this.props.company.company_id,
"monthly_report_id": this.props.monthlyReportId,
"months": this.props.month.month_id,
// "operating_indicator_id": this.props.data.operatingIndID, let payload = {
// "report_id": this.props.data.report_id, "operating_indicator_id": this.props.data.operatingIndID,
// "company_id": this.props.data.company.company_id, "report_id": this.props.data.report_id,
// "periode": this.props.data.periode "company_id": this.props.data.company.company_id,
"periode": this.props.data.periode,
"months": this.props.data.report_id === 22 ? 1 : 23 ? 2 : 24 ? 3 : 25 ? 4 : 27 ? 5 : 28 ? 6 : 29 ? 7 : 31 ? 8 : 32 ? 9 : 33 ? 10 : 35 ? 11 : 36 ? 12 : null
} }
api.create().getHierarkiMontlyReportOI(payload).then(response => { api.create().getHierarkiMontlyReportOI(payload).then(response => {
console.log(response.data); console.log(response);
// console.log(JSON.stringify(response));
let dataTable = [] let dataTable = []
if (response.data) { if (response.data) {
let res = response.data.data let res = response.data.data
...@@ -114,17 +114,18 @@ export default class OperatingIndicatorMR extends Component { ...@@ -114,17 +114,18 @@ export default class OperatingIndicatorMR extends Component {
item.formula, item.formula,
item.level, item.level,
item.description, item.description,
item.operating_indicator.uom, item.uom === "" ? null : item.uom,
item.operating_indicator.rolling_outlook === null ? "0.0" : item.operating_indicator.rolling_outlook === "" ? "0.0" : item.operating_indicator.rolling_outlook, item.monthly_report.rolling_outlook === null ? "0.0" : item.monthly_report.rolling_outlook === "" ? "0.0" : item.monthly_report.rolling_outlook,
item.operating_indicator.master_budget === null ? "0.0" : item.operating_indicator.rolling_outlook === "" ? "0.0" : item.operating_indicator.master_budget, item.monthly_report.master_budget === null ? "0.0" : item.monthly_report.rolling_outlook === "" ? "0.0" : item.monthly_report.master_budget,
item.operating_indicator.rolling_budget === null ? "0.0" : item.operating_indicator.rolling_outlook === "" ? "0.0" : item.operating_indicator.rolling_budget, item.monthly_report.rolling_budget === null ? "0.0" : item.monthly_report.rolling_outlook === "" ? "0.0" : item.monthly_report.rolling_budget,
item.operating_indicator.actual === null ? "0.0" : item.operating_indicator.rolling_outlook === "" ? "0.0" : item.operating_indicator.actual, item.monthly_report.actual === null ? "0.0" : item.monthly_report.rolling_outlook === "" ? "0.0" : item.monthly_report.actual,
item.operating_indicator.amount_act_vs_mb === null ? "0.0" : item.operating_indicator.rolling_outlook === "" ? "0.0" : item.operating_indicator.amount_act_vs_mb, item.monthly_report.amount_act_vs_mb === null ? "0.0" : item.monthly_report.rolling_outlook === "" ? "0.0" : item.monthly_report.amount_act_vs_mb,
item.operating_indicator.percent_act_vs_mb === null ? "0.0" : item.operating_indicator.rolling_outlook === "" ? "0.0" : item.operating_indicator.percent_act_vs_mb, item.monthly_report.percent_act_vs_mb === null ? "0.0" : item.monthly_report.rolling_outlook === "" ? "0.0" : item.monthly_report.percent_act_vs_mb,
item.operating_indicator.amount_act_vs_rb === null ? "0.0" : item.operating_indicator.rolling_outlook === "" ? "0.0" : item.operating_indicator.amount_act_vs_rb, item.monthly_report.amount_act_vs_rb === null ? "0.0" : item.monthly_report.rolling_outlook === "" ? "0.0" : item.monthly_report.amount_act_vs_rb,
item.operating_indicator.percent_act_vs_rb === null ? "0.0" : item.operating_indicator.rolling_outlook === "" ? "0.0" : item.operating_indicator.percent_act_vs_rb, item.monthly_report.percent_act_vs_rb === null ? "0.0" : item.monthly_report.rolling_outlook === "" ? "0.0" : item.monthly_report.percent_act_vs_rb,
item.operating_indicator.mtd_vs_mb === null ? "0.0" : item.operating_indicator.rolling_outlook === "" ? "0.0" : item.operating_indicator.mtd_vs_mb, item.monthly_report.mtd_vs_mb === null ? "0.0" : item.monthly_report.rolling_outlook === "" ? "0.0" : item.monthly_report.mtd_vs_mb,
item.operating_indicator.mtd_vs_rb === null ? "0.0" : item.operating_indicator.rolling_outlook === "" ? "0.0" : item.operating_indicator.mtd_vs_rb, item.monthly_report.mtd_vs_rb === null ? "0.0" : item.monthly_report.rolling_outlook === "" ? "0.0" : item.monthly_report.mtd_vs_rb,
item.order,
]) ])
} }
if (item.children !== null) { if (item.children !== null) {
...@@ -143,17 +144,18 @@ export default class OperatingIndicatorMR extends Component { ...@@ -143,17 +144,18 @@ export default class OperatingIndicatorMR extends Component {
item.formula, item.formula,
item.level, item.level,
item.description, item.description,
item.operating_indicator.uom, item.uom === "" ? null : item.uom,
item.operating_indicator.rolling_outlook === null ? "0.0" : item.operating_indicator.rolling_outlook === "" ? "0.0" : item.operating_indicator.rolling_outlook, item.monthly_report.rolling_outlook === null ? "0.0" : item.monthly_report.rolling_outlook === "" ? "0.0" : item.monthly_report.rolling_outlook,
item.operating_indicator.master_budget === null ? "0.0" : item.operating_indicator.rolling_outlook === "" ? "0.0" : item.operating_indicator.master_budget, item.monthly_report.master_budget === null ? "0.0" : item.monthly_report.rolling_outlook === "" ? "0.0" : item.monthly_report.master_budget,
item.operating_indicator.rolling_budget === null ? "0.0" : item.operating_indicator.rolling_outlook === "" ? "0.0" : item.operating_indicator.rolling_budget, item.monthly_report.rolling_budget === null ? "0.0" : item.monthly_report.rolling_outlook === "" ? "0.0" : item.monthly_report.rolling_budget,
item.operating_indicator.actual === null ? "0.0" : item.operating_indicator.rolling_outlook === "" ? "0.0" : item.operating_indicator.actual, item.monthly_report.actual === null ? "0.0" : item.monthly_report.rolling_outlook === "" ? "0.0" : item.monthly_report.actual,
item.operating_indicator.amount_act_vs_mb === null ? "0.0" : item.operating_indicator.rolling_outlook === "" ? "0.0" : item.operating_indicator.amount_act_vs_mb, item.monthly_report.amount_act_vs_mb === null ? "0.0" : item.monthly_report.rolling_outlook === "" ? "0.0" : item.monthly_report.amount_act_vs_mb,
item.operating_indicator.percent_act_vs_mb === null ? "0.0" : item.operating_indicator.rolling_outlook === "" ? "0.0" : item.operating_indicator.percent_act_vs_mb, item.monthly_report.percent_act_vs_mb === null ? "0.0" : item.monthly_report.rolling_outlook === "" ? "0.0" : item.monthly_report.percent_act_vs_mb,
item.operating_indicator.amount_act_vs_rb === null ? "0.0" : item.operating_indicator.rolling_outlook === "" ? "0.0" : item.operating_indicator.amount_act_vs_rb, item.monthly_report.amount_act_vs_rb === null ? "0.0" : item.monthly_report.rolling_outlook === "" ? "0.0" : item.monthly_report.amount_act_vs_rb,
item.operating_indicator.percent_act_vs_rb === null ? "0.0" : item.operating_indicator.rolling_outlook === "" ? "0.0" : item.operating_indicator.percent_act_vs_rb, item.monthly_report.percent_act_vs_rb === null ? "0.0" : item.monthly_report.rolling_outlook === "" ? "0.0" : item.monthly_report.percent_act_vs_rb,
item.operating_indicator.mtd_vs_mb === null ? "0.0" : item.operating_indicator.rolling_outlook === "" ? "0.0" : item.operating_indicator.mtd_vs_mb, item.monthly_report.mtd_vs_mb === null ? "0.0" : item.monthly_report.rolling_outlook === "" ? "0.0" : item.monthly_report.mtd_vs_mb,
item.operating_indicator.mtd_vs_rb === null ? "0.0" : item.operating_indicator.rolling_outlook === "" ? "0.0" : item.operating_indicator.mtd_vs_rb, item.monthly_report.mtd_vs_rb === null ? "0.0" : item.monthly_report.rolling_outlook === "" ? "0.0" : item.monthly_report.mtd_vs_rb,
item.order,
]) ])
if (item.children !== null) { if (item.children !== null) {
if (item.children.length > 0) { if (item.children.length > 0) {
...@@ -171,10 +173,10 @@ export default class OperatingIndicatorMR extends Component { ...@@ -171,10 +173,10 @@ export default class OperatingIndicatorMR extends Component {
downloadTemplate = async () => { downloadTemplate = async () => {
let res = await fetch( let res = await fetch(
`https://tia.eksad.com/tia-reporting-dev/public/transaction/monthly_report_oi/download_template?report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}` `https://tia.eksad.com/tia-reporting-dev/public/transaction/monthly_report_oi/download_template?report_id=${this.props.data.report_id}&&company_id=${this.props.data.company.company_id}&&year=${this.props.data.periode}`
) )
res = await res.blob() res = await res.blob()
// console.log(res) // // console.log(res)
if (res.size > 0) { if (res.size > 0) {
let url = window.URL.createObjectURL(res); let url = window.URL.createObjectURL(res);
let a = document.createElement('a'); let a = document.createElement('a');
...@@ -185,10 +187,10 @@ export default class OperatingIndicatorMR extends Component { ...@@ -185,10 +187,10 @@ export default class OperatingIndicatorMR extends Component {
} }
async downloadAllData() { async downloadAllData() {
let url = `https://tia.eksad.com/tia-reporting-dev/public/transaction/monthly_report_oi/export_monthly_report?monthly_report_id=${this.props.monthlyReportId}&&report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&revision=${this.props.revision}&&months=${this.props.month.month_id}` let url = `https://tia.eksad.com/tia-reporting-dev/public/transaction/monthly_report_oi/export_monthly_report?operating_indicator_id=${this.props.data.operatingIndID == null ? "" : this.props.data.operatingIndID}&&report_id=${this.props.data.report_id}&&company_id=${this.props.data.company.company_id}&&year=${this.props.data.periode}&&months=${this.props.data.report_id === 22 ? 1 : 23 ? 2 : 24 ? 3 : 25 ? 4 : 27 ? 5 : 28 ? 6 : 29 ? 7 : 31 ? 8 : 32 ? 9 : 33 ? 10 : 35 ? 11 : 36 ? 12 : null}`
console.log(url); console.log(url);
let res = await fetch( let res = await fetch(
`https://tia.eksad.com/tia-reporting-dev/public/transaction/monthly_report_oi/export_monthly_report?monthly_report_id=${this.props.monthlyReportId === null ? "" : this.props.monthlyReportId}&&report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&revision=${this.props.revision}&&months=${this.props.month.month_id}` `https://tia.eksad.com/tia-reporting-dev/public/transaction/monthly_report_oi/export_monthly_report?operating_indicator_id=${this.props.data.operatingIndID === null ? "" : this.props.data.operatingIndID}&&report_id=${this.props.data.report_id}&&company_id=${this.props.data.company.company_id}&&year=${this.props.data.periode}&&months=${this.props.data.report_id === 22 ? 1 : 23 ? 2 : 24 ? 3 : 25 ? 4 : 27 ? 5 : 28 ? 6 : 29 ? 7 : 31 ? 8 : 32 ? 9 : 33 ? 10 : 35 ? 11 : 36 ? 12 : null}`
) )
res = await res.blob() res = await res.blob()
this.setState({ loading: false }) this.setState({ loading: false })
...@@ -201,8 +203,7 @@ export default class OperatingIndicatorMR extends Component { ...@@ -201,8 +203,7 @@ export default class OperatingIndicatorMR extends Component {
} }
} }
backToMonthlyReport(type) { createData(type) {
// console.log(this.state.dataTable);
let data = [] let data = []
this.state.dataTable.map(i => { this.state.dataTable.map(i => {
data.push({ data.push({
...@@ -221,31 +222,19 @@ export default class OperatingIndicatorMR extends Component { ...@@ -221,31 +222,19 @@ export default class OperatingIndicatorMR extends Component {
}) })
}) })
let payload = { let payload = {
"monthly_report_id": this.props.submissionID, "operating_indicator_id": this.props.data.operatingIndID,
"company_id": this.props.company.company_id, "report_id": this.props.data.report_id,
"periode": this.props.periode, "company_id": this.props.data.company.company_id,
"report_id": this.props.report_id, "periode": this.props.data.periode,
"status": type, "status": type,
"months": this.props.month.month_id, "months": this.props.data.report_id === 22 ? 1 : 23 ? 2 : 24 ? 3 : 25 ? 4 : 27 ? 5 : 28 ? 6 : 29 ? 7 : 31 ? 8 : 32 ? 9 : 33 ? 10 : 35 ? 11 : 36 ? 12 : null,
"operating_indicator": data "monthly_report": data
} }
api.create('UPLOAD').createMonthlyReportOI(payload).then(response => { console.log(payload);
console.log(response); // // console.log('=========================')
if (response.data) { // // console.log(JSON.stringify(payload))
if (response.data.status === "success") { this.props.saveMonthlyOI(payload)
this.props.saveToMonthlyReport() this.props.onClickClose()
} else {
this.setState({ loading: false }, () => {
this.props.saveToMonthlyReport()
})
}
} else {
this.setState({ loading: false }, () => {
this.getSubmission()
document.body.style.overflow = 'unset';
})
}
})
} }
render() { render() {
...@@ -285,10 +274,10 @@ export default class OperatingIndicatorMR extends Component { ...@@ -285,10 +274,10 @@ export default class OperatingIndicatorMR extends Component {
const handleVariance = (tableMeta, dex, type) => { const handleVariance = (tableMeta, dex, type) => {
let total = 0 let total = 0
if (dex === 1) { if (dex === 1) {
total = Number(tableMeta.rowData[10]) - Number(tableMeta.rowData[8]) total = Number(tableMeta.rowData[10]) - Number(tableMeta.rowData[8]).toFixed(1)
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = Number(total).toFixed(1) dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = Number(total).toFixed(1)
} else if (dex === 2) { } else if (dex === 2) {
total = Number(tableMeta.rowData[10]) - Number(tableMeta.rowData[9]) total = Number(tableMeta.rowData[10]) - Number(tableMeta.rowData[9]).toFixed(1)
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = Number(total).toFixed(1) dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = Number(total).toFixed(1)
} }
return total return total
...@@ -308,6 +297,75 @@ export default class OperatingIndicatorMR extends Component { ...@@ -308,6 +297,75 @@ export default class OperatingIndicatorMR extends Component {
return total return total
} }
const handleFormula = (data, tableMeta, type) => {
let arrayFormula = tableMeta.rowData[3].match(/[a-zA-Z]+|[0-9]+|[-!$%^&*()_+|~=`{}\[\]:";'<>?,.\/]+(?:\.[0-9]+@|)/g)
let arrayJumlah = []
let tambahan = false
let opet = ""
arrayFormula.map((item, indexs) => {
if (item == 'X') {
tambahan = true
} else if (item == '-' || item == '+' || item == '/' || item == '*') {
arrayJumlah.push(item)
} else {
let index = dataTable2.findIndex((val) => val[17] == item)
if (tambahan) {
if (item == '-' || item == '+' || item == '/' || item == '*') {
opet = item
} else {
arrayJumlah.push(opet == '' ? Number(item) : Number(String(opet + String(item))))
tambahan = false
opet = ""
}
} else {
if (index != -1) {
arrayJumlah.push(dataTable2[index][tableMeta.columnIndex + type])
}
}
}
})
let array = arrayJumlah
let total = 0
let opt = ""
array.map((item, index) => {
if (item == "+") {
opt = "tambah"
} else if (item == "-") {
opt = "kurang"
} else if (item == "*") {
opt = "kali"
} else if (item == "/") {
opt = "bagi"
} else {
if (opt == "tambah") {
total = Number(total) + Number(item)
} else if (opt == "kurang") {
total = Number(total) - Number(item)
} else if (opt == "kali") {
total = Number(total) * Number(item)
// if (tableMeta.rowData[22] === 3) {
// console.log(dataTable2[tableMeta.rowIndex]);
// console.log(total);
// console.log(item);
// console.log(arrayJumlah);
// }
} else if (opt == "bagi") {
total = R.equals((Number(total) / Number(item)), NaN) ? '0' : Number(total) / Number(item)
} else {
total += Number(item)
}
}
})
let a = dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = Number(total)
return a
}
let columns = [ let columns = [
{ {
name: "", name: "",
...@@ -394,11 +452,11 @@ export default class OperatingIndicatorMR extends Component { ...@@ -394,11 +452,11 @@ export default class OperatingIndicatorMR extends Component {
control={ control={
<Input <Input
disableUnderline={true} disableUnderline={true}
style={{ color: "#5198ea", fontSize: 12, textAlign: 'left', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} style={{ color: "#000", fontSize: 12, textAlign: 'left', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
defaultValue={"Ton"} defaultValue={val}
// onBlur={(event) => { // onBlur={(event) => {
// // updateValue(event.target.value) // // updateValue(event.target.value)
// handleNotes(event.target.value, tableMeta) // handleNotes(event.target.value, tableMeta)
...@@ -438,6 +496,24 @@ export default class OperatingIndicatorMR extends Component { ...@@ -438,6 +496,24 @@ export default class OperatingIndicatorMR extends Component {
value={Number(handleValue(tableMeta, 0)).toFixed(1)} value={Number(handleValue(tableMeta, 0)).toFixed(1)}
/> />
</span> : </span> :
tableMeta.rowData[0] === 6 ?
<div style={{ flex: 1 }}>
<FormControlLabel
style={{ margin: 0 }}
value={tableMeta.rowData[7]}
control={
<NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={Number(handleFormula(val, tableMeta, 0)).toFixed(1)}
/>
}
/>
</div>
:
<div style={{ flex: 1 }}> <div style={{ flex: 1 }}>
<FormControlLabel <FormControlLabel
style={{ margin: 0 }} style={{ margin: 0 }}
...@@ -509,6 +585,24 @@ export default class OperatingIndicatorMR extends Component { ...@@ -509,6 +585,24 @@ export default class OperatingIndicatorMR extends Component {
/> />
</span> </span>
: :
tableMeta.rowData[0] === 6 ?
<div style={{ flex: 1 }}>
<FormControlLabel
style={{ margin: 0 }}
value={tableMeta.rowData[8]}
control={
<NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={Number(handleFormula(val, tableMeta, 1)).toFixed(1)}
/>
}
/>
</div>
:
<div style={{ flex: 1 }}> <div style={{ flex: 1 }}>
<FormControlLabel <FormControlLabel
style={{ margin: 0 }} style={{ margin: 0 }}
...@@ -544,6 +638,24 @@ export default class OperatingIndicatorMR extends Component { ...@@ -544,6 +638,24 @@ export default class OperatingIndicatorMR extends Component {
/> />
</span> </span>
: :
tableMeta.rowData[0] === 6 ?
<div style={{ flex: 1 }}>
<FormControlLabel
style={{ margin: 0 }}
value={tableMeta.rowData[9]}
control={
<NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={Number(handleFormula(val, tableMeta, 1)).toFixed(1)}
/>
}
/>
</div>
:
<div style={{ flex: 1 }}> <div style={{ flex: 1 }}>
<FormControlLabel <FormControlLabel
style={{ margin: 0 }} style={{ margin: 0 }}
...@@ -981,77 +1093,91 @@ export default class OperatingIndicatorMR extends Component { ...@@ -981,77 +1093,91 @@ export default class OperatingIndicatorMR extends Component {
return ( return (
<div style={{ height: this.props.height, backgroundColor: '#f8f8f8', marginBottom: 100, minHeight: 1000 }}> <div style={{ height: this.props.height, backgroundColor: '#f8f8f8', marginBottom: 100, minHeight: 1000 }}>
{this.state.loading && loadingComponent}
<div className={"main-color"} style={{ height: 78, flex: 1, display: 'flex', alignItems: 'center', paddingLeft: 20 }}> <div className={"main-color"} style={{ height: 78, flex: 1, display: 'flex', alignItems: 'center', paddingLeft: 20 }}>
<Typography style={{ fontSize: '16px', color: 'white' }}>Monthly Report</Typography> <Typography style={{ fontSize: '16px', color: 'white' }}>Monthly Report</Typography>
</div> </div>
<Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
<Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
{this.state.messageAlert}
</Alert>
</Snackbar>
<div style={{ flex: 1, padding: 20, width: '100%' }}> <div style={{ flex: 1, padding: 20, width: '100%' }}>
<Paper style={{ paddingTop: 10 }}> {this.state.visibleOI === true ?
<div style={{ borderBottom: 'solid 1px #c4c4c4' }} > <Paper style={{ paddingTop: 10, paddingBottom: 20 }}>
<Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Monthly Report - Operating Indicator</Typography> <div style={{ borderBottom: 'solid 1px #c4c4c4' }} >
</div> <Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Monthly Report - Operating Indicator</Typography>
<div style={{ padding: 20 }}>
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
<div>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{this.props.company.company_name}</Typography>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Period : {this.props.periode} (rev.{this.props.revision})</Typography>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
</div>
<div style={{ width: '50%' }}>
<div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
<a data-tip={'Download Template'} data-for="template">
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
margin: 5
}}
onClick={() => this.downloadTemplate()}
>
<img src={Images.template} />
</button>
</a>
<ReactTooltip border={true} id="template" place="bottom" type="light" effect="solid" />
<a data-tip={'Upload'} data-for="upload">
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
margin: 5
}}
onClick={() => null}
>
<img src={Images.upload} />
</button>
</a>
<ReactTooltip border={true} id="upload" place="bottom" type="light" effect="solid" />
<a data-tip={'Download'} data-for="download">
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
margin: 5
}}
onClick={() =>
this.setState({ loading: true }, () => {
setTimeout(() => {
this.downloadAllData()
}, 100);
})}
>
<img src={Images.download} />
</button>
</a>
<ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" />
</div>
</div>
</div> </div>
<div style={{ padding: 20 }}>
{!this.state.emptyData && <div style={{ display: 'flex', justifyContent: 'space-between' }}>
<div>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{this.props.company.company_name}</Typography>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>
Period : {
this.props.data.report_id === 22 ? 'Jan' :
this.props.data.report_id === 23 ? 'Feb' :
this.props.data.report_id === 24 ? 'Mar' :
this.props.data.report_id === 23 ? 'Apr' :
this.props.data.report_id === 23 ? 'May' :
this.props.data.report_id === 23 ? 'Jun' :
this.props.data.report_id === 23 ? 'Jul' :
this.props.data.report_id === 23 ? 'Aug' :
this.props.data.report_id === 23 ? 'Sep' :
this.props.data.report_id === 23 ? 'Oct' :
this.props.data.report_id === 23 ? 'Nov' :
this.props.data.report_id === 23 ? 'Dec' : "" } {this.props.data.periode}
</Typography>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
</div>
<div style={{ width: '50%' }}>
<div style={{ justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
{(this.props.permission.create || this.props.permission.edit) && this.props.isSubmit && <a data-tip={'Download Template'} data-for="template">
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
margin: 5
}}
onClick={() => this.downloadTemplate()}
>
<img src={Images.template} />
</button>
</a>}
<ReactTooltip border={true} id="template" place="bottom" type="light" effect="solid" />
{(this.props.permission.create || this.props.permission.edit) && this.props.isSubmit && <a data-tip={'Upload'} data-for="upload">
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
margin: 5
}}
onClick={() => this.setState({ visibleUpload: true, editable: true })}
>
<img src={Images.upload} />
</button>
</a>}
<ReactTooltip border={true} id="upload" place="bottom" type="light" effect="solid" />
<a data-tip={'Download'} data-for="download">
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
margin: 5
}}
onClick={() => this.downloadAllData()}
>
<img src={Images.download} />
</button>
</a>
<ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" />
</div>
</div>
</div>}
<div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}> <div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
{!this.state.loading && ( {this.state.loading && loadingComponent}
<MuiThemeProvider theme={getMuiTheme()}> <MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable <MUIDataTable
data={dataTable2} data={dataTable2}
...@@ -1059,50 +1185,41 @@ export default class OperatingIndicatorMR extends Component { ...@@ -1059,50 +1185,41 @@ export default class OperatingIndicatorMR extends Component {
options={options} options={options}
/> />
</MuiThemeProvider> </MuiThemeProvider>
)} </div>
<Typography style={{ fontSize: '11px', color: '#4b4b4b', marginTop: 20 }}>Last Updated by : {this.state.updateBy}</Typography>
</div> </div>
{/* {this.props.isApprover === true || this.state.dataTable.length == 0 ? null : <div className="grid grid-2x">
(this.props.lastStatus === 'SUBMIT' || this.props.lastStatus === 'REVISION') && this.props.prevRevision === false && (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted') ? */}
<div className="grid grid-2x" style={{ marginTop: 20 }}>
<div className="col-1"> <div className="col-1">
<button <button
className="button"
type="button" type="button"
onClick={() => this.setState({ loading: true }, () => {
setTimeout(() => {
this.props.onClickClose()
}, 100);
})}
style={{ style={{
backgroundColor: 'transparent', backgroundColor: 'transparent',
cursor: 'pointer', cursor: 'pointer',
borderColor: 'transparent', borderColor: 'transparent',
outline: 'none'
}} }}
onClick={() => {
this.props.onClickClose()
this.props.getReport()
}
}
> >
<div style={{ backgroundColor: '#019ce5', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}> <div style={{ backgroundColor: '#019ce5', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Back</Typography> <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Back</Typography>
</div> </div>
</button> </button>
</div> </div>
<div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%' }}> {!this.state.emptyData && (this.props.permission.create || this.props.permission.edit) && this.props.isSubmit && <div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%' }}>
<button <button
className="button"
type="button" type="button"
style={{ onClick={() =>
backgroundColor: 'transparent', this.setState({ loading: true, editable: false }, () => {
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none',
marginRight: 20
}}
onClick={() => {
this.setState({ loading: true }, () => {
setTimeout(() => { setTimeout(() => {
this.setState({ loading: false }) this.setState({ loading: false, buttonError: false })
// this.handleValidate()
}, 100); }, 100);
}) })
}} }
style={{ marginRight: 20 }}
> >
<div style={{ backgroundColor: '#fff', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', border: 'solid 1px #354960' }}> <div style={{ backgroundColor: '#fff', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', border: 'solid 1px #354960' }}>
<Typography style={{ fontSize: '11px', color: '#354960', textAlign: 'center' }}>Calculate</Typography> <Typography style={{ fontSize: '11px', color: '#354960', textAlign: 'center' }}>Calculate</Typography>
...@@ -1111,21 +1228,19 @@ export default class OperatingIndicatorMR extends Component { ...@@ -1111,21 +1228,19 @@ export default class OperatingIndicatorMR extends Component {
<button <button
className="button" className="button"
type="button" type="button"
disabled={this.state.editable}
style={{ style={{
backgroundColor: 'transparent', backgroundColor: 'transparent',
cursor: this.state.saveDraft !== true ? 'pointer' : 'default', cursor: this.state.editable === true ? 'default' : 'pointer',
borderColor: 'transparent', borderColor: 'transparent',
outline: 'none', outline: 'none',
marginRight: 20 marginRight: 20
}} }}
onClick={() => onClick={() => this.setState({ loading: true }, () => {
this.state.saveDraft === true ? setTimeout(() => {
null : this.createData("draft")
this.state.handleTekTekTek == 1 ? null : }, 100);
this.setState({ handleTekTekTek: 1 }, () => { })}
this.backToMonthlyReport('draft')
})
}
> >
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}> <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save as Draft</Typography> <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save as Draft</Typography>
...@@ -1133,34 +1248,191 @@ export default class OperatingIndicatorMR extends Component { ...@@ -1133,34 +1248,191 @@ export default class OperatingIndicatorMR extends Component {
</button> </button>
<button <button
type="button" type="button"
// disabled={this.state.buttonError} disabled={this.state.editable}
onClick={() => onClick={() => this.setState({ loading: true }, () => {
this.state.buttonError ? setTimeout(() => {
this.setState({ alert: true, messageAlert: 'Data is not complete !', tipeAlert: 'warning' }) this.createData("submitted")
: }, 100);
this.state.handleTekTekTek == 1 ? null : })}
this.setState({ handleTekTekTek: 1 }, () => {
this.backToMonthlyReport('submitted')
})}
style={{ style={{
backgroundColor: 'transparent', backgroundColor: 'transparent',
cursor: this.state.buttonError === true ? 'default' : 'pointer', cursor: this.state.editable === true ? 'default' : 'pointer',
borderColor: 'transparent', borderColor: 'transparent',
outline: 'none', outline: 'none',
marginRight: 20
}} }}
> >
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}> <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save & Complete</Typography> <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save & Complete</Typography>
</div> </div>
</button> </button>
</div>}
</div>
</Paper>
:
<Paper style={{ paddingTop: 10, paddingBottom: 20 }}>
<div>
<div style={{ padding: 25 }}>
<div>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{this.props.company.company_name}</Typography>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>
Period : {
this.props.data.report_id === 22 ? 'Jan' :
this.props.data.report_id === 23 ? 'Feb' :
this.props.data.report_id === 24 ? 'Mar' :
this.props.data.report_id === 23 ? 'Apr' :
this.props.data.report_id === 23 ? 'May' :
this.props.data.report_id === 23 ? 'Jun' :
this.props.data.report_id === 23 ? 'Jul' :
this.props.data.report_id === 23 ? 'Aug' :
this.props.data.report_id === 23 ? 'Sep' :
this.props.data.report_id === 23 ? 'Oct' :
this.props.data.report_id === 23 ? 'Nov' :
this.props.data.report_id === 23 ? 'Dec' : "" } {this.props.data.periode}
</Typography>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
</div>
{this.state.dataLoaded && (
<div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150) }}>
{this.state.loading && loadingComponent}
<MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable
data={dataTable2}
columns={columns}
options={options}
/>
</MuiThemeProvider>
</div>
)}
</div>
<div className="grid grid-2x">
<div className="col-1">
<button
className="button"
type="button"
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
}}
onClick={() =>
this.setState({ loading: true, visibleOI: true }, () => {
setTimeout(() => {
this.getDataDetail()
}, 100)
})}
>
<div style={{ backgroundColor: '#019ce5', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Back</Typography>
</div>
</button>
</div>
{!this.state.emptyData && this.state.templateNull && <div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%' }}>
<button
type="button"
onClick={() =>
this.setState({ loading: true, editable: false }, () => {
setTimeout(() => {
this.setState({ loading: false, buttonError: false })
}, 100);
})
}
style={{ marginRight: 20 }}
>
<div style={{ backgroundColor: '#fff', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', border: 'solid 1px #354960' }}>
<Typography style={{ fontSize: '11px', color: '#354960', textAlign: 'center' }}>Calculate</Typography>
</div>
</button>
<button
className="button"
type="button"
style={{
backgroundColor: 'transparent',
cursor: this.state.editable === true ? 'default' : 'pointer',
borderColor: 'transparent',
outline: 'none',
marginRight: 20
}}
disabled={this.state.editable}
onClick={() =>
this.state.editable === true ?
null : this.setState({ loading: true }, () => {
setTimeout(() => {
this.uploadOI("draft")
}, 100);
})}
>
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save as Draft</Typography>
</div>
</button>
<button
type="button"
onClick={() =>
this.state.editable === true ?
null :
this.setState({ loading: true }, () => {
setTimeout(() => {
this.uploadOI("submitted")
}, 100);
})}
disabled={this.state.editable}
style={{
backgroundColor: 'transparent',
cursor: this.state.editable === true ? 'default' : 'pointer',
borderColor: 'transparent',
outline: 'none',
marginRight: 20
}}
>
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save & Complete</Typography>
</div>
</button>
</div>}
</div>
</div>
</Paper>}
</div>
{this.state.visibleUpload && (
<div className="test app-popup-show">
<div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}>
<div className="popup-panel grid grid-2x main-color" style={{ height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}>
<div className="col-1" style={{ maxWidth: "inherit", display: 'flex', alignItems: 'center' }}>
<div className="popup-title">
<span style={{ color: '#fff', fontSize: 16, fontWeight: 'bold' }}>Upload File</span>
</div>
</div>
<div className="col-2 content-right" style={{ maxWidth: "inherit", alignSelf: 'center' }}>
<button
type="button"
className="btn btn-circle btn-white"
onClick={() => this.setState({ visibleUpload: false })}
>
<img src={Images.close} />
</button>
</div> </div>
</div> </div>
{/* : null <UploadFile
} */} type={this.state.uploadStatus}
percentage={this.state.percentage}
result={this.state.result}
acceptedFiles={["xlsx"]}
onHandle={(dt) => {
this.fileHandler(dt)
this.setState({ uploadStatus: 'idle', percentage: '0' })
}}
onUpload={() => {
this.state.judul === "MONTHLY REPORT - OPERATING INDICATOR" ?
this.checkUpload() :
this.setState({ alert: true, messageAlert: "Invalid Template", tipeAlert: 'warning' })
}}
/>
</div> </div>
</Paper> </div>
</div> )}
</div> </div>
) );
} }
} }
...@@ -680,7 +680,7 @@ export default class ProfitLossMR extends Component { ...@@ -680,7 +680,7 @@ export default class ProfitLossMR extends Component {
} }
} }
}, { }, {
name: "Rolling Outlook (FY 2021)", name: `Rolling Outlook (FY ${this.props.periode})`,
options: { options: {
customHeadRender: (columnMeta) => ( customHeadRender: (columnMeta) => (
<TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#07a7d0', width: 96, borderLeft: '1px #fff solid', borderRight: '1px #fff solid' }}> <TableCell style={{ ...style2, top: 0, zIndex: 99, backgroundColor: '#07a7d0', width: 96, borderLeft: '1px #fff solid', borderRight: '1px #fff solid' }}>
...@@ -698,7 +698,7 @@ export default class ProfitLossMR extends Component { ...@@ -698,7 +698,7 @@ export default class ProfitLossMR extends Component {
<div style={{ flex: 1 }}> <div style={{ flex: 1 }}>
<FormControlLabel <FormControlLabel
style={{ margin: 0 }} style={{ margin: 0 }}
value={tableMeta.rowData[9]} value={tableMeta.rowData[7]}
control={ control={
<NumberFormat <NumberFormat
thousandSeparator={true} thousandSeparator={true}
......
...@@ -113,7 +113,7 @@ export default class TaxPlanningMR extends Component { ...@@ -113,7 +113,7 @@ export default class TaxPlanningMR extends Component {
} }
api.create().getHierarkiMontlyReportTP(payload).then(response => { api.create().getHierarkiMontlyReportTP(payload).then(response => {
console.log(response); console.log(response);
console.log(payload); // console.log(payload);
let dataTable = [] let dataTable = []
if (response.data) { if (response.data) {
if (response.data.status == 'success') { if (response.data.status == 'success') {
...@@ -138,6 +138,7 @@ export default class TaxPlanningMR extends Component { ...@@ -138,6 +138,7 @@ export default class TaxPlanningMR extends Component {
}, },
item.tax_planning.trial_balance_fiscal_actual === null ? "0.0" : item.tax_planning.trial_balance_fiscal_actual === "" ? "0.0" : item.tax_planning.trial_balance_fiscal_actual, item.tax_planning.trial_balance_fiscal_actual === null ? "0.0" : item.tax_planning.trial_balance_fiscal_actual === "" ? "0.0" : item.tax_planning.trial_balance_fiscal_actual,
item.tax_planning.trial_balance_fiscal_mb === null ? "0.0" : item.tax_planning.trial_balance_fiscal_mb === "" ? "0.0" : item.tax_planning.trial_balance_fiscal_mb, item.tax_planning.trial_balance_fiscal_mb === null ? "0.0" : item.tax_planning.trial_balance_fiscal_mb === "" ? "0.0" : item.tax_planning.trial_balance_fiscal_mb,
item.tax_planning.actual_formula,
item.order, item.order,
{ tbc: item.condition_it_should_be_tax.value_tbc, fcp: item.condition_it_should_be_tax.value_fc, tbf: item.condition_it_should_be_tax.value_tbf }, { tbc: item.condition_it_should_be_tax.value_tbc, fcp: item.condition_it_should_be_tax.value_fc, tbf: item.condition_it_should_be_tax.value_tbf },
{ tbc: item.condition_if_wrong_tax.value_tbc, fcp: item.condition_if_wrong_tax.value_fc, tbf: item.condition_if_wrong_tax.value_tbf }, { tbc: item.condition_if_wrong_tax.value_tbc, fcp: item.condition_if_wrong_tax.value_fc, tbf: item.condition_if_wrong_tax.value_tbf },
...@@ -169,6 +170,7 @@ export default class TaxPlanningMR extends Component { ...@@ -169,6 +170,7 @@ export default class TaxPlanningMR extends Component {
}, },
item.tax_planning.trial_balance_fiscal_actual === null ? "0.0" : item.tax_planning.trial_balance_fiscal_actual === "" ? "0.0" : item.tax_planning.trial_balance_fiscal_actual, item.tax_planning.trial_balance_fiscal_actual === null ? "0.0" : item.tax_planning.trial_balance_fiscal_actual === "" ? "0.0" : item.tax_planning.trial_balance_fiscal_actual,
item.tax_planning.trial_balance_fiscal_mb === null ? "0.0" : item.tax_planning.trial_balance_fiscal_mb === "" ? "0.0" : item.tax_planning.trial_balance_fiscal_mb, item.tax_planning.trial_balance_fiscal_mb === null ? "0.0" : item.tax_planning.trial_balance_fiscal_mb === "" ? "0.0" : item.tax_planning.trial_balance_fiscal_mb,
item.tax_planning.actual_formula,
item.order, item.order,
{ tbc: item.condition_it_should_be_tax.value_tbc, fcp: item.condition_it_should_be_tax.value_fc, tbf: item.condition_it_should_be_tax.value_tbf }, { tbc: item.condition_it_should_be_tax.value_tbc, fcp: item.condition_it_should_be_tax.value_fc, tbf: item.condition_it_should_be_tax.value_tbf },
{ tbc: item.condition_if_wrong_tax.value_tbc, fcp: item.condition_if_wrong_tax.value_fc, tbf: item.condition_if_wrong_tax.value_tbf }, { tbc: item.condition_if_wrong_tax.value_tbc, fcp: item.condition_if_wrong_tax.value_fc, tbf: item.condition_if_wrong_tax.value_tbf },
...@@ -307,7 +309,7 @@ export default class TaxPlanningMR extends Component { ...@@ -307,7 +309,7 @@ export default class TaxPlanningMR extends Component {
checkUpload() { checkUpload() {
api.create().checkUploadMonthlyReportTP(this.state.payload).then(response => { api.create().checkUploadMonthlyReportTP(this.state.payload).then(response => {
// console.log(JSON.stringify(this.state.payload)); // console.log(JSON.stringify(this.state.payload));
console.log(this.state.payload) // console.log(this.state.payload)
console.log(response) console.log(response)
if (response.data) { if (response.data) {
if (response.data.status === 'success') { if (response.data.status === 'success') {
...@@ -330,6 +332,7 @@ export default class TaxPlanningMR extends Component { ...@@ -330,6 +332,7 @@ export default class TaxPlanningMR extends Component {
}, },
item.trial_balance_fiscal_actual === null ? "0.0" : item.trial_balance_fiscal_actual === "" ? "0.0" : item.trial_balance_fiscal_actual, item.trial_balance_fiscal_actual === null ? "0.0" : item.trial_balance_fiscal_actual === "" ? "0.0" : item.trial_balance_fiscal_actual,
item.trial_balance_fiscal_mb === null ? "0.0" : item.trial_balance_fiscal_mb === "" ? "0.0" : item.trial_balance_fiscal_mb, item.trial_balance_fiscal_mb === null ? "0.0" : item.trial_balance_fiscal_mb === "" ? "0.0" : item.trial_balance_fiscal_mb,
item.actual_formula,
item.orders, item.orders,
{ tbc: item.condition_it_should_be.tbc, fcp: item.condition_it_should_be.fcp, tbf: item.condition_it_should_be.tbf }, { tbc: item.condition_it_should_be.tbc, fcp: item.condition_it_should_be.fcp, tbf: item.condition_it_should_be.tbf },
{ tbc: item.condition_if_wrong.tbc, fcp: item.condition_if_wrong.fcp, tbf: item.condition_if_wrong.tbf }, { tbc: item.condition_if_wrong.tbc, fcp: item.condition_if_wrong.fcp, tbf: item.condition_if_wrong.tbf },
...@@ -338,12 +341,12 @@ export default class TaxPlanningMR extends Component { ...@@ -338,12 +341,12 @@ export default class TaxPlanningMR extends Component {
}) })
this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false, editable: true, saveDraft: true }, () => { this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false, editable: true, saveDraft: true }, () => {
this.state.dataTable.map(item => { this.state.dataTable.map(item => {
if (item[15].length > 0) { if (item[16].length > 0) {
// console.log('masuk') // console.log('masuk')
this.setState({ buttonError: true, errorPreview: true, editable: true, saveDraft: true }) this.setState({ buttonError: true, errorPreview: true, editable: true, saveDraft: true })
} }
}) })
console.log(this.state.dataTable); // console.log(this.state.dataTable);
}) })
} }
} }
...@@ -373,8 +376,8 @@ export default class TaxPlanningMR extends Component { ...@@ -373,8 +376,8 @@ export default class TaxPlanningMR extends Component {
} }
// console.log(data); // console.log(data);
api.create('UPLOAD').uploadMonthlyReportTP(body).then(response => { api.create('UPLOAD').uploadMonthlyReportTP(body).then(response => {
console.log(body); // console.log(body);
console.log(JSON.stringify(body)); // console.log(JSON.stringify(body));
console.log(response); console.log(response);
if (response.data) { if (response.data) {
if (response.data.status === "success") { if (response.data.status === "success") {
...@@ -521,7 +524,7 @@ export default class TaxPlanningMR extends Component { ...@@ -521,7 +524,7 @@ export default class TaxPlanningMR extends Component {
if (String(item).includes('#')) { if (String(item).includes('#')) {
let splitform = String(item).split('#') let splitform = String(item).split('#')
if (splitform[1] == 'TP1' || splitform[1] == 'TP2' || splitform[1] == 'TP3') { if (splitform[1] == 'TP1' || splitform[1] == 'TP2' || splitform[1] == 'TP3') {
let indexID = dataTable2.findIndex((val) => val[24] == splitform[0]) let indexID = dataTable2.findIndex((val) => val[13] == splitform[0])
if (indexID !== -1) { if (indexID !== -1) {
let data = splitform[1] == 'TP1' ? dataTable2[indexID][tableMeta.columnIndex].tbc : splitform[1] == 'TP2' ? dataTable2[indexID][tableMeta.columnIndex].fcp : dataTable2[indexID][tableMeta.columnIndex].tbf let data = splitform[1] == 'TP1' ? dataTable2[indexID][tableMeta.columnIndex].tbc : splitform[1] == 'TP2' ? dataTable2[indexID][tableMeta.columnIndex].fcp : dataTable2[indexID][tableMeta.columnIndex].tbf
let valuezz = data.value == undefined ? data : data.value let valuezz = data.value == undefined ? data : data.value
...@@ -546,19 +549,19 @@ export default class TaxPlanningMR extends Component { ...@@ -546,19 +549,19 @@ export default class TaxPlanningMR extends Component {
anjay.push(valuezz == "" ? 0 : valuezz) anjay.push(valuezz == "" ? 0 : valuezz)
} }
} else { } else {
let data = dex == 1 ? value.tbc : dex == 2 ? value.fcp : value.tbf let data = tableMeta.rowData[12]
// console.log(data); // console.log(data);
let indexID = data.formula.findIndex((val) => val.item_formula == String(`@${item}`) && val.periode == Number(this.props.periode)) let indexID = data.findIndex((val) => val.item_formula == String(`@${item}`) && val.periode == Number(this.props.periode))
if (indexID !== -1) { if (indexID !== -1) {
let valuezz = data.formula[indexID].value let valuezz = data[indexID].value
anjay.push(valuezz == "" ? 0 : valuezz) anjay.push(valuezz == "" ? 0 : valuezz)
} }
} }
} }
} else { } else {
let indexID = dataTable2.findIndex((val) => val[24] == item) let indexID = dataTable2.findIndex((val) => val[13] == item)
if (indexID !== -1) { if (indexID !== -1) {
if (dataTable2[indexID][24] == tableMeta.rowData[24]) { if (dataTable2[indexID][13] == tableMeta.rowData[13]) {
anjay.push(0) anjay.push(0)
} else { } else {
// console.log(dataTable2[indexID][tableMeta.columnIndex]); // console.log(dataTable2[indexID][tableMeta.columnIndex]);
...@@ -927,7 +930,7 @@ export default class TaxPlanningMR extends Component { ...@@ -927,7 +930,7 @@ export default class TaxPlanningMR extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={Number(value.tbc).toFixed(1)} value={Number(handleValueFormula(value, tableMeta, 1)).toFixed(1)}
/> />
} }
/> />
...@@ -979,7 +982,7 @@ export default class TaxPlanningMR extends Component { ...@@ -979,7 +982,7 @@ export default class TaxPlanningMR extends Component {
<div style={{ flex: 1 }}> <div style={{ flex: 1 }}>
<FormControlLabel <FormControlLabel
style={{ margin: 0 }} style={{ margin: 0 }}
value={value.fcp} value={value.tbc}
control={ control={
<NumberFormat <NumberFormat
thousandSeparator={true} thousandSeparator={true}
...@@ -987,7 +990,7 @@ export default class TaxPlanningMR extends Component { ...@@ -987,7 +990,7 @@ export default class TaxPlanningMR extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={Number(value.fcp).toFixed(1)} value={Number(handleValueFormula(value, tableMeta, 2)).toFixed(1)}
/> />
} }
/> />
...@@ -1035,54 +1038,71 @@ export default class TaxPlanningMR extends Component { ...@@ -1035,54 +1038,71 @@ export default class TaxPlanningMR extends Component {
/> />
</div> </div>
: :
// tableMeta.rowData[3] === 5 || tableMeta.rowData[3] === 6 ?
// <NumberFormat
// thousandSeparator={true}
// style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
// type="text"
// placeholder=""
// disabled={true}
// value={Number(handleTotal(tableMeta, 6)).toFixed(1)}
// />
tableMeta.rowData[3] === 5 || tableMeta.rowData[3] === 6 ? tableMeta.rowData[3] === 5 || tableMeta.rowData[3] === 6 ?
<NumberFormat <div style={{ flex: 1 }}>
thousandSeparator={true} <FormControlLabel
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }} style={{ margin: 0 }}
type="text" value={value.tbc}
placeholder="" control={
disabled={true} <NumberFormat
value={Number(handleTotal(tableMeta, 6)).toFixed(1)} thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={Number(handleValueFormula(value, tableMeta, 3)).toFixed(1)}
/>
}
/> />
: </div>
tableMeta.rowData[3] === 7 ? null :
// (Number(handleValueFormula(value, tableMeta, 3)).toFixed(1) >= Number(this.state.minValue) && Number(handleValueFormula(value, tableMeta, 3)).toFixed(1) <= Number(this.state.maxValue)) ? tableMeta.rowData[3] === 7 ?
// <NumberFormat (Number(handleValueFormula(value, tableMeta, 3)).toFixed(1) >= Number(this.state.minValue) && Number(handleValueFormula(value, tableMeta, 3)).toFixed(1) <= Number(this.state.maxValue)) ?
// thousandSeparator={true} <NumberFormat
// style={{ thousandSeparator={true}
// fontSize: 12, style={{
// textAlign: 'right', fontSize: 12,
// borderColor: 'transparent', textAlign: 'right',
// margin: 0, borderColor: 'transparent',
// width: 96, margin: 0,
// backgroundColor: 'transparent', width: 96,
// color: 'black' backgroundColor: 'transparent',
// }} color: 'black'
// type="text" }}
// placeholder="" type="text"
// disabled={true} placeholder=""
// value={Number(handleValueFormula(value, tableMeta, 3)).toFixed(1)} disabled={true}
// /> : value={Number(handleValueFormula(value, tableMeta, 3)).toFixed(1)}
// <LightTooltip title={this.state.minValue === null ? `Value Should be ${tableMeta.rowData[13].tbf}` : `Value Should be (${this.state.minValue}) up to (${this.state.maxValue})`} arrow> /> :
// <NumberFormat <LightTooltip title={this.state.minValue === null ? `Value Should be ${tableMeta.rowData[14].tbf}` : `Value Should be (${this.state.minValue}) up to (${this.state.maxValue})`} arrow>
// thousandSeparator={true} <NumberFormat
// style={{ thousandSeparator={true}
// fontSize: 12, style={{
// textAlign: 'right', fontSize: 12,
// borderColor: 'transparent', textAlign: 'right',
// margin: 0, borderColor: 'transparent',
// width: 96, margin: 0,
// backgroundColor: 'transparent', width: 96,
// color: 'red' backgroundColor: 'transparent',
// }} color: 'red'
// type="text" }}
// placeholder="" type="text"
// disabled={true} placeholder=""
// value={Number(handleValueFormula(value, tableMeta, 3)).toFixed(1)} disabled={true}
// /> value={Number(handleValueFormula(value, tableMeta, 3)).toFixed(1)}
// </LightTooltip> />
: </LightTooltip>
null :
null
} }
</div> </div>
</div> </div>
...@@ -1163,42 +1183,42 @@ export default class TaxPlanningMR extends Component { ...@@ -1163,42 +1183,42 @@ export default class TaxPlanningMR extends Component {
/> />
</div> </div>
: :
tableMeta.rowData[0] === 7 ? null tableMeta.rowData[0] === 7 ?
// (Number(handleValueFormula(value, tableMeta, 3)).toFixed(1) >= Number(this.state.minValue) && Number(handleValueFormula(value, tableMeta, 3)).toFixed(1) <= Number(this.state.maxValue)) ? (Number(handleValueFormula(value, tableMeta, 3)).toFixed(1) >= Number(this.state.minValue) && Number(handleValueFormula(value, tableMeta, 3)).toFixed(1) <= Number(this.state.maxValue)) ?
// <NumberFormat <NumberFormat
// thousandSeparator={true} thousandSeparator={true}
// style={{ style={{
// fontSize: 12, fontSize: 12,
// textAlign: 'right', textAlign: 'right',
// borderColor: 'transparent', borderColor: 'transparent',
// margin: 0, margin: 0,
// width: 96, width: 96,
// backgroundColor: 'transparent', backgroundColor: 'transparent',
// color: 'black' color: 'black'
// }} }}
// type="text" type="text"
// placeholder="" placeholder=""
// disabled={true} disabled={true}
// value={Number(handleValueFormula(value, tableMeta, 3)).toFixed(1)} value={Number(handleValueFormula(value, tableMeta, 3)).toFixed(1)}
// /> : /> :
// <LightTooltip title={this.state.minValue === null ? `Value Should be ${tableMeta.rowData[13].tbf}` : `Value Should be (${this.state.minValue}) up to (${this.state.maxValue})`} arrow> <LightTooltip title={this.state.minValue === null ? `Value Should be ${tableMeta.rowData[14].tbf}` : `Value Should be (${this.state.minValue}) up to (${this.state.maxValue})`} arrow>
// <NumberFormat <NumberFormat
// thousandSeparator={true} thousandSeparator={true}
// style={{ style={{
// fontSize: 12, fontSize: 12,
// textAlign: 'right', textAlign: 'right',
// borderColor: 'transparent', borderColor: 'transparent',
// margin: 0, margin: 0,
// width: 96, width: 96,
// backgroundColor: 'transparent', backgroundColor: 'transparent',
// color: 'red' color: 'red'
// }} }}
// type="text" type="text"
// placeholder="" placeholder=""
// disabled={true} disabled={true}
// value={Number(handleValueFormula(value, tableMeta, 3)).toFixed(1)} value={Number(handleValueFormula(value, tableMeta, 3)).toFixed(1)}
// /> />
// </LightTooltip> </LightTooltip>
: :
<div style={{ flex: 1 }}> <div style={{ flex: 1 }}>
<FormControlLabel <FormControlLabel
...@@ -1312,7 +1332,7 @@ export default class TaxPlanningMR extends Component { ...@@ -1312,7 +1332,7 @@ export default class TaxPlanningMR extends Component {
// disabled={true} // disabled={true}
// value={Number(handleValueFormula(value, tableMeta, 3)).toFixed(1)} // value={Number(handleValueFormula(value, tableMeta, 3)).toFixed(1)}
// /> : // /> :
// <LightTooltip title={this.state.minValue === null ? `Value Should be ${tableMeta.rowData[13].tbf}` : `Value Should be (${this.state.minValue}) up to (${this.state.maxValue})`} arrow> // <LightTooltip title={this.state.minValue === null ? `Value Should be ${tableMeta.rowData[14].tbf}` : `Value Should be (${this.state.minValue}) up to (${this.state.maxValue})`} arrow>
// <NumberFormat // <NumberFormat
// thousandSeparator={true} // thousandSeparator={true}
// style={{ // style={{
......
...@@ -89,46 +89,6 @@ export default class OperatingIndicator extends Component { ...@@ -89,46 +89,6 @@ export default class OperatingIndicator extends Component {
}) })
} }
// getMonth() {
// api.create().getMonthTransaction().then(response => {
// console.log(response);
// let dateNow = new Date
// let month = format(dateNow, 'MMMM')
// if (response.data) {
// if (response.data.status === "success") {
// console.log(response);
// let data = response.data.data
// let monthData = data.map((item) => {
// return {
// month_id: item.id,
// month_value: String(item.month_name).substr(0, 3)
// }
// })
// let defaultProps = {
// options: monthData,
// getOptionLabel: (option) => option.month_value,
// };
// let index = data.sort((a, b) => a - b).findIndex((val) => val.month_name == month)
// console.log(index);
// this.setState({ listMonth: defaultProps, month: index == -1 ? monthData[0] : monthData[index] }, () => {
// this.getLastPeriod()
// })
// } else {
// this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
// if (response.data.message.includes("Someone Logged In")) {
// setTimeout(() => {
// localStorage.removeItem(Constant.TOKEN)
// window.location.reload();
// }, 1000);
// }
// })
// }
// } else {
// this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
// }
// })
// }
getReportAttachment() { getReportAttachment() {
let payload = { let payload = {
"company_id": this.state.company.company_id, "company_id": this.state.company.company_id,
...@@ -295,34 +255,6 @@ export default class OperatingIndicator extends Component { ...@@ -295,34 +255,6 @@ export default class OperatingIndicator extends Component {
}) })
} }
getRevision() {
let payload = {
"company_id": this.state.company.company_id,
"periode": this.state.periode.periode
}
api.create().getRevision(payload).then(response => {
// console.log(response);
if (response.data) {
if (response.data.status === "success") {
let data = response.data.data
let revisionData = data.map((item) => {
return {
revision: item,
}
})
let defaultProps = {
options: revisionData,
getOptionLabel: (option) => option.revision,
};
this.setState({ listRevision: defaultProps, revision: revisionData[0] }, () => {
this.getReport()
this.getReportAttachment()
})
}
}
})
}
getOperatingID() { getOperatingID() {
let payload = { let payload = {
"company_id": this.state.company.company_id, "company_id": this.state.company.company_id,
...@@ -386,7 +318,8 @@ export default class OperatingIndicator extends Component { ...@@ -386,7 +318,8 @@ export default class OperatingIndicator extends Component {
visibleOperatingIndicator: false, visibleOperatingIndicator: false,
visibleDetailOpt: false, visibleDetailOpt: false,
visibleDetailMonthly: true, visibleDetailMonthly: true,
visibleDetailRolling: false visibleDetailRolling: false,
months: id === 22 ? 1 : 23 ? 2 : 24 ? 3 : 25 ? 4 : 27 ? 5 : 28 ? 6 : 29 ? 7 : 31 ? 8 : 32 ? 9 : 33 ? 10 : 35 ? 11 : 36 ? 12 : 0
}, () => console.log(this.state.dataDetail)) }, () => console.log(this.state.dataDetail))
...@@ -449,6 +382,13 @@ export default class OperatingIndicator extends Component { ...@@ -449,6 +382,13 @@ export default class OperatingIndicator extends Component {
}) })
} }
saveMonthlyOI(payload) {
api.create().createMonthlyReportOI(payload).then((response) => {
this.getReport()
this.getOperatingID()
})
}
render() { render() {
const columns = ["#", "Report Type", const columns = ["#", "Report Type",
// { // {
...@@ -671,14 +611,14 @@ export default class OperatingIndicator extends Component { ...@@ -671,14 +611,14 @@ export default class OperatingIndicator extends Component {
data={this.state.dataDetail} data={this.state.dataDetail}
height={this.props.height} height={this.props.height}
width={this.props.width} width={this.props.width}
// month={this.state.month} months={this.state.months}
company={this.state.company} company={this.state.company}
onClickClose={() => this.setState({ visibleDetailMonthly: false, visibleOperatingIndicator: true }, () => { onClickClose={() => this.setState({ visibleDetailMonthly: false, visibleOperatingIndicator: true }, () => {
this.getOperatingID() this.getOperatingID()
this.forceUpdate() this.forceUpdate()
})} })}
getReport={() => this.getOperatingID()} getReport={() => this.getOperatingID()}
saveOperatingInd={this.saveOperatingInd.bind(this)} saveMonthlyOI={this.saveMonthlyOI.bind(this)}
isSubmit={this.state.statusDetail == 'closed'? false : this.state.isSubmit} isSubmit={this.state.statusDetail == 'closed'? false : this.state.isSubmit}
permission={{ create: this.state.buttonCreate, edit: this.state.buttonEdit, delete: this.state.buttonDelete }} permission={{ create: this.state.buttonCreate, edit: this.state.buttonEdit, delete: this.state.buttonDelete }}
/> />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment