Commit f859094d authored by Rifka Kurnia Irfiana's avatar Rifka Kurnia Irfiana

taxplan form

parent fde3083b
......@@ -103,7 +103,7 @@ export default class TaxPlanning extends Component {
item.type_report_tax.value_tbf.type_report_id,
item.id,
item.parent,
item.formula,
{tbc : item.formula_tax.value_tbc, fcp: item.formula_tax.value_fc, tbf: item.formula_tax.value_tbf },
item.level,
item.description,
{tbc : item.tax_planning.january.tbc, fcp: item.tax_planning.january.fcp, tbf: item.tax_planning.january.tbf},
......@@ -140,7 +140,7 @@ export default class TaxPlanning extends Component {
item.type_report_tax.value_tbf.type_report_id,
item.id,
item.parent,
item.formula,
{tbc : item.formula_tax.value_tbc, fcp: item.formula_tax.value_fc, tbf: item.formula_tax.value_tbf },
item.level,
item.description,
{tbc : item.tax_planning.january.tbc, fcp: item.tax_planning.january.fcp, tbf: item.tax_planning.january.tbf},
......@@ -785,48 +785,106 @@ export default class TaxPlanning extends Component {
return a
}
const handleFormula = (data, tableMeta) => {
let arrayFormula = tableMeta.rowData[6].match(/[a-zA-Z]+|[0-9]+|[-!$%^&*()_+|~=`{}\[\]:";'<>?,.\/]+(?:\.[0-9]+@|)/g)
let arrayJumlah = []
arrayFormula.map((item, indexs) => {
let index = dataTable2.findIndex((val) => val[4] == item)
if (index > 0) {
arrayJumlah.push(dataTable2[index][tableMeta.columnIndex])
const handleFormula = (data, tableMeta, month, rowColumn) => {
let rilFormula = String(rowColumn == 0 ? tableMeta.rowData[6].tbc : tableMeta.rowData[6].tbf)
if (rilFormula.includes('#')) {
if (this.props.status === "not-yet") {
let splitOrder = String(rowColumn == 0 ? tableMeta.rowData[6].tbc : tableMeta.rowData[6].tbf).split('@')
for (let index = 0; index < splitOrder.length; index++) {
if (splitOrder[index] === "") {
} else {
if (splitOrder[index].includes('#')) {
} else {
let splitOperator = splitOrder[index].match(/[a-zA-Z]+|[0-9]+|[-!$%^&*()_+|~=`{}\[\]:";'<>?,.\/]+(?:\.[0-9]+@|)/g)
let reg = /^\d+$/
splitOperator.map((item) => {
if (reg.test(item) === true) {
let i = dataTable2.findIndex((val) => val[23] == item)
if (i > 0) {
rilFormula = rilFormula.replace(item, dataTable2[i][tableMeta.columnIndex] === "" ? "0" : dataTable2[i][tableMeta.columnIndex])
}
}
})
}
}
}
let body = {
"submission_id": null,
"company_id": this.props.company.company_id,
"report_id": this.props.report_id,
"year": this.props.periode,
"month": month,
"formula": rilFormula
}
api.create().countingFormula(body).then(response => {
console.log(response);
})
} else {
arrayJumlah.push(item)
let body = {
"submission_id": this.props.submissionID,
"company_id": this.props.company.company_id,
"report_id": this.props.report_id,
"year": this.props.periode,
"month": month,
"formula": rilFormula
}
api.create().countingFormula(body).then(response => {
console.log(response)
console.log(tableMeta)
console.log(tableMeta.rowIndex)
console.log(rowColumn)
if (response.data) {
if (response.data.status === "success") {
return response.data.data.result
}
}
})
}
// if (indexs % 2 !== 0) {
// operator.push(item)
// }
})
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)
} else if (opt == "bagi") {
total = Number(total) / Number(item)
} else {
let kondisi = rowColumn == 0 ? tableMeta.rowData[6].tbc : tableMeta.rowData[6].tbf
let arrayFormula = kondisi.match(/[a-zA-Z]+|[0-9]+|[-!$%^&*()_+|~=`{}\[\]:";'<>?,.\/]+(?:\.[0-9]+@|)/g)
let arrayJumlah = []
arrayFormula.map((item, indexs) => {
let index = dataTable2.findIndex((val) => val[23] == item)
if (index > 0) {
arrayJumlah.push(dataTable2[index][tableMeta.columnIndex])
} else {
total += item
arrayJumlah.push(item)
}
}
})
let a = dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(total)
return a
// if (indexs % 2 !== 0) {
// operator.push(item)
// }
})
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)
} else if (opt == "bagi") {
total = Number(total) / Number(item)
} else {
total += item
}
}
})
let a = dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(total)
return a
}
}
const columns = [{
......@@ -975,26 +1033,24 @@ export default class TaxPlanning extends Component {
null
:
tableMeta.rowData[1] === 6 ?
// <NumberFormat
// thousandSeparator={true}
// style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
// type="text"
// placeholder=""
// disabled={true}
// value={Number(handleFormula(value, tableMeta)).toFixed(1)}
// />
null
<NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={Number(handleFormula(value, tableMeta, 1, 0)).toFixed(1)}
/>
:
tableMeta.rowData[1] === 5 ?
// <NumberFormat
// thousandSeparator={true}
// style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
// type="text"
// placeholder=""
// disabled={true}
// value={Number(handleFormula(value, tableMeta)).toFixed(1)}
// />
null
<NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={false}
value={Number(handleFormula(value, tableMeta, 1, 0)).toFixed(1)}
/>
:
tableMeta.rowData[1] === 1 ?
// value[0] === "" ?
......@@ -1131,26 +1187,24 @@ export default class TaxPlanning extends Component {
null
:
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(handleFormula(value, tableMeta)).toFixed(1)}
// />
null
<NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={true}
value={Number(handleFormula(value, tableMeta, 1, 2)).toFixed(1)}
/>
:
tableMeta.rowData[3] === 5 ?
// <NumberFormat
// thousandSeparator={true}
// style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
// type="text"
// placeholder=""
// disabled={true}
// value={Number(handleFormula(value, tableMeta)).toFixed(1)}
// />
null
<NumberFormat
thousandSeparator={true}
style={{ fontSize: 12, textAlign: 'right', borderColor: 'transparent', margin: 0, width: 96, backgroundColor: 'transparent' }}
type="text"
placeholder=""
disabled={false}
value={Number(handleFormula(value, tableMeta, 1, 2)).toFixed(1)}
/>
:
tableMeta.rowData[3] === 1 ?
// value[2] === "" ?
......
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