The @fatturazione-elettronica-aruba/notifications package provides methods to retrieve and manage SDI (Sistema di Interscambio) notifications for both sent and received invoices.
pnpm add @fatturazione-elettronica-aruba/notifications
import { NotificationsClient } from '@fatturazione-elettronica-aruba/notifications';
const notifications = new NotificationsClient({
httpClient: client.http,
});
Options:
| Name | Type | Required | Description |
|---|---|---|---|
httpClient | HttpClient | Yes | HTTP client instance from ArubaClient |
Retrieves notifications for sent invoices.
async getSentNotifications(params: GetNotificationsParams): Promise<NotificationsResponse>
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
id | string | No | SDI identifier of the invoice |
filename | string | No | Invoice filename |
id or filename must be provided.Example:
const response = await notifications.getSentNotifications({
filename: 'IT01234567890_00001.xml',
});
console.log(`Found ${response.count} notifications`);
for (const notification of response.notifications) {
console.log(`${notification.docType}: ${notification.notificationDate}`);
}
Retrieves the full content of a specific notification for a sent invoice.
async getSentNotificationDetail(params: GetNotificationDetailParams): Promise<Notification>
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
filename | string | Yes | Notification filename |
Example:
const notification = await notifications.getSentNotificationDetail({
filename: 'IT01234567890_00001_RC_001.xml',
});
console.log('Notification file content:', notification.file);
Retrieves notifications for received invoices.
async getReceivedNotifications(params: GetNotificationsParams): Promise<NotificationsResponse>
Parameters: Same as getSentNotifications
Retrieves the full content of a specific notification for a received invoice.
async getReceivedNotificationDetail(params: GetNotificationDetailParams): Promise<Notification>
Parameters: Same as getSentNotificationDetail
SDI notification types:
| Code | Name | Description |
|---|---|---|
RC | Ricevuta di Consegna | Invoice was successfully delivered to the recipient |
NS | Notifica di Scarto | Invoice was rejected due to validation errors |
MC | Mancata Consegna | Invoice could not be delivered (recipient unreachable) |
NE | Notifica Esito | Buyer's acceptance/rejection outcome (EC01/EC02) |
DT | Decorrenza Termini | 15-day deadline expired without buyer response |
AT | Attestazione di Trasmissione | Transmission certificate (for PA invoices) |
type NotificationType = 'RC' | 'NS' | 'MC' | 'NE' | 'DT' | 'AT';
Buyer outcome codes (used in NE notifications):
| Code | Description |
|---|---|
EC01 | Invoice accepted |
EC02 | Invoice rejected |
type EsitoResult = 'EC01' | 'EC02';
interface Notification {
date: string; // Invoice date
docType: NotificationType; // Notification type (RC, NS, MC, etc.)
file: string; // Base64-encoded notification XML
filename: string; // Notification filename
invoiceId: string; // SDI identifier
notificationDate: string; // When notification was received
number: string | null; // Invoice number
result: EsitoResult | null; // EC01/EC02 (only for NE notifications)
}
interface NotificationsResponse {
count: number; // Total number of notifications
notifications: Notification[]; // Array of notifications
}
interface GetNotificationsParams {
id?: string; // SDI identifier
filename?: string; // Invoice filename
}
interface GetNotificationDetailParams {
filename: string; // Notification filename
}
Invoice Sent
│
▼
┌─────────┐
│ NS │──── Rejected (validation errors)
└────┬────┘
│ Valid
▼
┌─────────┐
│ RC / MC │──── Delivered (RC) or Failed delivery (MC)
└────┬────┘
│ Delivered (RC)
▼
┌─────────┐
│ NE │──── Buyer outcome (EC01: accept, EC02: reject)
└────┬────┘
│ No response within 15 days
▼
┌─────────┐
│ DT │──── Deadline expired (tacit acceptance)
└─────────┘
async function waitForDelivery(
notifications: NotificationsClient,
filename: string,
maxAttempts = 10,
intervalMs = 30000
): Promise<Notification | null> {
for (let i = 0; i < maxAttempts; i++) {
const response = await notifications.getSentNotifications({ filename });
const delivery = response.notifications.find(
(n) => n.docType === 'RC' || n.docType === 'NS' || n.docType === 'MC'
);
if (delivery) {
return delivery;
}
await new Promise((resolve) => setTimeout(resolve, intervalMs));
}
return null;
}