Commit f19e40c0 authored by Faisal Hamdi's avatar Faisal Hamdi

Merge branch 'faisal' into 'master'

FAM MR

See merge request !746
parents ee35d2a5 6b571570
...@@ -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 })}
/> />
)} )}
......
...@@ -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,10 +291,9 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -299,10 +291,9 @@ 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 { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => { this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
if (response.data.message.includes("Someone Logged In")) { if (response.data.message.includes("Someone Logged In")) {
...@@ -312,10 +303,6 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -312,10 +303,6 @@ export default class FixedAssetsMovementMR extends Component {
}, 1000); }, 1000);
} }
}) })
// alert(response.data.status)
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error', loading: false })
} }
} 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,90 +365,183 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -376,90 +365,183 @@ 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)) {
baru.push(subForm)
baru.push(items)
} else { } else {
dataTable2[tableMeta.rowIndex][8] = Number(val).toFixed(1) 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) => { // console.log(baru);
let arrayFormula = tableMeta.rowData[3].match(/[a-zA-Z]+|[0-9]+|[-!$%^&*()_+|~=`{}\[\]:";'<>?,.\/]+(?:\.[0-9]+@|)/g)
let arrayJumlah = [] baru.map((item, index) => {
let tambahan = false if (item == '-' || item == '+' || item == '/' || item == '*' || item == '(' || item == ')') {
let opet = "" anjay.push(item)
} else {
if (String(item).includes('#')) {
if (String(item).includes('[M-1]')) {
let tst = String(item).replace('[M-1]', '')
let indexID = dataTable2.findIndex((val) => val[17] == tst)
// console.log(indexID);
arrayFormula.map((item, indexs) => { if (indexID !== -1) {
if (item == 'X') { let valuezz = dataTable2[indexID][8]
tambahan = true anjay.push(valuezz == "" ? 0 : valuezz)
} else if (item == '-' || item == '+' || item == '/' || item == '*') { }
arrayJumlah.push(item)
} else { } else {
let index = dataTable2.findIndex((val) => val[22] == item) let data = tableMeta.rowData[16]
if (tambahan) { let indexID = data.findIndex((val) => val.item_formula == String(`@${item}`))
if (item == '-' || item == '+' || item == '/' || item == '*') { if (indexID !== -1) {
opet = item let valuezz = data[indexID].value
anjay.push(valuezz == "" ? 0 : valuezz)
}
}
} else { } else {
arrayJumlah.push(opet == '' ? Number(item) : Number(String(opet + String(item)))) if (String(item).includes('[M-1]')) {
tambahan = false let tst = String(item).replace('[M-1]', '')
opet = "" let indexID = dataTable2.findIndex((val) => val[17] == tst)
if (indexID !== -1) {
let valuezz = dataTable2[indexID][8]
anjay.push(valuezz == "" ? 0 : valuezz)
} }
} else { } else {
if (index != -1) { let indexID = dataTable2.findIndex((val) => val[17] == item)
arrayJumlah.push(dataTable2[index][tableMeta.columnIndex + type]) 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 (opt == "tambah") {
total = Number(total) + Number(totalPrio)
} else if (opt == "kurang") {
total = Number(total) - Number(totalPrio)
} else if (opt == "kali") {
total = Number(total) * Number(totalPrio)
} else if (opt == "bagi") {
total = Number(total) / Number(totalPrio) == NaN ? 0 : Number(total) / Number(totalPrio)
} else {
total += Number(totalPrio)
}
}
} else {
if (item == "+") { if (item == "+") {
opt = "tambah" opt = "tambah"
if (prio) {
total = Number(Number(totalPrio) + Number(total))
prio = false
totalPrio = 0
optPrio = ""
}
} else if (item == "-") { } else if (item == "-") {
opt = "kurang" opt = "kurang"
if (prio) {
total = Number(Number(totalPrio) + Number(total))
prio = false
totalPrio = 0
optPrio = ""
}
} else if (item == "*") { } else if (item == "*") {
opt = "kali" opt = "kali"
if (prio) {
total = Number(Number(totalPrio) + Number(total))
prio = false
totalPrio = 0
optPrio = ""
}
} else if (item == "/") { } else if (item == "/") {
opt = "bagi" opt = "bagi"
if (prio) {
total = Number(Number(totalPrio) + Number(total))
prio = false
totalPrio = 0
optPrio = ""
}
} else { } else {
if (opt == "tambah") { if (opt == "tambah") {
total = Number(total) + Number(item) total = Number(total) + Number(item)
...@@ -467,27 +549,62 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -467,27 +549,62 @@ export default class FixedAssetsMovementMR extends Component {
total = Number(total) - Number(item) total = Number(total) - Number(item)
} else if (opt == "kali") { } else if (opt == "kali") {
total = Number(total) * Number(item) 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") { } else if (opt == "bagi") {
total = R.equals((Number(total) / Number(item)), NaN) ? '0' : Number(total) / Number(item) total = Number(total) / Number(item) == NaN ? 0 : Number(total) / Number(item)
} else { } else {
total += Number(item) 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])
// // }
// // }
// if (dataTable2[tableMeta.rowIndex][colIdx].value == undefined) {
dataTable2[tableMeta.rowIndex][colIdx] = total
// } else {
// dataTable2[tableMeta.rowIndex][column].value = total
// }
// loading = false
return total
}
let a = dataTable2[tableMeta.rowIndex][tableMeta.columnIndex + type] = Number(total) const handleChange = (value, tableMeta, type) => {
dataTable2[tableMeta.rowIndex][type] = value
// console.log(dataTable2[tableMeta.rowIndex][type]);
// console.log(value);
return a }
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 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
} }
...@@ -622,24 +748,7 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -622,24 +748,7 @@ export default class FixedAssetsMovementMR extends Component {
{ {
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 ?
<div style={{ flex: 1 }}>
<FormControlLabel
style={{ margin: 0 }}
value={value}
control={
<NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 90, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={Number(tableMeta.rowData[6]).toFixed(1)}
/>
}
/>
</div> :
tableMeta.rowData[0] === 5 ?
<span style={{ fontSize: 12, textAlign: 'right' }}> <span style={{ fontSize: 12, textAlign: 'right' }}>
<NumberFormat <NumberFormat
thousandSeparator={true} thousandSeparator={true}
...@@ -647,21 +756,25 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -647,21 +756,25 @@ export default class FixedAssetsMovementMR extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={Number(handleFormula(value, tableMeta, 0)).toFixed(1)} value={Number(handleValueFormula(tableMeta, 6)).toFixed(1)}
/> />
</span> : </span> :
tableMeta.rowData[0] === 6 ? <div style={{ flex: 1 }}>
<span style={{ fontSize: 12, textAlign: 'right' }}> <FormControlLabel
style={{ margin: 0 }}
value={value}
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(handleFormula(value, tableMeta, 0)).toFixed(1)} value={Number(value).toFixed(1)}
/> />
</span> : }
null />
</div>
} }
</div> </div>
</div> </div>
...@@ -678,10 +791,9 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -678,10 +791,9 @@ 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 }}
...@@ -693,12 +805,11 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -693,12 +805,11 @@ export default class FixedAssetsMovementMR extends Component {
type="text" type="text"
placeholder="" placeholder=""
disabled={true} disabled={true}
value={Number(tableMeta.rowData[7]).toFixed(1)} value={Number(value).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
style={{ margin: 0 }}
value={value}
control={
<NumberFormat <NumberFormat
thousandSeparator={true} thousandSeparator={true}
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=""
disabled={true} disabled={true}
value={Number(handleFormula(value, tableMeta, 2)).toFixed(1)} value={Number(value).toFixed(1)}
/> />
</span> : }
null />
</div>
} }
</div> </div>
</div> </div>
...@@ -778,14 +892,13 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -778,14 +892,13 @@ export default class FixedAssetsMovementMR extends Component {
<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>
) )
...@@ -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,10 +1005,9 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -889,10 +1005,9 @@ 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
...@@ -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,10 +1056,9 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -941,10 +1056,9 @@ 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
...@@ -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,10 +1107,9 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -993,10 +1107,9 @@ 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
...@@ -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 = (
...@@ -1337,13 +1456,13 @@ export default class FixedAssetsMovementMR extends Component { ...@@ -1337,13 +1456,13 @@ 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 }, () => {
......
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