UNPKG

@adncorp/account-book-parser-adapter

Version:

parsing sheet adapter for account book

125 lines (94 loc) 4.25 kB
"use strict"; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } /* eslint-disable spellcheck/spell-checker */ /* eslint-disable no-multiple-empty-lines */ var parsingodoo = require('./odoo/'); var parsingodoocommunity = require('./odoo_community/'); var parsingsage = require('./sage/'); var parsingautre = require('./autre/'); var parsingsagei7 = require('./sage-i7/'); var parsingsage30 = require('./sage-30/'); var parsingsagecoala = require('./sage-coala/'); var fileUtils = require('./utils/fileUtils.js'); var fs = require('fs'); /** * @module Adapters */ /** * @interface AccountBookParserAdapter */ var AccountBookParserAdapter = /*#__PURE__*/ function () { /** *Creates an instance of AccountBookParserAdapter. * @constructor * @param {Object} filePath path to the general ledger file * @param {Object} softwareName software name * @memberof AccountBookParserAdapter */ function AccountBookParserAdapter(filePath, softwareName) { _classCallCheck(this, AccountBookParserAdapter); this.filePath = filePath; this.softwareName = softwareName; } /** * get result of parsing account book * @return {promiss} result of parsing account book according of the filetype */ _createClass(AccountBookParserAdapter, [{ key: "getParser", value: function getParser() { if (this.filePath === undefined || this.filePath === null || !fs.existsSync(this.filePath) && !fileUtils.isUri(this.filePath)) { return new Promise(function (resolve, reject) { var errorLoadingFile = { code: '301', libelle: 'InvalidPath', message: "Erreur sur le chemin du fichier du grand livre. Aucun fichier valide n'a été trouvé sur le chemin d'accès" // stop the process if not workbook was provided }; reject(errorLoadingFile); }); } else if (this.softwareName === undefined || this.softwareName === null) { return new Promise(function (resolve, reject) { var errorLoadingType = { code: '302', libelle: 'MissingSource', message: "Erreur sur la source choisie. Aucune source n'a été choisie" // stop the process if not workbook was provided }; reject(errorLoadingType); }); } else { switch (this.softwareName) { case 'ODOO': return parsingodoo(this.filePath, this.softwareName); case 'ODOO-COMMUNITY': return parsingodoocommunity(this.filePath, this.softwareName); case 'SAGE': return parsingsage(this.filePath, this.softwareName); case 'SAGE-i7': return parsingsagei7(this.filePath, this.softwareName); case 'SAGE-30': return parsingsage30(this.filePath, this.softwareName); case 'SAGE-COALA': return parsingsagecoala(this.filePath, this.softwareName); case 'AUTRE': return parsingautre(this.filePath, this.softwareName); default: return new Promise(function (resolve, reject) { var errorType = { code: '303', libelle: 'InvalidSource', message: 'Erreur sur le type du fichier du grand livre. Pas encore de parsing pour cette source' // stop the process if not workbook was provided }; reject(errorType); }); } } } }]); return AccountBookParserAdapter; }(); module.exports = AccountBookParserAdapter; //# sourceMappingURL=accountbookparseradapter.js.map