Skip to content

Commit

Permalink
add receipt feature
Browse files Browse the repository at this point in the history
  • Loading branch information
ebdonato committed Jun 27, 2022
1 parent a117b9b commit 2829d3f
Show file tree
Hide file tree
Showing 19 changed files with 873 additions and 65 deletions.
43 changes: 22 additions & 21 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
{
"editor.bracketPairColorization.enabled": true,
"editor.guides.bracketPairs": "active",
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.codeActionsOnSave": ["source.fixAll.eslint"],
"eslint.validate": ["javascript", "javascriptreact", "typescript", "vue"],
"cSpell.words": [
"Addressbar",
"CNPJ",
"Contato",
"Contatos",
"Desenvolvedor",
"firestore",
"icongenie",
"Iconpacks",
"Rainério",
"Tchau",
"vueuse"
]
}
{
"editor.bracketPairColorization.enabled": true,
"editor.guides.bracketPairs": "active",
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.codeActionsOnSave": ["source.fixAll.eslint"],
"eslint.validate": ["javascript", "javascriptreact", "typescript", "vue"],
"cSpell.words": [
"Addressbar",
"CNPJ",
"Contato",
"Contatos",
"Desenvolvedor",
"firestore",
"icongenie",
"Iconpacks",
"Itapemirim",
"Rainério",
"Tchau",
"vueuse"
]
}
3 changes: 3 additions & 0 deletions firestore.rules
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ service cloud.firestore {
match /users/{userId}/invoices/{document=**} {
allow read: if true;
}
match /users/{userId}/receipts/{document=**} {
allow read: if true;
}
match /users/{userId}/{document=**} {
allow write, read: if request.auth != null && request.auth.uid == userId;
}
Expand Down
15 changes: 13 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "rai-invoices",
"version": "0.11.7",
"description": "Sistema para Gestão dos Orçamentos do Rainério",
"productName": "Orçamentos do Rainério",
"description": "Sistema para Gestão dos Recibos e Orçamentos do Rainério",
"productName": "Recibos e Orçamentos do Rainério",
"author": "Eduardo Donato <[email protected]>",
"private": true,
"scripts": {
Expand All @@ -19,6 +19,7 @@
"@vueuse/core": "^8.6.0",
"cpf-cnpj-validator": "^1.0.3",
"firebase": "^9.8.1",
"n2words": "^1.11.1",
"nanoid": "^3.3.4",
"quasar": "^2.6.0",
"vue": "^3.0.0",
Expand Down
10 changes: 10 additions & 0 deletions src/assets/customFormatters.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,13 @@ export const formatPhone = (text) => {
const cleanedText = cleanText(text)
return cleanedText.length >= 11 ? formatPhone9Digits(cleanedText) : formatPhone8Digits(cleanedText)
}

export const formatLocal = (city, state) => (city && state ? `${city}/${state}` : "")

const numberCurrencyFormat = new Intl.NumberFormat("pt-BR", { style: "currency", currency: "BRL" })

const numberFormat = new Intl.NumberFormat("pt-BR")

export const formatCurrency = (value) => numberCurrencyFormat.format(value)

export const formatNumber = (value) => numberFormat.format(value)
2 changes: 1 addition & 1 deletion src/boot/firebase.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const firebaseConfig = {
measurementId: "G-X1MNYGDXN4",
}

const publicRoutesName = ["InvoicePublicPage"]
const publicRoutesName = ["InvoicePublicPage", "ReceiptPublicPage"]

// "async" is optional;
// more info on params: https://v2.quasar.dev/quasar-cli/boot-files
Expand Down
2 changes: 1 addition & 1 deletion src/components/CustomerDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ const onSubmit = () => {
$q.notify({
type: "negative",
message: "Erro ao obter dados",
message: "Erro ao enviar dados",
caption: error.message,
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,30 @@
</template>

<script setup>
import { computed } from "vue"
import { useShare } from "@vueuse/core"
import { copyToClipboard, openURL, useQuasar } from "quasar"
const { share, isSupported } = useShare()
const $q = useQuasar()
const url = `${location.protocol}//${location.host}/#/pub/u/${props.userId}/i/${props.invoiceId}`
function startShare() {
const title = `Orçamento ${props.userInfoName ? "de" : ""} ${props.userInfoName}`
const title = `${docName.value} ${props.userInfoName ? "de" : ""} ${props.userInfoName}`
share({
title,
text: `Orçamento ID: ${props.invoiceId}`,
url,
text: `${docName.value} ID: ${props.docId}`,
url: url.value,
})
}
function openLink() {
openURL(url)
openURL(url.value)
}
function copyLink() {
copyToClipboard(url)
copyToClipboard(url.value)
.then(() => {
$q.notify({
type: "positive",
Expand All @@ -55,10 +54,18 @@ function copyLink() {
}
const props = defineProps({
invoiceId: {
docId: {
type: String,
required: true,
},
docType: {
type: String,
required: false,
default: "invoice",
validator(value) {
return ["invoice", "receipt"].includes(value)
},
},
userId: {
type: String,
required: true,
Expand All @@ -69,6 +76,24 @@ const props = defineProps({
default: "",
},
})
const docName = computed(() => {
const docTypeTranslateToName = {
invoice: "Orçamento",
receipt: "Recibo",
}
return docTypeTranslateToName[props.docType] ?? "Orçamento"
})
const url = computed(() => {
const docTypeTranslateToUrlPart = {
invoice: "i",
receipt: "r",
}
return `${location.protocol}//${location.host}/#/pub/u/${props.userId}/${docTypeTranslateToUrlPart[props.docType] ?? "i"}/${props.docId}`
})
</script>
<style lang="scss" scoped></style>
4 changes: 3 additions & 1 deletion src/components/InfoPublicHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const props = defineProps({
},
})
const emit = defineEmits(["error"])
const emit = defineEmits(["error", "username"])
const isLoading = ref(true)
Expand All @@ -62,6 +62,8 @@ const getInfo = async () => {
if (!info.name) {
throw new Error("Informações não encontradas")
}
emit("username", info.fantasyName || info.name)
} else {
// doc.data() will be undefined in this case
throw new Error("Informações não existem")
Expand Down
Loading

0 comments on commit 2829d3f

Please sign in to comment.