Skip to content

Commit 6c77d98

Browse files
Merge pull request #73 from mathewmeconry/feat/bills-v4-implementation
feat: implement bexio Bills V4 API endpoint
2 parents bb905a1 + 2363da0 commit 6c77d98

File tree

12 files changed

+4723
-2840
lines changed

12 files changed

+4723
-2840
lines changed

.github/workflows/nightly.yml

Lines changed: 0 additions & 31 deletions
This file was deleted.

.github/workflows/test.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,15 @@ jobs:
1515

1616
steps:
1717
- uses: actions/checkout@v1
18+
19+
- name: Use Node.js ${{ matrix.node-version }}
20+
uses: actions/setup-node@v6
21+
with:
22+
node-version: ${{ matrix.node-version }}
23+
24+
- name: Enable corepack
25+
run: corepack enable
26+
1827
- name: Use Node.js ${{ matrix.node-version }}
1928
uses: actions/setup-node@v6
2029
with:

.yarnrc.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nodeLinker: node-modules

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bexio",
3-
"version": "3.3.0",
3+
"version": "3.4.0",
44
"description": "NPM Package for the api of bexio.com",
55
"main": "lib/index.js",
66
"types": "lib/index.d.ts",
@@ -79,5 +79,6 @@
7979
"roots": [
8080
"./src"
8181
]
82-
}
82+
},
83+
"packageManager": "yarn@4.12.0"
8384
}

src/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import Users from "./resources/Users";
1616
import Items from "./resources/Items";
1717
import Invoices from "./resources/Invoices";
1818
import Currencies from "./resources/Currencies";
19+
import BillsV4 from "./resources/BillsV4";
1920

2021
export * from "./interfaces/BillsStatic";
2122
export * from "./interfaces/BusinessActivitiesStatic";
@@ -39,6 +40,7 @@ export * from "./interfaces/ItemsStatic";
3940
export * from "./interfaces/InvoicesStatic";
4041
export * from "./interfaces/PositionStatic";
4142
export * from "./interfaces/CurrenciesStatic";
43+
export * from "./interfaces/BillsV4Static";
4244

