2014-03-02 12:09:27 +00:00
|
|
|
(function (module) {
|
|
|
|
|
mifosX.controllers = _.extend(module, {
|
|
|
|
|
XBRLController: function (scope, resourceFactory, location, dateFilter, route, http, API_VERSION, $rootScope, localStorageService, $timeout) {
|
|
|
|
|
scope.offices = [];
|
|
|
|
|
scope.date = {};
|
|
|
|
|
scope.restrictDate = new Date();
|
|
|
|
|
scope.formData = {};
|
|
|
|
|
scope.mixtaxonomyArray = [];
|
|
|
|
|
resourceFactory.xbrlMixtaxonomyResource.get(function (data) {
|
|
|
|
|
scope.mixtaxonomyArray = data;
|
|
|
|
|
http({
|
|
|
|
|
method: 'GET',
|
|
|
|
|
url: $rootScope.hostUrl + API_VERSION + '/mixmapping'
|
|
|
|
|
})
|
2020-08-30 12:59:35 +00:00
|
|
|
.then(function onSuccess(response) {
|
|
|
|
|
var data = response.data;
|
2014-03-02 12:09:27 +00:00
|
|
|
var mappingJson = data.config;
|
|
|
|
|
if (mappingJson != undefined && mappingJson.length > 0) {
|
|
|
|
|
for (var i = scope.mixtaxonomyArray.length - 1; i >= 0; i--) {
|
|
|
|
|
var taxonomyId = scope.mixtaxonomyArray[i]["id"];
|
|
|
|
|
var mapping = ($.parseJSON(mappingJson))['' + taxonomyId];
|
|
|
|
|
if (mapping != undefined) {
|
|
|
|
|
scope.mixtaxonomyArray[i].mapping = mapping;
|
|
|
|
|
}
|
2013-12-17 08:05:00 +00:00
|
|
|
|
2014-03-02 12:09:27 +00:00
|
|
|
}
|
2013-12-17 08:05:00 +00:00
|
|
|
}
|
2020-08-30 12:59:35 +00:00
|
|
|
}).catch(function onError(response) {
|
|
|
|
|
console.log("Error Detected: ", response.data)
|
2014-03-02 12:09:27 +00:00
|
|
|
});
|
2013-12-17 08:05:00 +00:00
|
|
|
});
|
|
|
|
|
|
2014-03-02 12:09:27 +00:00
|
|
|
resourceFactory.accountCoaResource.getAllAccountCoas(function (data) {
|
|
|
|
|
scope.glaccounts = [];
|
2013-12-17 08:05:00 +00:00
|
|
|
|
2014-03-02 12:09:27 +00:00
|
|
|
for (var i = 0; i < data.length; i++) {
|
|
|
|
|
var glaccount = {};
|
|
|
|
|
glaccount.label = "{" + data[i].glCode + "}" + " - " + data[i].name;
|
|
|
|
|
glaccount.value = "{" + data[i].glCode + "}";
|
|
|
|
|
scope.glaccounts.push(glaccount);
|
|
|
|
|
}
|
2013-12-17 08:05:00 +00:00
|
|
|
|
2014-03-02 12:09:27 +00:00
|
|
|
});
|
|
|
|
|
|
2014-12-11 15:57:46 +00:00
|
|
|
if (localStorageService.getFromLocalStorage('XbrlReportSaveSuccess') == 'true') {
|
2014-03-02 12:09:27 +00:00
|
|
|
scope.savesuccess = true;
|
2014-12-11 15:57:46 +00:00
|
|
|
localStorageService.removeFromLocalStorage('XbrlReportSaveSuccess');
|
2014-03-02 12:09:27 +00:00
|
|
|
scope.XbrlSuccess = true;
|
|
|
|
|
$timeout(function () {
|
|
|
|
|
scope.XbrlSuccess = false;
|
|
|
|
|
}, 3000);
|
2013-12-17 08:05:00 +00:00
|
|
|
|
2014-03-02 12:09:27 +00:00
|
|
|
}
|
2013-12-17 08:05:00 +00:00
|
|
|
|
2014-03-02 12:09:27 +00:00
|
|
|
scope.isPortfolio = function (mixtaxonomy) {
|
|
|
|
|
if (mixtaxonomy.type === 0) {
|
|
|
|
|
return true;
|
|
|
|
|
} else {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
};
|
2013-12-17 08:05:00 +00:00
|
|
|
|
2014-03-02 12:09:27 +00:00
|
|
|
scope.isBalanceSheet = function (mixtaxonomy) {
|
|
|
|
|
if (mixtaxonomy.type === 1) {
|
|
|
|
|
return true;
|
|
|
|
|
} else {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
};
|
2013-12-17 08:05:00 +00:00
|
|
|
|
2014-03-02 12:09:27 +00:00
|
|
|
scope.isIncome = function (mixtaxonomy) {
|
|
|
|
|
if (mixtaxonomy.type === 2) {
|
|
|
|
|
return true;
|
|
|
|
|
} else {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
};
|
2013-12-17 08:05:00 +00:00
|
|
|
|
2014-03-02 12:09:27 +00:00
|
|
|
scope.isExpense = function (mixtaxonomy) {
|
|
|
|
|
if (mixtaxonomy.type === 3) {
|
|
|
|
|
return true;
|
|
|
|
|
} else {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
};
|
2013-12-17 08:05:00 +00:00
|
|
|
|
2014-03-02 12:09:27 +00:00
|
|
|
scope.run = function () {
|
|
|
|
|
scope.startDate = dateFilter(scope.date.startDate, 'yyyy-MM-dd');
|
|
|
|
|
scope.endDate = dateFilter(scope.date.endDate, 'yyyy-MM-dd');
|
2013-12-17 08:05:00 +00:00
|
|
|
|
2014-03-02 12:09:27 +00:00
|
|
|
if (scope.startDate === undefined) {
|
|
|
|
|
scope.startDate = "";
|
|
|
|
|
}
|
|
|
|
|
if (scope.endDate === undefined) {
|
|
|
|
|
scope.endDate = "";
|
|
|
|
|
}
|
2013-12-17 08:05:00 +00:00
|
|
|
|
2014-03-02 12:09:27 +00:00
|
|
|
http({
|
|
|
|
|
method: 'GET',
|
|
|
|
|
url: $rootScope.hostUrl + API_VERSION + '/mixreport?startDate=' + scope.startDate + '&endDate=' + scope.endDate
|
2020-08-30 12:59:35 +00:00
|
|
|
}).then(function onSuccess(response) {
|
|
|
|
|
var data = response.data;
|
2014-03-02 12:09:27 +00:00
|
|
|
var parser = new DOMParser();
|
|
|
|
|
var xmlDoc = parser.parseFromString(data, "text/xml");
|
|
|
|
|
$rootScope.xmlData = xmlDoc;
|
|
|
|
|
location.path('/xbrlreport');
|
2020-08-30 12:59:35 +00:00
|
|
|
}) .catch( function onError(response) {
|
|
|
|
|
console.log("Error Detected: ", response.data)
|
2014-03-02 12:09:27 +00:00
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
scope.submit = function () {
|
|
|
|
|
var config = {};
|
|
|
|
|
var serialObject = {};
|
|
|
|
|
for (var i = scope.mixtaxonomyArray.length - 1; i >= 0; i--) {
|
|
|
|
|
var taxonomyId = scope.mixtaxonomyArray[i]["id"];
|
|
|
|
|
var mapping = scope.mixtaxonomyArray[i].mapping;
|
|
|
|
|
config["" + taxonomyId] = mapping;
|
|
|
|
|
}
|
|
|
|
|
serialObject["config"] = JSON.stringify(config);
|
|
|
|
|
serialObject["identifier"] = "default";
|
|
|
|
|
resourceFactory.xbrlMixMappingResource.update({}, JSON.stringify(serialObject), function (data) {
|
2014-12-11 15:57:46 +00:00
|
|
|
localStorageService.addToLocalStorage('XbrlReportSaveSuccess', true);
|
2014-03-02 12:09:27 +00:00
|
|
|
route.reload();
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
mifosX.ng.application.controller('XBRLController', ['$scope', 'ResourceFactory', '$location', 'dateFilter', '$route', '$http', 'API_VERSION', '$rootScope',
|
|
|
|
|
'localStorageService', '$timeout', mifosX.controllers.XBRLController]).run(function ($log) {
|
|
|
|
|
$log.info("XBRLController initialized");
|
|
|
|
|
});
|
2013-12-17 08:05:00 +00:00
|
|
|
}(mifosX.controllers || {}));
|