bexio 4.0.0 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.d.mts CHANGED
@@ -873,6 +873,7 @@ declare namespace OrdersStatic {
873
873
 
874
874
  declare namespace PositionsStatic {
875
875
  type KbDocumentType = "kb_invoice" | "kb_offer" | "kb_order";
876
+ type PositionType = "KbPositionCustom" | "KbPositionArticle" | "KbPositionText" | "KbPositionSubtotal" | "KbPositionPagebreak" | "KbPositionDiscount" | "KbPositionSubposition";
876
877
  interface DefaultPositionCreate {
877
878
  amount: string;
878
879
  amount_reserved: string;
@@ -918,6 +919,42 @@ declare namespace PositionsStatic {
918
919
  }
919
920
  }
920
921
 
922
+ declare namespace PositionStatic {
923
+ interface PositionCreate {
924
+ amount?: string;
925
+ unit_id?: number;
926
+ account_id?: number;
927
+ tax_id?: number;
928
+ text: string;
929
+ unit_price?: string;
930
+ discount_in_percent?: string;
931
+ type: string;
932
+ parent_id?: number | null;
933
+ article_id?: number;
934
+ show_pos_nr?: boolean;
935
+ is_percentual?: boolean;
936
+ value?: string;
937
+ }
938
+ interface Position {
939
+ id: number;
940
+ type: PositionsStatic.PositionType;
941
+ amount: string;
942
+ unit_id: number;
943
+ account_id: number;
944
+ unit_name: string;
945
+ tax_id: number;
946
+ tax_value: string;
947
+ text: string;
948
+ unit_price: string;
949
+ discount_in_percent: string | null;
950
+ position_total: string;
951
+ pos: string;
952
+ internal_pos: number;
953
+ parent_id: number | null;
954
+ is_optional: boolean;
955
+ }
956
+ }
957
+
921
958
  declare class Orders extends BaseCrud<OrdersStatic.OrderSmall, OrdersStatic.OrderFull, OrdersStatic.OrderSmall, OrdersStatic.OrderSearchParameters, OrdersStatic.OrderCreate, OrdersStatic.OrderCreate> {
922
959
  constructor(apiToken: string);
923
960
  /**
@@ -947,6 +984,42 @@ declare class Orders extends BaseCrud<OrdersStatic.OrderSmall, OrdersStatic.Orde
947
984
  * @memberof Orders
948
985
  */
949
986
  createTextPosition(orderId: number, position: PositionsStatic.TextPositionCreate): Promise<PositionsStatic.TextPosition>;
987
+ /**
988
+ * Delete a default position for an order
989
+ *
990
+ * @param {number} orderId
991
+ * @param {number} positionId
992
+ * @returns {Promise<boolean>}
993
+ * @memberof Orders
994
+ */
995
+ deleteDefaultPosition(orderId: number, positionId: number): Promise<boolean>;
996
+ /**
997
+ * Delete an item position for an order
998
+ *
999
+ * @param {number} orderId
1000
+ * @param {number} positionId
1001
+ * @returns {Promise<boolean>}
1002
+ * @memberof Orders
1003
+ */
1004
+ deleteItemPosition(orderId: number, positionId: number): Promise<boolean>;
1005
+ /**
1006
+ * Delete a text position for an order
1007
+ *
1008
+ * @param {number} orderId
1009
+ * @param {number} positionId
1010
+ * @returns {Promise<boolean>}
1011
+ * @memberof Orders
1012
+ */
1013
+ deleteTextPosition(orderId: number, positionId: number): Promise<boolean>;
1014
+ /**
1015
+ * Delete a position for an order, whatever its type
1016
+ *
1017
+ * @param {number} orderId
1018
+ * @param {Pick<PositionStatic.Position, "id" | "type">} position
1019
+ * @returns {Promise<boolean>}
1020
+ * @memberof Orders
1021
+ */
1022
+ deletePosition(orderId: number, position: Pick<PositionStatic.Position, "id" | "type">): Promise<boolean>;
950
1023
  }
951
1024
 
952
1025
  declare namespace ProjectsStatic {
@@ -1423,42 +1496,6 @@ declare class Items extends BaseCrud<ItemsStatic.Item, ItemsStatic.Item, ItemsSt
1423
1496
  constructor(apiToken: string);
1424
1497
  }
1425
1498
 
1426
- declare namespace PositionStatic {
1427
- interface PositionCreate {
1428
- amount?: string;
1429
- unit_id?: number;
1430
- account_id?: number;
1431
- tax_id?: number;
1432
- text: string;
1433
- unit_price?: string;
1434
- discount_in_percent?: string;
1435
- type: string;
1436
- parent_id?: number | null;
1437
- article_id?: number;
1438
- show_pos_nr?: boolean;
1439
- is_percentual?: boolean;
1440
- value?: string;
1441
- }
1442
- interface Position {
1443
- id: number;
1444
- type: string;
1445
- amount: string;
1446
- unit_id: number;
1447
- account_id: number;
1448
- unit_name: string;
1449
- tax_id: number;
1450
- tax_value: string;
1451
- text: string;
1452
- unit_price: string;
1453
- discount_in_percent: null;
1454
- position_total: string;
1455
- pos: string;
1456
- internal_pos: number;
1457
- parent_id: null;
1458
- is_optional: false;
1459
- }
1460
- }
1461
-
1462
1499
  declare namespace InvoicesStatic {
1463
1500
  interface Invoice {
1464
1501
  id: number;
@@ -1508,6 +1545,7 @@ declare namespace InvoicesStatic {
1508
1545
  title?: string | null;
1509
1546
  contact_id: number;
1510
1547
  contact_sub_id?: number | null;
1548
+ contact_address_manual?: string | null;
1511
1549
  user_id: number;
1512
1550
  pr_project_id?: number | null;
1513
1551
  logopaper_id?: number;
@@ -1531,6 +1569,7 @@ declare namespace InvoicesStatic {
1531
1569
  title?: string | null;
1532
1570
  contact_id?: number;
1533
1571
  contact_sub_id?: number | null;
1572
+ contact_address_manual?: string | null;
1534
1573
  user_id?: number;
1535
1574
  pr_project_id?: number | null;
1536
1575
  logopaper_id?: number;
@@ -1729,6 +1768,42 @@ declare class Invoices extends BaseCrud<InvoicesStatic.Invoice, InvoicesStatic.I
1729
1768
  * @memberof Invoices
1730
1769
  */
1731
1770
  createTextPosition(invoiceId: number, position: PositionsStatic.TextPositionCreate): Promise<PositionsStatic.TextPosition>;
1771
+ /**
1772
+ * Delete a default position for an invoice
1773
+ *
1774
+ * @param {number} invoiceId
1775
+ * @param {number} positionId
1776
+ * @returns {Promise<boolean>}
1777
+ * @memberof Invoices
1778
+ */
1779
+ deleteDefaultPosition(invoiceId: number, positionId: number): Promise<boolean>;
1780
+ /**
1781
+ * Delete an item position for an invoice
1782
+ *
1783
+ * @param {number} invoiceId
1784
+ * @param {number} positionId
1785
+ * @returns {Promise<boolean>}
1786
+ * @memberof Invoices
1787
+ */
1788
+ deleteItemPosition(invoiceId: number, positionId: number): Promise<boolean>;
1789
+ /**
1790
+ * Delete a text position for an invoice
1791
+ *
1792
+ * @param {number} invoiceId
1793
+ * @param {number} positionId
1794
+ * @returns {Promise<boolean>}
1795
+ * @memberof Invoices
1796
+ */
1797
+ deleteTextPosition(invoiceId: number, positionId: number): Promise<boolean>;
1798
+ /**
1799
+ * Delete a position for an invoice, whatever its type
1800
+ *
1801
+ * @param {number} invoiceId
1802
+ * @param {Pick<PositionStatic.Position, "id" | "type">} position
1803
+ * @returns {Promise<boolean>}
1804
+ * @memberof Invoices
1805
+ */
1806
+ deletePosition(invoiceId: number, position: Pick<PositionStatic.Position, "id" | "type">): Promise<boolean>;
1732
1807
  }
1733
1808
 
1734
1809
  declare namespace CurrenciesStatic {
package/lib/index.d.ts CHANGED
@@ -873,6 +873,7 @@ declare namespace OrdersStatic {
873
873
 
874
874
  declare namespace PositionsStatic {
875
875
  type KbDocumentType = "kb_invoice" | "kb_offer" | "kb_order";
876
+ type PositionType = "KbPositionCustom" | "KbPositionArticle" | "KbPositionText" | "KbPositionSubtotal" | "KbPositionPagebreak" | "KbPositionDiscount" | "KbPositionSubposition";
876
877
  interface DefaultPositionCreate {
877
878
  amount: string;
878
879
  amount_reserved: string;
@@ -918,6 +919,42 @@ declare namespace PositionsStatic {
918
919
  }
919
920
  }
920
921
 
922
+ declare namespace PositionStatic {
923
+ interface PositionCreate {
924
+ amount?: string;
925
+ unit_id?: number;
926
+ account_id?: number;
927
+ tax_id?: number;
928
+ text: string;
929
+ unit_price?: string;
930
+ discount_in_percent?: string;
931
+ type: string;
932
+ parent_id?: number | null;
933
+ article_id?: number;
934
+ show_pos_nr?: boolean;
935
+ is_percentual?: boolean;
936
+ value?: string;
937
+ }
938
+ interface Position {
939
+ id: number;
940
+ type: PositionsStatic.PositionType;
941
+ amount: string;
942
+ unit_id: number;
943
+ account_id: number;
944
+ unit_name: string;
945
+ tax_id: number;
946
+ tax_value: string;
947
+ text: string;
948
+ unit_price: string;
949
+ discount_in_percent: string | null;
950
+ position_total: string;
951
+ pos: string;
952
+ internal_pos: number;
953
+ parent_id: number | null;
954
+ is_optional: boolean;
955
+ }
956
+ }
957
+
921
958
  declare class Orders extends BaseCrud<OrdersStatic.OrderSmall, OrdersStatic.OrderFull, OrdersStatic.OrderSmall, OrdersStatic.OrderSearchParameters, OrdersStatic.OrderCreate, OrdersStatic.OrderCreate> {
922
959
  constructor(apiToken: string);
923
960
  /**
@@ -947,6 +984,42 @@ declare class Orders extends BaseCrud<OrdersStatic.OrderSmall, OrdersStatic.Orde
947
984
  * @memberof Orders
948
985
  */
949
986
  createTextPosition(orderId: number, position: PositionsStatic.TextPositionCreate): Promise<PositionsStatic.TextPosition>;
987
+ /**
988
+ * Delete a default position for an order
989
+ *
990
+ * @param {number} orderId
991
+ * @param {number} positionId
992
+ * @returns {Promise<boolean>}
993
+ * @memberof Orders
994
+ */
995
+ deleteDefaultPosition(orderId: number, positionId: number): Promise<boolean>;
996
+ /**
997
+ * Delete an item position for an order
998
+ *
999
+ * @param {number} orderId
1000
+ * @param {number} positionId
1001
+ * @returns {Promise<boolean>}
1002
+ * @memberof Orders
1003
+ */
1004
+ deleteItemPosition(orderId: number, positionId: number): Promise<boolean>;
1005
+ /**
1006
+ * Delete a text position for an order
1007
+ *
1008
+ * @param {number} orderId
1009
+ * @param {number} positionId
1010
+ * @returns {Promise<boolean>}
1011
+ * @memberof Orders
1012
+ */
1013
+ deleteTextPosition(orderId: number, positionId: number): Promise<boolean>;
1014
+ /**
1015
+ * Delete a position for an order, whatever its type
1016
+ *
1017
+ * @param {number} orderId
1018
+ * @param {Pick<PositionStatic.Position, "id" | "type">} position
1019
+ * @returns {Promise<boolean>}
1020
+ * @memberof Orders
1021
+ */
1022
+ deletePosition(orderId: number, position: Pick<PositionStatic.Position, "id" | "type">): Promise<boolean>;
950
1023
  }
951
1024
 
952
1025
  declare namespace ProjectsStatic {
@@ -1423,42 +1496,6 @@ declare class Items extends BaseCrud<ItemsStatic.Item, ItemsStatic.Item, ItemsSt
1423
1496
  constructor(apiToken: string);
1424
1497
  }
1425
1498
 
1426
- declare namespace PositionStatic {
1427
- interface PositionCreate {
1428
- amount?: string;
1429
- unit_id?: number;
1430
- account_id?: number;
1431
- tax_id?: number;
1432
- text: string;
1433
- unit_price?: string;
1434
- discount_in_percent?: string;
1435
- type: string;
1436
- parent_id?: number | null;
1437
- article_id?: number;
1438
- show_pos_nr?: boolean;
1439
- is_percentual?: boolean;
1440
- value?: string;
1441
- }
1442
- interface Position {
1443
- id: number;
1444
- type: string;
1445
- amount: string;
1446
- unit_id: number;
1447
- account_id: number;
1448
- unit_name: string;
1449
- tax_id: number;
1450
- tax_value: string;
1451
- text: string;
1452
- unit_price: string;
1453
- discount_in_percent: null;
1454
- position_total: string;
1455
- pos: string;
1456
- internal_pos: number;
1457
- parent_id: null;
1458
- is_optional: false;
1459
- }
1460
- }
1461
-
1462
1499
  declare namespace InvoicesStatic {
1463
1500
  interface Invoice {
1464
1501
  id: number;
@@ -1508,6 +1545,7 @@ declare namespace InvoicesStatic {
1508
1545
  title?: string | null;
1509
1546
  contact_id: number;
1510
1547
  contact_sub_id?: number | null;
1548
+ contact_address_manual?: string | null;
1511
1549
  user_id: number;
1512
1550
  pr_project_id?: number | null;
1513
1551
  logopaper_id?: number;
@@ -1531,6 +1569,7 @@ declare namespace InvoicesStatic {
1531
1569
  title?: string | null;
1532
1570
  contact_id?: number;
1533
1571
  contact_sub_id?: number | null;
1572
+ contact_address_manual?: string | null;
1534
1573
  user_id?: number;
1535
1574
  pr_project_id?: number | null;
1536
1575
  logopaper_id?: number;
@@ -1729,6 +1768,42 @@ declare class Invoices extends BaseCrud<InvoicesStatic.Invoice, InvoicesStatic.I
1729
1768
  * @memberof Invoices
1730
1769
  */
1731
1770
  createTextPosition(invoiceId: number, position: PositionsStatic.TextPositionCreate): Promise<PositionsStatic.TextPosition>;
1771
+ /**
1772
+ * Delete a default position for an invoice
1773
+ *
1774
+ * @param {number} invoiceId
1775
+ * @param {number} positionId
1776
+ * @returns {Promise<boolean>}
1777
+ * @memberof Invoices
1778
+ */
1779
+ deleteDefaultPosition(invoiceId: number, positionId: number): Promise<boolean>;
1780
+ /**
1781
+ * Delete an item position for an invoice
1782
+ *
1783
+ * @param {number} invoiceId
1784
+ * @param {number} positionId
1785
+ * @returns {Promise<boolean>}
1786
+ * @memberof Invoices
1787
+ */
1788
+ deleteItemPosition(invoiceId: number, positionId: number): Promise<boolean>;
1789
+ /**
1790
+ * Delete a text position for an invoice
1791
+ *
1792
+ * @param {number} invoiceId
1793
+ * @param {number} positionId
1794
+ * @returns {Promise<boolean>}
1795
+ * @memberof Invoices
1796
+ */
1797
+ deleteTextPosition(invoiceId: number, positionId: number): Promise<boolean>;
1798
+ /**
1799
+ * Delete a position for an invoice, whatever its type
1800
+ *
1801
+ * @param {number} invoiceId
1802
+ * @param {Pick<PositionStatic.Position, "id" | "type">} position
1803
+ * @returns {Promise<boolean>}
1804
+ * @memberof Invoices
1805
+ */
1806
+ deletePosition(invoiceId: number, position: Pick<PositionStatic.Position, "id" | "type">): Promise<boolean>;
1732
1807
  }
1733
1808
 
1734
1809
  declare namespace CurrenciesStatic {
package/lib/index.js CHANGED
@@ -616,6 +616,64 @@ var TextPositions = class extends BaseCrud {
616
616
  }
617
617
  };
618
618
 
619
+ // src/resources/Positions.ts
620
+ var Positions = class _Positions extends BaseCrud {
621
+ static {
622
+ this.endpoints = {
623
+ KbPositionCustom: "kb_position_custom",
624
+ KbPositionArticle: "kb_position_article",
625
+ KbPositionText: "kb_position_text",
626
+ KbPositionSubtotal: "kb_position_subtotal",
627
+ KbPositionPagebreak: "kb_position_pagebreak",
628
+ KbPositionDiscount: "kb_position_discount",
629
+ KbPositionSubposition: "kb_position_subposition"
630
+ };
631
+ }
632
+ constructor(apiToken, documentType, documentId, positionType) {
633
+ super(
634
+ apiToken,
635
+ `/2.0/${documentType}/${documentId}/${_Positions.endpoint(positionType)}`
636
+ );
637
+ }
638
+ /**
639
+ * Endpoint segment of a position type
640
+ *
641
+ * @private
642
+ * @static
643
+ * @param {PositionsStatic.PositionType} positionType
644
+ * @returns {string}
645
+ * @memberof Positions
646
+ */
647
+ static endpoint(positionType) {
648
+ if (!Object.prototype.hasOwnProperty.call(_Positions.endpoints, positionType)) {
649
+ throw new Error(`Unknown position type "${positionType}"`);
650
+ }
651
+ return _Positions.endpoints[positionType];
652
+ }
653
+ /**
654
+ * Not implemented by Bexio yet
655
+ *
656
+ * @param {Array<BaseStatic.SearchParameter<{}>>} searchOptions
657
+ * @param {BaseStatic.BaseOptions} [options]
658
+ * @returns {Promise<Array<{}>>}
659
+ * @memberof Positions
660
+ */
661
+ async search(searchOptions, options) {
662
+ throw new Error("not implemented by Bexio yet");
663
+ }
664
+ /**
665
+ * Not implemented by Bexio yet
666
+ *
667
+ * @param {number} id
668
+ * @param {{}} ressource
669
+ * @returns {Promise<PositionStatic.Position>}
670
+ * @memberof Positions
671
+ */
672
+ async overwrite(id, ressource) {
673
+ throw new Error("not implemented by Bexio yet");
674
+ }
675
+ };
676
+
619
677
  // src/resources/Orders.ts
620
678
  var Orders = class extends BaseCrud {
621
679
  constructor(apiToken) {
@@ -660,6 +718,61 @@ var Orders = class extends BaseCrud {
660
718
  position
661
719
  );
662
720
  }
721
+ /**
722
+ * Delete a default position for an order
723
+ *
724
+ * @param {number} orderId
725
+ * @param {number} positionId
726
+ * @returns {Promise<boolean>}
727
+ * @memberof Orders
728
+ */
729
+ async deleteDefaultPosition(orderId, positionId) {
730
+ return new DefaultPositions(this.apiToken, "kb_order", orderId).delete(
731
+ positionId
732
+ );
733
+ }
734
+ /**
735
+ * Delete an item position for an order
736
+ *
737
+ * @param {number} orderId
738
+ * @param {number} positionId
739
+ * @returns {Promise<boolean>}
740
+ * @memberof Orders
741
+ */
742
+ async deleteItemPosition(orderId, positionId) {
743
+ return new ItemPositions(this.apiToken, "kb_order", orderId).delete(
744
+ positionId
745
+ );
746
+ }
747
+ /**
748
+ * Delete a text position for an order
749
+ *
750
+ * @param {number} orderId
751
+ * @param {number} positionId
752
+ * @returns {Promise<boolean>}
753
+ * @memberof Orders
754
+ */
755
+ async deleteTextPosition(orderId, positionId) {
756
+ return new TextPositions(this.apiToken, "kb_order", orderId).delete(
757
+ positionId
758
+ );
759
+ }
760
+ /**
761
+ * Delete a position for an order, whatever its type
762
+ *
763
+ * @param {number} orderId
764
+ * @param {Pick<PositionStatic.Position, "id" | "type">} position
765
+ * @returns {Promise<boolean>}
766
+ * @memberof Orders
767
+ */
768
+ async deletePosition(orderId, position) {
769
+ return new Positions(
770
+ this.apiToken,
771
+ "kb_order",
772
+ orderId,
773
+ position.type
774
+ ).delete(position.id);
775
+ }
663
776
  };
664
777
 
665
778
  // src/resources/Projects.ts
@@ -1072,6 +1185,61 @@ var Invoices = class extends BaseCrud {
1072
1185
  position
1073
1186
  );
1074
1187
  }
1188
+ /**
1189
+ * Delete a default position for an invoice
1190
+ *
1191
+ * @param {number} invoiceId
1192
+ * @param {number} positionId
1193
+ * @returns {Promise<boolean>}
1194
+ * @memberof Invoices
1195
+ */
1196
+ async deleteDefaultPosition(invoiceId, positionId) {
1197
+ return new DefaultPositions(this.apiToken, "kb_invoice", invoiceId).delete(
1198
+ positionId
1199
+ );
1200
+ }
1201
+ /**
1202
+ * Delete an item position for an invoice
1203
+ *
1204
+ * @param {number} invoiceId
1205
+ * @param {number} positionId
1206
+ * @returns {Promise<boolean>}
1207
+ * @memberof Invoices
1208
+ */
1209
+ async deleteItemPosition(invoiceId, positionId) {
1210
+ return new ItemPositions(this.apiToken, "kb_invoice", invoiceId).delete(
1211
+ positionId
1212
+ );
1213
+ }
1214
+ /**
1215
+ * Delete a text position for an invoice
1216
+ *
1217
+ * @param {number} invoiceId
1218
+ * @param {number} positionId
1219
+ * @returns {Promise<boolean>}
1220
+ * @memberof Invoices
1221
+ */
1222
+ async deleteTextPosition(invoiceId, positionId) {
1223
+ return new TextPositions(this.apiToken, "kb_invoice", invoiceId).delete(
1224
+ positionId
1225
+ );
1226
+ }
1227
+ /**
1228
+ * Delete a position for an invoice, whatever its type
1229
+ *
1230
+ * @param {number} invoiceId
1231
+ * @param {Pick<PositionStatic.Position, "id" | "type">} position
1232
+ * @returns {Promise<boolean>}
1233
+ * @memberof Invoices
1234
+ */
1235
+ async deletePosition(invoiceId, position) {
1236
+ return new Positions(
1237
+ this.apiToken,
1238
+ "kb_invoice",
1239
+ invoiceId,
1240
+ position.type
1241
+ ).delete(position.id);
1242
+ }
1075
1243
  };
1076
1244
 
1077
1245
  // src/resources/Currencies.ts