Files
Excel-Pajak-Generator-Ak/QWEN.md
2026-03-09 08:54:42 +07:00

4.1 KiB

Excel Pajak Application

Project Overview

Excel Pajak is a .NET 10.0 console application that connects to a PostgreSQL database to handle tax-related data processing. The application is designed to execute database queries and process employee information, with a focus on connecting to specific database schemas containing employee data.

Architecture

  • Main Application: Console application in the excel_pajak directory
  • Test Project: Unit and integration tests in the excel_pajak_test directory
  • Technology Stack:
    • .NET 10.0
    • PostgreSQL database connectivity via Npgsql
    • Microsoft.Extensions.Configuration for configuration management
    • MSTest for unit testing
    • Moq for mocking dependencies
    • Shouldly for assertions

Key Components

  1. DatabaseService (Services/DatabaseService.cs): Handles PostgreSQL connections and executes scalar queries
  2. EmployeeInfo Model (Models/EmployeeInfo.cs): Represents employee data structure with employee number and schema
  3. Configuration: Managed through appsettings.json with connection strings and application settings
  4. Examples: Demonstrates JSON deserialization of employee data

Building and Running

Prerequisites

  • .NET 10.0 SDK
  • PostgreSQL database server (version compatible with Npgsql 10.0.1)
  • Access to the configured database (default connection points to localhost:55432)

Build Commands

# Restore dependencies
dotnet restore

# Build the application
dotnet build

# Run the application
dotnet run --project excel_pajak/excel_pajak.csproj

# Run tests
dotnet test

Configuration

The application uses appsettings.json for configuration:

  • Connection string for PostgreSQL database
  • Schema list (currently contains "_onx4pzkwkeortehfjthgyfkb7c")
  • Year setting (currently "2025")

Development Conventions

Coding Standards

  • Uses nullable reference types (#nullable enable)
  • Follows .NET naming conventions
  • Implements asynchronous programming patterns where appropriate
  • Includes proper error handling with specific exception types

Testing Approach

  • Unit tests for business logic with mocked dependencies
  • Integration tests that connect to actual PostgreSQL database
  • Tests cover both positive and negative scenarios
  • Uses Shouldly for readable assertions

Error Handling

  • Validates input parameters and throws appropriate exceptions
  • Handles database connection errors gracefully
  • Provides detailed error messages for debugging

Project Structure

excel_pajak/
├── excel_pajak/                 # Main application
│   ├── Models/                  # Data models
│   │   └── EmployeeInfo.cs      # Employee data structure
│   ├── Services/                # Business logic services
│   │   └── DatabaseService.cs   # PostgreSQL database operations
│   ├── Examples/                # Usage examples
│   │   └── EmployeeJsonExample.cs # JSON processing example
│   ├── Program.cs              # Application entry point
│   ├── appsettings.json        # Configuration file
│   └── excel_pajak.csproj      # Project file
├── excel_pajak_test/           # Test project
│   ├── DatabaseServiceTests.cs # Unit tests
│   ├── DatabaseServiceIntegrationTests.cs # Integration tests
│   └── excel_pajak_test.csproj # Test project file
└── openspec/                   # OpenAPI specification directory

Database Connection

The application connects to PostgreSQL using Npgsql with the connection string defined in appsettings.json. The default configuration connects to:

  • Server: localhost
  • Port: 55432
  • Database: andal_kharisma
  • User: postgres
  • Password: Release@2024

Testing

The project includes both unit tests (with mocked dependencies) and integration tests (requiring a live database connection). Unit tests validate the logic without external dependencies, while integration tests verify actual database connectivity and query execution.

To run integration tests, ensure that a PostgreSQL database is accessible with the configured connection string.