0.1.18 • Published 8 days ago

@vita-mojo/fiscalization-sdk v0.1.18

Weekly downloads
-
License
-
Repository
-
Last release
8 days ago

fiscalization-sdk

This package serves as a wrapper for integrating with various fiscalization providers. As of now, the SDK only supports Fiskaltrust.

Using the SDK

Run npm i @vita-mojo/fiscalization-sdk to install this package.

You must first initialise the SDK with the provider name and other required parameters.

import { fiscalizationSdk } from '@vita-mojo/fiscalization-sdk';

const options = {
  apiKey: 'provider_api_key',
  settings: {}, // 'fiscalization.integration' tenant/store level setting
  terminalId: 'pos_terminal_id',
  logger: {}, // optional logger
};

const fiskalProvider = fiskalizationSdk('fiskaltrust', options);

Once initialised, the SDK returns an object containing several methods, each of which correspond to a fiscalization action.

const { generateBill } = fiskalProvider;
const order = {}; // vita-mojo order
const bill = await generateBill(order);
console.log(bill);

Here's a list of supported actions:

MethodParametersReturn Type
generateBillVM OrderFiscalResponse
generateTicketVM OrderFiscalResponse
generateDuplicateTicketVM Order, reason(string)FiscalResponse
eventLogEventPayloadIReceipt
healthCheck-boolean
cashDepositamount(number), reason(string)FiscalResponse
payoutamount(number), reason(string)FiscalResponse
refundTicketVM OrderFiscalResponse
dailyClosingFlow{ zeroReceipt: FiscalResponse; dailyReceipt: FiscalResponse; }
monthlyClosingFlow{ monthlyReceipt: FiscalResponse; monthlyArchive: FiscalResponse; }
yearlyReceiptFiscalResponse

Settings

The settings option for initialising the SDK should come from the fiscalization.integration tenants-management setting. It can be defined on tenant or store level. An example configuration may look like this:

{
  "name": "fiskaltrust",
  "commonFields": {
    "apiUrl": "https://fiscal_provider.url"
  },
  "fiskaltrust": {
    "cashbox": "cashbox_id",
    "posSystem": "pos_system_id",
    "receiptCase": {
      "bill": "5067112530745229320",
      "ticket": "5067112530745229313",
      "eventLog": "5067112530745229330",
      "cashDeposit": "5067112530745229322",
      "payout": "5067112530745229323",
      "copy": "5067112530745229334",
      "void": "262144",
      "zeroReceipt": "5067112530745229327",
      "dailyReceipt": "5067112530745229317",
      "monthlyReceipt": "5067112530745229318",
      "yearlyReceipt": "5067112530745229319",
    },
    "chargeItemCase": {
      "unknown": "5067112530745229312"
    },
    "payItemCase": {
      "default": "5067112530745229312",
      "cashPayment": "5067112530745229313",
      "internalConsumption": "5067112530745229329"
    }
  }
}

Logger

You may provide an additional logger object while initialising the SDK. The logger should specify a log level and, optionally, logger method overrides for different log levels. Here's an example logger configuration:

import { LogLevels } from '@vita-mojo/fiscalization-sdk';

const logger = {
  logLevel: LogLevels.debug, // Supported levels: none, error, info, debug
  debug: (...messages) => {
    /* debug loggger */
  },
  info: (...messages) => {
    /* info logger */
  },
};

The log level defaults to error if not provided.

Building and Running Locally

Run npm run build:sdk to build the SDK.

To build the SDK in watch mode, run npm run build:sdk:w.

Running unit tests

Run npm run test:sdk to run unit tests via Jest.

0.1.18

8 days ago

0.1.17

1 month ago

0.1.16

1 month ago

0.1.15

3 months ago

0.1.14

4 months ago

0.1.13

7 months ago

0.1.12

7 months ago

0.1.11

7 months ago

0.1.10

7 months ago

0.1.9

7 months ago

0.1.8

8 months ago

0.1.6

8 months ago

0.1.5

8 months ago

0.1.4

9 months ago

0.1.3

9 months ago

0.1.2

9 months ago

0.1.1

10 months ago