示例#1
0
def checkon(con, bk):
    if not hasinput(con): con = ''
    if not hasinput(bk): bk = ''
    if con == 'TBD' or len(con) < 9:
        retcon = 'XXX'
    else:
        retcon = con
    if len(bk) < 6:
        retbk = 'YYY'
    else:
        retbk = bk
    return retcon, retbk
示例#2
0
    next_month = any_day.replace(day=28) + datetime.timedelta(days=4)
    # subtract the number of remaining 'overage' days to get last day of current month, or said programattically said, the previous day of the first of next month
    return next_month - datetime.timedelta(days=next_month.day)


#Separate customers into invoiced and cash-paying, this provides a way to determine what
#amounts should show up in bank
legitco = []
cashco = []
keydates = []
pdata = People.query.filter(People.Ptype == 'Trucking').all()
for pdat in pdata:
    e1 = pdat.Email
    e2 = pdat.Associate1
    e3 = pdat.Associate2
    if hasinput(e1) or hasinput(e2) or hasinput(e3):
        legitco.append(pdat.Company)
    else:
        cashco.append(pdat.Company)
#print(f'Legitco: {legitco}')
#print(f'Cashco : {cashco}')

#Create the invoice periods of interest. This creates a data output for each 2 weeks
year = 2021
ytd_month = 1
ytd_day = 5
d1 = datetime.date(2021, 1, 15)
while year < 2022:
    year = d1.year
    keydates.append(d1)
    d1 = d1 + timedelta(14)
示例#3
0
today = runat.date()
lookback = runat - timedelta(20)
lbdate = lookback.date()
conlist = []
outbookings = []
unpulled_exports = []
unpulled_imports = []
pulled_exports = []
pulled_imports = []

# Define Status as Export or Import
jdata = Orders.query.filter((Orders.Hstat == 0) & (Orders.Date > lbdate)).all()
for jdat in jdata:
    con = jdat.Container
    bk = jdat.Booking
    if hasinput(con) and con != 'TBD':
        print(f'Job for {jdat.Shipper} and {bk} {con} is import')
        jdat.Path = 'Import'
        unpulled_imports.append(con)
    else:
        print(f'Job for {jdat.Shipper} and {bk} {con} is export')
        jdat.Path = 'Export'
        unpulled_exports.append(bk)
db.session.commit()

# Define Status as Export or Import for Pulled Containers if not Defined Already
jdata = Orders.query.filter((Orders.Hstat == 1) & (Orders.Date > lbdate)).all()
for jdat in jdata:
    con = jdat.Container
    bk = jdat.Booking
    idat = Interchange.query.filter((Interchange.Container == con)
lookback = runat - timedelta(20)
lookback_ocean = runat - timedelta(20)
lbdate = lookback.date()
lbdate_ocean = lookback_ocean.date()
print(' ')
print('________________________________________________________')
print(f'This sequence run at {runat} with look back to {lbdate}')
print('________________________________________________________')
print(' ')

#Make sure all the booking and container numbers for orders have upper case:
#These correction made only once, using Release...set to 1 after corrections
jdata = Orders.query.filter( (~Orders.Status.endswith('3')) & (Orders.Date > lbdate) & (Orders.Release == 0) ).all()
for jdat in jdata:
    bk = jdat.Booking
    if hasinput(bk):
        bk = bk.upper()
        bk = bk.strip()
    else:
        bk = ''
    con = jdat.Container
    if hasinput(con):
        con = con.upper()
        con = con.strip()
    else:
        con = ''
    jdat.Booking = bk
    jdat.Container = con
    jdat.Release = 1
    db.session.commit()