Skip to content

Commit

Permalink
fixed quotation bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Ron Valstar committed May 11, 2020
1 parent 5b1b589 commit 990c191
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "project-invoice",
"version": "3.0.6",
"version": "3.0.7",
"description": "Invoicing without sharing data.",
"keywords": [],
"main": "src/index.js",
Expand Down
3 changes: 2 additions & 1 deletion public/static/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -209,5 +209,6 @@
"youCurrentlyHaveNoDrafts": "You currently have no drafts... :-/",
"youCurrentlyHaveNoOpenInvoices": "There are no open invoices :-)",
"zipcode": "zipcode",
"zippost": "zippost"
"zippost": "zippost",
"print": "print"
}
3 changes: 2 additions & 1 deletion public/static/i18n/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -209,5 +209,6 @@
"youCurrentlyHaveNoDrafts": "Je hebt op dit moment geen concepten... :-/",
"youCurrentlyHaveNoOpenInvoices": "Je hebt geen opestaande facturen :-)",
"zipcode": "postcode",
"zippost": "postbus postcode"
"zippost": "postbus postcode",
"print": "print"
}
7 changes: 7 additions & 0 deletions src/components/Parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,15 @@ export const Parse = ({children, state, values, lang}) => {
const {copy} = state
const string = copy.hasOwnProperty(children)&&copy[children][lang]||children

// enhance project
values.project = enhanceProject(values.project, {_client:values.client, model:state})

// reduce copy to lang
values.copy = Object.entries(copy).reduce((acc, [key, obj])=>{
acc[key] = obj[lang]
return acc
}, {})

return <span dangerouslySetInnerHTML={{ __html: decode(marked(interpolate(string, values))) }} />
}

Expand Down
4 changes: 2 additions & 2 deletions src/components/PrintInvoice.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ export const PrintInvoice = forwardRef(({state, project, client, invoiceIndex, l
{invoiceIndex>0&&invoice.interest&&invoice.exhortation&&<small><Parse>exhortation_</Parse></small>}
</div>
{/*isQuotation*/}
{isQuotation&&<div className="wrapper"><Parse>{project.quotationBefore}</Parse></div>}
{isQuotation&&project.quotationBefore&&<div className="wrapper"><Parse>{project.quotationBefore}</Parse></div>}
{/*isQuotation*/}
<div className="wrapper">
<h3 className="payment"><T>{isQuotation?'quotation':'payment'}</T></h3>
Expand Down Expand Up @@ -292,7 +292,7 @@ export const PrintInvoice = forwardRef(({state, project, client, invoiceIndex, l
</table>
</div>
{/*isQuotation*/}
{isQuotation&&<div className="wrapper"><Parse>{project.quotationAfter}</Parse></div>}
{isQuotation&&project.quotationAfter&&<div className="wrapper"><Parse>{project.quotationAfter}</Parse></div>}
{/*isQuotation*/}
</div>
<footer className="wrapper">
Expand Down
18 changes: 12 additions & 6 deletions src/views/Project.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, {useEffect, useState} from 'react'
import {connect} from 'react-redux'
import {Link, withRouter} from 'react-router-dom'
import {isEqual, cloneDeep} from 'lodash'
import {nbsp, getGetSetter, capitalise, moveArrayItem} from '../util'
import {nbsp,getGetSetter,capitalise,moveArrayItem,getInterpolationContext} from '../util'
import {saveable} from '../util/signal'
import {storeProject, removeProject, cloneProject} from '../model/clients/actions'
import {
Expand All @@ -23,7 +23,6 @@ import {Button, IconButton} from '../components/Button'
import {ButtonLink} from '../components/ButtonLink'
import {InputText, InputDate, InputNumber, InputCheckbox} from '../components/Input'
import {Table} from '../components/Table'
import {Textarea} from '../components/Textarea'
import {Icon} from '../components/Icon'
import {Price} from '../components/Price'
import {Select} from '../components/Select'
Expand All @@ -32,6 +31,7 @@ import {useTranslation} from 'react-i18next'
import {Dialog} from '../components/Dialog'
import {Tabs} from '../components/Tabs'
import {FormSpan} from '../components/FormSpan'
import {InterpolationInput} from '../components/InterpolationInput'
import {DirtyPrompt} from '../components/DirtyPrompt'
import {CSSTransition, TransitionGroup} from 'react-transition-group'
import styled from 'styled-components'
Expand Down Expand Up @@ -205,6 +205,8 @@ export const Project = withRouter(
const totalHours = getTotalHours(project)
const discount = getDiscountPart(project)

const context = getInterpolationContext(state)

return (
(isProject && (
<StyledProject>
Expand Down Expand Up @@ -310,17 +312,21 @@ export const Project = withRouter(
</section>

<section>
<Button onClick={onClickAddInvoiceButton} className="float-right"><T>show quotation</T></Button>
<ButtonLink to={`${getProjectHref(project)}/quotation`} className="float-right"><T>show quotation</T></ButtonLink>
<h3 className="invisible"><T>quotation</T></h3>
{[
{ key: 'quotationDate', Element: InputDate }
, { key: 'quotationStartDate', Element: InputDate }
, { key: 'quotationDuration', Element: InputNumber }
, { key: 'quotationSubject', Element: InputText }
, { key: 'quotationBefore', Element: Textarea }
, { key: 'quotationAfter', Element: Textarea }
, { key: 'quotationBefore', Element: InterpolationInput }
, { key: 'quotationAfter', Element: InterpolationInput }
].map(({key, Element}) => {
return <Label key={key}><T>{key}</T><Element value={project[key]} setter={getSetter(key)} /></Label>
return <Label key={key}><T>{key}</T><Element
value={project[key]}
setter={getSetter(key)}
context={context}
/></Label>
})}
</section>
</Tabs>
Expand Down

0 comments on commit 990c191

Please sign in to comment.