Does anyone have a perfect way of determining the ...
# suiteql
m
Does anyone have a perfect way of determining the currency of the
transactionaccountingline.amount
field? I feel like the data may come from a lot of different tables depending on the features enabled in the netsuite account
t
@Marc Reicher I think it's just the Currency value at the Transaction header level.
Copy code
SELECT
	TAL.Amount,
	Currency.Symbol,
	Currency.ExchangeRate AS Rate_Current,
	Transaction.ExchangeRate AS Rate_Trans
FROM
	Transaction
	INNER JOIN TransactionAccountingLine AS TAL ON
		( TAL.Transaction = Transaction.ID )
	INNER JOIN Currency ON
		( Currency.ID = Transaction.Currency )
WHERE
	Transaction.ID = 2466063
m
@tdietrich so let's say you have a USD subsidiary with a GBP transaction. My understanding is: • the
transaction.currency
would be GBP • the
transactionline.foreignamount
would be in GBP • the
transactionaccountingline.amount
would be in USD I don't believe the
transaction
, the
transactionline
, or the
transactionaccountingline
has a field that shows the currency of the
transactionaccountingline.amount
field (though I could be wrong). I know I could join on the
subsidiary
for some NetSuite accounts (and just look at the
subsidiary.currency
value), but there are two other interesting edge cases where this strategy wouldn't work: • NetSuite accounts without subsidiaries (i.e. non NetSuite OneWorld) but with multi-currency enabled • NetSuite accounts with subsidiaries but without multi-currency enabled In those two situations, I'm not sure where I'd grab the currency
For the latter two edge cases, not sure if there is a table with just the default settings on the netsuite account, include the default functional currency
t
I see what you mean, and yeah, it gets complicated pretty quickly. I'm not sure if this will help, but I see "currency" in at least 32 different tables:
Copy code
account
AccountingBookSubsidiaries
amortizationSchedule
billingAccount
BillingRateCardPriceMultiForSearch
budgets
charge
customer
customerCurrencyBalance
customerItemPricing
employee
EmployeeExpenseReportCurrencies
ExpenseCategoryRate
expenseMachine
fairValuePrice
InvoiceGroup
invtItemPriceHistory
job
memDocTransactionTemplate
otherName
priceBook
pricePlan
pricing
ProjectIcChargeRequest
promotionCode
promotionCodeCurrency
revenueElement
subscription
subsidiary
subsidiaryAccountingBookDetail
transaction
vendor
vendorCurrencyBalance
m
Oh that's a clever way of look at the problem hah. Not sure if it will be in there though. And do you know if there is a table that shows the features that are enabled on an account? I know something like that exists in suitescript, but not sure if it's accessible via suiteql
t
Also, I haven't identified a table that provides an account's default settings. However, you might be able to use the N/config module to get some of the values that you'd need to programmatically determine the features that are enabled, etc. For example, there's a "multicurrency" value exposed.
👍 1
Copy code
features = config.load( { type: config.Type.FEATURES } );
m
I just tried another trick that you (or maybe someone else in this channel) taught me. I know there is a spot in the UI that shows the piece of data I want https://{account_id}.app.netsuite.com/app/common/otherlists/company.nl?whence= So then I added
&xml=true
to the end of the URL https://{account_id}.app.netsuite.com/app/common/otherlists/company.nl?whence=&xml=true Interestingly enough, this revealed that the company settings page is actually rendering a subsidiary record (see screenshot)? Any chance you have access to a NetSuite account that does not have subsidiaries enabled? I wonder what
recordType
would be listed in the xml
All of my netsuite accounts have OneWorld 😞
t
I sure do. Let me look...
message has been deleted
m
such a bummer. And this is an account without subsidiaries right? My guess is a
select * from subsidiary
will fail for that customer
t
I thought that, too. But sure enough, it returns a single record.
m
Hmm that's really interesting. Are you using an admin role?
t
Yeah.
There is a SubsidiarySettings table that I just started looking at.
m
In that NetSuite account, if you go to create a new role, is there actually a permissions option for Lists => Subsidiaries? If not, then my guess is behind the scenes, all NetSuite accounts have one subsidiary, but on a non OneWorld account, perhaps only admins can actually view the data in SuiteQL
If that permission does in fact show up when you go to create a role, then this may actually be a NetSuite account with the subsidiaries feature enabled, but just not configured
t
No, it's not an option.
m
Wow ok yeah then that's really interesting
t
And I think you're right about the "one subsidiary" theory.
m
We have a lot of clients where that permission is not an option, so the
select * from subsidiary
query always fails. I never even considered that it would work if you ran it as an admin
Too bad our clients would never give us an admin role token! Lol
t
Also...
SubsidiarySettings isn't available in that single subsidiary, non one-world account. But it is available in a one world account. ha!
Regardless, there's nothing helpful in it...
Copy code
{
    "excludebsfromglnumbering": null,
    "incomesummaryprofitaccount": null,
    "externalid": null,
    "balancesheetclosingaccount": null,
    "allowperiodendjournalentries": "F",
    "subsidiary": 6,
    "createbscloseandopenjournals": null,
    "createincomesummaryjournals": null,
    "balancesheetopeningaccount": null,
    "requirememoonperiodendjournals": null,
    "groupbythesesegments": null,
    "incomesummarylossaccount": null,
    "id": 6
  },
