Shipping accound address doctype added and data

main
vrashank 8 months ago
parent c1f2fab23f
commit e1f58d9b1b

@ -0,0 +1,49 @@
{
"actions": [],
"allow_rename": 1,
"autoname": "field:customer_name",
"creation": "2025-05-05 23:28:00.914008",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"trading_partner_id_column",
"customer_name",
"trading_partner_id"
],
"fields": [
{
"fieldname": "trading_partner_id_column",
"fieldtype": "Column Break",
"label": "Trading Partner ID"
},
{
"fieldname": "customer_name",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Customer Name",
"options": "Customer",
"unique": 1
},
{
"fetch_from": "customer_name.custom_trading_partner_id",
"fieldname": "trading_partner_id",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Trading Partner ID"
}
],
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2025-05-05 23:33:29.668402",
"modified_by": "Administrator",
"module": "SPS Integration",
"name": "Dropship Partners",
"naming_rule": "By fieldname",
"owner": "Administrator",
"permissions": [],
"sort_field": "modified",
"sort_order": "DESC",
"states": []
}

@ -0,0 +1,9 @@
# Copyright (c) 2025, UnifyXperts and contributors
# For license information, please see license.txt
# import frappe
from frappe.model.document import Document
class DropshipPartners(Document):
pass

@ -0,0 +1,8 @@
// Copyright (c) 2025, UnifyXperts and contributors
// For license information, please see license.txt
// frappe.ui.form.on("Shipping Account Address", {
// refresh(frm) {
// },
// });

