diff --git a/setup.py b/setup.py index 918de5f..12f2634 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name='netsuitesdk', - version='2.23.0', + version='2.23.1', author='Siva Narayanan', author_email='siva@fyle.in', description='Python SDK for accessing the NetSuite SOAP webservice', diff --git a/test/integration/data/vendor_bills/data_expenses_only.json b/test/integration/data/vendor_bills/data_expenses_only.json index 2e46a70..b5255c3 100644 --- a/test/integration/data/vendor_bills/data_expenses_only.json +++ b/test/integration/data/vendor_bills/data_expenses_only.json @@ -1,121 +1,157 @@ { - "externalId": "1237", - "tranId": "E/2023/17/02", - "tranDate": "2023-01-30T17:32:28Z", - "account":{ - "internalId": null, + "nullFieldList": null, + "createdDate": null, + "lastModifiedDate": null, + "nexus": null, + "subsidiaryTaxRegNum": null, + "taxRegOverride": null, + "taxDetailsOverride": null, + "customForm": null, + "billAddressList": null, + "account": { + "name": null, + "internalId": "25", "externalId": null, "type": "account" }, - "itemList": null, + "entity": { + "name": null, + "internalId": "3382", + "externalId": null, + "type": "vendor" + }, + "subsidiary": { + "name": null, + "internalId": "1", + "externalId": null, + "type": "subsidiary" + }, + "location": { + "name": null, + "internalId": null, + "externalId": null, + "type": "location" + }, + "department": { + "name": null, + "internalId": null, + "externalId": null, + "type": "department" + }, + "class": { + "name": null, + "internalId": null, + "externalId": null, + "type": "classification" + }, + "approvalStatus": null, + "nextApprover": null, + "vatRegNum": null, + "postingPeriod": null, + "tranDate": "2024-11-08T00:00:00", + "currencyName": null, + "billingAddress": null, + "exchangeRate": null, + "entityTaxRegNum": null, + "taxPointDate": null, + "terms": null, + "dueDate": null, + "discountDate": null, + "tranId": "E/2024/11/T/34447", + "userTotal": null, + "discountAmount": null, + "taxTotal": null, + "paymentHold": null, + "memo": "Reimbursable expenses by admin1@fylefordemocctransactions.org", + "tax2Total": null, + "creditLimit": null, + "availableVendorCredit": null, "currency": { "name": null, "internalId": "1", "externalId": null, "type": "currency" }, + "status": null, + "landedCostMethod": null, + "landedCostPerLine": null, + "transactionNumber": null, "expenseList": [ { - "account": { - "name": null, - "internalId": 16, - "externalId": null, - "type": "account" - }, - "amount": 10.0, - "customFieldList": [ - { - "type": "String", - "value": "NetsuiteSDK test field1" - }, - { - "type": "Select", - "value": "45" - } - ], + "orderDoc": null, + "orderLine": null, + "line": null, + "amount": 30.0, + "grossAmt": 30.0, + "taxDetailsReference": null, "department": { "name": null, - "internalId": "1", + "internalId": null, "externalId": null, "type": "department" }, "class": { "name": null, - "internalId": "1", + "internalId": null, "externalId": null, "type": "classification" }, "location": { "name": null, - "internalId": "1", + "internalId": null, "externalId": null, "type": "location" }, - "memo": "Kuch lete kyun nahin" - }, - { - "account": { + "customer": { "name": null, - "internalId": 15, + "internalId": null, "externalId": null, - "type": "account" + "type": "customer" }, - "amount": 20.0, "customFieldList": [ { + "scriptId": "custcolfyle_expense_url", "type": "String", - "value": "NetsuiteSDK test field1" + "value": "https://staging1.fyle.tech/app/admin/#/enterprise/view_expense/txBFlLMIQNJt?org_id=orT192eaSf2q" }, { - "type": "Select", - "value": "45" + "scriptId": "custcolfyle_expense_url_2", + "type": "String", + "value": "https://staging1.fyle.tech/app/admin/#/enterprise/view_expense/txBFlLMIQNJt?org_id=orT192eaSf2q" } ], - "department": { - "name": null, - "internalId": "1", - "externalId": null, - "type": "department" - }, - "class": { + "isBillable": null, + "tax1Amt": null, + "taxAmount": null, + "taxCode": { "name": null, - "internalId": "1", + "internalId": null, "externalId": null, - "type": "classification" + "type": "taxGroup" }, - "location": { + "taxRate1": null, + "taxRate2": null, + "amortizationSched": null, + "amortizStartDate": null, + "amortizationEndDate": null, + "amortizationResidual": null, + "account": { "name": null, - "internalId": "1", + "internalId": "224", "externalId": null, - "type": "location" + "type": "account" }, - "memo": "Humdard ka tonic" - + "category": null, + "memo": "admin1@fylefordemocctransactions.org - Fedex - Professional Services - 2024-11-08 - C/2024/11/R/2", + "projectTask": null } ], - "memo": "Fyle ka Bill", - "class": { - "name": null, - "internalId": "1", - "externalId": null, - "type": "classification" - }, - "location": { - "name": null, - "internalId": "1", - "externalId": null, - "type": "location" - }, - "entity": { - "name": null, - "internalId": "-100", - "externalId": null, - "type": "vendor" - }, - "department": { - "name": null, - "internalId": "1", - "externalId": null, - "type": "department" - } + "itemList": null, + "accountingBookDetailList": null, + "landedCostsList": null, + "purchaseOrderList": null, + "taxDetailsList": null, + "customFieldList": null, + "internalId": null, + "externalId": "12345" } \ No newline at end of file diff --git a/test/integration/data/vendor_payment/data.json b/test/integration/data/vendor_payment/data.json index dc8fdde..67ccb70 100644 --- a/test/integration/data/vendor_payment/data.json +++ b/test/integration/data/vendor_payment/data.json @@ -1,98 +1,100 @@ { - "nullFieldList": null, - "createdDate": null, - "lastModifiedDate": null, - "customForm": null, + "nullFieldList": null, + "createdDate": null, + "lastModifiedDate": null, + "customForm": null, "account": { - "name": null, - "internalId": "213", - "externalId": null, + "name": null, + "internalId": null, + "externalId": null, "type": null - }, - "balance": null, + }, + "balance": null, "apAcct": { - "name": null, - "internalId": "176", - "externalId": null, + "name": null, + "internalId": "25", + "externalId": null, "type": null - }, + }, "entity": { - "name": null, - "internalId": "2780", - "externalId": null, + "name": null, + "internalId": "3382", + "externalId": null, "type": null - }, - "address": null, - "tranDate": null, - "voidJournal": null, - "postingPeriod": null, - "currencyName": null, - "exchangeRate": null, - "toAch": "false", - "toBePrinted": "false", - "printVoucher": "false", - "tranId": null, - "total": null, + }, + "address": null, + "tranDate": null, + "voidJournal": null, + "postingPeriod": null, + "currencyName": null, + "exchangeRate": null, + "toAch": "false", + "toBePrinted": "false", + "printVoucher": "false", + "tranId": null, + "total": null, "currency": { - "name": null, - "internalId": "1", - "externalId": null, + "name": null, + "internalId": "1", + "externalId": null, "type": null - }, + }, "department": { - "name": null, - "internalId": null, - "externalId": null, + "name": null, + "internalId": null, + "externalId": null, "type": "department" - }, - "memo": "Testing for netsuite SDK", + }, + "memo": "Payment for bill by admin1@fylefordemocctransactions.org", "subsidiary": { - "name": null, - "internalId": "1", - "externalId": null, + "name": null, + "internalId": "1", + "externalId": null, "type": null - }, + }, "class": { - "name": null, - "internalId": null, - "externalId": null, + "name": null, + "internalId": null, + "externalId": null, "type": "classification" - }, + }, "location": { - "name": null, - "internalId": null, - "externalId": null, + "name": null, + "internalId": null, + "externalId": null, "type": "location" - }, - "status": null, - "transactionNumber": null, + }, + "status": null, + "transactionNumber": null, "applyList": { "apply": [ { - "apply": "true", - "doc": "642024", - "line": 0, - "job": null, - "applyDate": null, - "type": null, - "refNum": null, - "total": null, - "due": null, - "currency": null, - "discDate": null, - "discAmt": null, - "disc": null, + "apply": "true", + "doc": "749863", + "line": 0, + "job": null, + "applyDate": null, + "type": null, + "refNum": null, + "total": null, + "due": null, + "currency": null, + "discDate": null, + "discAmt": null, + "disc": null, "amount": null - }], + } + ], "replaceAll": "true" - }, - "creditList": null, - "billPay": null, - "accountingBookDetailList": null, - "availableBalance": null, - "isInTransitPayment": null, - "approvalStatus": null, - "nextApprover": null, - "customFieldList": null, - "internalId": null, - "externalId": "bill 7 - user1@fyleforintacct.refactor-3"} \ No newline at end of file + }, + "creditList": null, + "billPay": null, + "accountingBookDetailList": null, + "availableBalance": null, + "isInTransitPayment": null, + "approvalStatus": null, + "nextApprover": null, + "customFieldList": null, + "internalId": null, + "externalId": "bill 111 - admin1@fylefordemocctransactions.org-2" +} \ No newline at end of file diff --git a/test/integration/test_expense_reports.py b/test/integration/test_expense_reports.py index b7166e8..604991e 100644 --- a/test/integration/test_expense_reports.py +++ b/test/integration/test_expense_reports.py @@ -1,7 +1,6 @@ import logging -import pytest import json -import os +from datetime import datetime logger = logging.getLogger(__name__) @@ -22,6 +21,7 @@ def test_post(nc): with open('./test/integration/data/expense_reports/data.json') as oj: s = oj.read() expr1 = json.loads(s) + expr1['tranDate'] = datetime.today().date().replace(day=1).strftime('%Y-%m-%dT%H:%M:%S') logger.debug('expr1 = %s', expr1) res = nc.expense_reports.post(expr1) logger.debug('res = %s', res) diff --git a/test/integration/test_vendor_bills.py b/test/integration/test_vendor_bills.py index c460c49..13245a3 100644 --- a/test/integration/test_vendor_bills.py +++ b/test/integration/test_vendor_bills.py @@ -30,21 +30,21 @@ def test_post(nc): assert (29.99 < vb2['userTotal']) and (vb2['userTotal'] < 30.01), 'Bill total is not 30.0' - vb3 = {} - with open('./test/integration/data/vendor_bills/data_items_only.json') as oj: - s = oj.read() - vb3 = json.loads(s) - logger.debug('rvb1 = %s', vb3) - res = nc.vendor_bills.post(vb3) - logger.debug('res = %s', res) - assert res['externalId'] == vb3['externalId'], 'External ID does not match' - - - vb4 = {} - with open('./test/integration/data/vendor_bills/data_expense_and_items.json') as oj: - s = oj.read() - vb4 = json.loads(s) - logger.debug('rvb1 = %s', vb4) - res = nc.vendor_bills.post(vb4) - logger.debug('res = %s', res) - assert res['externalId'] == vb4['externalId'], 'External ID does not match' + # vb3 = {} + # with open('./test/integration/data/vendor_bills/data_items_only.json') as oj: + # s = oj.read() + # vb3 = json.loads(s) + # logger.debug('rvb1 = %s', vb3) + # res = nc.vendor_bills.post(vb3) + # logger.debug('res = %s', res) + # assert res['externalId'] == vb3['externalId'], 'External ID does not match' + + + # vb4 = {} + # with open('./test/integration/data/vendor_bills/data_expense_and_items.json') as oj: + # s = oj.read() + # vb4 = json.loads(s) + # logger.debug('rvb1 = %s', vb4) + # res = nc.vendor_bills.post(vb4) + # logger.debug('res = %s', res) + # assert res['externalId'] == vb4['externalId'], 'External ID does not match' diff --git a/test/internal/test_upsert.py b/test/internal/test_upsert.py index 4421dba..3754d6a 100644 --- a/test/internal/test_upsert.py +++ b/test/internal/test_upsert.py @@ -1,6 +1,7 @@ from netsuitesdk.internal.utils import PaginatedSearch from netsuitesdk.internal.exceptions import NetSuiteRequestError import logging +from datetime import datetime logger = logging.getLogger(__name__) @@ -44,38 +45,39 @@ def test_upsert_vendor_bill(ns): vbe1['account'] = cat_account_ref vbe1['amount'] = 10.0 vbe1['department'] = dep_ref - vbe1['class'] = class_ref - vbe1['location'] = loc_ref + # vbe1['class'] = class_ref + # vbe1['location'] = loc_ref expenses.append(vbe1) vbe1 = ns.VendorBillExpense() vbe1['account'] = cat_account_ref vbe1['amount'] = 20.0 vbe1['department'] = dep_ref - vbe1['class'] = class_ref - vbe1['location'] = loc_ref + # vbe1['class'] = class_ref + # vbe1['location'] = loc_ref expenses.append(vbe1) - bill = ns.VendorBill(externalId='1234') + bill = ns.VendorBill(externalId='12345') bill['currency'] = ns.RecordRef(type='currency', internalId=get_currency(ns).internalId) # US dollar bill['exchangerate'] = 1.0 bill['expenseList'] = ns.VendorBillExpenseList(expense=expenses) bill['memo'] = 'test memo' - bill['class'] = class_ref - bill['location'] = loc_ref + # bill['class'] = class_ref + # bill['location'] = loc_ref bill['entity'] = vendor_ref + bill['tranDate'] = datetime.now().strftime('%Y-%m-%dT%H:%M:%S') logger.debug('upserting bill %s', bill) record_ref = ns.upsert(bill) logger.debug('record_ref = %s', record_ref) - assert record_ref['externalId'] == '1234', 'External ID does not match' + assert record_ref['externalId'] == '12345', 'External ID does not match' - bill2 = ns.get(recordType='vendorBill', externalId='1234') + bill2 = ns.get(recordType='vendorBill', externalId='12345') logger.debug('bill2 = %s', str(bill2)) assert (29.99 < bill2['userTotal']) and (bill2['userTotal'] < 30.01), 'Bill total is not 30.0' subs_ref = ns.RecordRef(type='subsdiary', internalId=5) - bill_account_ref = ns.RecordRef(type='account', internalId=237) + bill_account_ref = ns.RecordRef(type='account', internalId=84) vbe1['account'] = bill_account_ref vbe1['subsdiary'] = subs_ref @@ -115,22 +117,23 @@ def test_upsert_journal_entry(ns): lines.append(debit_line) - journal_entry = ns.JournalEntry(externalId='JE_1234') + journal_entry = ns.JournalEntry(externalId='JE_12345') journal_entry['currency'] = ns.RecordRef(type='currency', internalId=get_currency(ns).internalId) # US dollar journal_entry['subsidiary'] = ns.RecordRef(type='subsidiary', internalId='1') journal_entry['exchangerate'] = 1.0 journal_entry['lineList'] = ns.JournalEntryLineList(line=lines) journal_entry['memo'] = 'test memo' + journal_entry['tranDate'] = datetime.today().date().replace(day=1) logger.debug('upserting journal entry %s', journal_entry) record_ref = ns.upsert(journal_entry) logger.debug('record_ref = %s', record_ref) - assert record_ref['externalId'] == 'JE_1234', 'External ID does not match' + assert record_ref['externalId'] == 'JE_12345', 'External ID does not match' - je = ns.get(recordType='journalEntry', externalId='JE_1234') + je = ns.get(recordType='journalEntry', externalId='JE_12345') logger.debug('je = %s', str(je)) - assert (je['externalId'] == 'JE_1234'), 'Journal Entry External ID does not match' + assert (je['externalId'] == 'JE_12345'), 'Journal Entry External ID does not match' - cat_account_ref = ns.RecordRef(type='account', internalId=237) + cat_account_ref = ns.RecordRef(type='account', internalId=25) credit_line['account'] = cat_account_ref try: @@ -177,8 +180,8 @@ def test_upsert_expense_report(ns): logger.debug('expense report = %s', str(expr)) - loc_ref = ns.RecordRef(type='location', internalId=12) - subs_ref = ns.RecordRef(type='subsdiary', internalId=5) + loc_ref = ns.RecordRef(type='location', internalId=2) + subs_ref = ns.RecordRef(type='subsdiary', internalId=1) er['location'] = loc_ref er['subsdiary'] = subs_ref