Oh well.
m
That's really interesting. Well I guess then the
subsidiary
join is the answer after all. It just won't work for non OneWorld accounts unless an admin token is used. What a strange thing to have to explain to a customer 🙂
Thanks so much for going down this rabbit hole with me @tdietrich
t
No problem at all. It's an interesting and challenging problem, and the fact that you're unable to tap into the power of SuiteScript makes it even more so.
If you need anything else, let me know.
Fun fact: There's actually a table named: SubsidiaryAccountingBooksWithPejeEnabled
😂 1
Ok, one more finding...
In that non one-world account, I can see the Subsidiary table in their Release Preview account (2021.1). But I cannot see it in their production account. So maybe that's a change we'll see soon... And... Even in their RP account, I cannot see the currency column in the Subsidiary table. This - SELECT Currency FROM Subsidiary - fails, because the "Multiple Currencies" feature is disabled.
m
I was actually just about to ask you about whether that account had multi-currency enabled hah
t
So it seems like there are some roundabout ways to determine what you're dealing with. But man, it's confusing.
m
here is another funny question. Can you do a
select currency FROM transaction
on that account?
I would have to believe that throws an error as well
t
In RP, I can see that column...
In production, I cannot.
m
and it's just like an integer? but you can't join it against the currency table?
t
In RP, yes. In production...
m
Also to go back to your earlier comment about the RP environment, you mentioned you can't do a
select currency FROM subsidiary
, but if you do a
select * FROM subsidiary
I wonder if the currency field does in fact return. I also wonder if
select * FROM currency
works lol
t
No.
So in RP, the currency column is not available in the Subsidiary table.
I just wonder if we'll see that same behavior when 2021.1 rolls out.
m
What a mess haha. I mean that’s crazy that the transaction has a currency column but that you can’t join on the currency table to see what the currency is.
I see a lot of defaulting to USD in our codebase coming lol.
t
I think we should revisit all of this when 2021.1 goes live. I'd be happy to give it another try.
Just assume that the currency is Bitcoin and you should be good to go.
😂 1
m
Absolutely. I think the permissions errors in SuiteQL are still a little wacky. Not surprising given that it’s still relatively new
It would makes sense that even the non OneWorld accounts have a single subsidiary record and that the non multiCurrency accounts would still have a single currency record. I just wish they would expose that data
t
I agree.
It would also be nice if the columns were consistent across all accounts, even if they just had nulls in them (in cases where a feature is disabled).
m
Exactly. There are so many stupid conditionals in our codebase as a result of this haha