Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add payment type and reference #3003

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

brunomiguelpinto
Copy link
Contributor

@brunomiguelpinto brunomiguelpinto commented Dec 24, 2024

Context

This PR lays the groundwork for implementing manual/partial payment functionality in our system. It introduces necessary changes to the payments and invoices tables to enable the tracking and management of these new payment types and statuses.

Description

Migration: Add payment_type and reference columns to payments

  • Added a new payment_type column as an ENUM with values provider and manual.
  • Added a reference column to store additional metadata for payments.
  • Backfilled existing records, defaulting payment_type to provider.
  • Set payment_type to NOT NULL with a default value of provider.

Migration: Add total_paid_amount_cents column to invoices

  • Added a total_paid_amount_cents column to track the cumulative amount paid toward an invoice.
  • Backfilled existing records with a default value of 0.
  • Set total_paid_amount_cents to NOT NULL with a default value of 0.

@brunomiguelpinto brunomiguelpinto self-assigned this Dec 24, 2024
@brunomiguelpinto brunomiguelpinto changed the title feat(partial-payments): Add payment type and reference feat(manul-payments): Add payment type and reference Dec 24, 2024
@brunomiguelpinto brunomiguelpinto changed the title feat(manul-payments): Add payment type and reference feat: Add payment type and reference Dec 24, 2024
@brunomiguelpinto brunomiguelpinto marked this pull request as draft December 26, 2024 12:39
@brunomiguelpinto brunomiguelpinto marked this pull request as ready for review December 27, 2024 11:59

safety_assured do
change_table :payments, bulk: true do |t|
t.column :payment_type, :enum, enum_type: 'payment_type', null: true
Copy link
Contributor

Choose a reason for hiding this comment

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

will we need index on this column?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes good catch I will add it

disable_ddl_transaction!

def up
add_column :invoices, :total_paid_amount_cents, :bigint, null: true, default: 0
Copy link
Contributor

Choose a reason for hiding this comment

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

will in the future we update the existing paid invoices with real values? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes I will do a migration to fill the values i was thinking on another pr but can be on this one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants