Skip to content

Commit

Permalink
use current date when duplicates receipts
Browse files Browse the repository at this point in the history
  • Loading branch information
ebdonato committed Jul 18, 2023
1 parent 0e009ec commit 743c44d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rai-invoices",
"version": "3.1.0",
"version": "3.2.0",
"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]>",
Expand Down
11 changes: 7 additions & 4 deletions src/components/ReceiptDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
</template>

<script setup>
import { useDialogPluginComponent, useQuasar, date } from "quasar"
import { useDialogPluginComponent, useQuasar, date as dateHelper } from "quasar"
import { getFirestore, doc, getDoc, setDoc, deleteDoc, updateDoc, serverTimestamp } from "firebase/firestore"
import { getAuth } from "firebase/auth"
import { ref, onMounted, reactive } from "vue"
Expand All @@ -115,7 +115,7 @@ const $q = useQuasar()
const receipt = reactive({
customerName: "",
customer: null,
date: date.formatDate(Date.now(), "DD/MM/YYYY"),
date: dateHelper.formatDate(Date.now(), "DD/MM/YYYY"),
value: 0,
details: "",
state: "ES",
Expand Down Expand Up @@ -143,7 +143,7 @@ const props = defineProps({
const receiptsPath = `users/${user.uid}/receipts`
const getReceipt = (id) => {
const getReceipt = (id, useDefaultDate = false) => {
const docRef = doc(db, receiptsPath, id)
$q.loading.show()
Expand All @@ -153,6 +153,7 @@ const getReceipt = (id) => {
if (docSnap.exists()) {
const { customerName = "", customer = null, date = "", value = 0, details = "", state, city } = docSnap.data()
Object.assign(receipt, { customerName, customer, date, value, details, state, city })
useDefaultDate && (receipt.date = dateHelper.formatDate(Date.now(), "DD/MM/YYYY"))
} else {
// doc.data() will be undefined in this case
throw new Error("Documento não encontrado")
Expand Down Expand Up @@ -264,7 +265,9 @@ const onCancelClick = () => {
onMounted(() => {
props.id && getReceipt(props.id)
!props.id && props.copyFromId && getReceipt(props.copyFromId)
const USE_DEFAULT_DATE = true
!props.id && props.copyFromId && getReceipt(props.copyFromId, USE_DEFAULT_DATE)
getCities(receipt.state)
.then((response) => {
Expand Down

0 comments on commit 743c44d

Please sign in to comment.