Skip to content

Commit

Permalink
Adding support for VendorCredits (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
gustahrodrigues authored Sep 2, 2021
1 parent f8613bd commit 84561a8
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 0 deletions.
71 changes: 71 additions & 0 deletions netsuitesdk/api/vendor_credits.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
from collections import OrderedDict

from .base import ApiBase
import logging

logger = logging.getLogger(__name__)


class VendorCredits(ApiBase):
SIMPLE_FIELDS = [
'accountingBookDetailList',
'applied',
'applyList',
'autoApply',
'billingAddress',
'createdDate',
'currencyName',
'customFieldList',
'exchangeRate',
'expenseList',
'internalId',
'itemList',
'lastModifiedDate',
'memo',
'taxDetailsList',
'taxDetailsOverride',
'taxPointDate',
'taxRegOverride',
'total',
'tranDate',
'tranId',
'transactionNumber',
'unApplied',
'userTaxTotal',
'userTotal',
'nullFieldList',
]

RECORD_REF_FIELDS = [
'account',
'billAddressList',
'class',
'createdFrom',
'currency',
'customForm',
'department',
'entityTaxRegNum',
'location',
'nexus',
'postingPeriod',
'subsidiary',
'subsidiaryTaxRegNum',
]

def __init__(self, ns_client):
ApiBase.__init__(self, ns_client=ns_client, type_name='VendorCredit')

def post(self, data) -> OrderedDict:
assert data['externalId'], 'missing external id'
vendor_credit = self.ns_client.VendorCredit(**data)

vendor_credit['entity'] = self.ns_client.RecordRef(**(data['entity']))

self.build_simple_fields(self.SIMPLE_FIELDS, data, vendor_credit)

self.build_record_ref_fields(self.RECORD_REF_FIELDS, data, vendor_credit)

logger.debug('able to create vendor credit = %s', vendor_credit)

res = self.ns_client.upsert(vendor_credit)
return self._serialize(res)
2 changes: 2 additions & 0 deletions netsuitesdk/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from .api.currencies import Currencies
from .api.locations import Locations
from .api.vendor_bills import VendorBills
from .api.vendor_credits import VendorCredits
from .api.vendors import Vendors
from .api.subsidiaries import Subsidiaries
from .api.journal_entries import JournalEntries
Expand Down Expand Up @@ -45,6 +46,7 @@ def __init__(self, account, consumer_key, consumer_secret, token_key, token_secr
self.currencies = Currencies(ns_client)
self.locations = Locations(ns_client)
self.vendor_bills = VendorBills(ns_client)
self.vendor_credits = VendorCredits(ns_client)
self.vendors = Vendors(ns_client)
self.subsidiaries = Subsidiaries(ns_client)
self.journal_entries = JournalEntries(ns_client)
Expand Down
11 changes: 11 additions & 0 deletions netsuitesdk/internal/netsuite_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@
'ClassificationSearchBasic',
],

'ns6': [
'ItemCostEstimateType',
],

# urn:relationships.lists.webservices.netsuite.com
'ns13': [
'CustomerAddressbook', 'CustomerAddressbookList',
Expand Down Expand Up @@ -109,6 +113,13 @@
'VendorBillExpenseList',
'VendorBillItem',
'VendorBillItemList',
'VendorCredit',
'VendorCreditApply',
'VendorCreditApplyList',
'VendorCreditExpense',
'VendorCreditExpenseList',
'VendorCreditItem',
'VendorCreditItemList',
'VendorPayment',
'VendorPaymentApplyList',
'VendorPaymentCredit',
Expand Down

0 comments on commit 84561a8

Please sign in to comment.