Skip to content

Commit

Permalink
Merge pull request #82 from SanduDS/2201.1.x
Browse files Browse the repository at this point in the history
[Branch 2201.1.X] Add item group record support for invoices
  • Loading branch information
LakshanSS authored Oct 31, 2022
2 parents 7c6299c + 9e2608a commit 58f349a
Show file tree
Hide file tree
Showing 16 changed files with 667 additions and 125 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Ballerina Build
uses: ballerina-platform/ballerina-action/@nightly
uses: ballerina-platform/ballerina-action/@2201.1.1
with:
args:
pack ./netsuite
- name: Ballerina Test
uses: ballerina-platform/ballerina-action/@nightly
uses: ballerina-platform/ballerina-action/@2201.1.1
with:
args:
test --code-coverage ./netsuite
Expand Down
72 changes: 0 additions & 72 deletions .github/workflows/daily-build.yml

This file was deleted.

6 changes: 3 additions & 3 deletions .github/workflows/dev-stg-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Ballerina Build
uses: ballerina-platform/ballerina-action/@master
uses: ballerina-platform/ballerina-action/@2201.1.1
with:
args:
pack ./netsuite

- name: Push to Staging
if: github.event.inputs.bal_central_environment == 'STAGE'
uses: ballerina-platform/ballerina-action/@master
uses: ballerina-platform/ballerina-action/@2201.1.1
with:
args:
push
Expand All @@ -36,7 +36,7 @@ jobs:

- name: Push to Dev
if: github.event.inputs.bal_central_environment == 'DEV'
uses: ballerina-platform/ballerina-action/@master
uses: ballerina-platform/ballerina-action/@2201.1.1
with:
args:
push
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Ballerina Build
uses: ballerina-platform/ballerina-action/@master
uses: ballerina-platform/ballerina-action/@2201.1.1
with:
args:
pack ./netsuite
Expand All @@ -22,7 +22,7 @@ jobs:
NS_CLIENT_SECRET: ${{ secrets.CONSUMERSECRET }}
NS_ACCOUNTID: ${{secrets.ACCOUNTID}}
- name: Ballerina Push
uses: ballerina-platform/ballerina-action/@master
uses: ballerina-platform/ballerina-action/@2201.1.1
with:
args:
push
Expand Down
4 changes: 2 additions & 2 deletions netsuite/Ballerina.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[package]
distribution = "2201.0.0"
distribution = "2201.1.1"
org = "ballerinax"
name = "netsuite"
version = "2.2.0"
version = "2.2.1"
authors = ["Ballerina"]
repository = "https://github.com/ballerina-platform/module-ballerinax-netsuite"
keywords = ["Business Management/ERP", "Cost/Paid"]
Expand Down
39 changes: 36 additions & 3 deletions netsuite/Invoice.bal
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import ballerina/http;

isolated function mapInvoiceRecordFields(Invoice invoice) returns string|error {
isolated function mapInvoiceRecordFields(Invoice invoice, boolean replaceAll = false) returns string|error {
string finalResult = EMPTY_STRING;
map<anydata>|error invoiceMap = invoice.cloneWithType(MapAnyData);
if (invoiceMap is map<anydata>) {
Expand All @@ -33,7 +33,7 @@ isolated function mapInvoiceRecordFields(Invoice invoice) returns string|error {
string itemElements = check buildInvoiceItemElement(item);
itemXMLList += itemElements;
}
finalResult += string`<itemList>${itemXMLList}</itemList>`;
finalResult += string`<itemList replaceAll="${replaceAll}">${itemXMLList}</itemList>`;
}
position += 1;
}
Expand Down Expand Up @@ -113,11 +113,44 @@ isolated function mapInvoiceRecord(xml response) returns Invoice|error {
status: extractStringFromXML(response/**/<tranSales:status>/*),
entity: extractRecordRefFromXML(response/**/<tranSales:entity>),
currency: extractRecordRefFromXML(response/**/<tranSales:currency>),
internalId: extractRecordInternalIdFromXMLAttribute(response/**/<'record>)
internalId: extractRecordInternalIdFromXMLAttribute(response/**/<'record>),
itemList: check mapItemListMemberRecord(response/**/<tranSales:itemList>/*)
};
return invoice;
}

isolated function mapItemListMemberRecord(xml itemMembersXml) returns Item[]|error {
xmlns "urn:sales_2020_2.transactions.webservices.netsuite.com" as tranSales;
Item[] itemMembers = [];
foreach xml element in itemMembersXml {
xml elementItem = element/*;
Item itemMember = {
subscription: extractRecordRefFromXML(elementItem/**/<tranSales:subscription>/*),
item: extractRecordRefFromXML(elementItem/**/<tranSales:item>),
quantityAvailable: extractDecimalFromXML(elementItem/**/<tranSales:quantityAvailable>/*),
quantityOnHand: extractDecimalFromXML(elementItem/**/<tranSales:quantityOnHand>/*),
quantity: extractDecimalFromXML(elementItem/**/<tranSales:quantity>/*),
units: extractRecordRefFromXML(elementItem/**/<tranSales:units>),
description: extractStringFromXML(elementItem/**/<tranSales:description>/*),
price: extractRecordRefFromXML(elementItem/**/<tranSales:price>),
rate: extractStringFromXML(elementItem/**/<tranSales:rate>/*),
amount: extractDecimalFromXML(elementItem/**/<tranSales:amount>/*),
location: extractRecordRefFromXML(elementItem/**/<tranSales:location>/*),
line: extractDecimalFromXML(elementItem/**/<tranSales:line>/*)
};
boolean|error value = extractBooleanValueFromXMLOrText(element/**/<tranSales:excludeFromRateRequest>/*);
if value is boolean {
itemMember.excludeFromRateRequest = value;
}
value = extractBooleanValueFromXMLOrText(element/**/<tranSales:isTaxable>/*);
if value is boolean {
itemMember.isTaxable = value;
}
itemMembers.push(itemMember);
}
return itemMembers;
}

isolated function getInvoiceResult(http:Response response) returns @tainted Invoice|error {
xml xmlValue = check formatPayload(response);
if (response.statusCode == http:STATUS_OK) {
Expand Down
2 changes: 1 addition & 1 deletion netsuite/Package.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This package provides the capability to access NetSuite and manipulate NetSuite
### Compatibility
| | Version |
|-------------------------------|---------------------------|
| Ballerina Language | Swan Lake 2201.0.0 |
| Ballerina Language | Swan Lake 2201.1.1 |
| SOAP API | SOAP 1.1 |
| WSDL | 2020.2.0 |

Expand Down
Loading

0 comments on commit 58f349a

Please sign in to comment.