NetSuite Tax Rate not showing - netsuite

So I was doing a simple custom search but somehow the tax rate is not showing. I am still new to NetSuite and I tried to find workarounds about this. Any suggestions?
var columns = new Array();
columns[0] = new nlobjSearchColumn('internalid');
columns[1] = new nlobjSearchColumn('name');
columns[2] = new nlobjSearchColumn('itemid');
columns[3] = new nlobjSearchColumn('rate');
columns[4] = new nlobjSearchColumn('taxtype')
var res = nlapiSearchRecord('salesTaxItem', null, null, columns);
wcache('res---> '+ JSON.stringify(res));
return;

not sure if it matters but the name should be 'salestaxitem' not 'salesTaxItem' Also do you know if you have any tax items or codes in your account?
If you are on a One World account you need to make sure you have access to the subisdiary that has tax items.

I see all the rates when I run your code in my account.
The Netsuite record browser has this to say about the rate field:
Enter the appropriate tax rate as a percentage. Example: 8% This percentage will be calculated when you select this tax item on transactions. This field is available only if the SuiteTax feature is disabled in your account.

Related

How to insert Adjustment record with Contract API

I'm trying to insert an adjustment record via the SOAP API using the following code.
Dim NewAdjustment As Adjustment = New Adjustment With {
.ExternalRef = New StringValue With {.Value = "TEST1234"},
.Description = New StringValue With {.Value = "1234TEST"},
.[Date] = New DateTimeValue With {.Value = "12/20/2018"},
.Details = {New AdjustmentDetail With {
.BranchID = New StringValue With {.Value = "PRODWHOLE"},
.InventoryID = New StringValue With {.Value = "18r.5"},
.WarehouseID = New StringValue With {.Value = "RETAIL"},
.Qty = New DecimalValue With {.Value = 100}
}}
}
Dim InsertAdjustment As Adjustment = CType(soapClient.Put(NewAdjustment), Adjustment)
I get an error px.data.pcexception: Error: 'Branch' cannot be empty. Error: 'Post Period' cannot be empty. Error Inserting 'Receipt' record raised at least one error.
I'm guessing I need to fill those values but I'm not sure how to do that. I see them in the table but not the API interface. I'm new to Acumatica, so I'm guessing this is just something I'm missing.
Thanks in advance.
I have never seen the usage of the Date property as [Date], but that does not mean it will not work. The Posting period is defaulted based on the value of the date property. Make sure that the December 2018 posting period is open on the company that you are logged into with the API. I have seen this error from time to time when the accounting department does not open the period in a timely fashion.
The BranchID is defaulted based on the login parameters of the soapClient. One thing to be aware of is that your API login user needs to have permissions to the BranchID being used, or you will definitely get an error about the Branch being invalid.
Depending on the Inventory costing methodology used by your company, Inventory Adjustments might require that they be processed against an inventory Receipt. This can be tricky to figure out what to do, especially if you have never received anything for this Item in a new implementation, and you want to increase inventory levels. For positive Adjustments in your business case, you might want to consider creating Inventory Receipts instead of Adjustments. The entity is very similar to the Adjustments. For negative Adjustments you might want to consider using Inventory Issues which is again, quite similar.
If you decide to use adjustments, you will have to search the Inventory Receipts for an appopriate Receipt number to use when populating the transaction details. One for each line you insert.

How can bypass the credit limit while creating invoice or saleorder in Netsuite using SuiteTalk Webservice?

I am using Netsuite SuiteTalk web service since 3-4 months I felt comfortable to use it. now, i have issues i want to create saleorder/invoice in netsuite using SuiteTalk but i am unable to do that because everytime i am getting error of credit limit i.e customer invoice amount is more than their credit limit. it's O.K, but as long as i am sending payments too with the same webservice request.
I would appreciate if someone or Netsuite people can help me to bypass credit limit while creating invoice.
please have a look suitetalk c# code.
Invoice inv = new Invoice();
inv.entity = new RecordRef() { internalId = 25, type = RecordType.customer, typeSpecified = true };
inv.tranDate = new DateTime(2018,9,18);
inv.memo = "Test Memo";
inv.department = new RecordRef() { internalId = 10, type = RecordType.department, typeSpecified = true };
inv.location = new RecordRef() { internalId = 16, type = RecordType.location, typeSpecified = true };
InvoiceItemList itemList = new InvoiceItemList();
InvoiceItem[] items = new InvoiceItem[1];
// invoice items
InvoiceItem item = new InvoiceItem();
item.item = new RecordRef() { internalId = 12510 };
item.rate = 2.65;
item.amount = 265.00;
item.quantity = 100;
items[0] = item;
itemList.item = items;
inv.itemList = itemList;
inv.amountPaid = 180;
inv.amountPaidSpecified = true;
inv.onCreditHold = "true";
WriteResponse writeRes = ns.Service.add(inv);
Try below solution
Go to -> Setup -> Accounting -> Accounting Preferences
In General tab account Receivable section
See that CUSTOMER CREDIT LIMIT HANDLING field. choose appropriate value based on your situation.
Ignore – Select this method to allow sales orders and invoices to be entered without a warning for a customer that is at or above their credit limit.
Warn Only – Select this method to generate a warning when a sales order or invoice is being entered that puts the customer at or above their credit limit. You can choose to enter or cancel the transaction once the warning has appeared.
Enforce Holds – Select this method to block the entry of a sales order or invoice that puts the customer at or above their credit limit. This method also blocks the addition of items to existing orders for customers at or above their credit limit.
I have found the best solution, in order to avoid credit limit while creating invoice we can create Payment as PaymentItem and then we need to add in invoice.

NetSuite - using nlapiCopyRecord function

