DocumentSeriesService

DocumentSeriesService TypeScript Class Reference

Overview

SERVICE This class is a "service" and it is automatically injected if declared as a member in the constructor of the consuming class. - See the constructor section below for details - See the Automatic Instance Injection page for details on the topic

The DocumentSeriesService class provides methods to consume local (on-device) document series. The document series feature allows the developer to generate unique number sequences as needed, where the actual format of the number sequences can be controlled by the system administrator. This feature is used in functionalities like invoice and order number generation as well as any other document number generation scenarios, where each document type must have separate number sequence.

No Properties

▶️ getCurrentNumber(documentType: number): Promise<string>

getCurrentNumber method return the current number for a given document series uniquely defined by the documentType argument.

▶️ getNextNumber(documentType: number): Promise<string>

getNextNumber method return the next number for a given document series, uniquely defined by the documentType argument. Note that calling getNextNumber multiple times with the same value for documentType argument, will return the same value always, unless incrementNumber method is called

▶️ increaseNumber(documentType: number): Promise<string>

ncrementNumber method return the next number for a given document series uniquely defined by the documentType argument and persists the new value, e.g. making it current. Note that calling incrementNumber multiple times with the same value for documentType argument, will return different value (incremental) every time.

How to use

import { View, DocumentSeriesService, UserInterfaceService } from '@dms';
import { Invoice } from '@dms-bo';

// it is supposed that there is defined business object Invoice in the Business Object folder

@View()
export class MyView {

  constructor(
      private DocumentSeriesService: DocumentSeriesService,
      private UserInterfaceService: UserInterfaceService){

  }

  createInvoice = async ()=>{      
  //create new document 
  var document = new Invoice(); 
  //get tne next number for displaying purposes
  document.No = await this.DocumentSeriesService.getNextNumber(0);


  this.UserInterfaceService.showMessage(`The new document number will be ${document.No}`); //expected to show 1   


  //persist increased document number and persist document
  document.no =  await this.DocumentSeriesService.increaseNumber(0);
  //persist document in the local device database
  await document.add();
  //show the new number on the screen
  this.UserInterfaceService.showMessage(`The new document number is ${document.No}`); //expected to show 1   

  var newDocNo = await this.DocumentSeriesService.getNextNumber(0);
  console.log(newDocNo); //expected to show 2, because method increaseNumber was called before

  }

Last updated

Dynamics Mobile provided by Mobile Affairs Ltd. | 1712 Sofia, Bulgaria, Alexander Malinov 51 | sales@dynamicsmobile.com