Skip to content
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

Billett-/salgsrapport #96

Open
henrist opened this issue Mar 12, 2017 · 0 comments
Open

Billett-/salgsrapport #96

henrist opened this issue Mar 12, 2017 · 0 comments
Labels

Comments

@henrist
Copy link
Member

henrist commented Mar 12, 2017

Vi trenger en side som genererer rapport over nettsalget. Salg over skranke får man i dag oversikt over gjennom oppgjørsgruppene, men nettsalget har ikke noe tilsvarende.

Kode som kan generere dette foreløpig:

Lagre som /tmp/uka-2017.txt:
https://billett.blindernuka.no/api/ticket?filter=event.eventgroup.id=3&with=event,ticketgroup&limit=10&offset=0

const fs = require('fs')

const data = JSON.parse(fs.readFileSync('/tmp/uka-2017.txt', { encoding: 'utf-8' }))

const formatDateTime = time => {
  return `${time.getFullYear()}-${(time.getMonth()+1)}-${time.getDate()} ${time.getHours()}:${time.getMinutes()}`
}

// Change this structure to fit the need
const val = data.result
  .filter(
    node =>
      node.is_valid &&
      node.valid_paymentgroup_id === null
  )
  .map(node => ({
    ticket_id: node.id,
    ticket_time: formatDateTime(new Date(node.time * 1000)),
    event_id: node.event.id,
    event_time_start: formatDateTime(new Date(node.event.time_start * 1000)),
    event_title: node.event.title,
    event_category: node.event.category,
    ticketgroup_price: node.ticketgroup.price + node.ticketgroup.fee,
    ticketgroup_title: node.ticketgroup.title
  }))

const headers = Object.keys(val[0]);
const list =
  headers.join('\t') +
  '\n' +
  val.map(ticket => {
    const values = headers.map(key => ticket[key]);
    return values.join('\t') + '\n'
  }).join('')

console.log(list)

Koden ovenfor er benyttet til rapporten for 2017.

@henrist henrist added the admin label Mar 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant