Check for shipments already made against orders.

master
bleeson 2024-11-22 12:13:34 -08:00
parent bc6f82ada2
commit a239a09799
1 changed files with 123 additions and 107 deletions

View File

@ -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,6 +414,16 @@ 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:
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,
@ -517,6 +531,8 @@ def import_shipment(warehouse_shipment):
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: