headintheclouddev / typings-suitescript-2.0

TypeScript typings for SuiteScript version 2.0
MIT License
146 stars 92 forks source link

transaction.void type improve #123

Closed arook closed 4 years ago

arook commented 4 years ago

https://github.com/headintheclouddev/typings-suitescript-2.0/blob/dd102b7bca633516b349225f56efc1921b6fcfbe/N/transaction.d.ts#L4

Can this be improved?

//Add additional code 
...
var voidSalesOrderId = transaction.void({
    type: transaction.Type.SALES_ORDER,
    id: salesOrderId
});
...
//Add additional code
MrRob commented 4 years ago

@arook What additional code are you wanting to see there? The transaction module only has one documented method.

steven-t-h commented 4 years ago

@MrRob this looks like it's been untouched for a while, but since it's still open... Maybe they're looking for a type enumeration instead of "string". Similar to search.Type.SALES_ORDER or record.Type.CUSTOMER. That way you could be sure the of available transactions to void.

You can see this is used in the SS2.0 API Guide (pg. 1006):


var voidSalesOrderId = transaction.void({
     type: transaction.Type.SALES_ORDER,
     id: salesOrderId
});
steven-t-h commented 4 years ago

@MrRob to follow up:


interface VoidOptions {
    id: number | string;
    type: Type | string;
}

interface TransactionVoidFunction {
    (options: VoidOptions): number;
    promise(options: VoidOptions): Promise<number>;
}

declare var voidFunc: TransactionVoidFunction;
export {voidFunc as void};

/** N/transaction.Type enum */
export enum Type { // As of 15 June 2020
    ADV_INTER_COMPANY_JOURNAL_ENTRY, // 'advintercompanyjournalentry'
    CASH_REFUND, // 'cashrefund'
    CASH_SALE, // 'cashsale'
    CHECK, // 'check'
    CREDIT_MEMO, // 'creditmemo'
    CUSTOMER_DEPOSIT, // 'customerdeposit'
    CUSTOMER_PAYMENT, // 'customerpayment'
    CUSTOMER_REFUND, // 'customerrefund'
    ESTIMATE_QUOTE, //
    EXPENSE_REPORT, // 'expensereport'
    INTER_COMPANY_JOURNAL_ENTRY, // 'intercompanyjournalentry'
    INVOICE, // 'invoice'
    JOURNAL_ENTRY, // 'journalentry'
    PAYCHECK_JOURNAL, // 'paycheckjournal'
    RETURN_AUTHORIZATION, // 'returnauthorization'
    SALES_ORDER, // 'salesorder'
    TRANSFER_ORDER, // 'transferorder'
    VENDOR_BILL, // 'vendorbill'
    VENDOR_CREDIT, // 'vendorcredit'
    VENDOR_PAYMENT, // 'vendorpayment'
    VENDOR_RETURN_AUTHORIZATION, // 'vendorreturnauthorization'
    WORK_ORDER, // 'workorder'
}
MrRob commented 4 years ago

Okay, I've added the enumeration now in version 2020.1.14 :)

Thank you!