Commit 0402a3cf authored by EKSAD's avatar EKSAD

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

parents 9dfaf10a 56a6e542
......@@ -168,6 +168,7 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') =>
const getDetailReportMB = (body) => api.post('/transaction/master_budget/get_report_hierarki', body)
const createSubmitReport = (body) => api.post('transaction/master_budget/create_submission_report', body)
const getSubmission = (body) => api.post('transaction/get_submission_id', body)
const checkUploadMB = (body) => api.post('transaction/master_budget/check_import', body)
//Template
const downloadTemplate = (fileName, fileType) => api.get(`attachment/download_file?fileName=${fileName}&&fileType=${fileType}`)
......@@ -291,7 +292,8 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') =>
updateDocument,
downloadDocument,
createSubmitReport,
getSubmission
getSubmission,
checkUploadMB
}
}
......
......@@ -8,6 +8,8 @@ import { values } from 'ramda';
import PropagateLoader from "react-spinners/PropagateLoader"
import Images from '../../assets/Images';
import ReactTooltip from 'react-tooltip';
import UploadFile from "../../library/Upload";
import { ExcelRenderer } from 'react-excel-renderer';
var ct = require("../../library/CustomTable");
const getMuiTheme = () => createMuiTheme(ct.customTable3());
......@@ -40,9 +42,12 @@ export default class BalanceSheet extends Component {
// ["Notes Receivable", "", ""],
// ["Accounts Receivable", "172,031", "97,112"],
// ["Trade Receivables - Third Party", "142,668", "77,480"],
]
],
visibleBalanceSheet: true,
disabledSave: true
}
this.handleValue = this.handleValue.bind(this)
this.fileHandler = this.fileHandler.bind(this);
}
componentDidMount() {
......@@ -753,6 +758,134 @@ export default class BalanceSheet extends Component {
this.props.onClickClose()
}
downloadTemplate = async () => {
let res = await fetch(
`https://tia.eksad.com/tia-reporting-dev/public/transaction/master_budget/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 Balance Sheet.xlsx';
a.click();
}
}
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 = []
isi.map((i, index) => {
if (i.length > 0) {
payload.push({
item_report_id: i[0] === undefined ? "" : String(i[0]).trim(),
item_report: i[1] === undefined ? "" : String(i[1]).trim(),
total_actual_before: i[2] === undefined ? "" : String(i[2]).trim(),
january: i[3] === undefined ? "" : String(i[3]).trim(),
february: i[4] === undefined ? "" : String(i[4]).trim(),
march: i[5] === undefined ? "" : String(i[5]).trim(),
april: i[6] === undefined ? "" : String(i[6]).trim(),
may: i[7] === undefined ? "" : String(i[7]).trim(),
june: i[8] === undefined ? "" : String(i[8]).trim(),
july: i[9] === undefined ? "" : String(i[9]).trim(),
august: i[10] === undefined ? "" : String(i[10]).trim(),
september: i[11] === undefined ? "" : String(i[11]).trim(),
october: i[12] === undefined ? "" : String(i[12]).trim(),
november: i[13] === undefined ? "" : String(i[13]).trim(),
december: i[14] === undefined ? "" : String(i[14]).trim(),
total_current_year: i[15] === undefined ? "" : String(i[15]).trim(),
total_next_year: i[16] === undefined ? "" : String(i[16]).trim(),
total_more_year: i[16] === undefined ? "" : String(i[17]).trim()
})
}
})
let rows = isi.map((i, index) => {
return [
String(i[0]) === '-' ? 4 : 3,
0,
0,
"",
1,
i[0] === undefined ? "" : String(i[0]),
i[1] === undefined ? "" : String(i[1]),
i[2] === undefined ? "" : String(i[2]),
i[3] === undefined ? "" : String(i[3]),
i[4] === undefined ? "" : String(i[4]),
i[5] === undefined ? "" : String(i[5]),
i[6] === undefined ? "" : String(i[6]),
i[7] === undefined ? "" : String(i[7]),
i[8] === undefined ? "" : String(i[8]),
i[9] === undefined ? "" : String(i[9]),
i[10] === undefined ? "" : String(i[10]),
i[11] === undefined ? "" : String(i[11]),
i[12] === undefined ? "" : String(i[12]),
i[13] === undefined ? "" : String(i[13]),
i[14] === undefined ? "" : String(i[14]),
i[15] === undefined ? "" : String(i[15]),
i[16] === undefined ? "" : String(i[16])
]
})
let body = {
company_id: this.props.company.company_id,
periode: this.props.periode,
report_id: this.props.report_id,
balance_sheet: payload
}
// console.log(JSON.stringify(body))
this.setState({ payload: body, buttonError: false, judul: resp.rows[1][0] })
}
});
}
checkUpload() {
api.create().checkUploadMB(this.state.payload).then(response => {
console.log(JSON.stringify(this.state.payload));
console.log(response)
if (response.data) {
if (response.data.status === 'success') {
this.setState({ visibleUpload: false, visibleBalanceSheet: 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.january,
item.february,
item.march,
item.april,
item.may,
item.june,
item.july,
item.august,
item.september,
item.october,
item.november,
item.december,
item.total_current_year,
item.total_next_year,
item.total_more_year,
item.error
]
})
this.setState({ dataTable, dataLoaded: true, loading: false })
}
}
})
}
render() {
let dataTable2 = this.state.dataTable
const handleChange = (value, tableMeta) => {
......@@ -861,13 +994,42 @@ export default class BalanceSheet extends Component {
customBodyRender: (val, tableMeta) => {
return (
<div style={{ width: 300 }}>
{tableMeta.rowData[4] == 0 ?
{tableMeta.rowData[22] ?
tableMeta.rowData[22].length > 0 ?
tableMeta.rowData[22][0].field === 'item' ?
tableMeta.rowData[4] == 0 ?
<a data-tip={tableMeta.rowData[22][0].message} data-for="account">
<span style={{ fontSize: 12, fontWeight: 'bold', color: 'red' }}>{String(tableMeta.rowData[0] === 4 ? "" : val).toUpperCase()}</span>
</a>
:
<div style={{ paddingLeft: 20 * Number(tableMeta.rowData[4]) }}>
<a data-tip={tableMeta.rowData[22][0].message} data-for="account">
<span style={{ fontSize: 12, color: 'red' }}>{tableMeta.rowData[0] === 4 ? "" : val}</span>
</a>
</div>
:
tableMeta.rowData[4] == 0 ?
<span style={{ fontSize: 12, fontWeight: 'bold' }}>{String(tableMeta.rowData[0] === 4 ? "" : val).toUpperCase()}</span>
:
<div style={{ paddingLeft: 20 * Number(tableMeta.rowData[4]) }}>
<span style={{ fontSize: 12 }}>{tableMeta.rowData[0] === 4 ? "" : val}</span>
</div>
:
tableMeta.rowData[4] == 0 ?
<span style={{ fontSize: 12, fontWeight: 'bold' }}>{String(tableMeta.rowData[0] === 4 ? "" : val).toUpperCase()}</span>
:
<div style={{ paddingLeft: 20 * Number(tableMeta.rowData[4]) }}>
<span style={{ fontSize: 12 }}>{tableMeta.rowData[0] === 4 ? "" : val}</span>
</div>
:
tableMeta.rowData[4] == 0 ?
<span style={{ fontSize: 12, fontWeight: 'bold' }}>{String(tableMeta.rowData[0] === 4 ? "" : val).toUpperCase()}</span>
:
<div style={{ paddingLeft: 20 * Number(tableMeta.rowData[4]) }}>
<span style={{ fontSize: 12 }}>{tableMeta.rowData[0] === 4 ? "" : val}</span>
</div>
}
<ReactTooltip border={true} id="account" place="bottom" type="light" effect="solid" />
</div>
)
}
......@@ -2248,6 +2410,12 @@ export default class BalanceSheet extends Component {
)
}
}
},
{
name: "",
options: {
display: false
}
}
]
const loadingComponent = (
......@@ -2268,6 +2436,7 @@ export default class BalanceSheet extends Component {
</div>
{this.state.loading && loadingComponent}
<div style={{ flex: 1, padding: 20, width: '100%' }}>
{this.state.visibleBalanceSheet === true ?
<Paper style={{ paddingTop: 10, paddingBottom: 20 }}>
<div style={{ borderBottom: 'solid 1px #c4c4c4' }} >
<Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Budget Tahunan - Balance Sheet</Typography>
......@@ -2289,7 +2458,7 @@ export default class BalanceSheet extends Component {
borderColor: 'transparent',
margin: 5
}}
onClick={() => null}
onClick={() => this.downloadTemplate()}
>
<img src={Images.template} />
</button>
......@@ -2303,7 +2472,7 @@ export default class BalanceSheet extends Component {
borderColor: 'transparent',
margin: 5
}}
onClick={() => null}
onClick={() => this.setState({ visibleUpload: true })}
>
<img src={Images.upload} />
</button>
......@@ -2362,27 +2531,95 @@ export default class BalanceSheet extends Component {
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none'
outline: 'none',
marginRight: 20
}}
onClick={() => {
this.props.onClickClose()
}}
>
<div style={{ backgroundColor: '#fff', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', border: 'solid 1px #354960', marginRight: 20 }}>
<div style={{ backgroundColor: '#fff', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', border: 'solid 1px #354960' }}>
<Typography style={{ fontSize: '11px', color: '#354960', textAlign: 'center' }}>Cancel</Typography>
</div>
</button>
<button
type="button"
disabled={this.state.disabledSave}
onClick={() => this.backToMasterBudget('submitted')}
style={{
backgroundColor: 'transparent',
cursor: this.state.disabledSave === true ? 'default' : 'pointer',
borderColor: 'transparent',
outline: 'none',
marginRight: 20
}}
>
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center'}}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save</Typography>
</div>
</button>
<button
className="button"
type="button"
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none'
}}
onClick={() => {
this.setState({ loading: true }, () => {
setTimeout(() => {
this.setState({ loading: false, disabledSave: false })
}, 100);
})
}}
>
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', marginRight: 20 }}>
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Calculate</Typography>
</div>
</button>
</div>
</div>
</Paper>
:
<Paper style={{ paddingTop: 10, paddingBottom: 20 }}>
<div>
<div style={{ padding: 25 }}>
<div>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>{this.props.company.company_name}</Typography>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>Periode : {this.props.periode}</Typography>
<Typography style={{ fontSize: '11px', color: '#4b4b4b' }}>in IDR mn</Typography>
</div>
{this.state.dataLoaded && (
<div style={{ marginTop: 20, width: this.props.width - (this.props.open === true ? 400 : 150), height: this.props.height - 400 }}>
{!this.state.loading && <MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable
data={dataTable2}
columns={columns}
options={options}
/>
</MuiThemeProvider>}
</div>
)}
</div>
<div style={{ display: 'flex', width: '100%', placeContent: 'flex-end', padding: 20 }}>
<button
type="button"
onClick={() => this.setState({ visibleBalanceSheet: true }, () => this.getItemHierarki())}
style={{ marginRight: 20 }}
>
<div style={{ backgroundColor: '#fff', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', border: 'solid 1px #354960'}}>
<Typography style={{ fontSize: '11px', color: '#354960', textAlign: 'center' }}>Cancel</Typography>
</div>
</button>
<button
type="button"
disabled={this.state.buttonError == true ? true : false}
onClick={() => null}
style={{ marginRight: 20 }}
>
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save</Typography>
</div>
</button>
......@@ -2396,9 +2633,9 @@ export default class BalanceSheet extends Component {
outline: 'none'
}}
onClick={() => {
this.setState({loading: true}, () => {
this.setState({ loading: true }, () => {
setTimeout(() => {
this.setState({loading: false})
this.setState({ loading: false, buttonError: false })
}, 100);
})
}}
......@@ -2409,8 +2646,46 @@ export default class BalanceSheet extends Component {
</button>
</div>
</div>
</Paper>
</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={() => {
this.state.judul === "MASTER BUDGET - BALANCE SHEET" ?
this.checkUpload() :
this.setState({ alert: true, messageAlert: "Invalid Template", tipeAlert: 'warning' })
}}
/>
</div>
</div>
)}
</div>
);
}
......
......@@ -777,6 +777,21 @@ export default class ProfitLoss extends Component {
this.props.onClickClose()
}
downloadTemplate = async () => {
let res = await fetch(
`https://tia.eksad.com/tia-reporting-dev/public/transaction/master_budget/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 Profit Loss.xlsx';
a.click();
}
}
render() {
let dataTable2 = this.state.dataTable
const handleChange = (value, tableMeta) => {
......@@ -2357,7 +2372,7 @@ export default class ProfitLoss extends Component {
borderColor: 'transparent',
margin: 5
}}
onClick={() => null}
onClick={() => this.downloadTemplate()}
>
<img src={Images.template} />
</button>
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -168,11 +168,11 @@ export default class CreateManagementDoc extends Component {
validasi() {
if (R.isNil(this.state.getPerusahaan)) {
this.setState({ errorPerusahaan: true, msgErrorPerusahaan: 'Company Cannot be Empty.' })
this.setState({ errorPerusahaan: true, msgErrorPerusahaan: 'Company Cannot be Empty' })
} else if (R.isNil(this.state.getDocument)) {
this.setState({ errorDocument: true, msgErrorDocument: 'Category Cannot be Empty.' })
this.setState({ errorDocument: true, msgErrorDocument: 'Category Cannot be Empty' })
} else if (R.isNil(this.state.file)) {
this.setState({ alert: true, messageAlert: 'File Cannot be Empty.', tipeAlert: 'warning' })
this.setState({ alert: true, messageAlert: 'File Cannot be Empty', tipeAlert: 'warning' })
} else {
const formData = new FormData();
formData.append("file", this.state.file);
......
......@@ -162,9 +162,7 @@ export default class DocumentManagement extends Component {
onClick={() => this.setState({ visibleCreate: true, refresh: '' })}
style={{ marginRight: 25 }}
>
<div style={{ width: 150, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
<span style={{ color: '#fff', fontSize: 11 }}>Add</span>
</div>
<img src={Images.add} />
</button>
</div>
<div style={{ display: 'flex' }}>
......
......@@ -15,7 +15,8 @@ export default class ManualBookTia extends Component {
this.state = {
dataTable: [],
visibleCreate: false,
refresh: ''
refresh: '',
alert: false,
}
}
......
......@@ -23,7 +23,8 @@ export default class QReview extends Component {
this.state = {
dataTable: [],
visibleCreate: false,
refresh: ''
refresh: '',
alert: false,
}
}
......@@ -47,9 +48,6 @@ export default class QReview extends Component {
api.create().getAllDocument(payload).then((response) => {
console.log(response)
if (response.problem){
alert(response.problem)
}
if (response.data) {
if (response.ok) {
if (response.data.status == 'success') {
......@@ -94,7 +92,6 @@ export default class QReview extends Component {
openPopUp = async (index, val, type) =>{
if (type === 'download') {
console.log(this.state.docPath[val])
let res = await fetch(
"https://tia.eksad.com/tia-reporting-dev/public/document/download_document?documentName="+this.state.docPath[val]+"&&fileType="+index[5]
)
......@@ -110,6 +107,10 @@ export default class QReview extends Component {
}
}
closeAlert() {
this.setState({ alert: false })
}
render() {
let columns = [{
name: "Action",
......@@ -117,7 +118,6 @@ export default class QReview extends Component {
filter: false,
sort: false,
customBodyRender: (val, tableMeta) => {
console.log(tableMeta)
return (
<div style={{ display: 'flex' }}>
{/* {this.state.btnedit && <span> */}
......
......@@ -70,7 +70,7 @@ class Upload extends Component {
// alert('File Tidak Boleh Lebih Dari 1MB')
}
} else {
this.setState({ alertMessage: 'File extension not allowed.', alert: true })
this.setState({ alertMessage: 'File extension not allowed', alert: true })
// alert('File Tidak Mendukung')
}
}
......@@ -81,7 +81,7 @@ class Upload extends Component {
uploadProgress: false,
percentage: '0'
})
this.setState({ alertMessage: "File extension not allowed.", alert: true })
this.setState({ alertMessage: "File extension not allowed", alert: true })
// alert("Unsupported Media Type")
}
} else {
......@@ -105,7 +105,7 @@ class Upload extends Component {
uploadProgress: false,
percentage: '0'
})
this.setState({ alertMessage: "File extension not allowed.", alert: true })
this.setState({ alertMessage: "File extension not allowed", alert: true })
// alert("Unsupported Media Type")
}
}
......@@ -154,7 +154,7 @@ class Upload extends Component {
}
}
} else {
this.setState({ alertMessage: 'File extension not allowed.', alert: true })
this.setState({ alertMessage: 'File extension not allowed', alert: true })
// alert('File Tidak Mendukung')
}
}
......
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