@ -0,0 +1,98 @@
{
"actions": [],
"allow_rename": 1,
"autoname": "field:edi_no",
"creation": "2025-05-05 21:21:25.647193",
"doctype": "DocType",
"engine": "InnoDB",
"field_order": [
"customer",
"edi_no",
"account_number",
"store_code",
"column_break_ixfr",
"carrier",
"modeservice",
"billing_option",
"section_break_nuxv",
"store_address"
],
"fields": [
{
"fetch_from": "customer.custom_trading_partner_id",
"fieldname": "edi_no",
"fieldtype": "Data",
"label": "EDI No",
"unique": 1
},
{
"fieldname": "account_number",
"fieldtype": "Data",
"label": "Account Number"
},
{
"fieldname": "store_code",
"fieldtype": "Data",
"label": "Store Code"
},
{
"fieldname": "store_address",
"fieldtype": "Small Text",
"label": "Store Address"
},
{
"fieldname": "column_break_ixfr",
"fieldtype": "Column Break"
},
{
"fieldname": "carrier",
"fieldtype": "Data",
"label": "Carrier"
},
{
"fieldname": "modeservice",
"fieldtype": "Data",
"label": "Mode/Service"
},
{
"fieldname": "billing_option",
"fieldtype": "Data",
"label": "Billing Option"
},
{
"fieldname": "section_break_nuxv",
"fieldtype": "Section Break"
},
{
"fieldname": "customer",
"fieldtype": "Link",
"label": "Customer",
"options": "Customer"
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2025-05-09 22:01:26.266550",
"modified_by": "Administrator",
"module": "SPS Integration",
"name": "Shipping Account Address",
"naming_rule": "By fieldname",
"owner": "Administrator",
"permissions": [
{
"create": 1,
"delete": 1,
"email": 1,
"export": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "System Manager",
"share": 1,
"write": 1
}
],
"sort_field": "modified",
"sort_order": "DESC",
"states": []
}

@ -0,0 +1,9 @@
# Copyright (c) 2025, UnifyXperts and contributors
# For license information, please see license.txt
# import frappe
from frappe.model.document import Document
class ShippingAccountAddress(Document):
pass

@ -0,0 +1,9 @@
# Copyright (c) 2025, UnifyXperts and Contributors
# See license.txt
# import frappe
from frappe.tests.utils import FrappeTestCase
class TestShippingAccountAddress(FrappeTestCase):
pass

@ -24,6 +24,7 @@
"default_item_group",
"marketplace",
"get_sales_order_url",
"customer",
"column_break_rxhv",
"customer_type",
"shipping_category",
@ -184,11 +185,17 @@
"fieldname": "order_acknowledgement_url",
"fieldtype": "Data",
"label": "Order Acknowledgement URL"
},
{
"fieldname": "customer",
"fieldtype": "Link",
"label": "Customer",
"options": "Customer"
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2025-04-07 04:05:58.550899",
"modified": "2025-05-09 21:43:43.570469",
"modified_by": "Administrator",
"module": "SPS Integration",
"name": "SPS Integration Settings",

@ -179,6 +179,7 @@ def create_sps_sales_order(data: dict, setting_doc: str, path: str) -> None:
consumer_order_number = order_header.get("CustomerOrderNumber")
po_date = order_header.get("PurchaseOrderDate")
doc = frappe.get_doc("SPS Integration Settings", setting_doc)
trading_partner_id = order_header.get("TradingPartnerId")
# Get delivery date
delivery_date = next(
@ -210,6 +211,19 @@ def create_sps_sales_order(data: dict, setting_doc: str, path: str) -> None:
"naming_series"
)
# Logic to fetch carrier, mode, service for partners (WWWG) and others partners to
if po_no:
if customer_name == doc.customer:
# Fetch by EDI number from po_no
edi_no = po_no.split("-")[1]
if frappe.db.exists("Shipping Account Address", edi_no):
shipping_account = frappe.get_doc("Shipping Account Address", edi_no)
else:
# Fetch by trading partner ID
if frappe.db.exists("Shipping Account Address", trading_partner_id):
shipping_account = frappe.get_doc("Shipping Account Address", trading_partner_id)
# Create Sales Order
sales_order = frappe.new_doc("Sales Order")
sales_order.naming_series = series_name
@ -224,6 +238,12 @@ def create_sps_sales_order(data: dict, setting_doc: str, path: str) -> None:
sales_order.shipping_address_name = shipping_address
sales_order.custom_do_not_apply_freight_rates = 1
sales_order.custom_sales_order_path = path
sales_order.custom_notes_for_extensiv = shipping_account.store_address
sales_order.custom_shipping_account_number = shipping_account.account_number
sales_order.custom_billing_code = shipping_account.billing_option
sales_order.custom_modeservice = shipping_account.modeservice
sales_order.custom_carrier = shipping_account.carrier
if contact_name:
sales_order.contact_person = contact_name
@ -264,6 +284,7 @@ def create_sps_sales_order_console(data: dict, setting_doc: str, path: str) -> N
po_no = order_header.get("PurchaseOrderNumber")
consumer_order_number = order_header.get("CustomerOrderNumber")
po_date = order_header.get("PurchaseOrderDate")
trading_partner_id = order_header.get("TradingPartnerId")
print(f"➡️ PO No: {po_no}, Customer Order No: {consumer_order_number}, PO Date: {po_date}")
print("🔧 Step 2: Fetching SPS Integration Settings...")
@ -325,6 +346,17 @@ def create_sps_sales_order_console(data: dict, setting_doc: str, path: str) -> N
return
print("📝 Step 8: Creating new Sales Order document...")
# Logic to fetch carrier, mode, service for partners (WWWG) and others partners to
if po_no:
if customer_name == doc.customer:
# Fetch by EDI number from po_no
edi_no = po_no.split("-")[1]
if frappe.db.exists("Shipping Account Address", edi_no):
shipping_account = frappe.get_doc("Shipping Account Address", edi_no)
else:
# Fetch by trading partner ID
if frappe.db.exists("Shipping Account Address", trading_partner_id):
shipping_account = frappe.get_doc("Shipping Account Address", trading_partner_id)
try:
sales_order = frappe.new_doc("Sales Order")
sales_order.naming_series = series_name
@ -338,6 +370,11 @@ def create_sps_sales_order_console(data: dict, setting_doc: str, path: str) -> N
sales_order.custom_do_not_apply_freight_rates = 1
sales_order.shipping_address_name = shipping_address
sales_order.custom_sales_order_path = path
sales_order.custom_notes_for_extensiv = shipping_account.store_address
sales_order.custom_shipping_account_number = shipping_account.account_number
sales_order.custom_billing_code = shipping_account.billing_option
sales_order.custom_modeservice = shipping_account.modeservice
sales_order.custom_carrier = shipping_account.carrier
if contact_name:
sales_order.contact_person = contact_name
print("✅ Sales Order initialized.")

Loading…
Cancel
Save