-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0ff67db
commit c731306
Showing
4 changed files
with
142 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import ballerinax/edifact.d03a.retail.mREQOTE; | ||
function transformQuoteRequest(mREQOTE:EDI_REQOTE_Request_for_quote_message quote) returns QuoteRequest|error { | ||
QuoteRequest quoteRequest = {accountName: "", oppName: ""}; | ||
mREQOTE:Segment_group_1_GType[] segmentGroup1 = quote.Segment_group_1; | ||
foreach mREQOTE:Segment_group_1_GType ref in segmentGroup1 { | ||
if ref.REFERENCE.REFERENCE.Reference_code_qualifier == "AES" { | ||
string? oppId = ref.REFERENCE.REFERENCE.Reference_identifier; | ||
if oppId is () { | ||
return error("Opportunity ID is not given"); | ||
} | ||
quoteRequest.oppName = oppId; | ||
} | ||
} | ||
mREQOTE:Segment_group_11_GType[] segmentGroup11 = quote.Segment_group_11; | ||
foreach mREQOTE:Segment_group_11_GType party in segmentGroup11 { | ||
if party.NAME_AND_ADDRESS.Party_function_code_qualifier == "BY" { | ||
string? prospectId = party.NAME_AND_ADDRESS?.PARTY_IDENTIFICATION_DETAILS?.Party_identifier; | ||
if prospectId is () { | ||
return error("Prospect identifier not available in quote."); | ||
} | ||
quoteRequest.accountName = prospectId; | ||
} | ||
} | ||
mREQOTE:Segment_group_27_GType[] items = quote.Segment_group_27; | ||
foreach mREQOTE:Segment_group_27_GType item in items { | ||
string? itemId = item.LINE_ITEM.Line_item_identifier; | ||
if itemId is () { | ||
return error("Item ID is not given"); | ||
} | ||
ItemData itemData = {itemId}; | ||
mREQOTE:QUANTITY_Type[] quantities = item.QUANTITY; | ||
foreach mREQOTE:QUANTITY_Type quantity in quantities { | ||
if quantity.QUANTITY_DETAILS.Quantity_type_code_qualifier == "21" { | ||
int|error amount = int:fromString(quantity.QUANTITY_DETAILS.Quantity); | ||
if amount is error { | ||
return error("Quantity must be a valid number."); | ||
} | ||
itemData.quantity = amount; | ||
break; | ||
} | ||
} | ||
quoteRequest.itemData.push(itemData); | ||
} | ||
return quoteRequest; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
type Email record {| | ||
string 'from; | ||
string subject; | ||
string body; | ||
|}; | ||
|
||
type Name record {| | ||
string firstName__c; | ||
string lastName__c; | ||
|}; | ||
|
||
type Lead record {| | ||
*Name; | ||
string email__c; | ||
string phoneNumber__c; | ||
string company__c; | ||
string designation__c; | ||
|}; |