forked from fylein/netsuite-sdk-py
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update to most recent #17
Open
ericroberts
wants to merge
10
commits into
master
Choose a base branch
from
update-to-most-recent
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
32cf0b0
Items support (#114)
labhvam5 8a14ba5
making expenses optional and adding items support for vendor_bill (#115)
labhvam5 bafb51a
feature: support of error parser for expense report export (#113)
NileshPant1999 3b02232
bug fix: minor fix for string replacement (#117)
NileshPant1999 b7228e6
netsuite error parser support for JE and Bills (#118)
NileshPant1999 14ed4b8
bug fix: additional conditional for customer entity (#119)
NileshPant1999 43eeb1e
use keys we store in destination attribute db and remove loggers (#120)
NileshPant1999 99d9884
Adding option for incremental fetch of Employees (#122)
Shwetabhk 6e7ed74
adjustable page size for employees generator (#123)
Shwetabhk 4c8d6ad
Merge remote-tracking branch 'source/master' into update-to-most-recent
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,24 @@ | ||
from .base import ApiBase | ||
from netsuitesdk.internal.utils import PaginatedSearch | ||
import logging | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
class Items(ApiBase): | ||
|
||
def __init__(self, ns_client): | ||
ApiBase.__init__(self, ns_client=ns_client, type_name='Item') | ||
|
||
def get_all_generator(self, is_inactive=False): | ||
# Get Only Active Items using SearchBooleanField | ||
record_type_search_field = self.ns_client.SearchBooleanField(searchValue=is_inactive) | ||
basic_search = self.ns_client.basic_search_factory('Item', isInactive=record_type_search_field) | ||
|
||
paginated_search = PaginatedSearch( | ||
client=self.ns_client, | ||
type_name='Item', | ||
basic_search=basic_search, | ||
pageSize=20 | ||
) | ||
|
||
return self._paginated_search_generator(paginated_search=paginated_search) |
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
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
Empty file.
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,81 @@ | ||
|
||
error_reference = { | ||
"expense_report": { | ||
'category_reference_error': { | ||
'regex': r"An error occured in a upsert request: Invalid category reference key \d+ for entity \d+", | ||
'keys': ['expense_category', 'employee'] | ||
}, | ||
'account_reference_error': { | ||
'regex': r"An error occured in a upsert request: Invalid account reference key \d+ for subsidiary \d+", | ||
'keys': ['account', 'subsidiary'] | ||
}, | ||
'project_reference_error': { | ||
'regex': r"An error occured in a upsert request: Invalid customer reference key \d+ for entity \d+", | ||
'keys': ['customer', 'employee'] | ||
}, | ||
'location_reference_error': { | ||
'regex': r"An error occured in a upsert request: Invalid location reference key \d+ for subsidiary \d+", | ||
'keys': ['location', 'subsidiary'] | ||
}, | ||
'department_reference_error': { | ||
'regex':r"An error occured in a upsert request: Invalid department reference key \d+ for subsidiary \d+" , | ||
'keys': ['department', 'subsidiary'] | ||
}, | ||
'currency_reference_error': { | ||
'regex': r"An error occured in a upsert request: Invalid currency reference key \d+ for subsidiary \d+", | ||
'keys': ['currency', 'subsidiary'] | ||
} | ||
}, | ||
"bills": { | ||
'bill_account_reference_error': { | ||
'regex': r"An error occured in a upsert request: Invalid account reference key \d+ for subsidiary \d+", | ||
'keys': ['account', 'subsidiary'] | ||
}, | ||
'location_reference_error': { | ||
'regex': r"An error occured in a upsert request: Invalid location reference key \d+ for subsidiary \d+", | ||
'keys': ['location', 'subsidiary'] | ||
}, | ||
'department_reference_error': { | ||
'regex':r"An error occured in a upsert request: Invalid department reference key \d+ for subsidiary \d+" , | ||
'keys': ['department', 'subsidiary'] | ||
}, | ||
'currency_reference_error': { | ||
'regex': r"An error occured in a upsert request: Invalid currency reference key \d+ for subsidiary \d+", | ||
'keys': ['currency', 'subsidiary'] | ||
}, | ||
'vendor_reference_error': { | ||
'regex': r"An error occured in a upsert request: Invalid entity reference key \d+ for subsidiary \d+", | ||
'keys': ['vendor', 'subsidiary'] | ||
} | ||
}, | ||
"journal_entry": { | ||
'location_reference_error': { | ||
'regex': r"An error occured in a upsert request: Invalid location reference key \d+ for subsidiary \d+", | ||
'keys': ['location', 'subsidiary'] | ||
}, | ||
'department_reference_error': { | ||
'regex':r"An error occured in a upsert request: Invalid department reference key \d+ for subsidiary \d+" , | ||
'keys': ['department', 'subsidiary'] | ||
}, | ||
'account_reference_error': { | ||
'regex': r"An error occured in a upsert request: Invalid account reference key \d+ for subsidiary \d+", | ||
'keys': ['account', 'subsidiary'] | ||
}, | ||
'currency_reference_error': { | ||
'regex': r"An error occured in a upsert request: Invalid currency reference key \d+ for subsidiary \d+", | ||
'keys': ['currency', 'subsidiary'] | ||
}, | ||
'project_reference_error': { | ||
'regex': r"An error occured in a upsert request: Invalid customer reference key \d+ for entity \d+", | ||
'keys': ['customer', 'employee'] | ||
}, | ||
} | ||
} | ||
|
||
|
||
list_of_dicts = [ | ||
['expense_category', 'employee'], ['account', 'subsidiary'], | ||
['customer', 'employee'], ['location', 'subsidiary'], | ||
['department', 'subsidiary'], ['currency', 'subsidiary'], | ||
['vendor', 'subsdiary'] | ||
] |
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,21 @@ | ||
import re | ||
from .errors import error_reference | ||
|
||
|
||
def replace_numbers(string , replacement1, replacement2, number1, number2): | ||
pattern = r"\b({0}|{1})\b".format(number1, number2) | ||
replaced_string = re.sub(pattern, lambda match: replacement1 if match.group() == str(number1) else replacement2, string) | ||
return replaced_string | ||
|
||
|
||
def convert_to_camelcase(word): | ||
return ''.join(word.title().split('_')) | ||
|
||
|
||
def export_error_matcher(string, export_type): | ||
for _, error_data in error_reference[export_type].items(): | ||
if re.match(error_data['regex'], string): | ||
numbers = re.findall(r'\d+', string) | ||
return {key: int(number) for key, number in zip(error_data['keys'], numbers)} | ||
|
||
return {} |
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,39 @@ | ||
from .helpers import replace_numbers, convert_to_camelcase | ||
from .errors import list_of_dicts | ||
|
||
class ErrorParser(): | ||
|
||
def __init__(self, get_instance): | ||
self.get_instance = get_instance | ||
|
||
def get_entity_values(self, error_dict): | ||
|
||
entity_keys = list(error_dict) | ||
object_1 = self.get_instance(convert_to_camelcase(entity_keys[0]), error_dict[entity_keys[0]]) | ||
object_2 = self.get_instance(convert_to_camelcase(entity_keys[1]), error_dict[entity_keys[1]]) | ||
|
||
if object_1 and object_2: | ||
if entity_keys[0] == 'customer' and entity_keys[1] == 'employee': | ||
return object_1['entityId'], object_2['entityId'] | ||
|
||
if entity_keys[1] == 'employee': | ||
return object_1['name'], object_2['entityId'] | ||
|
||
if entity_keys[0] == 'account': | ||
object_1 = object_1['acctName'] | ||
return object_1, object_2['name'] | ||
|
||
if entity_keys[0] == 'vendor': | ||
return object_1['entityId'], object_2['name'] | ||
|
||
return object_1['name'], object_2['name'] | ||
|
||
|
||
def export_error_parser(self, error_dict, message): | ||
|
||
parsed_message = message | ||
if list(error_dict) in list_of_dicts: | ||
object_1, object_2 = self.get_entity_values(error_dict) | ||
entity_keys = list(error_dict) | ||
parsed_message = replace_numbers(message, object_1, object_2, error_dict[entity_keys[0]], error_dict[entity_keys[1]]) | ||
return parsed_message |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the changes here are to support customFields for items. We don't use item based lines, so we're in the clear. 😄