extractor

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 1, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BoolCheckBoxExtractor

type BoolCheckBoxExtractor struct{}

func (*BoolCheckBoxExtractor) Extract

func (c *BoolCheckBoxExtractor) Extract(e *ExcelExtractor, sheetName string, criteria SearchCriteria, cellRange CellRange) (interface{}, error)

type BoolClassificationCriteria

type BoolClassificationCriteria struct {
	Offset      int
	SearchTerms []string // search terms for extra check if form control has that name or not
}

type BuyerDetails

type BuyerDetails struct {
	SheetName                       string `json:"sheet_name"`
	PartNumber                      string `json:"part_number"`
	PartDescription                 string `json:"part_description"`
	ClassificationOfItem            string `json:"classification_of_item"`
	ControlListClassificationNumber string `json:"control_list_classification_number"`
	RFQ                             string `json:"rfq"`
	BuildToPrint                    bool   `json:"build_to_print"`
	ManufacturedToSpecification     bool   `json:"manufactured_to_specification"`
	OriginalEquipmentManufacturer   bool   `json:"original_equipment_manufacturer"`
	Modified                        bool   `json:"modified"`
}

func (*BuyerDetails) GetSheetName

func (b *BuyerDetails) GetSheetName() string

Add methods to both structs to implement SheetNameGetter

type CellRange

type CellRange struct {
	StartCell string // e.g., "B12"
	EndCell   string // e.g., "D12"
}

CellRange represents an Excel cell range

type ClassificationCriteria

type ClassificationCriteria struct {
	Label       string
	SearchTerms []string // search terms for extra check if form control has that name or not
	Offset      int
}

type ColumnMapping added in v0.1.0

type ColumnMapping struct {
	FieldName   string
	SearchTerms []string
	FoundColumn string // Will store the actual column letter once found
}

type CompanyNameList

type CompanyNameList []string

type ControlCotent added in v0.1.0

type ControlCotent struct {
	SheetName                       string `json:"sheet_name"`
	ItemNum                         string `json:"item_num"`
	PartNumber                      string `json:"part_number"`
	ComponentManufacturerPartNumber string `json:"component_manufacturer_part_number"`
	PartDescription                 string `json:"part_description"`
	ManufacturerOfComponent         string `json:"manufacturer_of_component"`
	ExportRegulationCountry         string `json:"export_regulation_country"`
	DualControlListClfNum           string `json:"dual_control_list_clf_num"`
	MilitaryControlListClfNum       string `json:"military_control_list_clf_num"`
	IndicateLicenseApplication      string `json:"inidcate_license_application"`
	TopLevelDeliverableItem         string `json:"top_level_delierable_item"`
	USML_N                          string `json:"usml_n"`
	ECCN_N                          string `json:"eccn_n"`
	US_EA_CONTENT_RATIO             string `json:"us_ea_content_ratio"`
}

type DivideByZeroError

type DivideByZeroError struct {
	// contains filtered or unexported fields
}

type DualClassificationCriteria

type DualClassificationCriteria struct {
	TYPE_1 ClassificationCriteria
	TYPE_2 ClassificationCriteria
}

type DualColumnClfExtractor

type DualColumnClfExtractor struct{}

func (*DualColumnClfExtractor) Extract

func (d *DualColumnClfExtractor) Extract(e *ExcelExtractor, sheetName string, criteria SearchCriteria, cellRange CellRange) (interface{}, error)

type ExcelExtractor

type ExcelExtractor struct {
	Extraction *SECCFExtraction
	// contains filtered or unexported fields
}

func MakeSECCFExtractor

func MakeSECCFExtractor(filePath string, companyNames CompanyNameList) (*ExcelExtractor, error)

func (*ExcelExtractor) Close

func (e *ExcelExtractor) Close() error

func (*ExcelExtractor) Extract

func (e *ExcelExtractor) Extract() SECCFExtraction

func (*ExcelExtractor) GetCellValue

func (e *ExcelExtractor) GetCellValue(cellRange CellRange, sheetName string) (string, error)

func (*ExcelExtractor) ReadFormControls

func (e *ExcelExtractor) ReadFormControls()

func (*ExcelExtractor) ReplaceCompanyNames

func (e *ExcelExtractor) ReplaceCompanyNames(items []string) []string

func (*ExcelExtractor) ToJson added in v0.1.0

func (e *ExcelExtractor) ToJson() string

type ProductDetails

