Explorar el Código

work on improving payment information

Tomislav Cvetic hace 7 años
padre
commit
0625a99b82
Se han modificado 3 ficheros con 23 adiciones y 14 borrados
  1. 20 12
      src/App.js
  2. 1 0
      src/match/index.js
  3. 2 2
      src/playerList/index.js

+ 20 - 12
src/App.js

@@ -272,6 +272,7 @@ class App extends React.Component {
 
     this.state.match.matches.forEach((match) => {
       [match.Spieler1, match.Spieler2].forEach((matchPlayer) => {
+        const id = `${match.Konkurrenz}_${matchPlayer}`
         if (matchPlayer) {
           let foundPlayer = this.state.player.players.find((player) =>
             (player.name === matchPlayer) & (player.Konkurrenz === match.Konkurrenz)
@@ -280,9 +281,18 @@ class App extends React.Component {
             console.log('Debug payerlist:', foundPlayer, match)
             throw Error('Match player not found in player list. This is an error!')
           }
-          if (!foundPlayer.BezahltAm) {
-            foundPlayer.BezahltAm = match.Datum
-          }
+          foundPlayer.Matches.push(match)
+          foundPlayer.Matches = foundPlayer.Matches.sort((a, b) => {
+            if (a.Datum.getTime() < b.Datum.getTime()) {
+              return -1
+            }
+            if (a.Datum.getTime() === b.Datum.getTime()) {
+              return 0
+            }
+            if (a.Datum.getTime() > b.Datum.getTime()) {
+              return 1
+            }
+          })
         }
       })
     })
@@ -312,7 +322,7 @@ class App extends React.Component {
         [],
         [`${PLACES[place] || place}`, null, '50.- oder 30.- (Junioren Jg. 1999 oder jünger)'],
         [],
-        ['bezahlt', 'Kat.', 'Zeit', 'Name', 'Betrag bez.', 'Quittung']
+        ['Status', 'Kat.', 'Zeit', 'Name', 'Betrag bez.', 'Quittung']
       ]
 
       // Per place
@@ -323,20 +333,18 @@ class App extends React.Component {
             const player = this.state.player.players.find((player) =>
               (player.Konkurrenz === match.Konkurrenz) & (player.name === matchPlayer)
             )
-            let paid = null
-            if (player.BezahltAm < this.matchDate.value) {
-              paid = date2s(player.BezahltAm)
-            }
-            if (player.Bezahlt) {
-              paid = 'OK'
-            }
+            console.log(player.name, player.Matches)
+            const matchesBeforeToday = player.Matches.filter(match => {
+              return (match.Datum.getDate() < (new Date(this.matchDate.value)).getTime()) && match.result && (match.result !== 'WO')
+            })
+            console.log(matchesBeforeToday)
             let price
             if (player.isDoubles) {
               price = (player.isJunior ? 15 : 25) + (player.isJuniorDP ? 15 : 25)
             } else {
               price = player.isJunior ? 30 : 50
             }
-            payListPerPlace.push([ paid, match.Konkurrenz, time2s(match.Datum), `(${price}.-) ${matchPlayer}` ])
+            payListPerPlace.push([ player.Status, match.Konkurrenz, time2s(match.Datum), matchPlayer, price, null ])
           }
         })
       })

+ 1 - 0
src/match/index.js

@@ -19,6 +19,7 @@ class MatchClass {
     this.Spieler1Klassierung = normalize(data[5])
     this.Spieler2 = normalize(data[6])
     this.Spieler2Klassierung = normalize(data[7])
+    this.Resultat = data[8] ? normalize(data[8]) : null
   }
 
   isDoubles () {

+ 2 - 2
src/playerList/index.js

@@ -31,8 +31,8 @@ class Player {
     this.GeburtsdatumDP = data[26]
     this.KlassierungDP = normalize(data[27])
     this.Bestaetigt = data[29]
-    this.Bezahlt = data[31]
-    this.BezahltAm = null
+    //this.Bezahlt = data[31]
+    this.Status = data[31] ? 'bezahlt' : 'k.A.'
     this.Matches = []
     this.isDoubles = this.Konkurrenz.match(/DM.*|[MW]D.*/)
     this.isJunior = (this.Geburtsdatum) ? this.Geburtsdatum.getTime() >= (new Date((new Date()).getFullYear() - 18, 11, 31, 23, 59, 59, 999)).getTime() : false