def Order_Container_Update(oder): odat = Orders.query.get(oder) bk = odat.Booking bol = odat.BOL bk = real_use(bk, bol) if not hasinput(bk): bk = 'Book TBD' container = odat.Container start_date = odat.Date - timedelta(30) end_date = odat.Date + timedelta(30) idata = Interchange.query.filter((Interchange.Date > start_date) & (Interchange.Date < end_date) & ((Interchange.Container == container) | (Interchange.Release == bk))).all() for idat in idata: type = idat.Type idat.Company = odat.Shipper idat.Jo = odat.Jo if not hasinput(container) or container == 'TBD': if not seektaken(idat.Container, start_date): odat.Container = idat.Container if odat.Istat == -1: odat.Istat = 0 hstat = odat.Hstat if hstat is None: hstat = 0 if 'Out' in type: if hstat == 0: odat.Hstat = 1 odat.Date = idat.Date if 'In' in type: odat.Hstat = 2 odat.Date2 = idat.Date db.session.commit()
def Match_Trucking_Now(): odata = Orders.query.filter(Orders.Hstat < 2).all() for data in odata: container = data.Container if container is None: container = 'TBD' bk = data.Booking bol = data.BOL bk = real_use(bk, bol) if not hasinput(bk): bk = 'Book TBD' start_date = data.Date - timedelta(30) end_date = data.Date + timedelta(30) idata = Interchange.query.filter( (Interchange.Status == 'IO') & (Interchange.Date > start_date) & (Interchange.Date < end_date) & ((Interchange.Container == container) | (Interchange.Release == bk))).all() if idata is not None: for idat in idata: if data.Hstat < 2: data.Hstat = 2 if container == 'TBD': data.Container = idat.Container idat.Company = data.Shipper idat.Jo = data.Jo rel = idat.Release if not hasinput(rel): idat.Release = bk if 'Out' in idat.Type: data.Date = idat.Date if 'In' in idat.Type: data.Date2 = idat.Date db.session.commit() else: idat = Interchange.query.filter( (Interchange.Date > start_date) & (Interchange.Date < end_date) & ((Interchange.Container == container) | (Interchange.Release == bk))).first() if idat is not None: if data.Hstat == 0: data.Hstat = 1 if container == 'TBD': data.Container = idat.Container idat.Company = data.Shipper idat.Jo = data.Jo rel = idat.Release if not hasinput(rel): idat.Release = bk if 'Out' in idat.Type: data.Date = idat.Date if 'In' in idat.Type: data.Date2 = idat.Date db.session.commit()
def InterMatchThis(id): idat = Interchange.query.get(id) container = idat.Container release = idat.Release if not hasinput(container): container = 'Con TBD' if not hasinput(release): release = 'Bk TBD' type = idat.Type if 'In' in type: matcher = 'Out' else: matcher = 'In' mdat = Interchange.query.filter( (Interchange.Status != 'AAAAAA') & (~Interchange.Status.contains('IO')) & (Interchange.Type.contains(matcher)) & (Interchange.Container == container)).first() if mdat is not None: idat.Status = 'IO' mdat.Status = 'IO' db.session.commit() odat = Orders.query.filter((Orders.Container == container) | (Orders.Booking == release)).first() if odat is not None: hstat = odat.Hstat if hstat == 0 and 'Out' in type: if (odat.Container) == 'TBD': odat.Container = idat.Container odat.Hstat = 1 db.session.commit() if hstat == 1 and 'In' in type: odat.Hstat = 2 db.session.commit() odat = OverSeas.query.filter((OverSeas.Container == container) | (OverSeas.Booking == release)).first() if odat is not None: status = odat.Status bit1 = status[0] if bit1 == '0' and 'Out' in type: if (odat.Container) == 'TBD': odat.Container = idat.Container newstatus = stat_update(status, '1', 0) odat.Status = newstatus db.session.commit() if bit1 == '1' and 'In' in type: newstatus = stat_update(status, '2', 0) odat.Status = newstatus db.session.commit()
def Match_Ticket(oder, tick): myo = Orders.query.get(oder) myi = Interchange.query.get(tick) bk = myo.Booking bol = myo.BOL con = myi.Container bk = real_use(bk, bol) start_date = myi.Date - timedelta(30) end_date = myi.Date + timedelta(30) idata = Interchange.query.filter((Interchange.Status == 'IO') & (Interchange.Date > start_date) & (Interchange.Date < end_date) & (Interchange.Container == con)).all() myo.Container = myi.Container myo.Type = myi.ConType db.session.commit() if idata is not None: for idat in idata: idat.Company = myo.Shipper idat.Jo = myo.Jo rel = idat.Release if not hasinput(rel): idat.Release = bk if 'Out' in idat.Type: myo.Date = idat.Date if 'In' in idat.Type: myo.Date2 = idat.Date db.session.commit() else: myi.Company = myo.Shipper myi.Jo = myo.Jo rel = myi.Release if not hasinput(rel): myi.Release = bk db.session.commit()
def Push_Orders(): kdata = db.session.query(Interchange.Container).distinct() for data in kdata: container = data.Container idat = Interchange.query.filter( (Interchange.Status != 'AAAAAA') & (~Interchange.Status.contains('Lock')) & (Interchange.Container == container) & (Interchange.Type.contains('Out'))).first() if idat is not None: testid = idat.id type = idat.Type booking = idat.Release if not hasinput(booking): booking = 'Book TBD' odat = Orders.query.filter((Orders.Booking == booking) | ( Orders.Container == container)).first() if odat is not None: idat.Company = odat.Shipper idat.Jo = odat.Jo release = idat.Release if not hasinput(release): idat.Release = odat.Booking hstat = odat.Hstat if hstat == 0: odat.Hstat = 1 db.session.commit() #See if there is a matching interchange ticket to update as well mdat = Interchange.query.filter( (Interchange.Status != 'AAAAAA') & (~Interchange.Status.contains('Lock')) & (Interchange.Container == container) & (Interchange.Type.contains('In'))).first() if mdat is not None: mdat.Company = odat.Shipper mdat.Jo = odat.Jo if hstat < 2: odat.Hstat = 2 db.session.commit()
def real_use(bk, bol): if hasinput(bk) and not hasinput(bol): return bk elif hasinput(bol) and not hasinput(bk): return bol elif hasinput(bk) and hasinput(bol): return bk else: return None
def Push_Overseas(): kdata = db.session.query(Interchange.Container).distinct() for data in kdata: container = data.Container idat = Interchange.query.filter( (Interchange.Status != 'AAAAAA') & (~Interchange.Status.contains('Lock')) & (Interchange.Container == container) & (Interchange.Type.contains('Out'))).first() if idat is not None: testid = idat.id type = idat.Type booking = idat.Release if not hasinput(booking): booking = 'Book TBD' odat = OverSeas.query.filter(OverSeas.Booking == booking).first() if odat is not None: odat.Container = container idat.Company = odat.BillTo idat.Jo = odat.Jo status = odat.Status bit1 = status[0] if bit1 == '0': newstatus = stat_update(status, '1', 0) odat.Status = newstatus #See if there is a matching interchange ticket to update as well mdat = Interchange.query.filter( (Interchange.Status != 'AAAAAA') & (~Interchange.Status.contains('Lock')) & (Interchange.Container == container) & (Interchange.Type.contains('In'))).first() if mdat is not None: mdat.Company = odat.BillTo mdat.Jo = odat.Jo if bit1 == '0' or bit1 == '1': newstatus = stat_update(status, '2', 0) odat.Status = newstatus db.session.commit()
def isoAM(): if request.method == 'POST': # ____________________________________________________________________________________________________________________B.FormVariables.General from viewfuncs import parseline, popjo, jovec, newjo, timedata, nonone, nononef, stripper, check_shared, check_mirror_exp from viewfuncs import numcheck, numcheckv, viewbuttons, get_ints, numcheckvec, erud, hasinput, get_tmap, get_qmap #Zero and blank items for default username = session['username'].capitalize() cache=0 modata=0 modlink=0 scdata=0 tmap = None fmap = None qmap = None gmap = None today = datetime.date.today() now = datetime.datetime.now().strftime('%I:%M %p') modify = request.values.get('Qmod') shared = request.values.get('Shared') returnhit = request.values.get('Return') deletehit = request.values.get('Delete') # hidden values update = request.values.get('Update') newact=request.values.get('NewA') thisjob=request.values.get('ThisJob') oder=request.values.get('oder') modlink = request.values.get('modlink') companyon = request.values.get('actype') if companyon is None: companyon='Show All Accounts' oder=nonone(oder) modlink=nonone(modlink) leftscreen=1 err=[] if returnhit is not None: modlink=0 # ____________________________________________________________________________________________________________________E.FormVariables.General # ____________________________________________________________________________________________________________________B.DataUpdates.General if modlink==1: if oder > 0: modata=Accounts.query.get(oder) vals=['acctname','accttype','acctcat','acctsub','acctnumb','acctrout','acctpaye','acctdesc','accttax','acctco','qbmap'] a=list(range(len(vals))) for i,v in enumerate(vals): a[i]=request.values.get(v) modata.Name=a[0] modata.Type=a[1] if a[1] is not None: adat = Accttypes.query.filter(Accttypes.Name==a[1]).first() if adat is not None: defcat = adat.Category defsub = adat.Subcategory if a[2] is None: modata.Category = defcat else: modata.Category=a[2] if a[3] is None: modata.Subcategory = defsub else: modata.Subcategory=a[3] modata.AcctNumber=a[4] modata.Routing=a[5] modata.Payee=a[6] modata.Description=a[7] modata.Taxrollup=a[8] modata.Co=a[9] modata.QBmap = a[10] db.session.commit() err.append('Modification to Account id ' + str(modata.id) + ' completed.') # Narrow the selection boxes for company and type print('a[1]', a[1]) print(hasinput(a[1])) if hasinput(a[1]): fmap = Focusareas.query.filter(Focusareas.Co == a[9]).all() gmap = Taxmap.query.filter(Taxmap.Category.contains('deductions')).all() tmap = get_tmap(a[1], a[2]) qmap = get_qmap(a[1], a[2]) if update is not None: modlink=0 leftsize=10 else: leftsize=6 modata=Accounts.query.get(oder) # ____________________________________________________________________________________________________________________B.GetData.General if companyon == 'Show All Accounts': odata = Accounts.query.all() elif companyon == 'Show Shared Accounts': odata = Accounts.query.filter(Accounts.Shared != None).all() elif ':' in companyon: comp,focus = companyon.split(':') print(comp,focus) odata = Accounts.query.filter( (Accounts.Co==comp) & (Accounts.Subcategory==focus) ).all() else: odata = Accounts.query.filter((Accounts.Co.contains(companyon))).all() # ____________________________________________________________________________________________________________________B.Search.General if modlink==0: oder,numchecked=numcheck(1,odata,0,0,0,0,['oder']) else: numchecked = 0 # ____________________________________________________________________________________________________________________E.Search.General if shared is not None: if oder > 0 and numchecked == 1: odat = Accounts.query.get(oder) atype = odat.Type if atype == 'Expense': co1 = odat.Co thisdat = Divisions.query.filter(Divisions.Co == co1).first() co1name = thisdat.Name otherdat = Divisions.query.filter(Divisions.Co != co1).first() sid = otherdat.id co2 = otherdat.Co co2name = otherdat.Name err.append(f'Account **{odat.Name}** owned by code {odat.Co}') err.append(f'Is now set up for share with {otherdat.Name} code {otherdat.Co}') # Now check to see if the sharing accounts exist and if not create them fromtoid, err = check_shared(co1,co2name, err) tofromid, err = check_shared(co2,co1name, err) mirrorexpid, err = check_mirror_exp(co2,odat.id,odat.Name,err) slist = json.dumps([sid,fromtoid,tofromid,mirrorexpid]) odat.Shared = slist db.session.commit() mirrordat = Accounts.query.get(mirrorexpid) mirrordat.Shared = slist db.session.commit() if companyon == 'Show All Accounts': odata = Accounts.query.all() elif companyon == 'Show Shared Accounts': odata = Accounts.query.filter(Accounts.Shared != None).all() else: odata = Accounts.query.filter((Accounts.Co.contains(companyon))).all() else: err.append(f'Cannot share: {odat.Name} of type {atype}') err.append(f'Can only share and apportion **Expense** accounts') else: err.append(f'Must select one account to use this option') # ____________________________________________________________________________________________________________________B.Modify.General if modify is not None and numchecked==1 : modlink=1 leftsize=6 if oder>0: modata=Accounts.query.get(oder) err.append(f'Modify {modata.Name}:{modata.Co}:{modata.Type}') if hasinput(modata.Type): fmap = Focusareas.query.filter(Focusareas.Co == modata.Co).all() gmap = Taxmap.query.filter(Taxmap.Category.contains('deductions')).all() tmap = get_tmap(modata.Type, modata.Category) qmap = get_qmap(modata.Type, modata.Category) if modify is not None and numchecked!=1: modlink=0 err.append('Must check exactly one box to use this option') # ____________________________________________________________________________________________________________________E.Modify.General # ____________________________________________________________________________________________________________________B.Delete.General if deletehit is not None and numchecked==1: if oder>0: #This section is to determine if we can delete the source file along with the data. If other data is pointing to this #file then we need to keep it. modata=Accounts.query.get(oder) Accounts.query.filter(Accounts.id == oder).delete() db.session.commit() if companyon == 'Show All Accounts': odata = Accounts.query.all() elif companyon == 'Show Shared Accounts': divdata = Divisions.query.all() tester = '' for div in divdata: tester = tester + div.Co odata = Accounts.query.filter(Accounts.Co.like(tester)).all() else: odata = Accounts.query.filter((Accounts.Co.contains(companyon))).all() if deletehit is not None and numchecked != 1: err.append('Must have exactly one item checked to use this option') # ____________________________________________________________________________________________________________________E.Delete.General # ____________________________________________________________________________________________________________________B.Newjob.General if newact is not None: modlink=10 leftsize=6 modata=Accounts.query.get(1) if modata is not None: modata.Name='' modata.Type=None modata.Category=None modata.Subcategory=None modata.AcctNumber='' modata.Routing='' modata.Payee='' modata.Description='' modata.Taxrollup=None modata.Co=None modata.QBmap = None if newact is None and modlink==10: #Create the new database entry for the source document acctname=request.values.get('acctname') acctnumb=request.values.get('acctnumb') acctrout=request.values.get('acctrout') acctpaye=request.values.get('acctpaye') accttype=request.values.get('accttype') acctdesc=request.values.get('acctdesc') acctcat=request.values.get('acctcat') acctsub=request.values.get('acctsub') accttax=request.values.get('accttax') acctco=request.values.get('acctco') qbmap = request.values.get('qbmap') acctname = stripper(acctname) adat = Accounts.query.filter((Accounts.Name==acctname) & (Accounts.Co==acctco)).first() if adat is not None: err.append(f'Account with name {acctname} for {acctco} already exists') else: input = Accounts(Name=acctname,Balance=0.00,AcctNumber=acctnumb,Routing=acctrout,Payee=acctpaye,Type=accttype, Description=acctdesc,Category=acctcat,Subcategory=acctsub,Taxrollup=accttax,Co=acctco,QBmap=qbmap, Shared=None) db.session.add(input) db.session.commit() # Narrow the selection boxes for company and type if hasinput(accttype): print('acctco',acctco) fmap = Focusareas.query.filter(Focusareas.Co == acctco).all() gmap = Taxmap.query.filter(Taxmap.Category.contains('deductions')).all() tmap = get_tmap(accttype, 0) qmap = get_qmap(accttype, 0) odata = Accounts.query.all() modata = odata[-1] oder=modata.id modlink=1 # ____________________________________________________________________________________________________________________E.Newjob.General #This is the else for 1st time through (not posting data from overseas.html) else: from viewfuncs import popjo, jovec, timedata, nonone, nononef, init_truck_zero, erud today = datetime.date.today() #today = datetime.datetime.today().strftime('%Y-%m-%d') now = datetime.datetime.now().strftime('%I:%M %p') oder=0 cache=0 modata=0 modlink=0 scdata=0 odata = Accounts.query.all() companyon = 'Show All Accounts' leftscreen=1 leftsize=10 tmap = None fmap = None qmap = None gmap = None err = [] scdata=[] for odat in odata: catitem=odat.Category additem=odat.Subcategory if additem is not None and catitem is not None: if catitem=='G-A' and additem not in scdata: scdata.append(additem) scdata.sort() leftsize = 8 divdata = Divisions.query.all() colordict = {} for div in divdata: colordict.update({div.Co:div.Color}) print(colordict) err = erud(err) atypes = Accttypes.query.all() if fmap is None: fmap = Focusareas.query.all() return odata,oder,err,modata,modlink,leftscreen,leftsize,today,now,scdata,companyon,divdata,atypes,tmap,fmap,qmap, gmap, colordict
from viewfuncs import stripper, newjo, hasinput import os movem = 0 daybackfrom = 10 daybackto = 0 printif = 0 today = datetime.datetime.today() cutoffdate = today - timedelta(3) print(f'Running pdf builder for SCAC {scac} off Machine {machine}') print(addpath1('tmp/')) odata = Orders.query.filter(Orders.Date > cutoffdate).all() for odat in odata: if hasinput(odat.Container): idata = Interchange.query.filter( Interchange.Container == odat.Container).all() for idat in idata: print(idat.Container, idat.Original) if movem == 1: pythonline = websites[ 'ssh_data'] + f'vinterchange/{idat.Original}' placefile = addpath3(f'interchange/{idat.Original}') copyline1 = f'scp {pythonline} {placefile}' print(copyline1) os.system(copyline1) tunnel.stop()
def PushJobsThis(id): idat = Interchange.query.get(id) testid = idat.id type = idat.Type booking = idat.Release container = idat.Container if not hasinput(booking): booking = 'Book TBD' if not hasinput(container): container = 'Con TBD' odat = OverSeas.query.filter(OverSeas.Booking == booking).first() if odat is not None: odat.Container = container idat.Company = odat.BillTo idat.Jo = odat.Jo release = idat.Release if not hasinput(release): idat.Release = odat.Booking status = odat.Status bit1 = status[0] if bit1 == '0' and 'Out' in type: newstatus = stat_update(status, '1', 0) odat.Status = newstatus if 'Out' in type: odat.PuDate = idat.Date if (bit1 == '1' or bit1 == '0') and 'In' in type: newstatus = stat_update(status, '2', 0) odat.Status = newstatus if 'In' in type: odat.RetDate = idat.Date db.session.commit() odat = Orders.query.filter(( (Orders.Booking == booking) | (Orders.Container == container)) & (Orders.Date > cutoff)).first() if odat is not None: idat.Company = odat.Shipper idat.Jo = odat.Jo release = idat.Release if not hasinput(release): idat.Release = odat.Booking odat.Container = container hstat = odat.Hstat if hstat == 0 and 'Out' in type: odat.Hstat = 1 if 'Out' in type: odat.Date = idat.Date if hstat < 2 and 'In' in type: odat.Hstat = 2 if 'In' in type: odat.Date2 = idat.Date db.session.commit() #And also push back to Interchange in case several new bookings have been created odata = OverSeas.query.filter(OverSeas.Container == 'TBD') for data in odata: container = data.Container company = data.BillTo booking = data.Booking idat = Interchange.query.filter((Interchange.Release == booking) & ( Interchange.Status != 'AAAAAA')).first() if idat is not None: data.Container = idat.Container idat.Company = company idat.Jo = data.Jo db.session.commit()
def isoIncM(): if request.method == 'POST': # ____________________________________________________________________________________________________________________B.FormVariables.General from viewfuncs import parseline, popjo, jovec, newjo, timedata, nonone, nononef, erud, hasinput from viewfuncs import numcheck, numcheckv, viewbuttons, get_ints, numcheckvec, numcheckv #Zero and blank items for default username = session['username'].capitalize() cache = request.values.get('cache') cache = nonone(cache) modata = 0 modlink = 0 docref = '' oderstring = '' acdeposit = request.values.get('acdeposit') if acdeposit is None: acdeposit = request.values.get('actype') depojo = request.values.get('depojo') cofor = request.values.get('cofor') depdate = request.values.get('depdate') print(depdate, hasinput(depdate)) if not hasinput(depdate): depdate = datetime.datetime.today().strftime('%Y-%m-%d') depdata = [acdeposit, cofor, depojo, depdate] print(depdata) today = datetime.date.today() now = datetime.datetime.now().strftime('%I:%M %p') leftsize = 10 match = request.values.get('Match') modify = request.values.get('Qmod') vmod = request.values.get('Vmod') viewo = request.values.get('View') returnhit = request.values.get('Return') deletehit = request.values.get('Delete') delfile = request.values.get('DELF') # hidden values update = request.values.get('Update') newact = request.values.get('NewA') thisjob = request.values.get('ThisJob') oder = request.values.get('oder') modlink = request.values.get('modlink') depositmake = request.values.get('depositmake') recdeposit = request.values.get('recdeposit') unrecord = request.values.get('unrecord') thismuch = request.values.get('thismuch') oder = nonone(oder) modlink = nonone(modlink) leftscreen = 1 err = [] if returnhit is not None: modlink = 0 depojo = 0 depdata = [0, 0, 0, depdate] # ____________________________________________________________________________________________________________________E.FormVariables.General # ____________________________________________________________________________________________________________________B.DataUpdates.General if modlink == 1: if oder > 0: modata = Income.query.get(oder) vals = [ 'jo', 'account', 'from', 'description', 'amount', 'ref', 'pdate', 'original', 'bank', 'depdate', 'depositnum' ] a = list(range(len(vals))) for i, v in enumerate(vals): a[i] = request.values.get(v) modata.Jo = a[0] modata.Account = a[1] modata.From = a[2] modata.Description = a[3] modata.Amount = a[4] modata.Ref = a[5] modata.Date = a[6] modata.Original = a[7] modata.Bank = a[8] if a[9] == '': modata.Date2 = None else: modata.Date2 = a[9] modata.Depositnum = a[10] db.session.commit() err.append('Modification to Income id ' + str(modata.id) + ' completed.') if update is not None: modlink = 0 leftsize = 10 else: leftsize = 6 leftscreen = 0 modata = Income.query.get(oder) # ____________________________________________________________________________________________________________________B.GetData.General #odata = Income.query.all() odata = dataget_Inc(thismuch) # ____________________________________________________________________________________________________________________B.Search.General if modlink == 0: oder, numchecked = numcheck(1, odata, 0, 0, 0, 0, ['oder']) # ____________________________________________________________________________________________________________________E.Search.General # ____________________________________________________________________________________________________________________B.Modify.General if (modify is not None or vmod is not None) and numchecked == 1: modlink = 1 leftsize = 6 if vmod is not None: leftscreen = 0 if oder > 0: modata = Income.query.get(oder) docref = modata.Original if (modify is not None or vmod is not None) and numchecked != 1: modlink = 0 err.append('Must check exactly one box to use this option') # ____________________________________________________________________________________________________________________E.Modify.General # ____________________________________________________________________________________________________________________B.Delete.General if deletehit is not None and numchecked == 1: if oder > 0: #This section is to determine if we can delete the source file along with the data. If other data is pointing to this #file then we need to keep it. modata = Income.query.get(oder) Income.query.filter(Income.id == oder).delete() db.session.commit() odata = dataget_Inc(thismuch) if deletehit is not None and numchecked != 1: err.append('Must have exactly one item checked to use this option') acctsel = request.values.get('actype') if acctsel is not None and not hasinput(depojo): print(f'Getting depojo acctsel {acctsel}') cofor = 0 if oder > 0: inc = Income.query.get(oder) jo = inc.Jo cofor = jo[0] + 'D' else: acdat = Accounts.query.filter(Accounts.Name == acctsel).first() if acdat is not None: cofor = acdat.Co + 'D' if cofor != 0: todayyf = datetime.datetime.today().strftime('%Y-%m-%d') depojo = newjo(cofor, todayyf) depdata = [acctsel, cofor, depojo, depdate] # ____________________________________________________________________________________________________________________E.Delete.General if (depositmake is not None or recdeposit is not None) and depojo is not None: err.append('Must have exactly one item checked to use this option') odervec = numcheckv(odata) if len(odervec) > 0: oderstring = json.dumps(odervec) else: udat = users.query.filter(users.name == 'cache').first() oderstring = udat.email odervec = json.loads(oderstring) if odervec is not None: cache = request.values.get('cache') if cache is None: cache = 2 if recdeposit is not None: cache, docref = reportmaker('recdeposit', odervec) depojo = request.values.get('depojo') sourcelist = [] for oder in odervec: idat = Income.query.get(oder) fromco = idat.From if fromco is None: cdat = People.query.get(idat.Pid) if cdat is not None: fromco = cdat.Company else: fromco = 'Unknown Source' if fromco not in sourcelist: sourcelist.append(fromco) ref = idat.Ref acct = idat.Account bank = request.values.get('acdeposit') date2 = request.values.get('depdate') if len(ref) > 2 and ref != 'ChkNo': idata = Income.query.filter( (Income.Account == acct) & (Income.Ref == ref)).all() for data in idata: data.Depositnum = depojo data.Bank = bank data.Date2 = date2 data.From = fromco data.Original = os.path.basename(docref) db.session.commit() else: idat.Bank = bank idat.Date2 = date2 idat.Depositnum = depojo idat.From = fromco idat.Original = os.path.basename(docref) db.session.commit() print('Here', depojo, acctsel) if len(sourcelist) == 1: sendsource = sourcelist[0] else: sendsource = json.dumps(sourcelist) if len(sendsource) > 49: sendsource = 'Multiple Sources' from gledger_write import gledger_write gledger_write('deposit', depojo, acctsel, sendsource) else: print(odervec) cache, docref = reportmaker('deposit', odervec) leftscreen = 0 if unrecord is not None and numchecked == 1: if oder > 0: modata = Income.query.get(oder) subjo = modata.SubJo idata = Income.query.filter(Income.SubJo == subjo).all() for idat in idata: idat.SubJo = 'Mremit' db.session.commit() jdat = JO.query.filter(JO.jo == subjo).first() if jdat is not None: jdat.dinc = '0.00' db.session.commit() Gledger.query.filter(Gledger.Tcode == subjo).delete() db.session.commit() if viewo is not None and numchecked == 1: if oder > 0: modata = Income.query.get(oder) filename = modata.Depositnum docref = f'tmp/{scac}/data/vdeposits/' + filename + '.pdf' leftscreen = 0 if unrecord is not None and numchecked != 1: modlink = 0 err.append('Must check exactly one box to use this option') if cache is not None: #Save the current cache so we do not start from bad place in future udat = users.query.filter(users.name == 'cache').first() udat.username = str(cache) udat.email = oderstring db.session.commit() #This is the else for 1st time through (not posting data from overseas.html) else: from viewfuncs import popjo, jovec, timedata, nonone, nononef, init_truck_zero, erud today = datetime.date.today() today_str = datetime.datetime.today().strftime('%Y-%m-%d') now = datetime.datetime.now().strftime('%I:%M %p') oder = 0 modata = 0 modlink = 0 odata = Income.query.all() leftscreen = 1 leftsize = 10 docref = '' err = ['Ready to make and review account deposits'] thismuch = '2' udat = users.query.filter(users.name == 'Cache').first() cache = udat.username cache = nonone(cache) depdata = [0, 0, 0, today_str] odata = dataget_Inc(thismuch) leftsize = 8 acdata = Accounts.query.filter(Accounts.Type == 'Bank').all() err = erud(err) return odata, oder, err, modata, modlink, leftscreen, leftsize, today, now, docref, cache, acdata, thismuch, depdata
def isoDeposit(): if request.method == 'POST': # ____________________________________________________________________________________________________________________B.FormVariables.General from viewfuncs import parseline, popjo, jovec, newjo, timedata, nonone, nononef, erud, hasinput from viewfuncs import numcheck, numcheckv, viewbuttons, get_ints, numcheckvec, numcheckv, d2s #Zero and blank items for default username = session['username'].capitalize() cache = request.values.get('cache') cache = nonone(cache) modata = 0 modlink = 0 docref = '' oderstring = '' acdeposit = request.values.get('acdeposit') if acdeposit is None: acdeposit = request.values.get('actype') depojo = request.values.get('depojo') cofor = request.values.get('cofor') depdate = request.values.get('depdate') print(depdate, hasinput(depdate)) if not hasinput(depdate): depdate = datetime.datetime.today().strftime('%Y-%m-%d') depdata = [acdeposit, cofor, depojo, depdate] print(depdata) today = datetime.date.today() now = datetime.datetime.now().strftime('%I:%M %p') leftsize = 10 match = request.values.get('Match') modify = request.values.get('Qmod') vmod = request.values.get('Vmod') viewo = request.values.get('View') returnhit = request.values.get('Return') deletehit = request.values.get('Delete') delfile = request.values.get('DELF') # hidden values update = request.values.get('Update') newact = request.values.get('NewA') thisjob = request.values.get('ThisJob') oder = request.values.get('oder') modlink = request.values.get('modlink') depositmake = request.values.get('depositmake') recdeposit = request.values.get('recdeposit') unrecord = request.values.get('unrecord') thismuch = request.values.get('thismuch') oder = nonone(oder) modlink = nonone(modlink) leftscreen = 1 err = [] if returnhit is not None: modlink = 0 depojo = 0 depdata = [0, 0, 0, depdate] # ____________________________________________________________________________________________________________________E.FormVariables.General # ____________________________________________________________________________________________________________________B.DataUpdates.General # ____________________________________________________________________________________________________________________B.GetData.General odata = dataget_Dep(thismuch) gdata = undeposited(thismuch) # ____________________________________________________________________________________________________________________B.Search.General if modlink == 0: oder, numchecked = numcheck(1, gdata, 0, 0, 0, 0, ['oder']) # ____________________________________________________________________________________________________________________E.Search.General acctsel = request.values.get('actype') if acctsel is not None and not hasinput(depojo): print(f'Getting depojo acctsel {acctsel}') cofor = 0 if oder > 0: inc = Gledger.query.get(oder) jo = inc.Tcode cofor = jo[0] + 'D' else: acdat = Accounts.query.filter(Accounts.Name == acctsel).first() if acdat is not None: cofor = acdat.Co + 'D' if cofor != 0: todayyf = datetime.datetime.today().strftime('%Y-%m-%d') depojo = newjo(cofor, todayyf) depdata = [acctsel, cofor, depojo, depdate] # ____________________________________________________________________________________________________________________E.Delete.General if (depositmake is not None or recdeposit is not None) and depojo is not None: odervec = numcheckv(gdata) print('odervec', odervec) if len(odervec) > 0: try: oderstring = json.dumps(odervec) except: oderstring = '' else: udat = users.query.filter(users.name == 'cache').first() oderstring = udat.email odervec = json.loads(oderstring) if odervec is not None: cache = request.values.get('cache') if cache is None: cache = 2 if recdeposit is not None: cache, docref = reportmaker('recdeposit', odervec) depojo = request.values.get('depojo') sourcelist = [] total = 0.00 for oder in odervec: idat = Gledger.query.get(oder) amount = float(idat.Debit) / 100. total = total + amount for oder in odervec: idat = Gledger.query.get(oder) fromco = idat.Source amount = d2s(float(idat.Debit) / 100.) sid = idat.Sid jo = idat.Tcode ref = idat.Ref if fromco is None: cdat = People.query.get(idat.Sid) if cdat is not None: fromco = cdat.Company else: fromco = 'Unknown Source' if fromco not in sourcelist: sourcelist.append(fromco) acct = idat.Account bank = request.values.get('acdeposit') date2 = request.values.get('depdate') ddat = Deposits.query.filter( Deposits.Jo == idat.Tcode).first() if ddat is None: input = Deposits(Jo=jo, Account=acct, Pid=sid, Amount=amount, Total=d2s(total), Ref=ref, Date=date2, Original=os.path.basename(docref), From=fromco, Bank=bank, Date2=today, Depositnum=depojo) db.session.add(input) db.session.commit() else: ddat.Depositnum = depojo ddat.Bank = bank ddat.Date2 = date2 ddat.From = fromco ddat.Original = os.path.basename(docref) db.session.commit() print('Here', depojo, acctsel) if len(sourcelist) == 1: sendsource = sourcelist[0] else: sendsource = json.dumps(sourcelist) if len(sendsource) > 49: sendsource = 'Multiple Sources' from gledger_write import gledger_write gledger_write('deposit', depojo, acctsel, sendsource) else: print(odervec) cache, docref = reportmaker('deposit', odervec) leftscreen = 0 if unrecord is not None and numchecked == 1: if oder > 0: modata = Income.query.get(oder) subjo = modata.SubJo idata = Income.query.filter(Income.SubJo == subjo).all() for idat in idata: idat.SubJo = 'Mremit' db.session.commit() jdat = JO.query.filter(JO.jo == subjo).first() if jdat is not None: jdat.dinc = '0.00' db.session.commit() Gledger.query.filter(Gledger.Tcode == subjo).delete() db.session.commit() if viewo is not None and numchecked == 1: if oder > 0: modata = Income.query.get(oder) filename = modata.Depositnum docref = f'tmp/{scac}/data/vdeposits/' + filename + '.pdf' leftscreen = 0 if unrecord is not None and numchecked != 1: modlink = 0 err.append('Must check exactly one box to use this option') if cache is not None: #Save the current cache so we do not start from bad place in future udat = users.query.filter(users.name == 'cache').first() udat.username = str(cache) udat.email = oderstring db.session.commit() #This is the else for 1st time through (not posting data from overseas.html) else: from viewfuncs import popjo, jovec, timedata, nonone, nononef, init_truck_zero, erud today = datetime.date.today() today_str = datetime.datetime.today().strftime('%Y-%m-%d') now = datetime.datetime.now().strftime('%I:%M %p') oder = 0 modata = 0 modlink = 0 leftscreen = 1 leftsize = 10 docref = '' err = ['Ready to make and review account deposits'] thismuch = '2' udat = users.query.filter(users.name == 'Cache').first() cache = udat.username cache = nonone(cache) depdata = [0, 0, 0, today_str] gdata = undeposited(thismuch) odata = dataget_Dep(thismuch) leftsize = 8 acdata = Accounts.query.filter(Accounts.Type == 'Bank').all() err = erud(err) return odata, gdata, oder, err, modata, modlink, leftscreen, leftsize, today, now, docref, cache, acdata, thismuch, depdata