@@ -766,17 +766,17 @@ defmodule Algora.Bounties do
766766 % {
767767 owner: User . t ( ) ,
768768 amount: Money . t ( ) ,
769- bounty_id: String . t ( ) ,
769+ bounty: Bounty . t ( ) ,
770770 claims: [ Claim . t ( ) ]
771771 } ,
772772 opts :: [ ticket_ref: % { owner: String . t ( ) , repo: String . t ( ) , number: integer ( ) } , recipient: User . t ( ) ]
773773 ) ::
774774 { :ok , String . t ( ) } | { :error , atom ( ) }
775- def reward_bounty ( % { owner: owner , amount: amount , bounty_id: bounty_id , claims: claims } , opts \\ [ ] ) do
775+ def reward_bounty ( % { owner: owner , amount: amount , bounty: bounty , claims: claims } , opts \\ [ ] ) do
776776 create_payment_session (
777777 % { owner: owner , amount: amount , description: "Bounty payment for OSS contributions" } ,
778778 ticket_ref: opts [ :ticket_ref ] ,
779- bounty_id: bounty_id ,
779+ bounty: bounty ,
780780 claims: claims ,
781781 recipient: opts [ :recipient ]
782782 )
@@ -785,20 +785,28 @@ defmodule Algora.Bounties do
785785 @ spec generate_line_items (
786786 % { owner: User . t ( ) , amount: Money . t ( ) } ,
787787 opts :: [
788+ bounty: Bounty . t ( ) ,
788789 ticket_ref: % { owner: String . t ( ) , repo: String . t ( ) , number: integer ( ) } ,
789790 claims: [ Claim . t ( ) ] ,
790791 recipient: User . t ( )
791792 ]
792793 ) ::
793794 [ LineItem . t ( ) ]
794795 def generate_line_items ( % { owner: owner , amount: amount } , opts \\ [ ] ) do
796+ bounty = opts [ :bounty ]
795797 ticket_ref = opts [ :ticket_ref ]
796798 recipient = opts [ :recipient ]
797799 claims = opts [ :claims ] || [ ]
798800
799801 description = if ( ticket_ref , do: "#{ ticket_ref [ :repo ] } ##{ ticket_ref [ :number ] } " )
800802
801- platform_fee_pct = Decimal . div ( owner . fee_pct , 100 )
803+ platform_fee_pct =
804+ if bounty && Date . before? ( bounty . inserted_at , ~D[ 2025-04-16] ) do
805+ Decimal . div ( owner . fee_pct_prev , 100 )
806+ else
807+ Decimal . div ( owner . fee_pct , 100 )
808+ end
809+
802810 transaction_fee_pct = Payments . get_transaction_fee_pct ( )
803811
804812 payouts =
@@ -845,7 +853,7 @@ defmodule Algora.Bounties do
845853 opts :: [
846854 ticket_ref: % { owner: String . t ( ) , repo: String . t ( ) , number: integer ( ) } ,
847855 tip_id: String . t ( ) ,
848- bounty_id: String . t ( ) ,
856+ bounty: Bounty . t ( ) ,
849857 claims: [ Claim . t ( ) ] ,
850858 recipient: User . t ( )
851859 ]
@@ -858,17 +866,20 @@ defmodule Algora.Bounties do
858866 generate_line_items ( % { owner: owner , amount: amount } ,
859867 ticket_ref: opts [ :ticket_ref ] ,
860868 recipient: opts [ :recipient ] ,
861- claims: opts [ :claims ]
869+ claims: opts [ :claims ] ,
870+ bounty: opts [ :bounty ]
862871 )
863872
864873 gross_amount = LineItem . gross_amount ( line_items )
865874
875+ bounty_id = if bounty = opts [ :bounty ] , do: bounty . id
876+
866877 Repo . transact ( fn ->
867878 with { :ok , _charge } <-
868879 initialize_charge ( % {
869880 id: Nanoid . generate ( ) ,
870881 user_id: owner . id ,
871- bounty_id: opts [ : bounty_id] ,
882+ bounty_id: bounty_id ,
872883 gross_amount: gross_amount ,
873884 net_amount: amount ,
874885 total_fee: Money . sub! ( gross_amount , amount ) ,
@@ -881,7 +892,7 @@ defmodule Algora.Bounties do
881892 claims: opts [ :claims ] || [ ] ,
882893 tip_id: opts [ :tip_id ] ,
883894 recipient_id: if ( opts [ :recipient ] , do: opts [ :recipient ] . id ) ,
884- bounty_id: opts [ : bounty_id] ,
895+ bounty_id: bounty_id ,
885896 claim_id: nil ,
886897 amount: amount ,
887898 creator_id: owner . id ,
@@ -902,7 +913,7 @@ defmodule Algora.Bounties do
902913 opts :: [
903914 ticket_ref: % { owner: String . t ( ) , repo: String . t ( ) , number: integer ( ) } ,
904915 tip_id: String . t ( ) ,
905- bounty_id: String . t ( ) ,
916+ bounty: Bounty . t ( ) ,
906917 claims: [ Claim . t ( ) ] ,
907918 recipient: User . t ( )
908919 ]
@@ -915,11 +926,14 @@ defmodule Algora.Bounties do
915926 generate_line_items ( % { owner: owner , amount: amount } ,
916927 ticket_ref: opts [ :ticket_ref ] ,
917928 recipient: opts [ :recipient ] ,
918- claims: opts [ :claims ]
929+ claims: opts [ :claims ] ,
930+ bounty: opts [ :bounty ]
919931 )
920932
921933 gross_amount = LineItem . gross_amount ( line_items )
922934
935+ bounty_id = if bounty = opts [ :bounty ] , do: bounty . id
936+
923937 Repo . transact ( fn ->
924938 with { :ok , _charge } <-
925939 initialize_charge ( % {
@@ -937,7 +951,7 @@ defmodule Algora.Bounties do
937951 claims: opts [ :claims ] || [ ] ,
938952 tip_id: opts [ :tip_id ] ,
939953 recipient_id: if ( opts [ :recipient ] , do: opts [ :recipient ] . id ) ,
940- bounty_id: opts [ : bounty_id] ,
954+ bounty_id: bounty_id ,
941955 claim_id: nil ,
942956 amount: amount ,
943957 creator_id: owner . id ,
0 commit comments