Skip to content

Feat/ai parser multi transaction - #114

Merged
dhabyap merged 2 commits into
mainfrom
feat/ai-parser-multi-transaction
Sep 8, 2026
Merged

Feat/ai parser multi transaction#114
dhabyap merged 2 commits into
mainfrom
feat/ai-parser-multi-transaction

Conversation

@dhabyap

@dhabyap dhabyap commented Sep 8, 2026

Copy link
Copy Markdown
Owner

Summary by Sourcery

Expand transaction categorization defaults and document the required production migration steps.

New Features:

  • Expand the default category catalog with broader expense, income, and shared transaction categories and keyword mappings.

Bug Fixes:

  • Rename the legacy TRANSPORT category to TRANSPORTASI while preserving existing transaction references.

Enhancements:

  • Add deployment guidance for applying database migrations and clearing production caches after merges.

Deployment:

  • Document the production migration and optional cache-clearing steps required after database changes.

Documentation:

  • Add README guidance for safely updating production databases without deleting existing transaction data.

…ducation + more

- Add 22 categories: TELEKOMUNIKASI, KESEHATAN, KECANTIKAN, PENDIDIKAN,
  RUMAH TANGGA, INVESTASI, ASURANSI, CICILAN, DONASI, TRAVEL, OLAHRAGA,
  BONUS, FREELANCE, HADIAH, PENDAPATAN LAINNYA
- Rename TRANSPORT -> TRANSPORTASI (id preserved, transactions safe)
- INVESTASI as type=both (expense: nabung saham, income: dividen/cuan)

Closes #108
@sourcery-ai

sourcery-ai Bot commented Sep 8, 2026

Copy link
Copy Markdown

Reviewer's Guide

Adds a migration-backed expansion of transaction categories and keyword metadata, preserves existing transaction relationships while renaming TRANSPORT, and documents the production migration procedure required after deployment.

Flow diagram for category migration deployment

flowchart LR
    A["Merge migration PR"] --> B["git pull origin main"]
    B --> C["php artisan migrate --force"]
    C --> D["Expanded categories and keywords available"]
    C --> E["Existing transaction relationships preserved"]
Loading

File-Level Changes

Change Details Files
Expands and normalizes the default transaction category catalog through a database migration.
  • Adds expense, income, and shared categories with icons and keyword metadata for parser classification.
  • Uses name-based upserts so the migration can safely add or update category definitions.
  • Renames the legacy TRANSPORT category to TRANSPORTASI while preserving its ID and existing transaction references.
  • Provides a best-effort rollback that restores the legacy name and removes newly introduced categories.
database/migrations/2026_09_08_000001_expand_default_categories.php
Documents the production deployment steps required after merging migration changes.
  • Adds instructions to pull the latest code and run php artisan migrate --force in production.
  • Documents optional config/cache clearing and explicitly warns against migrate:fresh to protect existing data.
README.md

Possibly linked issues

  • #P0: PR secara langsung mengimplementasikan perluasan kategori, termasuk kategori utama yang hilang dan rename TRANSPORTASI.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 2 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="database/migrations/2026_09_08_000001_expand_default_categories.php" line_range="40-43" />
<code_context>
+            ['name' => 'LAINNYA', 'icon' => '📌', 'type' => 'both', 'keywords' => ['lainnya', 'misc']],
+        ];
+
+        foreach ($categories as $category) {
+            Category::updateOrCreate(
+                ['name' => $category['name']],
+                $category,
+            );
+        }
+
</code_context>
<issue_to_address>
**issue (broader_impact):** Running this migration overwrites the icon, type, and keywords of every existing category with the same name. Any category edits made by an administrator or user before deployment are silently lost.

**Triggers:** When an existing default category has been customized before this migration runs.

**Suggested fix:** Only insert missing defaults, or update only fields that are explicitly intended to be migrated while preserving user-managed values.

```suggestion
            Category::firstOrCreate(
                ['name' => $category['name']],
                $category,
            );
```
</issue_to_address>

### Comment 2
<location path="database/migrations/2026_09_08_000001_expand_default_categories.php" line_range="47-53" />
<code_context>
+        }
+
+        // Rename legacy TRANSPORT -> TRANSPORTASI (id stays the same, transactions safe)
+        $legacy = Category::where('name', 'TRANSPORT')->first();
+        if ($legacy) {
+            $legacy->update([
+                'name' => 'TRANSPORTASI',
+                'keywords' => ['goride', 'gojek', 'grab', 'bensin', 'parkir', 'tol', 'transport', 'ojek', 'ojol', 'taxi', 'taksi'],
+            ]);
+        }
+    }
+
</code_context>
<issue_to_address>
**issue (bug_risk):** The rename issues a unique-name collision if a `TRANSPORTASI` category already exists, causing the migration to fail after the earlier category upserts have run. The categories table has a unique constraint on `name`, so the legacy row cannot be renamed in that state.

**Triggers:** When `TRANSPORTASI` was created manually, by an earlier deployment, or by another seed process before this migration runs.

**Suggested fix:** Merge or explicitly handle an existing `TRANSPORTASI` row before renaming `TRANSPORT`, preserving the transaction references on the legacy row.
</issue_to_address>

Sourcery assessment

Needs a human reviewer. 2 findings to address first, and the migration writes persistent category rows, overwrites matching category metadata, and renames TRANSPORT to TRANSPORTASI; a rollback does not automatically restore any overwritten values and its cleanup can delete newly created category rows. The affected data is bounded and can be repaired with a targeted database migration or manual correction.

Blocking findings: database/migrations/2026_09_08_000001_expand_default_categories.php:43, database/migrations/2026_09_08_000001_expand_default_categories.php:53


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment on lines +40 to +43
Category::updateOrCreate(
['name' => $category['name']],
$category,
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (broader_impact): Running this migration overwrites the icon, type, and keywords of every existing category with the same name. Any category edits made by an administrator or user before deployment are silently lost.

Triggers: When an existing default category has been customized before this migration runs.

Suggested fix: Only insert missing defaults, or update only fields that are explicitly intended to be migrated while preserving user-managed values.

Suggested change
Category::updateOrCreate(
['name' => $category['name']],
$category,
);
Category::firstOrCreate(
['name' => $category['name']],
$category,
);

Comment on lines +47 to +53
$legacy = Category::where('name', 'TRANSPORT')->first();
if ($legacy) {
$legacy->update([
'name' => 'TRANSPORTASI',
'keywords' => ['goride', 'gojek', 'grab', 'bensin', 'parkir', 'tol', 'transport', 'ojek', 'ojol', 'taxi', 'taksi'],
]);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): The rename issues a unique-name collision if a TRANSPORTASI category already exists, causing the migration to fail after the earlier category upserts have run. The categories table has a unique constraint on name, so the legacy row cannot be renamed in that state.

Triggers: When TRANSPORTASI was created manually, by an earlier deployment, or by another seed process before this migration runs.

Suggested fix: Merge or explicitly handle an existing TRANSPORTASI row before renaming TRANSPORT, preserving the transaction references on the legacy row.

@dhabyap
dhabyap merged commit 808b738 into main Sep 8, 2026
1 of 3 checks passed
@dhabyap
dhabyap deleted the feat/ai-parser-multi-transaction branch September 8, 2026 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant