Commit e60849ac authored by Riri Novita's avatar Riri Novita

save monthly pl

parent 10579c37
......@@ -272,6 +272,7 @@ const create = (type = "") => {
// MonthlyPL
const getHierarkiMontlyReportPL = (body) => api.post('transaction/monthly_report_pl/get_report_hierarki', body)
const createMonthlyReportPL = (body) => api.post('transaction/monthly_report_pl/create_monthly_report', body)
//Template
const downloadTemplate = (fileName, fileType) => api.get(`attachment/download_file?fileName=${fileName}&&fileType=${fileType}`)
......@@ -405,6 +406,7 @@ const create = (type = "") => {
createSubmitReport,
createMonthlyReportBS,
createMonthlyReportTP,
createMonthlyReportPL,
getSubmission,
checkUploadMB,
getAllOperatingInd,
......
......@@ -6,6 +6,7 @@ import Images from '../../assets/Images';
import api from '../../api';
import NumberFormat from 'react-number-format';
import * as R from 'ramda';
import { PropagateLoader } from 'react-spinners';
const LightTooltip = withStyles((theme) => ({
tooltip: {
......@@ -149,6 +150,88 @@ export default class ProfitLossMR extends Component {
})
}
downloadTemplate = async () => {
let res = await fetch(
`https://tia.eksad.com/tia-reporting-dev/public/transaction/monthly_report_pl/download_template?report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}`
)
res = await res.blob()
// console.log(res)
if (res.size > 0) {
let url = window.URL.createObjectURL(res);
let a = document.createElement('a');
a.href = url;
a.download = 'Template Monthly Report Profit Loss.xlsx';
a.click();
}
}
async downloadAllData() {
let url = `https://tia.eksad.com/tia-reporting-dev/public/transaction/monthly_report_pl/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);
let res = await fetch(
`https://tia.eksad.com/tia-reporting-dev/public/transaction/monthly_report_pl/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) {
let url = window.URL.createObjectURL(res);
let a = document.createElement('a');
a.href = url;
a.download = 'Monthly Report Profit Loss.xlsx';
a.click();
}
}
backToMonthlyReport(type) {
console.log(this.state.dataTable);
let data = []
this.state.dataTable.map(i => {
data.push({
"item_report_id": i[2],
"rolling_outlook": i[6],
"master_budget": i[7],
"rolling_budget": i[8],
"actual": i[9],
"actual_previous_month": i[10],
"amount_act_vs_previous_month": i[11],
"percent_act_vs_previous_month": i[12],
"amount_act_vs_mb": i[13],
"percent_act_vs_mb": i[14],
"amount_act_vs_rb": i[15],
"percent_act_vs_rb": i[16],
"mtd_vs_previous_month": i[17],
"mtd_vs_mb": i[18],
"mtd_vs_rb": i[19]
})
})
let payload = {
"monthly_report_id": this.props.submissionID,
"company_id": this.props.company.company_id,
"periode": this.props.periode,
"report_id": this.props.report_id,
"status": type,
"months": this.props.month.month_id,
"balance_sheet": data
}
api.create('UPLOAD').createMonthlyReportPL(payload).then(response => {
console.log(response);
if (response.data) {
if (response.data.status === "success") {
this.props.saveToMonthlyReport()
} else {
this.setState({ loading: false }, () => {
this.props.saveToMonthlyReport()
})
}
} else {
this.setState({ loading: false }, () => {
this.getSubmission()
document.body.style.overflow = 'unset';
})
}
})
}
render() {
let dataTable2 = this.state.dataTable
......
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