UPO 4.3, fixes for invoices

This commit is contained in:
Michał Chudy
2026-01-16 08:35:43 +01:00
parent 1912b5b48d
commit 5fb5a624b8
64 changed files with 1044 additions and 1444 deletions

View File

@@ -6,6 +6,7 @@ import {
formatText,
getContentTable,
getTable,
getTStawkaPodatku,
getValue,
} from '../../../shared/PDF-functions';
import { HeaderDefine } from '../../../shared/types/pdf-types';
@@ -13,16 +14,20 @@ import { Procedura, TRodzajFaktury } from '../../../shared/consts/const';
import { Fa, FP } from '../../types/fa1.types';
import FormatTyp, { Position } from '../../../shared/enums/common.enum';
import { FormContentState } from '../../../shared/types/additional-data.types';
import { shouldAddMarza } from '../common/Wiersze';
import { addMarza } from '../common/Wiersze';
export function generateWiersze(faVat: Fa): Content {
const table: Content[] = [];
const rodzajFaktury: string | number | undefined = getValue(faVat.RodzajFaktury);
const isP_PMarzy: boolean = Boolean(Number(getValue(faVat.Adnotacje?.P_PMarzy)));
const isP_PMarzy = Boolean(Number(getValue(faVat.Adnotacje?.P_PMarzy)));
const faWiersze: Record<string, FP>[] = getTable(faVat.FaWiersze?.FaWiersz).map(
(wiersz: Record<string, FP>): Record<string, FP> => {
const marza: Record<string, FP> = shouldAddMarza(rodzajFaktury, isP_PMarzy, wiersz)!;
return marza ? { ...wiersz, ...marza } : wiersz;
const marza: Record<string, FP> = addMarza(rodzajFaktury, isP_PMarzy, wiersz)!;
if (getValue(wiersz.P_12)) {
wiersz.P_12._text = getTStawkaPodatku(getValue(wiersz.P_12) as string, 1);
}
return { ...wiersz, ...marza };
}
);
const definedHeaderLp: HeaderDefine[] = [
@@ -33,7 +38,7 @@ export function generateWiersze(faVat: Fa): Content {
{ name: 'P_7', title: 'Nazwa towaru lub usługi', format: FormatTyp.Default, width: '*' },
{ name: 'P_9A', title: 'Cena jedn. netto', format: FormatTyp.Currency, width: 'auto' },
{ name: 'P_9B', title: 'Cena jedn. brutto', format: FormatTyp.Currency, width: 'auto' },
{ name: 'P_8B', title: 'Ilość', format: FormatTyp.Right, width: 'auto' },
{ name: 'P_8B', title: 'Ilość', format: FormatTyp.Number, width: 'auto' },
{ name: 'P_8A', title: 'Miara', format: FormatTyp.Default, width: 'auto' },
{ name: 'P_10', title: 'Rabat', format: FormatTyp.Currency, width: 'auto' },
{ name: 'P_12', title: 'Stawka podatku', format: FormatTyp.Default, width: 'auto' },