How can i get tax codes from NetSuite? - netsuite

Now i have 2 ways to get tax code from NetSuite and these are advantage/disadvantage of each
1/ The first way:
I get all tax code from saleTaxItem list and save in database, with this way, it's easy and fast.
But we must to check, employees/vendors has permission to use it. in result, SalesTaxItem object don't have any property refer to employees/vendors and Employee/Vendor object don't have refer key to SalesTaxItem too.
So, how can i know employee/vendor has permission to use taxcode with this way?
This is structure of SalesTaxItem Object:
SalesTaxItem Object
(
[itemId] => Item Name
[displayName] =>
[description] =>
[rate] => 7.25%
[taxType] =>
[taxAgency] => RecordRef Object
(
[internalId] => -100
[externalId] =>
[type] =>
[name] => New Name
)
[purchaseAccount] =>
[saleAccount] =>
[isInactive] =>
[effectiveFrom] =>
[validUntil] =>
[eccode] =>
[reverseCharge] =>
[parent] =>
[exempt] =>
[isDefault] =>
[excludeFromTaxReports] =>
[available] =>
[export] =>
[taxAccount] => RecordRef Object
(
[internalId] => 37
[externalId] =>
[type] =>
[name] => New Name
)
[county] => Country Name
[city] =>
[state] => CA
[zip] => ,95646,96120
[nexusCountry] =>
[internalId] => -111
[externalId] =>
[nullFieldList] =>
)
2/ The second way:
I get employees list, vendors list. And foreach those lists to get taxcodes with function getSelectValueResult of NetsuiteService object.
With this way, with each employee/vendor we need call function getSelectValueResult to get taxcodes list of that employee/vendor. Althought we have 10 tax codes, but we need call function 1000 times (if we have 1000 employee/vendor).
Advantage of this way , we can save reference keys [taxcodes, employee], [taxcodes, vendor], it help check employee/vendor has permission to use tax code.
Disadvantage : slow and waste our time, and get duplicate tax code records.
This is structure of GetSelectValueResult Object when call function getSelectValueResult for each employee/vendor
[getSelectValueResult] => GetSelectValueResult Object
(
[status] => Status Object
(
[statusDetail] =>
[isSuccess] => 1
)
[totalRecords] => 2
[totalPages] => 1
[baseRefList] => BaseRefList Object
(
[baseRef] => Array
(
[0] => RecordRef Object
(
[internalId] => 25821
[externalId] =>
[type] => platformCore:RecordRef
[name] => My tax code name 1
)
[1] => RecordRef Object
(
[internalId] => 27812
[externalId] =>
[type] => platformCore:RecordRef
[name] => My tax code name 2
)
)
)
)
Which one i should to use ?
I think first way is good, but how can i check permission of employee/vendor when use taxcode?
Thank you very much.

Since Individual Tax codes does not have permission, you can get the roles of the employees separately and store it in a separate table. So you can join the roles whenever you need.

Related

Typo3: Where can i get list of TCA types?

I have bodytext and image so like this type of list where can I found? Can I get page list in select box?
$GLOBALS['TCA']['tt_content']['types']['text_image_left'] = [
'showitem' => '
--palette--;palette.general;general,
header, subheader, header_layout,menu,
bodytext;bodytext_formlabel,
--div--;tabs.images,
image,
--div--;tabs.appearance,
--palette--;palette.frames;frames,
--div--;tabs.access,
hidden;field.default.hidden,
--div--;tabs.extended
',
'columnsOverrides' => ['bodytext' => ['config' => ['enableRichtext' => true]]]
];
Hm, not sure if I get your question right. You asked
1. for a list of TCA types
2. how to get a list of pages in a select field (?)
You can find the complete TCA Documentation here:
https://docs.typo3.org/m/typo3/reference-tca/master/en-us/
Interesting part for you is the [column][*][config] part:
https://docs.typo3.org/m/typo3/reference-tca/master/en-us/ColumnsConfig/Index.html
In order to create a select with a page list, you need following kind of configuration.
I would suggest to use "group" type for field.
'page' => [
'exclude' => true,
'label' => 'List of Pages',
'config' => [
'type' => 'group',
'internal_type' => 'db',
'allowed' => 'pages',
'size' => 1,
'minitems' => 0,
'maxitems' => 1,
]
]

How to access a property of an object stdClass Object?

