feat(05-finances): filtr proforma w imporcie Fakturowni

Phase 5 Plan 03 complete:
- Dodano isProformaDocument() — pomija faktury proforma (kind=proforma lub prefiks FP)
- Wywolanie w processSingleDocument() przed normalizeDocument()
- Phase 5 complete: import Fakturowni z mapowaniem NIP i filtrem proforma

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-11 10:17:03 +02:00
parent 164b9b6a46
commit 3103c26827
7 changed files with 268 additions and 17 deletions

View File

@@ -117,6 +117,9 @@ class FakturowniaInvoiceImporter
if ( !$this -> matchesDocumentType( $rawDocument, $documentType ) )
return 'skipped';
if ( $this -> isProformaDocument( $rawDocument ) )
return 'skipped';
$document = $this -> normalizeDocument( $rawDocument, $documentType );
if ( !$document )
return 'skipped';
@@ -240,6 +243,24 @@ class FakturowniaInvoiceImporter
return !$isIncome;
}
private function isProformaDocument( $rawDocument )
{
if ( isset( $rawDocument['invoice'] ) && is_array( $rawDocument['invoice'] ) )
$rawDocument = $rawDocument['invoice'];
if ( !is_array( $rawDocument ) )
return false;
if ( isset( $rawDocument['kind'] ) && strtolower( (string)$rawDocument['kind'] ) === 'proforma' )
return true;
$number = (string)( $rawDocument['number'] ?? $rawDocument['full_number'] ?? '' );
if ( $number !== '' && strncasecmp( $number, 'FP', 2 ) === 0 )
return true;
return false;
}
private function isDateRelevantForImport( $rawDocument )
{
if ( isset( $rawDocument['invoice'] ) && is_array( $rawDocument['invoice'] ) )