Check for shipments already made against orders.
parent
bc6f82ada2
commit
a239a09799
|
@ -27,6 +27,8 @@ import records # type: ignore
|
|||
import yamamotoyama # type: ignore
|
||||
import yamamotoyama.x3_imports # type: ignore
|
||||
|
||||
import simple_email_notification
|
||||
|
||||
THIS_DIRECTORY = pathlib.Path(__file__).parent
|
||||
X12_DIRECTORY = THIS_DIRECTORY / "incoming"
|
||||
IMPORTS_DIRECTORY = THIS_DIRECTORY / "x3_imports"
|
||||
|
@ -202,7 +204,9 @@ X3_CUSTOMER_MAPPING = {
|
|||
'LOND1000_0000' : 'LOND0001',
|
||||
'VEND1000_VENDAB' : 'VEND0002',
|
||||
'ISLA1000_190132' : 'ISLA0005',
|
||||
'ISLA1000_0000' : 'ISLA0005',
|
||||
'PURI1000_0000' : 'PURI0002',
|
||||
'AVRI1000_AVRIGR' : 'AVRI0001',
|
||||
}
|
||||
|
||||
def main():
|
||||
|
@ -410,113 +414,125 @@ def process_file(edi_filename: pathlib.Path):
|
|||
def import_shipment(warehouse_shipment):
|
||||
"""send the shipment information to the shandex staging database"""
|
||||
with yamamotoyama.get_connection() as data_base:
|
||||
with data_base.transaction():
|
||||
data_base.query(
|
||||
INSERT_SHIPMENT,
|
||||
PO=warehouse_shipment.header.yclippership+'_'+warehouse_shipment.header.ylicplate,
|
||||
H='H',
|
||||
salfcy=warehouse_shipment.header.salfcy,
|
||||
stofcy=warehouse_shipment.header.stofcy,
|
||||
sdhnum=warehouse_shipment.header.sdhnum,
|
||||
bpcinv=warehouse_shipment.header.bpcinv,
|
||||
bpcord=warehouse_shipment.header.bpcord,
|
||||
bpaadd=warehouse_shipment.header.bpaadd,
|
||||
cur=warehouse_shipment.header.cur,
|
||||
shidat=warehouse_shipment.header.shidat.strftime("%Y%m%d"),
|
||||
cfmflg=warehouse_shipment.header.cfmflg,
|
||||
pjt=warehouse_shipment.header.pjt,
|
||||
bptnum=warehouse_shipment.header.bptnum,
|
||||
ylicplate=warehouse_shipment.header.ylicplate,
|
||||
yclippership=warehouse_shipment.header.yclippership,
|
||||
invdtaamt_2=warehouse_shipment.header.invdtaamt_2,
|
||||
invdtaamt_3=warehouse_shipment.header.invdtaamt_3,
|
||||
invdtaamt_4=warehouse_shipment.header.invdtaamt_4,
|
||||
invdtaamt_5=warehouse_shipment.header.invdtaamt_5,
|
||||
invdtaamt_6=warehouse_shipment.header.invdtaamt_6,
|
||||
invdtaamt_7=warehouse_shipment.header.invdtaamt_7,
|
||||
invdtaamt_8=warehouse_shipment.header.invdtaamt_8,
|
||||
invdtaamt_9=warehouse_shipment.header.invdtaamt_9,
|
||||
die=warehouse_shipment.header.die,
|
||||
die_1=warehouse_shipment.header.die_1,
|
||||
die_2=warehouse_shipment.header.die_2,
|
||||
die_3=warehouse_shipment.header.die_3,
|
||||
die_4=warehouse_shipment.header.die_4,
|
||||
die_5=warehouse_shipment.header.die_5,
|
||||
die_6=warehouse_shipment.header.die_6,
|
||||
die_7=warehouse_shipment.header.die_7,
|
||||
die_8=warehouse_shipment.header.die_8,
|
||||
die_9=warehouse_shipment.header.die_9,
|
||||
die_10=warehouse_shipment.header.die_10,
|
||||
die_11=warehouse_shipment.header.die_11,
|
||||
die_12=warehouse_shipment.header.die_12,
|
||||
die_13=warehouse_shipment.header.die_13,
|
||||
die_14=warehouse_shipment.header.die_14,
|
||||
die_15=warehouse_shipment.header.die_15,
|
||||
die_16=warehouse_shipment.header.die_16,
|
||||
die_17=warehouse_shipment.header.die_17,
|
||||
die_18=warehouse_shipment.header.die_18,
|
||||
die_19=warehouse_shipment.header.die_19,
|
||||
cce=warehouse_shipment.header.cce,
|
||||
cce_1=warehouse_shipment.header.cce_1,
|
||||
cce_2=warehouse_shipment.header.cce_2,
|
||||
cce_3=warehouse_shipment.header.cce_3,
|
||||
cce_4=warehouse_shipment.header.cce_4,
|
||||
cce_5=warehouse_shipment.header.cce_5,
|
||||
cce_6=warehouse_shipment.header.cce_6,
|
||||
cce_7=warehouse_shipment.header.cce_7,
|
||||
cce_8=warehouse_shipment.header.cce_8,
|
||||
cce_9=warehouse_shipment.header.cce_9,
|
||||
cce_10=warehouse_shipment.header.cce_10,
|
||||
cce_11=warehouse_shipment.header.cce_11,
|
||||
cce_12=warehouse_shipment.header.cce_12,
|
||||
cce_13=warehouse_shipment.header.cce_13,
|
||||
cce_14=warehouse_shipment.header.cce_14,
|
||||
cce_15=warehouse_shipment.header.cce_15,
|
||||
cce_16=warehouse_shipment.header.cce_16,
|
||||
cce_17=warehouse_shipment.header.cce_17,
|
||||
cce_18=warehouse_shipment.header.cce_18,
|
||||
cce_19=warehouse_shipment.header.cce_19,
|
||||
bpdnam=warehouse_shipment.header.bpdnam,
|
||||
bpdaddlig=warehouse_shipment.header.bpdaddlig,
|
||||
bpdaddlig_1=warehouse_shipment.header.bpdaddlig_1,
|
||||
bpdaddlig_2=warehouse_shipment.header.bpdaddlig_2,
|
||||
bpdposcod=warehouse_shipment.header.bpdposcod,
|
||||
bpdcty=warehouse_shipment.header.bpdcty,
|
||||
bpdsat=warehouse_shipment.header.bpdsat,
|
||||
bpdcry=warehouse_shipment.header.bpdcry,
|
||||
bpdcrynam=warehouse_shipment.header.bpdcrynam,
|
||||
sdhtyp=warehouse_shipment.header.sdhtyp,
|
||||
growei=warehouse_shipment.header.growei,
|
||||
pacnbr=warehouse_shipment.header.pacnbr,
|
||||
star71=warehouse_shipment.header.star71,
|
||||
star72=warehouse_shipment.header.star72,
|
||||
star81=warehouse_shipment.header.star81,
|
||||
star82=warehouse_shipment.header.star82
|
||||
)
|
||||
with data_base.transaction():
|
||||
for detail in warehouse_shipment.details:
|
||||
for subdetail in detail.subdetails:
|
||||
data_base.query(
|
||||
INSERT_SHIPMENT_DETAIL,
|
||||
PO=warehouse_shipment.header.yclippership+'_'+warehouse_shipment.header.ylicplate,
|
||||
L='L',
|
||||
sohnum=detail.sohnum,
|
||||
soplin=str(detail.soplin),
|
||||
itmref=detail.itmref,
|
||||
itmdes=detail.itmdes,
|
||||
sau=detail.sau,
|
||||
qty=str(detail.qty),
|
||||
gropri=detail.gropri,
|
||||
star91=detail.star91,
|
||||
star92=detail.star92,
|
||||
S='S',
|
||||
sta=subdetail.sta,
|
||||
pcu=subdetail.pcu,
|
||||
qtypcu=str(subdetail.qtypcu),
|
||||
loc=subdetail.loc,
|
||||
lot=subdetail.lot,
|
||||
sernum=subdetail.sernum
|
||||
)
|
||||
result = data_base.query(
|
||||
"""
|
||||
SELECT
|
||||
ylicplate
|
||||
FROM [staging].[dbo].[shandex_shipments]
|
||||
where ylicplate = :order
|
||||
""",
|
||||
order=warehouse_shipment.header.ylicplate,
|
||||
).all()
|
||||
if not result:
|
||||
with data_base.transaction():
|
||||
data_base.query(
|
||||
INSERT_SHIPMENT,
|
||||
PO=warehouse_shipment.header.yclippership+'_'+warehouse_shipment.header.ylicplate,
|
||||
H='H',
|
||||
salfcy=warehouse_shipment.header.salfcy,
|
||||
stofcy=warehouse_shipment.header.stofcy,
|
||||
sdhnum=warehouse_shipment.header.sdhnum,
|
||||
bpcinv=warehouse_shipment.header.bpcinv,
|
||||
bpcord=warehouse_shipment.header.bpcord,
|
||||
bpaadd=warehouse_shipment.header.bpaadd,
|
||||
cur=warehouse_shipment.header.cur,
|
||||
shidat=warehouse_shipment.header.shidat.strftime("%Y%m%d"),
|
||||
cfmflg=warehouse_shipment.header.cfmflg,
|
||||
pjt=warehouse_shipment.header.pjt,
|
||||
bptnum=warehouse_shipment.header.bptnum,
|
||||
ylicplate=warehouse_shipment.header.ylicplate,
|
||||
yclippership=warehouse_shipment.header.yclippership,
|
||||
invdtaamt_2=warehouse_shipment.header.invdtaamt_2,
|
||||
invdtaamt_3=warehouse_shipment.header.invdtaamt_3,
|
||||
invdtaamt_4=warehouse_shipment.header.invdtaamt_4,
|
||||
invdtaamt_5=warehouse_shipment.header.invdtaamt_5,
|
||||
invdtaamt_6=warehouse_shipment.header.invdtaamt_6,
|
||||
invdtaamt_7=warehouse_shipment.header.invdtaamt_7,
|
||||
invdtaamt_8=warehouse_shipment.header.invdtaamt_8,
|
||||
invdtaamt_9=warehouse_shipment.header.invdtaamt_9,
|
||||
die=warehouse_shipment.header.die,
|
||||
die_1=warehouse_shipment.header.die_1,
|
||||
die_2=warehouse_shipment.header.die_2,
|
||||
die_3=warehouse_shipment.header.die_3,
|
||||
die_4=warehouse_shipment.header.die_4,
|
||||
die_5=warehouse_shipment.header.die_5,
|
||||
die_6=warehouse_shipment.header.die_6,
|
||||
die_7=warehouse_shipment.header.die_7,
|
||||
die_8=warehouse_shipment.header.die_8,
|
||||
die_9=warehouse_shipment.header.die_9,
|
||||
die_10=warehouse_shipment.header.die_10,
|
||||
die_11=warehouse_shipment.header.die_11,
|
||||
die_12=warehouse_shipment.header.die_12,
|
||||
die_13=warehouse_shipment.header.die_13,
|
||||
die_14=warehouse_shipment.header.die_14,
|
||||
die_15=warehouse_shipment.header.die_15,
|
||||
die_16=warehouse_shipment.header.die_16,
|
||||
die_17=warehouse_shipment.header.die_17,
|
||||
die_18=warehouse_shipment.header.die_18,
|
||||
die_19=warehouse_shipment.header.die_19,
|
||||
cce=warehouse_shipment.header.cce,
|
||||
cce_1=warehouse_shipment.header.cce_1,
|
||||
cce_2=warehouse_shipment.header.cce_2,
|
||||
cce_3=warehouse_shipment.header.cce_3,
|
||||
cce_4=warehouse_shipment.header.cce_4,
|
||||
cce_5=warehouse_shipment.header.cce_5,
|
||||
cce_6=warehouse_shipment.header.cce_6,
|
||||
cce_7=warehouse_shipment.header.cce_7,
|
||||
cce_8=warehouse_shipment.header.cce_8,
|
||||
cce_9=warehouse_shipment.header.cce_9,
|
||||
cce_10=warehouse_shipment.header.cce_10,
|
||||
cce_11=warehouse_shipment.header.cce_11,
|
||||
cce_12=warehouse_shipment.header.cce_12,
|
||||
cce_13=warehouse_shipment.header.cce_13,
|
||||
cce_14=warehouse_shipment.header.cce_14,
|
||||
cce_15=warehouse_shipment.header.cce_15,
|
||||
cce_16=warehouse_shipment.header.cce_16,
|
||||
cce_17=warehouse_shipment.header.cce_17,
|
||||
cce_18=warehouse_shipment.header.cce_18,
|
||||
cce_19=warehouse_shipment.header.cce_19,
|
||||
bpdnam=warehouse_shipment.header.bpdnam,
|
||||
bpdaddlig=warehouse_shipment.header.bpdaddlig,
|
||||
bpdaddlig_1=warehouse_shipment.header.bpdaddlig_1,
|
||||
bpdaddlig_2=warehouse_shipment.header.bpdaddlig_2,
|
||||
bpdposcod=warehouse_shipment.header.bpdposcod,
|
||||
bpdcty=warehouse_shipment.header.bpdcty,
|
||||
bpdsat=warehouse_shipment.header.bpdsat,
|
||||
bpdcry=warehouse_shipment.header.bpdcry,
|
||||
bpdcrynam=warehouse_shipment.header.bpdcrynam,
|
||||
sdhtyp=warehouse_shipment.header.sdhtyp,
|
||||
growei=warehouse_shipment.header.growei,
|
||||
pacnbr=warehouse_shipment.header.pacnbr,
|
||||
star71=warehouse_shipment.header.star71,
|
||||
star72=warehouse_shipment.header.star72,
|
||||
star81=warehouse_shipment.header.star81,
|
||||
star82=warehouse_shipment.header.star82
|
||||
)
|
||||
with data_base.transaction():
|
||||
for detail in warehouse_shipment.details:
|
||||
for subdetail in detail.subdetails:
|
||||
data_base.query(
|
||||
INSERT_SHIPMENT_DETAIL,
|
||||
PO=warehouse_shipment.header.yclippership+'_'+warehouse_shipment.header.ylicplate,
|
||||
L='L',
|
||||
sohnum=detail.sohnum,
|
||||
soplin=str(detail.soplin),
|
||||
itmref=detail.itmref,
|
||||
itmdes=detail.itmdes,
|
||||
sau=detail.sau,
|
||||
qty=str(detail.qty),
|
||||
gropri=detail.gropri,
|
||||
star91=detail.star91,
|
||||
star92=detail.star92,
|
||||
S='S',
|
||||
sta=subdetail.sta,
|
||||
pcu=subdetail.pcu,
|
||||
qtypcu=str(subdetail.qtypcu),
|
||||
loc=subdetail.loc,
|
||||
lot=subdetail.lot,
|
||||
sernum=subdetail.sernum
|
||||
)
|
||||
else:
|
||||
simple_email_notification.email_noticication(['bleeson@stashtea.com'],'Shandex Order Error',[f'{warehouse_shipment.header.ylicplate} already exists, is this a reship?'])
|
||||
|
||||
@dataclasses.dataclass
|
||||
class WarehouseShipmentSubDetail:
|
||||
|
|
Loading…
Reference in New Issue