Commit 8f22a2c0 authored by r.kurnia's avatar r.kurnia

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

parents 98390e97 7dc4662d
......@@ -271,6 +271,7 @@ const create = (type = "") => {
const createMonthlyReportFAM = (body) => api.post('transaction/monthly_report/fam/create_monthly_report', body)
const createMonthlyReportOI = (body) => api.post('transaction/monthly_report_oi/create_monthly_report', body)
const checkUploadMonthlyReportTP = (body) => api.post('transaction/monthly_report_tp/check_import', body)
const checkUploadMonthlyReportFAM = (body) => api.post('transaction/monthly_report/fam/check_import', body)
// MonthlyPL
......@@ -484,6 +485,7 @@ const create = (type = "") => {
getHierarkiMontlyReportLOCF,
getHierarkiMontlyReportFAM,
checkUploadMonthlyReportTP,
checkUploadMonthlyReportFAM,
getMonthlyReport
}
}
......
......@@ -104,7 +104,7 @@ export default class ProfitLoss extends Component {
"submission_id": this.props.submissionID
}
api.create().getDetailReportMB(payload).then(response => {
// console.log(response);
console.log(response);
let dataTable = []
this.setState({ visibleProfitLoss: true })
if (response.data) {
......@@ -123,24 +123,28 @@ export default class ProfitLoss extends Component {
item.description,
item.profit_loss.notes === "" ? null : item.profit_loss.notes,
item.profit_loss.total_actual_before === null ? "0" : item.profit_loss.total_actual_before === "" ? "0" : item.profit_loss.total_actual_before,
this.props.status === 'CLOSED' ? Number(item.profit_loss.january).toFixed(1) : Number(item.profit_loss.january).toFixed(1),
this.props.status === 'CLOSED' ? Number(item.profit_loss.february).toFixed(1) : Number(item.profit_loss.february).toFixed(1),
this.props.status === 'CLOSED' ? Number(item.profit_loss.march).toFixed(1) : Number(item.profit_loss.march).toFixed(1),
this.props.status === 'CLOSED' ? Number(item.profit_loss.april).toFixed(1) : Number(item.profit_loss.april).toFixed(1),
this.props.status === 'CLOSED' ? Number(item.profit_loss.may).toFixed(1) : Number(item.profit_loss.may).toFixed(1),
this.props.status === 'CLOSED' ? Number(item.profit_loss.june).toFixed(1) : Number(item.profit_loss.june).toFixed(1),
this.props.status === 'CLOSED' ? Number(item.profit_loss.july).toFixed(1) : Number(item.profit_loss.july).toFixed(1),
this.props.status === 'CLOSED' ? Number(item.profit_loss.august).toFixed(1) : Number(item.profit_loss.august).toFixed(1),
this.props.status === 'CLOSED' ? Number(item.profit_loss.september).toFixed(1) : Number(item.profit_loss.september).toFixed(1),
this.props.status === 'CLOSED' ? Number(item.profit_loss.october).toFixed(1) : Number(item.profit_loss.october).toFixed(1),
this.props.status === 'CLOSED' ? Number(item.profit_loss.november).toFixed(1) : Number(item.profit_loss.november).toFixed(1),
this.props.status === 'CLOSED' ? Number(item.profit_loss.december).toFixed(1) : Number(item.profit_loss.december).toFixed(1),
Number(item.profit_loss.january).toFixed(1),
Number(item.profit_loss.february).toFixed(1),
Number(item.profit_loss.march).toFixed(1),
Number(item.profit_loss.april).toFixed(1),
Number(item.profit_loss.may).toFixed(1),
Number(item.profit_loss.june).toFixed(1),
Number(item.profit_loss.july).toFixed(1),
Number(item.profit_loss.august).toFixed(1),
Number(item.profit_loss.september).toFixed(1),
Number(item.profit_loss.october).toFixed(1),
Number(item.profit_loss.november).toFixed(1),
Number(item.profit_loss.december).toFixed(1),
item.profit_loss.total_current_year,
item.profit_loss.total_next_year,
item.profit_loss.total_more_year,
item.order
])
}
if (item.id === 20092) {
console.log(item);
console.log(dataTable);
}
if (item.children !== null) {
if (item.children.length > 0) {
item.children.map((items, indexs) => {
......@@ -159,18 +163,18 @@ export default class ProfitLoss extends Component {
item.description,
item.profit_loss.notes === "" ? null : item.profit_loss.notes,
item.profit_loss.total_actual_before === null ? "0" : item.profit_loss.total_actual_before === "" ? "0" : item.profit_loss.total_actual_before,
this.props.status === 'CLOSED' ? Number(item.profit_loss.january).toFixed(1) : Number(item.profit_loss.january).toFixed(1),
this.props.status === 'CLOSED' ? Number(item.profit_loss.february).toFixed(1) : Number(item.profit_loss.february).toFixed(1),
this.props.status === 'CLOSED' ? Number(item.profit_loss.march).toFixed(1) : Number(item.profit_loss.march).toFixed(1),
this.props.status === 'CLOSED' ? Number(item.profit_loss.april).toFixed(1) : Number(item.profit_loss.april).toFixed(1),
this.props.status === 'CLOSED' ? Number(item.profit_loss.may).toFixed(1) : Number(item.profit_loss.may).toFixed(1),
this.props.status === 'CLOSED' ? Number(item.profit_loss.june).toFixed(1) : Number(item.profit_loss.june).toFixed(1),
this.props.status === 'CLOSED' ? Number(item.profit_loss.july).toFixed(1) : Number(item.profit_loss.july).toFixed(1),
this.props.status === 'CLOSED' ? Number(item.profit_loss.august).toFixed(1) : Number(item.profit_loss.august).toFixed(1),
this.props.status === 'CLOSED' ? Number(item.profit_loss.september).toFixed(1) : Number(item.profit_loss.september).toFixed(1),
this.props.status === 'CLOSED' ? Number(item.profit_loss.october).toFixed(1) : Number(item.profit_loss.october).toFixed(1),
this.props.status === 'CLOSED' ? Number(item.profit_loss.november).toFixed(1) : Number(item.profit_loss.november).toFixed(1),
this.props.status === 'CLOSED' ? Number(item.profit_loss.december).toFixed(1) : Number(item.profit_loss.december).toFixed(1),
Number(item.profit_loss.january).toFixed(1),
Number(item.profit_loss.february).toFixed(1),
Number(item.profit_loss.march).toFixed(1),
Number(item.profit_loss.april).toFixed(1),
Number(item.profit_loss.may).toFixed(1),
Number(item.profit_loss.june).toFixed(1),
Number(item.profit_loss.july).toFixed(1),
Number(item.profit_loss.august).toFixed(1),
Number(item.profit_loss.september).toFixed(1),
Number(item.profit_loss.october).toFixed(1),
Number(item.profit_loss.november).toFixed(1),
Number(item.profit_loss.december).toFixed(1),
item.profit_loss.total_current_year,
item.profit_loss.total_next_year,
item.profit_loss.total_more_year,
......@@ -184,7 +188,7 @@ export default class ProfitLoss extends Component {
}
}
})
// console.log(dataTable)
console.log(dataTable)
this.setState({ dataTable, loading: false, buttonError: true, editable: true }, () => {
})
} else {
......@@ -418,7 +422,8 @@ export default class ProfitLoss extends Component {
profit_loss: data,
status: type
}
// console.log(data);
console.log(this.state.dataTable);
console.log(JSON.stringify(body));
api.create('UPLOAD').uploadMasterBudget(body).then(response => {
// console.log(response);
if (response.data) {
......@@ -526,6 +531,10 @@ export default class ProfitLoss extends Component {
total += Number(valItem)
}
})
// if (tableMeta.rowData[1] === 20092) {
// console.log(total);
// console.log(dataTable2[tableMeta.rowIndex]);
// }
let indexParent = dataTable2.findIndex((val) => val[1] == tableMeta.rowData[2])
if (String(tableMeta.rowData[5]).toLocaleLowerCase() == "sales price") {
let value = Number(dataTable2[tableMeta.rowIndex - 2][20]) / Number(dataTable2[tableMeta.rowIndex - 1][20])
......@@ -580,7 +589,11 @@ export default class ProfitLoss extends Component {
}
} else {
if (index != -1) {
arrayJumlah.push(dataTable2[index][tableMeta.columnIndex])
if (item === String(tableMeta.rowData[23])) {
arrayJumlah.push(0)
} else {
arrayJumlah.push(dataTable2[index][tableMeta.columnIndex])
}
}
}
}
......@@ -621,8 +634,15 @@ export default class ProfitLoss extends Component {
}
}
})
let a = dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(total)
return a
if (tableMeta.rowData[1] === 20092) {
console.log(total);
console.log(arrayJumlah);
}
// if (dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] === "" || dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] === undefined || dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] === null) {
dataTable2[tableMeta.rowIndex][tableMeta.columnIndex] = Number(total)
// }
return Number(total)
}
......
......@@ -6,6 +6,8 @@ import Images from '../../assets/Images';
import ReactTooltip from 'react-tooltip';
import NumberFormat from 'react-number-format';
import { PropagateLoader } from 'react-spinners';
import UploadFile from '../../library/Upload';
import { ExcelRenderer } from 'react-excel-renderer';
const LightTooltip = withStyles((theme) => ({
tooltip: {
......@@ -41,6 +43,7 @@ export default class FixedAssetsMovementMR extends Component {
dataTable: [],
loading: true
}
this.fileHandler = this.fileHandler.bind(this);
}
componentDidMount() {
......@@ -158,6 +161,92 @@ export default class FixedAssetsMovementMR extends Component {
}
}
fileHandler = (event) => {
let fileObj = event
ExcelRenderer(fileObj, (err, resp) => {
console.log(resp)
if (err) {
console.log(err);
}
else {
let isi = resp.rows.slice(3)
console.log(isi);
let payload = []
let reg = /^[-+]?(?:[0-9]+,)*[0-9]+(?:\.[0-9]+)?$/;
isi.map((i, index) => {
if (i.length > 0) {
payload.push({
item_report_id: i[1] === undefined ? "" : String(i[1]).trim(),
item_report: i[2] === undefined ? "" : String(i[2]).trim(),
mtd_mb: i[3] === undefined ? "0" : reg.test(String(i[3])) === false ? "0" : String(i[3]).trim()
})
}
})
let body = {
company_id: this.props.company.company_id,
periode: this.props.periode,
report_id: this.props.report_id,
fixed_asset_movement: payload,
months: this.props.month.month_id
}
console.log(body)
this.setState({ payload: body, judul: resp.rows[1][0], judulColumn: resp.rows[2] })
}
});
}
checkUpload() {
api.create().checkUploadMonthlyReportFAM(this.state.payload).then(response => {
console.log(JSON.stringify(this.state.payload));
console.log(this.state.payload)
console.log(response)
if (response.data) {
if (response.data.status === 'success') {
this.setState({ visibleUpload: false, loading: true })
// let dataTable = response.data.data.map((item, index) => {
// return [
// item.type_report_id,
// item.item_report_id,
// item.parent,
// item.formula,
// item.level,
// item.item_report,
// item.total_actual_before,
// item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.january, formula: item.january_formula } : Number(item.january).toFixed(1),
// item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.february, formula: item.february_formula } : Number(item.february).toFixed(1),
// item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.march, formula: item.march_formula } : Number(item.march).toFixed(1),
// item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.april, formula: item.april_formula } : Number(item.april).toFixed(1),
// item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.may, formula: item.may_formula } : Number(item.may).toFixed(1),
// item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.june, formula: item.june_formula } : Number(item.june).toFixed(1),
// item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.july, formula: item.july_formula } : Number(item.july).toFixed(1),
// item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.august, formula: item.august_formula } : Number(item.august).toFixed(1),
// item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.september, formula: item.september_formula } : Number(item.september).toFixed(1),
// item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.october, formula: item.october_formula } : Number(item.october).toFixed(1),
// item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.november, formula: item.november_formula } : Number(item.november).toFixed(1),
// item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.december, formula: item.december_formula } : Number(item.december).toFixed(1),
// Number(item.total_current_year).toFixed(1),
// Number(item.total_next_year).toFixed(1),
// Number(item.total_more_year).toFixed(1),
// item.orders,
// item.forecast_formula,
// item.before_formula,
// item.error
// ]
// })
// this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false, editable: true, saveDraft: true }, () => {
// this.state.dataTable.map(item => {
// if (item[12].length > 0) {
// // console.log('masuk')
// this.setState({ buttonError: true, errorPreview: true, editable: true, saveDraft: true })
// }
// })
// // console.log(this.state.dataTable);
// })
}
}
})
}
backToMonthlyReport(type) {
console.log(this.state.dataTable);
let data = []
......@@ -478,7 +567,7 @@ export default class FixedAssetsMovementMR extends Component {
<span style={{ fontSize: 12, textAlign: 'right' }}>
<NumberFormat
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"
placeholder=""
disabled={true}
......@@ -930,7 +1019,7 @@ export default class FixedAssetsMovementMR extends Component {
borderColor: 'transparent',
margin: 5
}}
onClick={() => null}
onClick={() => this.setState({ visibleUpload: true })}
>
<img src={Images.upload} />
</button>
......@@ -1008,7 +1097,8 @@ export default class FixedAssetsMovementMR extends Component {
onClick={() => {
this.setState({ loading: true }, () => {
setTimeout(() => {
this.handleValidate()
this.setState({ loading: false })
// this.handleValidate()
}, 100);
})
}}
......@@ -1068,6 +1158,43 @@ export default class FixedAssetsMovementMR extends Component {
</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>
<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={() => {
String(this.state.judul).includes("MONTHLY REPORT - FIXED ASSETS MOVEMENT") ?
this.checkUpload() :
this.setState({ alert: true, messageAlert: "Invalid Template", tipeAlert: 'warning' })
}}
/>
</div>
</div>
)}
</div>
)
}
......
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