-
-
Notifications
You must be signed in to change notification settings - Fork 188
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
Add support for multiple payers #146
base: main
Are you sure you want to change the base?
Conversation
Good job @dcbr . You should replace "Remove payer" option into dropdown with a "trash icon" close to amount. |
@dcbr it is perfect with this layout for my personal opinion. |
I would put the remove payer button either on the far right or the far left instead of in the middle, personally |
Align to the right, together with the "add payer" |
This right alignment is already part of the last commit, I just haven't updated the previous screenshots. |
This looks like a great addition! Thank you! This should do for the database migration: See here for the docs on prisma: https://www.prisma.io/docs/orm/prisma-migrate/getting-started |
Yes, I already did that. The problem is that the generated migration commands just drop the old |
I see. You need to manually adjust the migration file. This should do (please test!): -- CreateTable
CREATE TABLE "ExpensePaidBy" (
"expenseId" TEXT NOT NULL,
"participantId" TEXT NOT NULL,
"amount" INTEGER NOT NULL,
CONSTRAINT "ExpensePaidBy_pkey" PRIMARY KEY ("expenseId","participantId")
);
-- AddForeignKey
ALTER TABLE "ExpensePaidBy" ADD CONSTRAINT "ExpensePaidBy_expenseId_fkey" FOREIGN KEY ("expenseId") REFERENCES "Expense"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "ExpensePaidBy" ADD CONSTRAINT "ExpensePaidBy_participantId_fkey" FOREIGN KEY ("participantId") REFERENCES "Participant"("id") ON DELETE CASCADE ON UPDATE CASCADE;
/*
step 2: copy values of old column "paidById" to new table
*/
INSERT INTO "ExpensePaidBy"
SELECT "id" AS "expenseId", "paidById" AS "participantId", amount
FROM "Expense";
/*
step 3: drop old column "paidById"
*/
-- DropForeignKey
ALTER TABLE "Expense" DROP CONSTRAINT "Expense_paidById_fkey";
-- AlterTable
ALTER TABLE "Expense" DROP COLUMN "paidById"; |
a820694
to
d95b4bc
Compare
Thanks @shynst, that worked like a charm! :) The merge conflicts with the main branch are resolved and the database migration is correctly configured now. |
Co-authored-by: Stefan Hynst <[email protected]>
What is this PR waiting for? |
@scastiel could you let me know whether this is a feature you want in spliit or not? Because otherwise it's quite the hassle to continue resolving all conflicts introduced by later PRs. |
This is one of the key feature that folks are missing (coming from Splitwise). Is there a decision from the the core contributors that can be shared to the community? |
Hi @dcbr |
This PR adds support for multiple payers of a certain expense. The database changes are minimal and resemble the structure of the
paidFor
expense field. There's quite some changes to the interface, mostly to the expense form, which are showcased in the video below.Spliit_multi_payer.mp4
The PR is in a finished state, however it is still marked as draft as I don't know how to provide a correct migration strategy for existing databases (the prisma generated one just seems to drop the
paidById
column entirely). Some help there would be appreciated. The necessary migration is not too complicated: for each existing expense a newExpensePaidBy
row must be created withparticipantId
equal to the oldpaidById
,expenseId
equal to the corresponding expenseid
andamount
equal to the expense's (total)amount
.Closes #14.
Additionally fixes some small bugs regarding amount and balance formatting (this might resolve issues #87 and #140). Also resolves #156 by increasing the upper bound to 10 billion.