add source code
This commit is contained in:
74
src/lib-public/generators/FA2/Podmiot2Podmiot2k.ts
Normal file
74
src/lib-public/generators/FA2/Podmiot2Podmiot2k.ts
Normal file
@@ -0,0 +1,74 @@
|
||||
import { Content } from 'pdfmake/interfaces';
|
||||
import {
|
||||
createHeader,
|
||||
createLabelText,
|
||||
formatText,
|
||||
getTable,
|
||||
hasValue,
|
||||
verticalSpacing,
|
||||
} from '../../../shared/PDF-functions';
|
||||
import FormatTyp from '../../../shared/enums/common.enum';
|
||||
import { Podmiot2, Podmiot2K } from '../../types/fa3.types';
|
||||
import { generateAdres } from './Adres';
|
||||
import { generateDaneIdentyfikacyjneTPodmiot1Dto } from './PodmiotDaneIdentyfikacyjneTPodmiot1Dto';
|
||||
import { generateDaneKontaktowe } from './PodmiotDaneKontaktowe';
|
||||
|
||||
export function generatePodmiot2Podmiot2K(podmiot2: Podmiot2, podmiot2K: Podmiot2K): Content[] {
|
||||
const result: Content[] = createHeader('Nabywca');
|
||||
let firstColumn: Content[] = [];
|
||||
let secondColumn: Content[] = [];
|
||||
|
||||
firstColumn.push(createHeader('Dane identyfikacyjne'), createLabelText('Numer EORI: ', podmiot2.NrEORI));
|
||||
if (podmiot2.DaneIdentyfikacyjne) {
|
||||
firstColumn.push(...generateDaneIdentyfikacyjneTPodmiot1Dto(podmiot2.DaneIdentyfikacyjne));
|
||||
}
|
||||
|
||||
if (podmiot2.DaneKontaktowe) {
|
||||
firstColumn.push(generateDaneKontaktowe(getTable(podmiot2.DaneKontaktowe)));
|
||||
}
|
||||
if (podmiot2.NrKlienta) {
|
||||
firstColumn.push(createLabelText('Numer klienta: ', podmiot2.NrKlienta));
|
||||
}
|
||||
if (firstColumn.length) {
|
||||
result.push({
|
||||
columns: [firstColumn, []],
|
||||
columnGap: 20,
|
||||
});
|
||||
}
|
||||
firstColumn = generateCorrectedContent(podmiot2K);
|
||||
secondColumn = generateCorrectedContent(podmiot2);
|
||||
if (podmiot2.AdresKoresp) {
|
||||
secondColumn.push(
|
||||
formatText('Adres do korespondencji', [FormatTyp.Label, FormatTyp.LabelMargin]),
|
||||
generateAdres(podmiot2.AdresKoresp)
|
||||
);
|
||||
}
|
||||
|
||||
if (firstColumn.length || secondColumn.length) {
|
||||
result.push({
|
||||
columns: [firstColumn, secondColumn],
|
||||
columnGap: 20,
|
||||
});
|
||||
}
|
||||
if (result.length) {
|
||||
result.push(verticalSpacing(1));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export function generateCorrectedContent(podmiot: Podmiot2 | Podmiot2K): Content[] {
|
||||
const result: Content[] = [];
|
||||
|
||||
result.push(createHeader('Treść korygowana'));
|
||||
|
||||
if (hasValue(podmiot.IDNabywcy)) {
|
||||
result.push(createLabelText('Identyfikator nabywcy: ', podmiot.IDNabywcy));
|
||||
}
|
||||
if (podmiot.DaneIdentyfikacyjne) {
|
||||
result.push(...generateDaneIdentyfikacyjneTPodmiot1Dto(podmiot.DaneIdentyfikacyjne));
|
||||
}
|
||||
if (podmiot.Adres) {
|
||||
result.push(formatText('Adres', [FormatTyp.Label, FormatTyp.LabelMargin]), generateAdres(podmiot.Adres));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
Reference in New Issue
Block a user