Doing print_r() on my array I get the following:
stdClass Object
(
[Products] => Array
(
[0] => stdClass Object
(
[Id] => 265531
[ProductTitle] => test0
[ZarfiyatSalane] => 600.000
[MizanJazbMavad] => 660.000
)
[1] => stdClass Object
(
[Id] => 265532
[ProductTitle] => test1
[ZarfiyatSalane] => 500.000
[MizanJazbMavad] => 500.000
)
)
)
How can I access a specific value in the array?
The following code does not work because of the stdClass Object
echo $array['ProductTitle'];

How to filter the available fields in Netsuite using RESTlet?

[0] => Array
(
[id] => 1612
[phone] => 9638527410
[email] => sample#gmail.com
[entityid] => dummy entity
........
[recordtype] => contact
)
[1] => Array
(
[id] => 1812
[email] => sample0#gmail.com
[entityid] => dummy entity0
........
[recordtype] => contact
)
.........
.........
I got the result of all contacts like above. But now I want get only who is having Phone no. I tried
filters[0] = new nlobjSearchFilter('phone', null, 'noneof', '#NONE#');.
No success. What filter should use to get the my desired result?
Thanks in advance
Below should work using nlobjSearchFilter
nlapiSearchRecord('contact', null,
new nlobjSearchFilter('phone', null, 'isnotempty'));
If you are looking for filter expression:
nlapiSearchRecord('contact', null, ['phone', 'isnotempty', ''])

GetAll Netsuite Taxcode (SalesTaxItem) (Advance)

Since Tax Code (SalesTaxItem) don't have a search interface, so that I use getAll function.
But with some users, I receive error message "That record does not exist." although [totalRecords] = 67.
My first question : So how can I avoid this error ?
This is structure of GetAllResponse Object
(
[getAllResult] => GetAllResult Object
(
[status] => Status Object
(
[statusDetail] => Array
(
[0] => StatusDetail Object
(
[code] => RCRD_DSNT_EXIST
[message] => That record does not exist.
[type] => ERROR
)
)
[isSuccess] =>
)
[totalRecords] => 67
[recordList] =>
)
)
My second question: On success, I receive SalesTaxItem list. But don't have subsidiary list. How can I get subsidiary list of each SalesTaxItem ?
[getAllResult] => GetAllResult Object
(
[status] => Status Object
(
[statusDetail] =>
[isSuccess] => 1
)
[totalRecords] => 68
[recordList] => RecordList Object
(
[record] => Array
(
[0] => SalesTaxItem Object
(
[itemId] => tax company 15
[displayName] =>
[description] =>
[rate] => 1.00%
[taxType] => RecordRef Object
(
[internalId] => -75
[externalId] =>
[type] =>
[name] => Other 25 Sales Tax
)
[taxAgency] => RecordRef Object
(
[internalId] => 1285
[externalId] =>
[type] =>
[name] => Store Tax Agency
)
[purchaseAccount] =>
[saleAccount] =>
[isInactive] =>
[effectiveFrom] =>
[validUntil] =>
[eccode] =>
[reverseCharge] =>
[parent] =>
[exempt] =>
[isDefault] =>
[excludeFromTaxReports] =>
[available] =>
[export] =>
[taxAccount] => RecordRef Object
(
[internalId] => 375
[externalId] =>
[type] =>
[name] => Sales Taxes Payable
)
[county] =>
[city] =>
[state] =>
[zip] =>
[nexusCountry] =>
[internalId] => 955
[externalId] =>
[nullFieldList] =>
)
Thank you very much.
Best regards
Problems resolved.
First question :Because data on NetSuite have errors. I removed some invalid records on NetSuite.
Second question: Before I used PHP Toolkit v2013_1_0, when use new Toolkit v2013_2_0, result has SubsidiaryList.
Thank you very much.

How to query by custom post type values in WordPress?

I have a Custom Post Type using the Custom Post Type UI plugin called Case Studies. I'm also using the Custom Fields to add a capability field to the Case Studies.
How can I query Case Studies where the capability is equal to some ID?
$query = array('post_type' => 'case-studies','posts_per_page' => 3);
is my query so far
It could be
$query = array(
'post_type' => 'case-studies',
'meta_key' => 'capability',
'meta_value' => 10, // some ID
'posts_per_page' => 3
);
$the_query = new WP_Query( $query );
while ( $the_query->have_posts() ) : $the_query->the_post();
// echo here
endwhile;
wp_reset_postdata();
You need to set your key to capability, and then query value by your post ID.
'meta_query' => array(
array(
'key' => 'capability',
'value' => $post->ID,
'compare' => 'example'
)
)

Resources