def initializeData(self, mvcsession): proxy = self.getBusinessObjectProxy() usrobj = proxy.getObject('USROBJ') glsobj = proxy.getObject('GLSOBJ') info = usrobj.retrieveUserInfoDict(mvcsession) cono = info['USRCONO'] glopt = glsobj.getGLOpt(cono) if (cono in (None, '')): raise Exception('Default company for user %s is not assigned' % mvcsession.cookies['user_name'].encode('utf8')) opt = GLSOPT.get(cono) mstcmp = MSTCMP.get(cono) if not mstcmp: raise Exception('Default company has not been setup') mvcsession.entryDataset.Append() mvcsession.entryDataset.SetFieldValue('GLAGCONO', cono) mvcsession.entryDataset.SetFieldValue('GLAGSTID', opt.GLOPACSC) mvcsession.entryDataset.SetFieldValue('GLAGACTP', 'I') mvcsession.entryDataset.SetFieldValue('GLAGGRTP', 1) mvcsession.entryDataset.SetFieldValue('GLAGACLV', 5) mvcsession.entryDataset.SetFieldValue('GLAGACSQ', 5) if (opt.GLOPACSC not in (None, '')): obj = GLSACS.get(opt.GLOPACSC) if not obj: raise Exception('Account structure %s is not found' % fields['GLAGSTID']) mvcsession.entryDataset.SetFieldValue('GLAGSTNM', obj.ACASACNM) mvcsession.entryDataset.Post() return mvcsession
def executeJob(self, jobsession): job = GLYRED.get(jobsession.jobID) if not job: raise Exception('Job information could not be found') proxy = self.getBusinessObjectProxy() usrobj = proxy.getObject('USROBJ') glsobj = proxy.getObject('GLSOBJ') info = usrobj.getUserInfoEx(job.GLYRAUUS) cono = info[2] mstcmp = MSTCMP.get(cono) glopt = GLSOPT.get(cono) self.info_dict['fstp'] = job.GLYRFSTP self.info_dict['fsyr'] = job.GLYRFSYR self.info_dict['cono'] = cono self.info_dict['usr_info'] = info self.info_dict['cmp'] = mstcmp self.info_dict['glopt'] = glopt self.info_dict['jobsession'] = jobsession self.info_dict['job'] = job self.session = session self.do_YearEnd()
def getSystemInfo(self, usr_name): retdict = {} usr = EFUSRS.get(usr_name) if usr: retdict['user_name'] = usr.EFUSUSID retdict['first_name'] = usr.EFUSFSNM retdict['last_name'] = usr.EFUSLSNM auditfields = ('AUDT', 'AUTM', 'AUUS') if usr.EFUSCONO: mstcmp = MSTCMP.get(usr.EFUSCONO) if mstcmp: for key in MSTCMP.__dict__.iterkeys(): if isinstance(MSTCMP.__dict__[key], InstrumentedAttribute) and \ (key[4:] not in auditfields): val = getattr(mstcmp, key, None) retdict[key] = val mstdiv = CMPDIV.get((usr.EFUSCONO, usr.EFUSDVNO)) if mstdiv: for key in CMPDIV.__dict__.iterkeys(): if isinstance(CMPDIV.__dict__[key], InstrumentedAttribute) and \ (key[4:] not in auditfields): val = getattr(mstdiv, key, None) retdict[key] = val values = [(key, value) for key, value in retdict.iteritems()] return tuple(values)
def getCompany(self, cono): """ Get company code, name, default currency, and default rate used """ cono = cono if cono else '' pool = ecfpool.getCachePool() cmp_cache = pool.getCOMPDict(cono) if cmp_cache is None: obj = MSTCMP.get(cono) if obj: self.updateCOMPCache(obj) return (obj.CMCPCONO, obj.CMCPCONM, obj.CMCPCUCD, obj.CMCPRTCD) else: return (None, None, None, None) return (cmp_cache['CMCPCONO'], cmp_cache['CMCPCONM'], cmp_cache['CMCPCUCD'], cmp_cache['CMCPRTCD'])
def execYearEnd(self, fstp, fsyr, usr_name): proxy = self.getBusinessObjectProxy() usrobj = proxy.getObject('USROBJ') glsobj = proxy.getObject('GLSOBJ') info = usrobj.getUserInfoEx(job.usr_name) cono = info[2] mstcmp = MSTCMP.get(cono) glopt = GLSOPT.get(cono) self.info_dict['fstp'] = fstp self.info_dict['fsyr'] = fsyr self.info_dict['cono'] = cono self.info_dict['usr_info'] = info self.info_dict['cmp'] = mstcmp self.info_dict['glopt'] = glopt self.session = session self.do_YearEnd()
def initCompany(self): """ Initialize default company """ proxy = self.getBusinessObjectProxy() cnt = MSTCMP.query.filter(None).count() if cnt == 0: curobj = proxy.getObject('CUROBJ') curinfo = curobj.getCurrency('USD') rtinfo = curobj.getRateType('DAI') obj = MSTCMP(CMCPCONO='', CMCPCONM='Blank Company', CMCPCODS='Blank Company Configuration', CMCPMCST=1, CMCPCUCD=curinfo[0], CMCPCUNM=curinfo[1], CMCPRTCD=rtinfo[0], CMCPRTNM=rtinfo[1]) self.setAuditFields(obj, 'ADMIN') session.add(obj) session.commit() session.close()
def retrieveData(self, mvcsession): proxy = self.getBusinessObjectProxy() usrobj = proxy.getObject('USROBJ') glsobj = proxy.getObject('GLSOBJ') info = usrobj.retrieveUserInfoDict(mvcsession) cono = info['USRCONO'] glopt = glsobj.getGLOpt(cono) if mvcsession.execType == MVCExecAppend: params = mvcsession.paramDataset.FieldsAsDict() bcid = None if params['GLJIBCID'] not in (None, ''): obj = GLBCTL.getObj(False, GLBCCONO=cono, GLBCNOID=glopt['GLOPBCNO'], GLBCLSID=params['GLJIBCID']) if not obj: raise Exception('Batch no %s could not be found') # batch status not in (Open, ERROR) if obj.GLBCBCST not in (1, 4, 5): raise Exception( 'Could not create a new transaction for this batch %s ' % params['GLJIBCID']) bcid = '%.6d' % obj.GLBCLSID jhdr = GLJHDR.getObj(False, GLJHCONO=cono, GLJHNOID=glopt['GLOPBCNO'], GLJHBCID=int(params['GLJIBCID']), GLJHJEID=int(params['GLJIJEID'])) if not jhdr: raise Exception('Could not find header transaction') fsyr = CSYFSC.validateFiscalYear(glopt['GLOPFSTP'], jhdr.GLJHFSYR, (1, )) fsprd = CSYFSP.validateFSPeriod2(glopt['GLOPFSTP'], jhdr.GLJHFSYR, jhdr.GLJHFSPR) cmpdt = MSTCMP.get(cono) crextp = MSTCRT.get((cmpdt.CMCPCUCD, cmpdt.CMCPRTCD)) if not crextp: raise Exception('No exchange rate definition found for combination of '\ 'functional currency and default rate type used in company setting') currat = CURRAT.getRateDate(crextp, crextp.CMCTCUCD, dt.date.today().tointeger()) rtdt = None rtvl = None rtsp = None if currat: rtdt = currat.CRRTRTDT rtvl = currat.CRRTRTVL rtsp = currat.CRRTRTSP mvcsession.entryDataset.Append() mvcsession.entryDataset.SetFieldValue('GLJITRID', None) mvcsession.entryDataset.SetFieldValue('GLJISQNO', 0) mvcsession.entryDataset.SetFieldValue('GLJITRDS', None) mvcsession.entryDataset.SetFieldValue('GLJITRRF', None) mvcsession.entryDataset.SetFieldValue('GLJIACFM', None) mvcsession.entryDataset.SetFieldValue('GLJIACNM', None) mvcsession.entryDataset.SetFieldValue('GLJITRAM', 0) mvcsession.entryDataset.SetFieldValue('GLJITRTP', 1) mvcsession.entryDataset.SetFieldValue('GLJISRLG', 'GL') mvcsession.entryDataset.SetFieldValue('GLJISRTP', 'JE') mvcsession.entryDataset.SetFieldValue('GLJISRCL', 'GL-JE') mvcsession.entryDataset.SetFieldValue('GLJITRDT', dt.date.today().tointeger()) mvcsession.entryDataset.SetFieldValue('GLJICHCD', cmpdt.CMCPCUCD) mvcsession.entryDataset.SetFieldValue('GLJICSCD', cmpdt.CMCPCUCD) mvcsession.entryDataset.SetFieldValue('GLJICRTP', cmpdt.CMCPRTCD) mvcsession.entryDataset.SetFieldValue('GLJIRTOP', crextp.CMCTRTOP) mvcsession.entryDataset.SetFieldValue('GLJIDTMT', crextp.CMCTDTMT) mvcsession.entryDataset.SetFieldValue('GLJIRTDT', rtdt) mvcsession.entryDataset.SetFieldValue('GLJIRCVL', rtvl) mvcsession.entryDataset.SetFieldValue('GLJIRTVL', rtvl) mvcsession.entryDataset.SetFieldValue('GLJIRTSP', rtsp) mvcsession.entryDataset.SetFieldValue('GLJICUAM', 0) mvcsession.entryDataset.Post() else: fields = mvcsession.listDataset.FieldsAsDict() params = mvcsession.paramDataset.FieldsAsDict() bcid = None if params['GLJIBCID'] not in (None, ''): obj = GLBCTL.getObj(False, GLBCCONO=cono, GLBCNOID=glopt['GLOPBCNO'], GLBCLSID=params['GLJIBCID']) if not obj: raise Exception('Batch no %s could not be found') # batch status not in (Open, ERROR) if mvcsession.execType != MVCExecShow: if obj.GLBCBCST not in (1, 4, 5): raise Exception( 'No update/delete permitted on this transaction for batch %s ' % params['GLJIBCID']) bcid = '%.6d' % obj.GLBCLSID jhdr = GLJHDR.getObj(False, GLJHCONO=cono, GLJHNOID=glopt['GLOPBCNO'], GLJHBCID=int(params['GLJIBCID']), GLJHJEID=int(params['GLJIJEID'])) if not obj: raise Exception('Could not find header transaction') obj = GLJITM.getObj(False, GLJICONO=cono, GLJINOID=glopt['GLOPBCNO'], GLJIBCID=int(params['GLJIBCID']), GLJIJEID=int(params['GLJIJEID']), GLJITRID=int(fields['GLJITRID'])) if not obj: raise Exception('Transaction does not exist') dcm.getcontext().prec = 9 amount = dcm.Decimal(obj.GLJITRAM, CurrencyContext) namount = dcm.Decimal(obj.GLJICUAM, CurrencyContext) if amount < dcm.Decimal(0): amount = dcm.Decimal( obj.GLJITRAM * dcm.Decimal(-1, CurrencyContext), CurrencyContext) namount = dcm.Decimal( obj.GLJICUAM * dcm.Decimal(-1, CurrencyContext), CurrencyContext) mvcsession.entryDataset.Append() mvcsession.entryDataset.SetFieldValue('GLJITRID', '%.6d' % obj.GLJITRID) mvcsession.entryDataset.SetFieldValue('GLJISQNO', obj.GLJISQNO) mvcsession.entryDataset.SetFieldValue('GLJITRDS', obj.GLJITRDS) mvcsession.entryDataset.SetFieldValue('GLJITRRF', obj.GLJITRRF) mvcsession.entryDataset.SetFieldValue('GLJIACFM', obj.GLJIACFM) mvcsession.entryDataset.SetFieldValue('GLJIACNM', obj.GLJIACNM) mvcsession.entryDataset.SetFieldValue('GLJITRAM', amount) mvcsession.entryDataset.SetFieldValue('GLJITRTP', obj.GLJITRTP) mvcsession.entryDataset.SetFieldValue('GLJISRLG', obj.GLJISRLG) mvcsession.entryDataset.SetFieldValue('GLJISRTP', obj.GLJISRTP) mvcsession.entryDataset.SetFieldValue( 'GLJISRCL', '%s-%s' % (obj.GLJISRLG, obj.GLJISRTP)) mvcsession.entryDataset.SetFieldValue('GLJITRDT', obj.GLJITRDT) mvcsession.entryDataset.SetFieldValue('GLJICHCD', obj.GLJICHCD) mvcsession.entryDataset.SetFieldValue('GLJICSCD', obj.GLJICSCD) mvcsession.entryDataset.SetFieldValue('GLJICRTP', obj.GLJICRTP) mvcsession.entryDataset.SetFieldValue('GLJIRTOP', obj.GLJIRTOP) mvcsession.entryDataset.SetFieldValue('GLJIDTMT', obj.GLJIDTMT) mvcsession.entryDataset.SetFieldValue('GLJIRTDT', obj.GLJIRTDT) mvcsession.entryDataset.SetFieldValue('GLJIRCVL', obj.GLJIRTVL) mvcsession.entryDataset.SetFieldValue('GLJIRTVL', obj.GLJIRTVL) mvcsession.entryDataset.SetFieldValue('GLJIRTSP', obj.GLJIRTSP) mvcsession.entryDataset.SetFieldValue('GLJICUAM', namount) mvcsession.entryDataset.Post() return mvcsession
def retrieveData(self, mvcsession): listFields = mvcsession.listDataset.FieldsAsDict() paramFields = mvcsession.paramDataset.FieldsAsDict() proxy = self.getBusinessObjectProxy() usrobj = proxy.getObject('USROBJ') glsobj = proxy.getObject('GLSOBJ') info = usrobj.retrieveUserInfoDict(mvcsession) cono = info['USRCONO'] glopt = glsobj.getGLOpt(cono) if (cono in (None, '')): raise Exception('Default company for user % is not assigned' % mvcsession.cookies['user_name'].encode('utf8')) if mvcsession.execType == MVCExecAppend: opt = GLSOPT.query.filter_by(GLOPCONO=cono).first() mstcmp = MSTCMP.get(cono) if not mstcmp: raise Exception('Default company has not been setup') if not opt: raise Exception('G/L option has not been setup') # set default field value mvcsession.entryDataset.Append() mvcsession.entryDataset.SetFieldValue('GLACSTID', opt.GLOPACSC) mvcsession.entryDataset.SetFieldValue('GLACACTP', 'I') mvcsession.entryDataset.SetFieldValue('GLACBLTP', 'D') mvcsession.entryDataset.SetFieldValue('GLACGRTP', 1) mvcsession.entryDataset.SetFieldValue('GLACACST', 1) mvcsession.entryDataset.SetFieldValue('GLACCSST', 0) mvcsession.entryDataset.SetFieldValue('GLACALST', 0) mvcsession.entryDataset.SetFieldValue('GLACCUCD', mstcmp.CMCPCUCD) mvcsession.entryDataset.SetFieldValue('GLACCPTP', 1) if (opt.GLOPACSC not in (None, '')): obj = GLSACS.query.filter_by(ACASACCD=opt.GLOPACSC).first() if not obj: raise Exception('Account structure %s is not found' % fields['GLACSTID']) mvcsession.entryDataset.SetFieldValue('GLACSTNM', obj.ACASACNM) mvcsession.entryDataset.Post() if mvcsession.execType in (MVCExecShow, MVCExecEdit, MVCExecDelete, MVCExecCopy): pre = re.compile('\w+') q = GLACCT.query q = q.filter_by(GLACCONO=cono) q = q.filter_by( GLACACID=''.join(pre.findall(listFields['GLACACFM']))) obj = q.first() if (mvcsession.execType != MVCExecCopy): mvcsession.entryDataset.CopyFromORM( 'GLACACFM;GLACACNM;GLACACTP;GLACBLTP;GLACGRTP;'\ 'GLACACST;GLACCSST;GLACALST;GLACALSR;GLACSRNM;GLACSTID;GLACSTNM;GLACCUCD;GLACCPTP', 'GLACACFM;GLACACNM;GLACACTP;GLACBLTP;GLACGRTP;'\ 'GLACACST;GLACCSST;GLACALST;GLACALSR;GLACSRNM;GLACSTID;GLACSTNM;GLACCUCD;GLACCPTP', obj) else: mvcsession.entryDataset.CopyFromORM( 'GLACACTP;GLACBLTP;GLACGRTP;'\ 'GLACACST;GLACCSST;GLACALST;GLACALSR;GLACSRNM;GLACSTID;GLACSTNM', 'GLACACTP;GLACBLTP;GLACGRTP;'\ 'GLACACST;GLACCSST;GLACALST;GLACALSR;GLACSRNM;GLACSTID;GLACSTNM', obj) if obj.GLACALSR is not (None, ''): srcid = obj.GLACALSR if srcid not in (None, ''): mvcsession.entryDataset.Edit() mvcsession.entryDataset.SetFieldValue( 'GLACALSR', "%s-%s" % (srcid[:2], srcid[2:])) mvcsession.entryDataset.Post() if mvcsession.execType == MVCExecEdit: mvcsession.fieldDefs.GLACACFM.enabled = False mvcsession.fieldDefs.GLACSTID.enabled = False # fields = mvcsession.entryDataset.FieldsAsDict() # mvcsession.fieldDefs.GLACALSR.enabled = fields['GLACALST'] == 1 return mvcsession