Skip to content

Commit

Permalink
feat: API work to expose miscCosts for frontend query (#851)
Browse files Browse the repository at this point in the history
* Expose some miscCosts info

* Fix failing tests
  • Loading branch information
HappyNTH authored Oct 27, 2024
1 parent c2489cb commit 6269720
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
11 changes: 11 additions & 0 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,16 @@ type MiscCostNode implements Node {
value: Float
}

type MiscCostNodeConnection {
pageInfo: PageInfo!
edges: [MiscCostNodeEdge]!
}

type MiscCostNodeEdge {
node: MiscCostNode
cursor: String!
}

type Mutation {
recordFinancialTransfer(method: TransferMethodEnum!, reason: String, societyId: IdInputField!, value: Int!): RecordFinancialTransfer
concessionType(input: ConcessionTypeMutationInput!): ConcessionTypeMutationPayload
Expand Down Expand Up @@ -666,6 +676,7 @@ input ProductionWarning {
type Query {
images: [ImageNode]
paymentDevices(paymentProvider: PaymentProvider, paired: Boolean): [SquarePaymentDevice]
miscCosts(offset: Int, before: String, after: String, first: Int, last: Int, id: ID, name: String): MiscCostNodeConnection
bookings(offset: Int, before: String, after: String, first: Int, last: Int, createdAt: DateTime, updatedAt: DateTime, status: String, user: ID, creator: ID, reference: String, performance: ID, adminDiscountPercentage: Float, accessibilityInfo: String, expiresAt: DateTime, id: ID, statusIn: [String], search: String, productionSearch: String, productionSlug: String, performanceId: String, checkedIn: Boolean, active: Boolean, expired: Boolean, orderBy: String): BookingNodeConnection
me: ExtendedUserNode
societies(offset: Int, before: String, after: String, first: Int, last: Int, id: ID, name: String, slug: String, userHasPermission: String): SocietyNodeConnection
Expand Down
6 changes: 4 additions & 2 deletions uobtheatre/bookings/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@ class MiscCost(models.Model):
Additional costs are added to a booking's final total.
For example: Booking fee/Theatre improvement levy.
A misc costs is defined by either a value or a percentage. If both are
supplied the percentage will take precedence.
A misc costs is defined by either a value or a percentage, but not both.
Percentages are in decimal form (e.g. 0.1 for 10%).
Value is in pence.
Note:
Currently all misc costs are applied to all bookings.
Expand Down
18 changes: 18 additions & 0 deletions uobtheatre/bookings/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,27 @@
from uobtheatre.utils.filters import FilterSet


class MiscCostFilter(FilterSet):
class Meta:
model = MiscCost
fields = (
"id",
"name",
)


class MiscCostNode(DjangoObjectType):
class Meta:
model = MiscCost
interfaces = (relay.Node,)
filterset_class = MiscCostFilter
fields = (
"id",
"name",
"description",
"percentage",
"value",
)


class TicketNode(DjangoObjectType):
Expand Down Expand Up @@ -350,4 +367,5 @@ class Query(graphene.ObjectType):
These queries are appended to the main schema Query.
"""

miscCosts = DjangoFilterConnectionField(MiscCostNode)
bookings = DjangoFilterConnectionField(BookingNode)

0 comments on commit 6269720

Please sign in to comment.