4345
export default class Bexio {
4446
private token: string;
@@ -57,6 +59,11 @@ export default class Bexio {
5759
// Sales Order Management
5860
public orders: Orders;
5961
public expenses: Expenses;
62+
public billsV4: BillsV4;
63+
64+
/**
65+
* @deprecated Use BillsV4 instead
66+
*/
6067
public bills: Bills;
6168

6269
// Projects
@@ -95,6 +102,7 @@ export default class Bexio {
95102
this.projectStatuses = new ProjectStatuses(this.token);
96103
this.projectTypes = new ProjectTypes(this.token);
97104
this.expenses = new Expenses(this.token);
105+
this.billsV4 = new BillsV4(this.token);
98106
this.bills = new Bills(this.token);
99107
this.timetrackings = new Timetrackings(this.token);
100108
this.timetrackingStatuses = new TimetrackingStatuses(this.token);

src/interfaces/BillsV4Static.ts

Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
export namespace BillsV4Static {
2+
export interface Bill {
3+
id: string; // uuid, required
4+
document_no: string; // required, 1..255 chars
5+
title?: string; // 1..80 chars
6+
status: BillStatus; // required, enum
7+
firstname_suffix?: string; // 1..80 chars
8+
lastname_company: string; // required, 1..80 chars
9+
created_at: string; // required, date-time
10+
vendor_ref?: string; // 1..255 chars
11+
pending_amount?: number; // double
12+
currency_code: string; // required, 1..20 chars
13+
net?: number; // double, calculated from line_items and discounts
14+
gross?: number; // double, calculated from line_items and discounts
15+
bill_date: string; // required, date
16+
due_date: string; // required, date
17+
overdue: boolean; // required
18+
booking_account_ids: number[]; // required, array of int32
19+
attachment_ids: string[]; // required, array of uuid
20+
}
21+
22+
export interface BillFull extends Bill {
23+
supplier_id: number;
24+
contact_partner_id: number;
25+
amount_man: number;
26+
amount_calc: number;
27+
manual_amount: boolean;
28+
exchange_rate: number;
29+
base_currency_code: string;
30+
item_net: boolean;
31+
split_into_line_items: boolean;
32+
purchase_order_id?: number;
33+
base_currency_amount: number;
34+
qr_bill_information?: string;
35+
address: Address;
36+
line_items: LineItem[];
37+
discounts: Discount[];
38+
payment?: Payment;
39+
note?: string;
40+
}
41+
42+
export interface Address {
43+
title?: string;
44+
salutation?: string;
45+
firstname_suffix?: string;
46+
lastname_company: string;
47+
address_line?: string;
48+
postcode?: string;
49+
city?: string;
50+
country_code?: string;
51+
main_contact_id?: number;
52+
contact_address_id?: number;
53+
type: "PRIVATE" | "COMPANY";
54+
}
55+
56+
export interface LineItem {
57+
position: number;
58+
title?: string;
59+
tax_id?: number;
60+
amount: number;
61+
booking_account_id?: number;
62+
}
63+
64+
export interface Discount {
65+
position: number;
66+
amount: number;
67+
}
68+
69+
export interface Payment {
70+
type: PaymentType;
71+
bank_account_id?: number;
72+
fee?: PaymentFee;
73+
execution_date: string;
74+
exchange_rate?: number;
75+
amount: number;
76+
account_no?: string;
77+
iban?: string;
78+
name?: string;
79+
address?: string;
80+
street?: string;
81+
house_no?: string;
82+
postcode?: string;
83+
city?: string;
84+
country_code?: string;
85+
message?: string;
86+
booking_text?: string;
87+
salary_payment?: boolean;
88+
reference_no?: string;
89+
}
90+
91+
export interface BillCreate {
92+
supplier_id: number;
93+
vendor_ref?: string;
94+
title?: string;
95+
contact_partner_id: number;
96+
bill_date: string;
97+
due_date: string;
98+
amount_man?: number;
99+
amount_calc?: number;
100+
manual_amount: boolean;
101+
currency_code: string;
102+
exchange_rate?: number;
103+
base_currency_amount?: number;
104+
item_net: boolean;
105+
purchase_order_id?: number;
106+
qr_bill_information?: string;
107+
attachment_ids: string[];
108+
address: Address;
109+
line_items: LineItem[];
110+
discounts: Discount[];
111+
payment?: Payment;
112+
salary_payment?: boolean;
113+
reference_no?: string;
114+
note?: string;
115+
}
116+
117+
export interface BillOverwrite {
118+
document_no?: string;
119+
title?: string;
120+
supplier_id: number;
121+
vendor_ref?: string;
122+
contact_partner_id: number;
123+
bill_date: string;
124+
due_date: string;
125+
amount_man?: number;
126+
amount_calc?: number;
127+
manual_amount: boolean;
128+
currency_code: string;
129+
exchange_rate?: number;
130+
item_net: boolean;
131+
split_into_line_items: boolean;
132+
base_currency_amount?: number;
133+
attachment_ids: string[];
134+
address: Address;
135+
line_items: LineItem[];
136+
discounts: Discount[];
137+
payment?: Payment;
138+
}
139+
140+
export enum SearchParameters {
141+
document_no = "document_no",
142+
title = "title",
143+
vendor_ref = "vendor_ref",
144+
currency_code = "currency_code",
145+
lastname_company = "lastname_company",
146+
firstname_suffix = "firstname_suffix",
147+
}
148+
149+
export enum BillStatusUpdate {
150+
DRAFT = "DRAFT",
151+
BOOKED = "BOOKED",
152+
}
153+
154+
export enum BillAction {
155+
DUPLICATE = "DUPLICATE",
156+
}
157+
158+
export interface ListOptions {
159+
limit?: number;
160+
page?: number;
161+
order?: "asc" | "desc";
162+
sort?: string;
163+
search_term?: string;
164+
"fields[]"?: string[];
165+
status?: "DRAFTS" | "TODO" | "PAID" | "OVERDUE";
166+
bill_date_start?: string;
167+
bill_date_end?: string;
168+
due_date_start?: string;
169+
due_date_end?: string;
170+
vendor_ref?: string;
171+
title?: string;
172+
currency_code?: string;
173+
pending_amount_min?: number;
174+
pending_amount_max?: number;
175+
vendor?: string;
176+
gross_min?: number;
177+
gross_max?: number;
178+
net_min?: number;
179+
net_max?: number;
180+
document_no?: string;
181+
supplier_id?: number;
182+
average_exchange_rate_enabled?: boolean;
183+
}
184+
185+
export enum PaymentType {
186+
IBAN = "IBAN",
187+
MANUAL = "MANUAL",
188+
QR = "QR",
189+
}
190+
191+
export enum PaymentFee {
192+
BY_SENDER = "BY_SENDER",
193+
BY_RECEIVER = "BY_RECEIVER",
194+
BREAKDOWN = "BREAKDOWN",
195+
NO_FEE = "NO_FEE",
196+
}
197+
198+
export enum BillStatus {
199+
DRAFT = "DRAFT",
200+
BOOKED = "BOOKED",
201+
PARTIALLY_CREATED = "PARTIALLY_CREATED",
202+
CREATED = "CREATED",
203+
PARTIALLY_SENT = "PARTIALLY_SENT",
204+
SENT = "SENT",
205+
PARTIALLY_DOWNLOADED = "PARTIALLY_DOWNLOADED",
206+
DOWNLOADED = "DOWNLOADED",
207+
PARTIALLY_PAID = "PARTIALLY_PAID",
208+
PAID = "PAID",
209+
PARTIALLY_FAILED = "PARTIALLY_FAILED",
210+
FAILED = "FAILED",
211+
}
212+
}

src/resources/Bills.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ import Payments from "./Payments";
44
import { PaymentsStatic } from "../interfaces/PaymentsStatic";
55
import { BaseStatic } from "../interfaces/BaseStatic";
66

7+
/**
8+
* @deprecated Use BillsV4 instead
9+
*/
710
export default class Bills extends BaseCrud<
811
BillsStatic.Bill,
912
BillsStatic.BillFull,

0 commit comments

Comments
 (0)