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