I am generating an invoice when the original invoice is overdue by a certain time period. I want to know if we can use the nlapiCopyRecord to make a copy of the original invoice but allow us to insert a new line that will replace the old line item? I haven't found any sample to show how this is done.
Thanks.
Edit 1:
var new_inv = nlapiCopyRecord('invoice', internal_id,
{
item : 66,
amount: amount,
description: 'TEST'
});
var copiedId = nlapiSubmitRecord(new_inv);
return copiedId;
Above code fails in my scheduled script. You have entered an invalid default value for this record initialize operation.
I would like to override the line item on the newly copied invoice
Yes that is possible, just like if you copy a record in the UI you can modify the copy. You also need to remember that you need to save the record object after you have copied it.
Why are you doing this? If you are trying to charge a late fee you'd probably be better off by adding an expense line to the original invoice record. If you don't have expenses turned on then you could add an other "Other Charge for Sale"
If your code is running server side then:
var invRec = nlapiLoadRecord('invoice', internal_id);
var chargeIndex = invRec.getLineItemCount('item') + 1;
// don't think you need this for the end position invRec.insertLineItem('item', chargeIndex);
invRec.setLineItemValue('item', 'item', chargeIndex, charge_item_id);
invRec.setLineItemValue('item', 'rate', chargeIndex, amount);
invRec.setLineItemValue('item', 'amount', chargeIndex, amount);
nlapiSubmitRecord(invRec);
OR if you use an expense
var invRec = nlapiLoadRecord('invoice', internal_id);
invRec.insertLineItem('expense', 1);
invRec.setLineItemValue('expense', 'account', 1, penalty_account);
invRec.setLineItemValue('expense', 'amount', 1, amount);
invRec.setLineItemValue('expense', 'memo', 1, 'TEST');
nlapiSubmitRecord(invRec);

NetSuite - how to create reference link

When the billing schedule runs it auto generates invoices from sales order. When this happens - how can I create a link on the sales order that will allow me to load the corresponding invoice in code?
I need this so I can grab couple of field values from the invoice but I can't access the invoice directly from another entity which seems only related to sales order.
EDIT 1:
var fil = [];
fil[0] = new nlobjSearchFilter('createdfrom', null, 'is', nlapiGetRecordId())
var col = [];
col[0] = new nlobjSearchColumn('internalid');
var invoices = nlapiSearchRecord('invoice', null, fil, col);
nlapiLogExecution('DEBUG', 'field val', invoices);
Throws invalid operator or not in proper syntax: createdfrom.
Though adding a link on the Sales Order is a viable solution, it's not your only option. Alternatively, you could do a search for invoices where the createdfrom field is the internal ID of your Sales Order. Something like in SuiteScript 1.0:
var invoices = nlapiSearchRecord('invoice', null,
[['createdfrom', 'is', nlapiGetRecordId()]],
[/* create search columns for the fields you need off the invoice */]
) || [];
or in 2.0:
var invoices = search.create({
"type": search.Type.INVOICE,
"filters": [['createdfrom', 'is', context.currentRecord.id]],
"columns": [/* create search columns for the fields you need off the invoice */]
}).run().each(processResult);
This will get you a list of all the Invoices created from your Sales Order (which is likely only 1).
If you believe you need a link to the Invoice on the Sales Order, you could add the custom body field, then create a User Event on the Invoice record that populates this new field with its createdfrom value on the Before Submit event. But then what happens if your Sales Order gets paid via multiple Invoices?

Acumatica Web API Apply Discounts

I am trying to get a way to obtain the discount code from the web service API, i.e would there be a function call that could tell me which discount code to apply?
I am otherwise attempting to retrieve the discount codes but they can be by Item or By Item Price Class and Customer etc etc which is making the code longer than expected.
Hopeing there is a "GetBestDiscount" facility in the API that could help me?
Thanks,
G
At this moment Acumatica Discount Engine is deactivated for any Web Service call. Due to this fact, entering an order line without any discount will not populate the discount code.
However, at Acumatica University there is the GetSalesPrice.zip customization package made specifically to retrieving the price of an Item for a Customer (attached to the I200 Screen-Based Web Services 5.3 and the I210 Contract-Based Web Services 5.3 sources).
Sample call for Screen-Based API:
Content getSalesPriceSchema = context.GetSchema();
var commands = new Command[]
{
new Value
{
Value = customer,
LinkedCommand =getSalesPriceSchema.RequiredInputParameters.Customer
},
new Value
{
Value = inventoryID,
LinkedCommand =getSalesPriceSchema.RequiredInputParameters.InventoryID
},
getSalesPriceSchema.OutputPrice.Price
};
Content price = context.Submit(commands)[0];
Sample call for Contract-Based API:
GetSalesPriceInquiry priceToBeGet = new GetSalesPriceInquiry
{
Customer = new StringValue { Value = customer },
InventoryID = new StringValue { Value = inventoryID }
};
GetSalesPriceInquiry stockItemPrice = (GetSalesPriceInquiry)soapClient.Put(priceToBeGet);
I tried creating a temporary Sales order line via API Order Entry Screen without saving it as Gabriel suggestion.
I can retrieve the set price no problems but the Discount Percentage and Discount Code is not returned.
The discount percentage returned is zero and the discount Code is blank.
This is because the Acumatica Discount Engine is deactivated for any Web Service call I guess.
Any reason why the Acumatica Discount Engine is deactivated for any Web Service calls?
There is no such API, however you could use the sales order entry screen API to create a temporary sales order, add one line to it and retrieve the set price or discount without saving the order. This will be the most accurate information, since discounts and price can also depend on the date, quantity and also on other products being ordered at the same time.

Resources