add source code

This commit is contained in:
Michał Chudy
2025-11-14 15:51:00 +01:00
parent df0ef23857
commit b9972746aa
223 changed files with 24651 additions and 46774 deletions

View 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;
}