fix: B2C visitor count uses UnitQuantity (1 ticket = 1 visitor)
All checks were successful
Deploy HiHala Dashboard / deploy (push) Successful in 8s
All checks were successful
Deploy HiHala Dashboard / deploy (push) Successful in 8s
B2C generates one PDF ticket per person, so UnitQuantity = visitors. Other channels (POS, Safiyyah POS, etc.) use PeopleCount for visitors since group tickets cover multiple people. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -40,7 +40,11 @@ export function aggregateTransactions(sales: ERPSaleRecord[]): AggregatedRecord[
|
|||||||
|
|
||||||
for (const sale of sales) {
|
for (const sale of sales) {
|
||||||
const date = sale.TransactionDate.split(' ')[0];
|
const date = sale.TransactionDate.split(' ')[0];
|
||||||
const channel = getChannelLabel(sale.OperatingAreaName);
|
const rawChannel = sale.OperatingAreaName;
|
||||||
|
const channel = getChannelLabel(rawChannel);
|
||||||
|
// B2C: each ticket = one visitor (1 PDF per person)
|
||||||
|
// Other channels: PeopleCount = actual visitors (group tickets)
|
||||||
|
const isB2C = rawChannel === 'B2C';
|
||||||
|
|
||||||
for (const product of sale.Products) {
|
for (const product of sale.Products) {
|
||||||
const { museums, split } = getMuseumsFromProduct(product.ProductDescription);
|
const { museums, split } = getMuseumsFromProduct(product.ProductDescription);
|
||||||
@@ -72,7 +76,8 @@ export function aggregateTransactions(sales: ERPSaleRecord[]): AggregatedRecord[
|
|||||||
map.set(key, entry);
|
map.set(key, entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
entry.Visits += product.PeopleCount * split;
|
const visitors = isB2C ? product.UnitQuantity : product.PeopleCount;
|
||||||
|
entry.Visits += visitors * split;
|
||||||
entry.Tickets += product.UnitQuantity * split;
|
entry.Tickets += product.UnitQuantity * split;
|
||||||
entry.GrossRevenue += product.TotalPrice * split;
|
entry.GrossRevenue += product.TotalPrice * split;
|
||||||
entry.NetRevenue += (product.TotalPrice - product.TaxAmount) * split;
|
entry.NetRevenue += (product.TotalPrice - product.TaxAmount) * split;
|
||||||
|
|||||||
Reference in New Issue
Block a user