Commit fdd589a3 authored by d.arizona's avatar d.arizona

update banyak

parent 3531f4d8
......@@ -254,9 +254,12 @@ const create = (type = "") => {
const importRollingOutlookBS = (body) => api.post('transaction/balance_sheet/rolling_outlook/import_rolling_outlook', body)
const createRollingOutlookBS = (body) => api.post('transaction/balance_sheet/rolling_outlook/create_rolling_outlook', body)
const getRollingOutlookPL = (body) => api.post('transaction/profit_loss/rolling_outlook/get_report_hierarki', body)
const createRollingOutlookPL = (body) => api.post('transaction/profit_loss/rolling_outlook/create_rolling_outlook', body)
const checkImportRollingOutlookPL = (body) => api.post('transaction/profit_loss/rolling_outlook/check_import', body)
const importRollingOutlookPL = (body) => api.post('transaction/profit_loss/rolling_outlook/import_rolling_outlook', body)
const getRollingOutlookTP = (body) => api.post('transaction/rolling_outlook/tax_planning/get_report_hierarki', body)
const createRollingOutlookTP = (body) => api.post('transaction/rolling_outlook/tax_planning/store_ro_tax_planning', body)
const getSubmitRollingOutlook = (body) => api.post('transaction/rolling_outlook/get_latest_periode_submit', body)
//REPORT NEW
const getAllReportBS = (body) => api.post('/transaction/db_balance_sheet/get_report_hierarki', body)
......@@ -728,7 +731,11 @@ const create = (type = "") => {
getRollingOutlookRevision,
getRollingOutlookIsApprover,
checkImportRollingOutlookBS,
importRollingOutlookBS
importRollingOutlookBS,
createRollingOutlookPL,
checkImportRollingOutlookPL,
importRollingOutlookPL,
getSubmitRollingOutlook
}
}
......
......@@ -212,13 +212,15 @@ export default class RollingOutlook extends Component {
getLatestPeriodSubmit() {
let body = {
"company_id": this.state.company.company_id,
"periode": this.state.periode.periode
"periode": this.state.periode.periode,
"is_approver": this.state.isApprover,
"quartal": this.state.quarter.value
}
api.create().getSubmitMasterBudget(body).then(response => {
api.create().getSubmitRollingOutlook(body).then(response => {
console.log(response);
if (response.data) {
if (response.data.status === "success") {
this.setState({ isSubmit: true }, () => {
this.setState({ isSubmit: response.data.data.is_can_submit }, () => {
this.getReport()
this.getReportAttachment()
})
......@@ -751,9 +753,9 @@ export default class RollingOutlook extends Component {
borderColor: 'transparent'
}}
onClick={() =>
// tableMeta.rowData[5] == true ?
tableMeta.rowData[5] == true ?
this.clickDetail(tableMeta.rowData[1], tableMeta.rowData[4], tableMeta.rowData[2], tableMeta.rowData[3])
// : null
: null
}
>
{/* {this.state.isApprover == true ?
......@@ -1242,8 +1244,9 @@ export default class RollingOutlook extends Component {
rollingOutlookID={this.state.rollingOutlookID}
refresh={this.getRollingOutlookID.bind(this)}
onClickClose={() => this.setState({ visibleBS: false, visibleRollingOutlook: true })}
isApprover={'false'}
isApprover={this.state.isApprover}
quarter={this.state.quarter.value}
prevRevision={this.state.isSubmit ? this.state.prevRevision : true}
/>
)}
......@@ -1260,7 +1263,8 @@ export default class RollingOutlook extends Component {
onClickClose={() => this.setState({ visiblePL: false, visibleRollingOutlook: true })}
refresh={this.getRollingOutlookID.bind(this)}
quarter={this.state.quarter.value}
isApprover={'false'}
isApprover={this.state.isApprover}
prevRevision={this.state.isSubmit ? this.state.prevRevision : true}
/>
)}
......@@ -1279,7 +1283,8 @@ export default class RollingOutlook extends Component {
status={this.state.status}
lastStatus={this.state.lastStatus}
quarter={this.state.quarter.value}
isApprover={'false'}
isApprover={this.state.isApprover}
prevRevision={this.state.isSubmit ? this.state.prevRevision : true}
/>
)}
......
......@@ -64,6 +64,40 @@ export default class BalanceSheetRO extends Component {
componentDidMount() {
// this.getItemHierarki()
this.getSettingControl()
this.handleViewOnly()
}
handleViewOnly() {
let checkApprover = false
let checkLastStatus = false
let checkStatus = false
let checkPrevRev = false
if (this.props.isApprover) {
checkApprover = true
} else {
checkApprover = false
}
if (this.props.lastStatus == 'SUBMIT' || this.props.lastStatus == 'REVISION') {
checkLastStatus = true
} else {
checkLastStatus = false
}
if (this.props.prevRevision) {
checkPrevRev = true
} else {
checkPrevRev = false
}
if (this.props.status === 'revision' || this.props.status === 'not-yet' || this.props.status === 'draft' || this.props.status === 'submitted') {
checkStatus = true
} else {
checkStatus = false
}
this.setState({ viewOnly: !checkApprover && checkLastStatus && checkStatus && checkPrevRev })
}
getSettingControl() {
......@@ -212,7 +246,7 @@ export default class BalanceSheetRO extends Component {
`${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/balance_sheet/rolling_outlook/download_template?report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&quartal=${this.props.quarter}`
)
res = await res.blob()
// console.log(res)
console.log(`${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/balance_sheet/rolling_outlook/download_template?report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&quartal=${this.props.quarter}`)
if (res.size > 0) {
let url = window.URL.createObjectURL(res);
let a = document.createElement('a');
......
......@@ -103,7 +103,7 @@ export default class ProfitLossROO extends Component {
this.getItemHierarki()
// this.getLatestUpdate()
// this.getSettingControl()
// this.handleViewOnly()
this.handleViewOnly()
}
handleViewOnly() {
......@@ -395,7 +395,7 @@ export default class ProfitLossROO extends Component {
}
console.log(payload);
// console.log(JSON.stringify(payload));
api.create('UPLOAD').createRollingOutlookBS(payload).then(response => {
api.create('UPLOAD').createRollingOutlookPL(payload).then(response => {
console.log(response);
if (response.data) {
if (response.data.status === "success") {
......@@ -436,13 +436,21 @@ export default class ProfitLossROO extends Component {
if (i.length > 0) {
payload.push({
orders: i[0] === undefined ? "" : String(i[0]).trim(),
item_report_id: i[1] === undefined ? "" : String(i[1]).trim(),
item_report: i[2] === undefined ? "" : String(i[2]).trim(),
notes: i[3] === undefined ? "" : String(i[3]).trim(),
actual: i[4] === undefined ? "0" : reg.test(String(i[4])) === false ? "0" : String(i[4]).trim(),
mtd_vs_mb: i[5] === undefined ? "" : String(i[5]).trim(),
mtd_vs_rb: i[6] === undefined ? "" : String(i[6]).trim(),
mtd_vs_previous_month: i[7] === undefined ? "" : String(i[7]).trim(),
"item_report_id": i[1] === undefined ? 0 : i[1],
"item_report": i[2] === undefined ? "" : String(i[2]).trim(),
"notes": i[3] === undefined ? "0" : reg.test(String(i[3])) === false ? "0" : String(i[3]).trim(),
"january": i[4] === undefined ? "0" : reg.test(String(i[4])) === false ? "0" : String(i[4]).trim(),
"february": i[5] === undefined ? "0" : reg.test(String(i[5])) === false ? "0" : String(i[5]).trim(),
"march": i[6] === undefined ? "0" : reg.test(String(i[6])) === false ? "0" : String(i[6]).trim(),
"april": i[7] === undefined ? "0" : reg.test(String(i[7])) === false ? "0" : String(i[7]).trim(),
"may": i[8] === undefined ? "0" : reg.test(String(i[8])) === false ? "0" : String(i[8]).trim(),
"june": i[9] === undefined ? "0" : reg.test(String(i[9])) === false ? "0" : String(i[9]).trim(),
"july": i[10] === undefined ? "0" : reg.test(String(i[10])) === false ? "0" : String(i[10]).trim(),
"august": i[11] === undefined ? "0" : reg.test(String(i[11])) === false ? "0" : String(i[11]).trim(),
"september": i[12] === undefined ? "0" : reg.test(String(i[12])) === false ? "0" : String(i[12]).trim(),
"october": i[13] === undefined ? "0" : reg.test(String(i[13])) === false ? "0" : String(i[13]).trim(),
"november": i[14] === undefined ? "0" : reg.test(String(i[14])) === false ? "0" : String(i[14]).trim(),
"december": i[15] === undefined ? "0" : reg.test(String(i[15])) === false ? "0" : String(i[15]).trim(),
})
}
})
......@@ -450,7 +458,8 @@ export default class ProfitLossROO extends Component {
company_id: this.props.company.company_id,
periode: this.props.periode,
report_id: this.props.report_id,
months: this.props.month.month_id,
quartal: this.props.quarter,
rolling_outlook_id: this.props.rollingOutlookID,
status: 'submitted',
profit_loss: payload
}
......@@ -461,7 +470,7 @@ export default class ProfitLossROO extends Component {
}
checkUpload() {
api.create().checkUploadMonthlyReportPL(this.state.payload).then(response => {
api.create().checkImportRollingOutlookPL(this.state.payload).then(response => {
// console.log(JSON.stringify(this.state.payload));
console.log(response)
if (response.data) {
......@@ -475,39 +484,31 @@ export default class ProfitLossROO extends Component {
item.formula,
item.level,
item.item_report,
item.notes == null || item.notes == "null" ? "" : item.notes,
item.rolling_outlook === null ? "" : item.rolling_outlook === "" ? "" : item.rolling_outlook,
item.master_budget === "" ? "" : item.master_budget,
item.rolling_budget === "" ? "" : item.rolling_budget,
item.actual === "" ? "" : item.actual,
0,
item.actual_previous_month === null ? "" : item.actual_previous_month === "" ? "" : item.actual_previous_month,
// 0,
// 0,
// 0,
// 0,
// 0,
// 0,
item.amount_act_vs_previous_month,
item.percent_act_vs_previous_month,
item.amount_act_vs_mb,
item.percent_act_vs_mb,
item.amount_act_vs_rb,
item.percent_act_vs_rb,
item.mtd_vs_mb,
item.mtd_vs_rb,
item.mtd_vs_previous_month,
item.orders,
item.ytd_actual === null ? "" : item.ytd_actual === "" ? "" : item.ytd_actual,
item.error
item.notes,
item.last_year_total === "" ? "0" : item.last_year_total,
item.january === "" ? "0" : item.january,
item.february === "" ? "0" : item.february,
item.march === "" ? "0" : item.march,
item.april === "" ? "0" : item.april,
item.may === "" ? "0" : item.may,
item.june === "" ? "0" : item.june,
item.july === "" ? "0" : item.july,
item.august === "" ? "0" : item.august,
item.september === "" ? "0" : item.september,
item.october === "" ? "0" : item.october,
item.november === "" ? "0" : item.november,
item.december === "" ? "0" : item.december,
item.current_year_total === "" ? "0" : item.current_year_total,
"",
item.order,
]
})
this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false }, () => {
this.state.dataTable.map(item => {
if (item[24].length > 0) {
// console.log('masuk')
this.setState({ buttonError: true, errorPreview: true })
}
// if (item[24].length > 0) {
// // console.log('masuk')
// this.setState({ buttonError: true, errorPreview: true })
// }
})
// console.log(this.state.buttonError)
})
......@@ -517,27 +518,27 @@ export default class ProfitLossROO extends Component {
})
}
uploadProfitLossMR(type) {
uploadProfitLossRO(type) {
let data = []
this.state.dataTable.map(i => {
data.push({
item_report_id: i[1],
notes: String(i[6]),
rolling_outlook: String(Number(i[7]).toFixed(1)),
master_budget: String(Number(i[8]).toFixed(1)),
rolling_budget: String(Number(i[9]).toFixed(1)),
actual: String(Number(i[10]).toFixed(1)),
ytd_actual: String(Number(i[11]).toFixed(1)),
actual_previous_month: String(Number(i[12]).toFixed(1)),
amount_act_vs_previous_month: String(Number(i[13]).toFixed(1)),
percent_act_vs_previous_month: i[14],
amount_act_vs_mb: String(Number(i[15]).toFixed(1)),
percent_act_vs_mb: i[16],
amount_act_vs_rb: String(Number(i[17]).toFixed(1)),
percent_act_vs_rb: i[18],
mtd_vs_mb: String(i[19]),
mtd_vs_rb: String(i[20]),
mtd_vs_previous_month: String(i[21]),
"item_report_id": i[1],
"item_report": i[5],
"notes": String(i[6]),
"last_year_total": String(Number(i[7]).toFixed(1)),
"january": String(Number(i[8]).toFixed(1)),
"february": String(Number(i[9]).toFixed(1)),
"march": String(Number(i[10]).toFixed(1)),
"april": String(Number(i[11]).toFixed(1)),
"may": String(Number(i[12]).toFixed(1)),
"june": String(Number(i[13]).toFixed(1)),
"july": String(Number(i[14]).toFixed(1)),
"august": String(Number(i[15]).toFixed(1)),
"september": String(Number(i[16]).toFixed(1)),
"october": String(Number(i[17]).toFixed(1)),
"november": String(Number(i[18]).toFixed(1)),
"december": String(Number(i[19]).toFixed(1)),
"current_year_total": String(Number(i[20]).toFixed(1)),
})
})
let body = {
......@@ -545,21 +546,19 @@ export default class ProfitLossROO extends Component {
"company_id": this.props.company.company_id,
"periode": this.props.periode,
"report_id": this.props.report_id,
"months": this.props.month.month_id,
"quartal": this.props.quarter,
"rolling_outlook_id": this.props.rollingOutlookID,
"status": type,
"profit_loss": data
}
console.log(data);
api.create('UPLOAD').uploadMonthlyReportPL(body).then(response => {
api.create('UPLOAD').importRollingOutlookPL(body).then(response => {
console.log(response);
if (response.data) {
if (response.ok) {
if (response.data.status === "success") {
if (type == 'submitted') {
this.props.saveToMonthlyReport('PL')
} else {
this.props.saveToMonthlyReport()
}
this.props.onClickClose()
this.props.refresh()
// this.props.onClickClose()
// this.props.getReport()
} else {
......@@ -570,6 +569,8 @@ export default class ProfitLossROO extends Component {
window.location.reload();
}, 1000);
}
this.props.onClickClose()
this.props.refresh()
})
// alert(response.data.status)
}
......@@ -2608,7 +2609,7 @@ export default class ProfitLossROO extends Component {
:
this.state.handleTekTekTek == 1 ? null :
this.setState({ handleTekTekTek: 1, loading: true }, () => {
this.uploadProfitLossMR('draft')
this.uploadProfitLossRO('draft')
})
}
>
......@@ -2625,7 +2626,7 @@ export default class ProfitLossROO extends Component {
:
this.state.handleTekTekTek == 1 ? null :
this.setState({ handleTekTekTek: 1, loading: true }, () => {
this.uploadProfitLossMR('submitted')
this.uploadProfitLossRO('submitted')
})}
style={{
backgroundColor: 'transparent',
......@@ -2645,42 +2646,42 @@ export default class ProfitLossROO extends Component {
</div>
{this.state.visibleUpload && (
alert("Coming Soon...")
// <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.judulColumn).includes("TEMPLATE") && String(this.state.judulColumn).includes("UPLOAD") && String(this.state.judul).includes("MONTHLY") && String(this.state.judul).includes("REPORT") && String(this.state.judul).includes("PROFIT") && String(this.state.judul).includes("LOSS") ?
// this.checkUpload() :
// this.setState({ alert: true, messageAlert: "Invalid Template", tipeAlert: 'warning' })
// }}
// />
// </div>
// </div>
// alert("Coming Soon...")
<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.judulColumn).includes("TEMPLATE") && String(this.state.judulColumn).includes("UPLOAD") && String(this.state.judul).includes("ROLLING") && String(this.state.judul).includes("OUTLOOK") && String(this.state.judul).includes("PROFIT") && String(this.state.judul).includes("LOSS") ?
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