NetSuite Saved Search - Cash Transactions excluding Line of Credit Sweep Deposits - sql

My goal is to show the sum of cash debit transactions excluding line of credit deposits (i.e. sweep transactions from the line of credit). I can isolate cash transactions but have had difficulty excluding transactions that have a debit to the cash general ledger account and a credit to the line of credit general ledger account. Any help would be appreciated.
The deposits from the line of credit account are posted as an "Other Deposit" type, which translates to {type} = 'deposit'; {version} = '2'. However, NetSuite will not let me include {version} as a criteria filter or in the results.

I was able to generate a search that is permissible but not an exact answer to my original question.
The information below describes the Cash In version of the Search. There are two searches that correspond to the answer. A Cash In and a Cash Out search. They show cash received or disbursed each week, but net out sweeps to and from the line of credit. In fact, the searches show the debit and credit associated with the sweep transactions, which is not ideal. So, in the details of the search results you will see a positive (debit) amount and the same negative (credit) amount, which when added together, net to zero. So the assumption is that all debits and credits to and from the line of credit equal one another. It is not perfect, but it will work for now and at least clearly show the assumption made, to the end user of the searches.
The end goal was to use the searches as KPIs (i.e. a single total value on a NetSuite dashboard for cash received and then cash disbursed.
This is the NetSuite Saved Search Criteria and Results for the Cash In version:
Criteria:
Account is Cash, Short Term Liabilities
Posting is True
((Account is Cash AND Amount(Credit) is Empty) OR
(Account is Short Term Liabilities AND Amount(Debit) is Empty))
Results:
Date
Transaction Name
Name
Memo
Account
Formula(Numeric)
-Summary Type: Sum
-Formula: CASE WHEN {debitamount} >= '0' THEN {debitamount} ELSE ({creditamount} * '-1') END

Related

Integrating Netsuite back-end into Snowflake - how to find the exact currency exchange rates?

I'm using imported back-end tables from Netsuite in Snowflake.
I'm trying to determine exact exchange rates for foreign currency transactions to get the identical totals Netsuite has on the front-end. So I tried using Netsuite's "Currency" and "CurrencyRate" tables, but the amounts I am getting are incorrect.
The exchange rates from the table don't seem the same as those used on the front-end. Every amount I get is off by a little, which adds up when there are many transactions.
Is there another table I should keep an eye out for, or do they do something completely different to keep track of all the effective exchange rates on the back-end? Here's the query I have so far:
select
transline.transaction,
transline.id as line_item_id,
transline.creditforeignamount,
transline.rate,
transline.rateamount,
tran.currency as transaction_currency,
tran.recordtype,
tran.trandate::date as trandate,
tran.TRANID as netsuite_document_number,
tran.custbody_cust_primcurrfxrate,
transline.custcol_invoice_prim_curr_fx_rate, tran.exchangerate as tran_exchange_rate,
cr.exchangerate as officialexchangerate,
round((case
when cr.exchangerate not like 'null' then (cr.exchangerate * transline.creditforeignamount)
else creditforeignamount
end), 2) as amount
from transactionline transline
inner join transaction tran
on tran.id = transline.transaction
left join currencyrate cr
on (tran.currency = cr.transactioncurrency
and tran.custbody_cust_primcurrfxrate = cr.basecurrency
and tran.closedate = cr.effectivedate)
The issue may be that each transaction has an exchangerate field.
This is because each transaction may have been done at a custom rate and Netsuite should calculate an exchange rate gain/loss for you based on the difference between the transaction exchange rate and the official posted exchange rate (i.e. the currencyrate tables).
Common sources of differences:
bank transfers between currencies - you use the bank's forex rate
negotiated exchange rates for trading partners
user error where a transaction all takes place in one currency and the data entry person puts 1.0 as the rate. (e.g. Your company uses USD. You have a Canadian supplier who invoices in CAD and whom you pay from a CAD bank account. A naive user might put 1 as the exchange rate because all the transactions are in CAD but all the transactions actually should have had the USD - CAD rate for the date of the transaciton)

Custom Acumatica report variable not working consistently

in Acumatica, the out of the box GL report" lists gl beginning balance, debits, credit and ending balance by Account / Sub-Account. MY client is requesting that a new sub-total be added at the end of each account that totals for the account, i.e. if there are 3 sub-accounts on a single account, they are requesting the beginning balance, total debits, total credits and ending balance for the ACCOUNT.
I added a new Account group above the account/sub-account group and added variables for the beginning balance, debits and credits and ending balance.
the debit, credit and ending balance variables work perfectly, and SOMETIMES the beginning balance at the Account level is correct, but often the beginning balance variable is multiplied by the number of transactions at the account/sub-account level.
for instance, the beginning balance of account 10000-00-00 for 12-2021 is 9133.07, there are 3 pages of transactions and the beginning balance, debits, credits and ending balance in the Account group footer are correct, BUT for account 12080-00-00 the beginning balance is 1,063,150.46 and what is printing in the group footer for this account is 4,263,486.84 which is the actual beginning balance * 4 and there are 4 transactions in this account.
in the asset and liability section there are about 150 accounts, and this incorrect beginning balance shows up on only 4 accounts for period 11 and 12 of 2021. it does happen a LOT more on income statement accounts, and in other periods.
Because the variable DOES work sometimes but not others I THINK I have created the variable correctly, but I am not finding much support for variables.
Acumatica support was unable to help with this issue and suggested I post on Stack Overflow.
I have attached the logic for the variable itself as well as the variable I “copied”.
with the exception of the =$SignBal*, which if added to the $AcctBegBal always returns a 0 (if THAT is the issue I would expect the beginning balance to ALWAYS be incorrect)
$BegBalance variable logic - works at group footer AccountSubaccount
=$SignBal * Sum(IIF(Prev([GLHistoryByPeriod.BranchID]) <> [GLHistoryByPeriod.BranchID], IsNull(
IIF([HistoryLast.FinPeriodID] = [#StartPeriod],
IIF(#UseMasterCalendar = True, [HistoryLast.TranBegBalance], [HistoryLast.FinBegBalance]),
IIF(#UseMasterCalendar = True, [HistoryLast.TranYtdBalance], [HistoryLast.FinYtdBalance]))
, 0), 0))
$AcctBegBal variable logic (works sporatically at group footer Account )
=Sum(IIF(Prev([GLHistoryByPeriod.BranchID]) <> [GLHistoryByPeriod.BranchID], IsNull(
IIF([HistoryLast.FinPeriodID] = [#StartPeriod],
IIF(#UseMasterCalendar = True, [HistoryLast.TranBegBalance], [HistoryLast.FinBegBalance]),
IIF(#UseMasterCalendar = True, [HistoryLast.TranYtdBalance], [HistoryLast.FinYtdBalance]))
, 0), 0))
Thank you in advance for any help or guidance offered!
Terrie

SQL code to calculate purchase invoice descrepencies

I am looking to extract records with purchase invoice discrepancies from Purchase Invoice Line [PIL], Purchase Invoice header [PIH] and Purchase line [PL], and purchase header [PH] tables.
Do I really need to take any columns from PL AND PH at all or is it sufficient if I make use of only PIH AND PIL tables? And how to cross verify the result set at the end?
Thanks
To identify discrepancies you need to compare your purchase orders with your invoices. There's no way to compare an invoice with its purchase order without reading its purchase order. So yes you need to read from PL and PH.
Having worked on professional systems which do exactly this task I can say it tends to be more complicated. Usually the user will set acceptable limits on which discrepancies need to be flagged.
For example some companies will pay an invoice and never flag a discrepancy as long as the invoice total does not exceed the PO total. In those cases you don't need to look at the line PO / Invoice line level, just the header level.

Crystal Reports - Sum Records and display in detail section

I'm pretty new to CR and this is stumping me. I have two SQL tables, let's call them Invoice and AdditionalCosts. AdditionalCosts is linked to Invoice by invoice number. My report prints details regarding invoices for a particular day. AdditionalCosts can have multiple records for an invoice. I need to sum the costs and display the total with the invoice in the detail section.
I have several groups already and I tried adding an additional group for invoice number. I then suppressed the detail section. That works for the total of additional costs but it also sums the other fields in the report (total price, total cost, etc) if there are multiple records in AdditionalCosts.

Calculate price using percentage from product field

I'm using drupal commerce module and drive with pricing rule problem. User and product have percentage fields, which are discount values separately. Final discount gathered from sum of this fields. How can I calculate line item price with discount fields?