Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion public/locales/bn/team-form.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"invoicing": {
"invoice_late_fee": "জরিমানা (%)",
"invoice_due_days": "পরিশোধের শর্ত, দিন",
"currency": "প্রচলিত মুদ্রা"
"currency": "প্রচলিত মুদ্রা",
"thousands_separator": "হাজারের বিভাজক"
},
"address": {
"company_address": "কোম্পানীর ঠিকানা",
Expand Down
3 changes: 2 additions & 1 deletion public/locales/de/team-form.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"invoicing": {
"invoice_late_fee": "Verzugsgebühr (%)",
"invoice_due_days": "Bezahlungsbedingungen, Tage",
"currency": "Standardwährung"
"currency": "Standardwährung",
"thousands_separator": "Tausendertrennzeichen"
},
"address": {
"company_address": "Firmenadresse",
Expand Down
3 changes: 2 additions & 1 deletion public/locales/en/team-form.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"invoicing": {
"invoice_late_fee": "Late fee (%)",
"invoice_due_days": "Payment terms, days",
"currency": "Default currency"
"currency": "Default currency",
"thousands_separator": "Thousands separator"
},
"address": {
"company_address": "Company address",
Expand Down
3 changes: 2 additions & 1 deletion public/locales/es/team-form.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"invoicing": {
"invoice_late_fee": "Cargo por demora (%)",
"invoice_due_days": "Condiciones de pago, días",
"currency": "Mondea predeterminada"
"currency": "Mondea predeterminada",
"thousands_separator": "Separador de miles"
},
"address": {
"company_address": "Dirección de la compañía",
Expand Down
3 changes: 2 additions & 1 deletion public/locales/et/team-form.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"invoicing": {
"invoice_late_fee": "Viivis (%)",
"invoice_due_days": "Makse tähtaeg, päevades",
"currency": "Vaikimisi valuuta"
"currency": "Vaikimisi valuuta",
"thousands_separator": "Tuhandikute eraldaja"
},
"address": {
"company_address": "Firma aadress",
Expand Down
3 changes: 2 additions & 1 deletion public/locales/fa/team-form.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"invoicing": {
"invoice_late_fee": "هزینه دیرهنگام (%)",
"invoice_due_days": "شرایط پرداخت ، روزها",
"currency": "ارز پیش فرض"
"currency": "ارز پیش فرض",
"thousands_separator": "جداکننده هزارگان"
},
"address": {
"company_address": "آدرس شرکت",
Expand Down
3 changes: 2 additions & 1 deletion public/locales/fr/team-form.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"invoicing": {
"invoice_late_fee": "Intérêt de retard (%)",
"invoice_due_days": "Conditions de paiements, jours",
"currency": "Devise par défaut"
"currency": "Devise par défaut",
"thousands_separator": "Separateur de milliers"
},
"address": {
"company_address": "Address de la société",
Expand Down
3 changes: 2 additions & 1 deletion public/locales/id/team-form.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"invoicing": {
"invoice_late_fee": "Denda Keterlambatan (%)",
"invoice_due_days": "Ketentuan pemabarayan, hari",
"currency": "Mata uang baku"
"currency": "Mata uang baku",
"thousands_separator": "Pemisah ribuan"
},
"address": {
"company_address": "Alamat usaha",
Expand Down
3 changes: 2 additions & 1 deletion public/locales/it/team-form.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"invoicing": {
"invoice_late_fee": "Interessi (%)",
"invoice_due_days": "Termini pagamento, giorni",
"currency": "Valuta predefinita"
"currency": "Valuta predefinita",
"thousands_separator": "Separatore migliaia"
},
"address": {
"company_address": "Indirizzo Azienda",
Expand Down
3 changes: 2 additions & 1 deletion public/locales/kr/team-form.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"invoicing": {
"invoice_late_fee": "연착 요금 (%)",
"invoice_due_days": "지불조건, 일",
"currency": "기본 통화"
"currency": "기본 통화",
"thousands_separator": "천 단위 구분 기호"
},
"address": {
"company_address": "회사 주소",
Expand Down
3 changes: 2 additions & 1 deletion public/locales/pt_br/team-form.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"invoicing": {
"invoice_late_fee": "Taxa de atraso (%)",
"invoice_due_days": "Termos de pagamento, dias",
"currency": "Moeda Padrão"
"currency": "Moeda Padrão",
"thousands_separator": "Separador de milhares"
},
"address": {
"company_address": "Endereço da Empresa",
Expand Down
15 changes: 13 additions & 2 deletions src/components/invoices/InvoiceHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
</BModal>
<span :class="{'d-print-none': !invoice.late_fee}">
<br>{{ $t('late_fee') }}
<AppEditable :value="invoice.late_fee | currency"
<AppEditable :value="currency(invoice.late_fee)"
:errors="errors"
suffix="%"
field="late_fee"
Expand All @@ -54,6 +54,7 @@ import AppEditable from '@/components/form/AppEditable';
import AppDatePicker from '@/components/form/AppDatePicker';
import { formatDate } from '@/filters/date.filter';
import { formatCurrency } from '@/filters/currency.filter';
import { mapGetters } from 'vuex';

export default {
i18nOptions: { namespaces: 'invoice-header' },
Expand All @@ -68,9 +69,19 @@ export default {
},
filters: {
date: formatDate,
currency: formatCurrency,
},
computed: {
...mapGetters({
team: 'teams/team',
}),
},
methods: {
currency(val, digits = 2) {
const separator = (this.team && this.team.thousands_separator !== undefined)
? this.team.thousands_separator
: ',';
return formatCurrency(val, digits, separator);
},
updateProp(props) {
this.$emit('update', props);
},
Expand Down
19 changes: 14 additions & 5 deletions src/components/invoices/InvoiceRow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,22 @@
@change="updateProp({ unit: $event })"/>
</td>
<td>
<AppEditable :value="row.price | currency"
<AppEditable :value="currency(row.price)"
:errors="errors"
:field="`rows.${index}.price`"
:placeholder="$t('enter_price')"
@change="updateProp({ price: $event })"/>
</td>
<td v-for="(tax, taxIndex) in row.taxes" :title="tax.label">
<AppEditable v-if="tax.row_id"
:value="tax.value | currency"
:value="currency(tax.value)"
:errors="errors"
:field="`rows.${index}.taxes.${taxIndex}.value`"
:placeholder="$t('enter_tax')"
@change="updateTaxProp({ value: $event }, tax)"/>
</td>
<td class="text-right position-relative">
{{ (row.quantity * row.price) | currency }}
{{ currency(row.quantity * row.price) }}
<button class="btn btn-sm d-print-none invoice__row-control"
@click="removeRow(row)">
<i class="material-icons md-18 pointer">remove</i>
Expand All @@ -47,6 +47,7 @@
</template>

<script>
import { mapGetters } from 'vuex';
import { formatCurrency } from '../../filters/currency.filter';
import AppEditable from '../form/AppEditable';

Expand All @@ -57,10 +58,18 @@ export default {
components: {
AppEditable,
},
filters: {
currency: formatCurrency,
computed: {
...mapGetters({
team: 'teams/team',
}),
},
methods: {
currency(val, digits = 2) {
const separator = (this.team && this.team.thousands_separator !== undefined)
? this.team.thousands_separator
: ',';
return formatCurrency(val, digits, separator);
},
updateProp(props) {
this.$store.dispatch('invoiceRows/updateInvoiceRow', {
props,
Expand Down
14 changes: 10 additions & 4 deletions src/components/invoices/InvoiceTotals.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
<tfoot>
<tr class="text-right">
<td :colspan="colspan">{{ $t('subtotal') }}</td>
<td>{{ invoice.subTotal | currency }}</td>
<td>{{ currency(invoice.subTotal) }}</td>
</tr>
<tr class="text-right" v-for="tax in invoice.taxes" :key="tax.label">
<td :colspan="colspan">
{{ tax.label }} ({{ tax.rate }}%)
</td>
<td>{{ tax.total | currency }}</td>
<td>{{ currency(tax.total) }}</td>
</tr>
<tr class="text-right">
<th :colspan="colspan">
Expand All @@ -19,7 +19,7 @@
:placeholder="$t('add_currency')"
@change="updateProp({ currency: $event })"/>
</th>
<th class="text-nowrap">{{ invoice.total | currency }}</th>
<th class="text-nowrap">{{ currency(invoice.total) }}</th>
</tr>
</tfoot>
</template>
Expand All @@ -37,17 +37,23 @@ export default {
},
filters: {
date: formatDate,
currency: formatCurrency,
},
computed: {
...mapGetters({
taxes: 'invoiceRows/taxes',
team: 'teams/team',
}),
colspan() {
return 4 + this.taxes.length;
},
},
methods: {
currency(val, digits = 2) {
const separator = (this.team && this.team.thousands_separator !== undefined)
? this.team.thousands_separator
: ',';
return formatCurrency(val, digits, separator);
},
updateProp(props) {
this.$emit('update', props);
},
Expand Down
12 changes: 9 additions & 3 deletions src/components/invoices/InvoicesList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
<td>{{ invoice.client ? invoice.client.company_name : '' }}</td>
<td>{{ invoice.issued_at | date('D MMM YYYY', 'YYYY-MM-DD') }}</td>
<td>
{{ invoice.subTotal | currency }}
<small v-if="invoice.taxTotal"><br>({{ invoice.total | currency }})</small>
{{ currency(invoice.subTotal) }}
<small v-if="invoice.taxTotal"><br>({{ currency(invoice.total) }})</small>
</td>
<td class="text-right text-capitalize">
<i class="material-icons material-icons-round md-18 mr-2 text-warning"
Expand Down Expand Up @@ -52,20 +52,26 @@ export default {
},
filters: {
date: formatDate,
currency: formatCurrency,
},
directives: {
'b-tooltip': VBTooltip,
},
computed: {
...mapGetters({
invoices: 'invoices/all',
team: 'teams/team',
}),
},
mounted() {
this.$store.dispatch('invoices/getInvoices');
},
methods: {
currency(val, digits = 2) {
const separator = (this.team && this.team.thousands_separator !== undefined)
? this.team.thousands_separator
: ',';
return formatCurrency(val, digits, separator);
},
openInvoice(invoice) {
this.$store.commit('invoices/invoiceId', invoice.id);
this.$router.push({
Expand Down
5 changes: 4 additions & 1 deletion src/components/team/TeamForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@
<AppInput :value="team.invoice_late_fee" @change="updateProp({ invoice_late_fee: $event })"
type="number"
:label="$t('invoicing.invoice_late_fee')" field="invoice_late_fee" :errors="errors"
class="col-12"/>
class="col-sm-7"/>
<AppInput :value="team.thousands_separator" @change="updateProp({ thousands_separator: $event })"
:label="$t('invoicing.thousands_separator')" field="thousands_separator" :errors="errors"
class="col-sm-5"/>
<AppInput :value="team.invoice_due_days" @change="updateProp({ invoice_due_days: $event })"
type="number"
:label="$t('invoicing.invoice_due_days')" field="invoice_due_days" :errors="errors"
Expand Down
22 changes: 11 additions & 11 deletions src/filters/currency.filter.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
export function formatCurrency(val, digits = 2) {
if (val !== null) {
let x = parseFloat(val);
if (Number.isNaN(x)) {
return '';
}
const decimalLimiter = 10 ** digits;
x = Math.round((x + Number.EPSILON) * decimalLimiter) / decimalLimiter;
const parts = x.toFixed(digits).split('.');
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ' ');
return parts.join('.');
export function formatCurrency(val, digits = 2, thousandsSeparator = ',') {
if (val === null || val === undefined || val === '') return '';

let x = parseFloat(val);
if (Number.isNaN(x)) {
return '';
}
const decimalLimiter = 10 ** digits;
x = Math.round((x + Number.EPSILON) * decimalLimiter) / decimalLimiter;
const parts = x.toFixed(digits).split('.');
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, thousandsSeparator);
return parts.join('.');
}
1 change: 1 addition & 0 deletions src/store/invoices.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export default {
from_website: 'website',
from_email: 'contact_email',
from_phone: 'contact_phone',
thousands_separator: 'thousands_separator',
});
const invoice = getInvoice(payload.invoiceId);

Expand Down
1 change: 1 addition & 0 deletions src/store/models/team.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export default class Team extends Model {
currency: this.attr(null),
invoice_late_fee: this.attr(null),
invoice_due_days: this.attr(null),
thousands_separator: this.attr(','),
fields: this.hasMany(TeamField, 'team_id'),
updated_at: this.attr(''),
created_at: this.attr(''),
Expand Down