type ProductDetails struct {
	// Sheet Metadata
	SheetName string `json:"sheet_name"`

	// Supplier Details
	SupplierPartNumber    string `json:"supplier_part_number"`
	SupplierCompanyName   string `json:"supplier_company_name"`
	SupplierFullAddress   string `json:"supplier_full_address"`
	SupplierCountry       string `json:"supplier_country"`
	SupplierCompanyNumber string `json:"supplier_company_number"`

	// Manufacturer Details
	ManufacturerPartNumber    string `json:"manufacturer_part_number"`
	ManufacturerCompanyName   string `json:"manufacturer_company_name"`
	ManufacturerFullAddress   string `json:"manufacturer_full_address"`
	ManufacturerCountry       string `json:"manufacturer_country"`
	ManufacturerCompanyNumber string `json:"manufacturer_company_number"`

	// Product Details
	CountryOfOrigin                 string `json:"country_of_origin"`
	CustomsTariffCode               string `json:"customs_tariff_code"`
	ExportControlRegulated          string `json:"export_control_regulated"` // Yes/No
	PartClassification              string `json:"part_classification"`      // DU, MIL, CIVIL
	ControlListClassificationNumber string `json:"control_list_classification_number"`
	ThirdCountryControlledContent   string `json:"third_country_controlled_content"` // Yes/No
	EndUserStatementRequired        string `json:"end_user_statement_required"`      // Yes/No
	ExportLicenceShipmentRequired   string `json:"export_licence_shipment_required"` // Yes/No
	ExportLicenceEndUserRequired    string `json:"export_licence_end_user_required"` // Yes/No/End user not advised to supplier
	AdditionalExportDocsRequired    string `json:"additional_export_docs_required"`  // Yes/No

	// Mandatory
	TransferReexportConditions string `json:"transfer_reexport_conditions"`

	// Supplier Representative
	RepresentativeName      string `json:"representative_name"`
	RepresentativePosition  string `json:"representative_position"`
	RepresentativeCompany   string `json:"representative_company"`
	RepresentativeSignature string `json:"representative_signature"` // Available/Not Available
	SupplierCompanySeal     string `json:"supplier_company_seal"`    // Available/Not Available
	SignatureDate           string `json:"signature_date"`           // Date format
}

func (*ProductDetails) GetSheetName

func (p *ProductDetails) GetSheetName() string

type Response

type Response struct {
	Status  string `json:"status"`
	Message string `json:"message"`
	Data    any    `json:"data,omitempty"`
}

Response struct for structured output

type SECCFExtraction

type SECCFExtraction struct {
	BuyerDetails      *BuyerDetails   `json:"buyer_details"`
	ProductDetails    *ProductDetails `json:"product_details"`
	ControlledContent []ControlCotent `json:"controlled_content"`
}

type SearchCriteria

type SearchCriteria struct {
	SearchTerms           []string                   // Multiple possible terms to search for
	CellRanges            []CellRange                // Multiple cell ranges to search in
	DualColumnCheckBoxClf bool                       // check side by side column
	DualColumnClfCriteria DualClassificationCriteria // Add this to map checkbox text to values
	TriColumnCheckBoxClf  bool                       // check tri-side by side column
	TriColumnClfCriteria  TriClassificationCritera   // Add this to map checkbox text to values
	BoolCheckBox          bool
	BoolClfCriteria       BoolClassificationCriteria
	Offset                int // Default offset of value for simple fields
}

SearchCriteria defines what to look for and where

type SheetNameGetter

type SheetNameGetter interface {
	GetSheetName() string
}

Generic interface for structures with SheetName

type SheetNotFoundError

type SheetNotFoundError struct {
	// contains filtered or unexported fields
}

func (SheetNotFoundError) Error

func (e SheetNotFoundError) Error() string

type SimpleValueExtractor

type SimpleValueExtractor struct{}

Implement different extractors for different types of fields

func (*SimpleValueExtractor) Extract

func (s *SimpleValueExtractor) Extract(e *ExcelExtractor, sheetName string, criteria SearchCriteria, cellRange CellRange) (interface{}, error)

type TriClassificationCritera

type TriClassificationCritera struct {
	TYPE_1 ClassificationCriteria
	TYPE_2 ClassificationCriteria
	TYPE_3 ClassificationCriteria
}

type TriColumnClfExtractor

type TriColumnClfExtractor struct{}

func (*TriColumnClfExtractor) Extract

func (d *TriColumnClfExtractor) Extract(e *ExcelExtractor, sheetName string, criteria SearchCriteria, cellRange CellRange) (interface{}, error)

type ValueExtractor

type ValueExtractor interface {
	Extract(e *ExcelExtractor, sheetName string, criteria SearchCriteria, cellRange CellRange) (interface{}, error)
}

Add a method to handle value extraction based on criteria type

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL