Skip to content

Onsite Sales

singularName: onsite-salepluralName: onsite-sales

Table to store the sales activities at the runsite related to a run. Decision was taken to have all sales in one table members and guest records can be related to a sales item

Schema

NameTypeDetails
runrelationmanyToOne → Hareline
guestrelationmanyToOne → Guests
memberrelationmanyToOne → Members
sales_itemrelationmanyToOne → Sales Items
quantityinteger
total_amountinteger
payment_typeenumerationone of [Cash, DuitNow]

Lifecycles

beforeCreate (async)

Before creating a new onsite sale entry, this method checks:
- Either Guest or Member must be present
- An entry can only be for a Member OR a Guest
- Sales item must be present
- Sales item must be valid
- Members can only buy a subscription if it is of the same type as the member
- Payment type defaults to Cash if not provided
- Total amount spent is calculated as the item price multiplied by the quantity

Throws an error if the checks fail.

Parameters:

  • event: - The event object containing the parameters for the new onsite sale entry.

Services

generatePDF (async)

Generates a PDF report document for a specific run date.
This function creates a PDF document consisting of a financial report page and an appendix page containing the transaction details. The document is formatted with specific layout dimensions and includes headers, tables, and fonts. Financial data is fetched based on the provided run date, and the resulting PDF is returned as a buffer.

Parameters:

  • runDate: - The date of the run for which the report is generated.

Returns:

  • A buffer containing the bytes of the generated PDF document.

addAppendixPage (async)

createNewPage

addReportPage (async)

hexToRgbNormalized

createCashCollectionList

createSubscriptionsCollection

createCashExpenseCollection

createAppendixCollection

drawHeader

drawTitleBar

drawHeaderInfoBoxes

drawTableHeader

drawTableHeaderAppendix

drawFinancialRow

drawAppendixRow

fetchFinancialData (async)

Released under the MIT License.