Skip to content

Commit e3eb986

Browse files
committedNov 19, 2021
Re-export package content in index
1 parent e9d88e1 commit e3eb986

8 files changed

+110
-39
lines changed
 

‎CONTRIBUTING.md

Whitespace-only changes.

‎README.md

+63
Original file line numberDiff line numberDiff line change
@@ -1 +1,64 @@
11
# ZATCA (Fatoorah) QR-Code Implementation
2+
3+
[![npm version](https://badge.fury.io/js/recht.svg)](https://badge.fury.io/js/recht)
4+
[![build](https://travis-ci.org/user/project.svg?branch=master)](https://travis-ci.org/user/project)
5+
[![Coverage Status](https://coveralls.io/repos/github/user/project/badge.svg?branch=master)](https://coveralls.io/github/user/project?branch=master)
6+
[![dependencies Status](https://david-dm.org/user/project/status.svg)](https://david-dm.org/user/project)
7+
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/user/project/master/LICENSE)
8+
9+
An unofficial package to help developers implement ZATCA (Fatoora) QR code easily which is required for e-invoicing in
10+
Saudi Arabia.
11+
12+
## Installation
13+
14+
```bash
15+
npm i --save @axenda/zatca
16+
```
17+
18+
## Usage
19+
20+
### Generate TLV
21+
22+
```typescript
23+
```
24+
25+
### Generate Base64
26+
27+
```typescript
28+
```
29+
30+
### Render QR Code
31+
32+
You can generate image data (png) from base64 string and render it in browser.
33+
34+
```typescript
35+
```
36+
37+
## Documentation
38+
39+
| Argument | Description | Mandatory | Type | Rules |
40+
|:-------------:|:---------------------------------------------------------------------------------|:--------------:|:-----------------------:|:----------------------------------------------------------------------------------------------------------:|
41+
| 1 | Description of argument 1 | True / False | Type | |
42+
| 2 | Description of argument 2 | True / False | Type | |
43+
| 3 | Description of argument 3 | True / False | Type | |
44+
45+
## Package roadmap
46+
47+
- [x] Feature 1.
48+
- [ ] Feature 2.
49+
- [ ] Feature 3.
50+
- [ ] Feature 4.
51+
- [ ] Feature 5.
52+
- [ ] Feature 6.
53+
54+
## Contributing
55+
56+
**https://github.com/user/project**
57+
58+
## Bibliography
59+
60+
- It is always a good practise to support your work with scientific/ademic literature.
61+
62+
## License
63+
64+
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

‎package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
{
22
"name": "@axenda/zatca",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"description": "",
55
"main": "lib/index.js",
66
"types": "lib/index.d.ts",
7+
"type": "module",
78
"files": [
8-
"lib/**/*"
9+
"lib",
10+
"src"
911
],
1012
"dependencies": {
1113
"qrcode": "^1.4.4"

‎src/index.ts

+6-31
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,7 @@
1-
import { Tag } from './models/tag';
2-
import { Invoice } from './models/invoice';
3-
import { toTlv } from './utils/to-tlv';
4-
import { tagsToBase64, toBase64 } from './utils/to-base64';
5-
import { renderTags } from './utils/render-tags';
1+
export { Invoice } from './models/invoice';
2+
export { Tag } from './models/tag';
63

7-
const tags: Tag[] = [
8-
new Tag(1, 'Salla'),
9-
new Tag(2, '1234567891'),
10-
new Tag(3, '2021-07-12T14:25:09Z'),
11-
new Tag(4, '100.00'),
12-
new Tag(5, '15.00'),
13-
];
14-
15-
const tlv = toTlv(tags);
16-
toBase64(tlv);
17-
tagsToBase64(tags);
18-
renderTags(tags);
19-
20-
const invoice = new Invoice({
21-
sellerName: 'Salla',
22-
vatRegistrationNumber: '1234567891',
23-
invoiceTimestamp: '2021-12-04T00:00:00Z',
24-
invoiceTotal: '100.00',
25-
invoiceVatTotal: '15.00',
26-
});
27-
28-
console.log(invoice.toTlv());
29-
//console.log(invoice.toBase64());
30-
//invoice.render().then((qrcode) => {
31-
// console.log(qrcode);
32-
//});
4+
export { renderTags } from './utils/render-tags';
5+
export { toBase64, tagsToBase64 } from './utils/to-base64';
6+
export { toHex } from './utils/to-hex';
7+
export { toTlv } from './utils/to-tlv';

‎src/internal.ts

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { Tag } from './models/tag';
2+
import { Invoice } from './models/invoice';
3+
import { toTlv } from './utils/to-tlv';
4+
import { tagsToBase64, toBase64 } from './utils/to-base64';
5+
import { renderTags } from './utils/render-tags';
6+
7+
const tags: Tag[] = [
8+
new Tag(1, 'Salla'),
9+
new Tag(2, '1234567891'),
10+
new Tag(3, '2021-07-12T14:25:09Z'),
11+
new Tag(4, '100.00'),
12+
new Tag(5, '15.00'),
13+
];
14+
15+
const tlv = toTlv(tags);
16+
toBase64(tlv);
17+
tagsToBase64(tags);
18+
renderTags(tags);
19+
20+
const invoice = new Invoice({
21+
sellerName: 'Salla',
22+
vatRegistrationNumber: '1234567891',
23+
invoiceTimestamp: '2021-12-04T00:00:00Z',
24+
invoiceTotal: '100.00',
25+
invoiceVatTotal: '15.00',
26+
});
27+
28+
console.log(invoice.toTlv());
29+
//console.log(invoice.toBase64());
30+
//invoice.render().then((qrcode) => {
31+
// console.log(qrcode);
32+
//});

‎tests/invoice.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Invoice } from '../src/models/invoice';
1+
import { Invoice } from '../src';
22

33
test('Invoice.toBase64() returns a valid base64 string', () => {
44
const invoice = new Invoice({

‎tests/tag.test.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import { Tag } from '../src/models/tag';
2-
import { tagsToBase64 } from '../src/utils/to-base64';
3-
import { renderTags } from '../src/utils/render-tags';
1+
import { renderTags, Tag, tagsToBase64 } from '../src';
42

53
test('tagsToBase64() generates a valid base64 string from tags', () => {
64
const tags: Tag[] = [

‎tsconfig.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
],
55
"exclude": [
66
"node_modules",
7-
"**/__tests__/*"
7+
"tests"
88
],
99
"compilerOptions": {
1010
/* Visit https://aka.ms/tsconfig.json to read more about this file */
@@ -36,7 +36,8 @@
3636
/* Specify what module code is generated. */
3737
// "rootDir": "./", /* Specify the root folder within your source files. */
3838
// "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
39-
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
39+
"baseUrl": ".",
40+
/* Specify the base directory to resolve non-relative module names. */
4041
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
4142
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
4243
// "typeRoots": [], /* Specify multiple folders that act like `./node_modules/@types`. */

0 commit comments

Comments
 (0)
Please sign in to comment.