Code Monkey home page Code Monkey logo

aba-generator's People

Contributors

koresar avatar poputu avatar vkkis93 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

aba-generator's Issues

Payment Date / input doesn't work as expected

To create and time I had to pass the following options:

{
...
    date: '2021-10-26',
    time: '2021-10-26 14:00',
}

only then would the date by actually the 26 of October.
Time has to be a date object. because the date part of the header is using Time and not Date

const time = new Date(this.options.time || this.options.date || new Date());
 return printf(HEADER_FORMAT, {
            ...this.options,
            date: pad2(time.getDate()) + pad2(time.getMonth() + 1) + pad2(time.getFullYear() % 100), // DDMMYY
            bsb: formatBsb(this.options.bsb),
            time: this.options.time ? pad2(time.getHours()) + pad2(time.getMinutes()) : "" // HHmm
        });

So if you want Date + Time, you use Time, if you want Date only you use Date.
Why not have Date as a date string, and time just as the hours,

{
...
    date: '2021-10-26',
    time: '14:00',
}

?

Can you add typing file into your package so we can use this for Typescript with Import

I have created a type definition for you.
The only issue is your ABA.CREDIT and ABA.DEBIT. You declared them as part of the class but I don't think you can do it that way.
You could consider rewriting it into a TS package and compile it to JS.

declare module 'aba-generator' {

  class ABA {

     CREDIT: number;
     DEBIT: number;
     PAY: number;

    constructor(options: AbaOptions)

    generate(transactions: Transaction[]): string;
  }

  interface AbaOptions {
    bsb?: string;                   // Main account BSB. Should be ignored according to the specs.
    account?: string;               // Main account number. Up to 9 chars. Should be ignored according to the specs.
    bank: string;                   // Name of financial institution processing this file. 3 characters, like "ANZ", "WBC"
    user: string;                   // How the user will be shown in the transactions of the third party banks.
    userNumber: number;             // The ID of the user supplying the file.
    description: string;            // Description of this file entries. Up to 12 chars.
    date?: Date | string | number;   // Date to be processed.
    time?: Date | string | number;   // Time to be processed. Should be ignored according to the specs.
  }

  interface Transaction {
    bsb: string;                              // The third party account BSB
    tax?: 'N' | 'W' | 'X' | 'Y' | ' ' | '';
    transactionCode: number;                  // Debit or credit? ABA.CREDIT or ABA.DEBIT
    account: string;                          // The third party account number
    amount: number;
    accountTitle: string;                     // The third party (recipient) account name. Up to 32 chars.
    reference: string;                        // Payment reference, e.g. "Invoice # 123". Up to 18 chars.
    traceBsb: string;                         // The transacting account BSB
    traceAccount: string;                     // The transacting account number
    remitter: string;                         // The transacting company name.
    taxAmount?: number;
  }

  export = ABA;
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.