Skip to content

Commit 4d8b0de

Browse files
committed
v4.1.0 add getDeletedSalesInvoices and getDeletedSalesOrders
1 parent 1bf370d commit 4d8b0de

File tree

4 files changed

+60
-3
lines changed

4 files changed

+60
-3
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@rantalainen/netvisor-api-client",
3-
"version": "4.0.0",
3+
"version": "4.1.0",
44
"publishConfig": {
55
"access": "public"
66
},

src/interfaces/salesinvoices.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,3 +595,25 @@ export interface UpdateSalesInvoiceStatusParameters {
595595
netvisorKeyList?: string;
596596
status: 'open' | 'paid' | 'unsent' | 'overdue' | 'reminded' | 'requested' | 'collected' | 'creditloss';
597597
}
598+
599+
export interface DeletedSalesInvoices {
600+
deletedsalesinvoices: {
601+
deletedsalesinvoice: DeletedSalesInvoice[];
602+
};
603+
}
604+
605+
export interface DeletedSalesInvoice {
606+
netvisorkey: string;
607+
deletedate: {
608+
value: string;
609+
attr: {
610+
format: string;
611+
};
612+
};
613+
}
614+
615+
export interface DeletedSalesOrders {
616+
deletedsalesorders: {
617+
deletedsalesorder: DeletedSalesInvoice[];
618+
};
619+
}

src/methods/salesinvoices.ts

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@ import {
88
GetSalesInvoiceSalesInvoiceProductLine,
99
SalesInvoiceParameters,
1010
SalesInvoice,
11-
UpdateSalesInvoiceStatusParameters
11+
UpdateSalesInvoiceStatusParameters,
12+
DeletedSalesInvoices,
13+
DeletedSalesOrders
1214
} from '../interfaces/salesinvoices';
15+
import { isArray } from 'util';
1316

1417
export class NetvisorSalesMethod extends NetvisorMethod {
1518
constructor(client: NetvisorApiClient) {
@@ -319,4 +322,36 @@ export class NetvisorSalesMethod extends NetvisorMethod {
319322
async updateSalesInvoiceStatus(params: UpdateSalesInvoiceStatusParameters): Promise<void> {
320323
await this._client.post('updatesalesinvoicestatus.nv', undefined, params);
321324
}
325+
326+
/**
327+
* Get list of deleted sales invoices.
328+
* @param deletedsince Date string in format YYYY-MM-DD. Searches for events that have been deleted after a specified date. Events can be searched for up to 7 days back in history.
329+
*/
330+
async getDeletedSalesInvoices(params: { deletedsince: string }): Promise<DeletedSalesInvoices> {
331+
// Get the raw xml response from Netvisor
332+
const responseXml = await this._client.get('deletedsalesinvoices.nv', params);
333+
// Parse the xml to js object
334+
const xmlObject: DeletedSalesInvoices = parseXml(responseXml);
335+
336+
if (!Array.isArray(xmlObject.deletedsalesinvoices.deletedsalesinvoice)) {
337+
xmlObject.deletedsalesinvoices.deletedsalesinvoice = forceArray(xmlObject.deletedsalesinvoices.deletedsalesinvoice);
338+
}
339+
return xmlObject;
340+
}
341+
342+
/**
343+
* Get list of deleted sales orders.
344+
* @param deletedsince Date string in format YYYY-MM-DD. Searches for events that have been deleted after a specified date. Events can be searched for up to 7 days back in history.
345+
*/
346+
async getDeletedSalesOrders(params: { deletedsince: string }): Promise<DeletedSalesOrders> {
347+
// Get the raw xml response from Netvisor
348+
const responseXml = await this._client.get('deletedsalesorders.nv', params);
349+
// Parse the xml to js object
350+
const xmlObject: DeletedSalesOrders = parseXml(responseXml);
351+
352+
if (!Array.isArray(xmlObject.deletedsalesorders.deletedsalesorder)) {
353+
xmlObject.deletedsalesorders.deletedsalesorder = forceArray(xmlObject.deletedsalesorders.deletedsalesorder);
354+
}
355+
return xmlObject;
356+
}
322357
}

0 commit comments

Comments
 (0)