File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -506,8 +506,18 @@ <h3>Persons:</h3>
506506
507507function share ( ) {
508508 const title = document . title ;
509+
510+ const detailed = confirm ( "Include details? (product per person)" ) ;
509511 const totalDiff = ( itemsPrice - personsPrice ) . formatPrice ( ) ;
510- const text = data . persons . map ( person => `${ person . name } : ${ calculatePersonTotal ( person ) . formatPrice ( ) } ` ) . join ( "\n" ) + (
512+ const text = data . persons . flatMap ( person => [
513+ `${ person . name } : ${ calculatePersonTotal ( person ) . formatPrice ( ) } ${ person . paid ? ' (paid)' : '' } ` ,
514+ ...( ! detailed ? [ ] :
515+ // keep order from data.items array
516+ data . items . map ( item => [ item , getAmount ( person , item ) ] )
517+ . filter ( e => e [ 1 ] != 0 )
518+ . map ( ( [ item , amount ] ) => ` - ${ item . name } ${ amount == 1 ? '' : ` (${ amount } )` } : ${ ( item . price * amount ) . formatPrice ( ) } ` )
519+ )
520+ ] ) . join ( "\n" ) + (
511521 totalDiff > 0 ? `\nUnknown: ${ totalDiff } ` :
512522 totalDiff < 0 ? `\nExtra: ${ - totalDiff } ` :
513523 ""
You can’t perform that action at this time.
0 commit comments