flash-oss / aba-generator Goto Github PK
View Code? Open in Web Editor NEWGenerate Australian banking ABA file
License: Apache License 2.0
Generate Australian banking ABA file
License: Apache License 2.0
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',
}
?
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;
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.