Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 1x 1x 1x 1x 1x | import ProcessDto from '@orchesty/nodejs-sdk/dist/lib/Utils/ProcessDto';
import { checkErrorInResponse, NAME as APPLICATION_NAME, ResponseState } from '../PohodaApplication';
import APohodaConnector from './APohodaConnector';
export const NAME = `${APPLICATION_NAME}-post-invoice-connector`;
export enum SourceAgendaType {
RECEIVED_ORDER = 'receivedOrder',
ISSUE = 'issueSlip',
}
export enum InvoiceType {
ISSUED_INVOICE = 'issuedInvoice',
}
export default class PohodaPostInvoiceConnector extends APohodaConnector<IInput, IOutput, IResponse> {
public getName(): string {
return NAME;
}
protected getSchema(): string {
return 'http://www.stormware.cz/schema/version_2/invoice.xsd';
}
// eslint-disable-next-line @typescript-eslint/require-await
protected async createItemData(dto: ProcessDto<IInput>): Promise<object> {
return {
/* eslint-disable @typescript-eslint/naming-convention */
'itemData:invoice': {
'@_version': '2.0',
...dto.getJsonData(),
},
/* eslint-enable @typescript-eslint/naming-convention */
};
}
protected getItemData(data: IResponse): IOutput {
checkErrorInResponse(data.invoiceResponse.importDetails?.detail);
return data.invoiceResponse.producedDetails;
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/require-await
protected async getCustomDataPackAttributes(dto: ProcessDto<IInput>): Promise<object> {
return {
// eslint-disable-next-line @typescript-eslint/naming-convention
'@_xmlns:type': 'http://www.stormware.cz/schema/version_2/type.xsd',
};
}
}
export interface IInput {
/* eslint-disable @typescript-eslint/naming-convention */
'itemData:links': {
'type:link': {
'type:sourceAgenda': SourceAgendaType;
'type:sourceDocument': {
'type:id': string;
};
};
};
'itemData:invoiceHeader': {
'itemData:invoiceType': InvoiceType;
'itemData:intNote'?: string;
};
/* eslint-enable @typescript-eslint/naming-convention */
}
export interface IResponse {
invoiceResponse: {
importDetails?: {
detail: {
state: ResponseState;
note: string;
}[];
};
producedDetails: IOutput;
};
}
export interface IOutput {
id: number;
number: string;
actionType: string;
itemDetails: {
item: {
actionType: string;
producedItem: {
id: number;
};
};
type: string;
};
}
|