feat: Make TVA and payment method values editable, remove RON currency
- Make payment methods (CARD/NUMERAR) editable InputNumber fields - Remove RON currency display from TOTAL, TVA, and payment fields - Allow editing REJECTED receipts (to fix OCR errors before resubmit) - Add "Editeaza" button for REJECTED receipts in view mode - Fix null amount validation by converting to 0 before API call 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -254,11 +254,11 @@ class ReceiptCRUD:
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
async def can_edit(receipt: Receipt, username: str) -> bool:
|
async def can_edit(receipt: Receipt, username: str) -> bool:
|
||||||
"""Check if user can edit receipt."""
|
"""Check if user can edit receipt."""
|
||||||
# Only DRAFT receipts can be edited
|
# DRAFT and REJECTED receipts can be edited (to fix and resubmit)
|
||||||
if receipt.status != ReceiptStatus.DRAFT:
|
if receipt.status not in [ReceiptStatus.DRAFT, ReceiptStatus.REJECTED]:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# Only creator can edit their own drafts
|
# Only creator can edit their own receipts
|
||||||
return receipt.created_by == username
|
return receipt.created_by == username
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|||||||
@@ -351,9 +351,6 @@
|
|||||||
<label>TOTAL *</label>
|
<label>TOTAL *</label>
|
||||||
<InputNumber
|
<InputNumber
|
||||||
v-model="form.amount"
|
v-model="form.amount"
|
||||||
mode="currency"
|
|
||||||
currency="RON"
|
|
||||||
locale="ro-RO"
|
|
||||||
:minFractionDigits="2"
|
:minFractionDigits="2"
|
||||||
:maxFractionDigits="2"
|
:maxFractionDigits="2"
|
||||||
required
|
required
|
||||||
@@ -374,10 +371,18 @@
|
|||||||
class="dropdown-payment"
|
class="dropdown-payment"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<!-- Payment methods from OCR (CARD, NUMERAR) with uniform layout -->
|
<!-- Payment methods from OCR (CARD, NUMERAR) - editable -->
|
||||||
<div class="value-item payment-method-item" v-for="pm in form.payment_methods" :key="pm.method">
|
<div class="value-item payment-method-item" v-for="(pm, idx) in form.payment_methods" :key="pm.method">
|
||||||
<label>{{ pm.method }}</label>
|
<label>{{ pm.method }}</label>
|
||||||
<span class="payment-method-value">{{ formatCurrency(pm.amount) }}</span>
|
<InputNumber
|
||||||
|
v-model="form.payment_methods[idx].amount"
|
||||||
|
locale="en-US"
|
||||||
|
:minFractionDigits="2"
|
||||||
|
:maxFractionDigits="2"
|
||||||
|
:disabled="isReadOnly"
|
||||||
|
:inputStyle="{ width: '110px' }"
|
||||||
|
class="input-payment-method"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -387,10 +392,8 @@
|
|||||||
<label>TVA {{ entry.code }} {{ entry.percent }}%</label>
|
<label>TVA {{ entry.code }} {{ entry.percent }}%</label>
|
||||||
<InputNumber
|
<InputNumber
|
||||||
v-model="form.tva_breakdown[idx].amount"
|
v-model="form.tva_breakdown[idx].amount"
|
||||||
mode="currency"
|
|
||||||
currency="RON"
|
|
||||||
locale="ro-RO"
|
|
||||||
:minFractionDigits="2"
|
:minFractionDigits="2"
|
||||||
|
:maxFractionDigits="2"
|
||||||
:disabled="isReadOnly"
|
:disabled="isReadOnly"
|
||||||
:inputStyle="{ width: '110px' }"
|
:inputStyle="{ width: '110px' }"
|
||||||
class="input-tva"
|
class="input-tva"
|
||||||
@@ -532,7 +535,7 @@
|
|||||||
<!-- View mode buttons -->
|
<!-- View mode buttons -->
|
||||||
<template v-if="isViewMode">
|
<template v-if="isViewMode">
|
||||||
<Button
|
<Button
|
||||||
v-if="receipt?.status === 'draft'"
|
v-if="receipt?.status === 'draft' || receipt?.status === 'rejected'"
|
||||||
icon="pi pi-pencil"
|
icon="pi pi-pencil"
|
||||||
label="Editeaza"
|
label="Editeaza"
|
||||||
@click="$router.push(`/receipt/${receipt.id}/edit`)"
|
@click="$router.push(`/receipt/${receipt.id}/edit`)"
|
||||||
@@ -1719,9 +1722,22 @@ const saveReceipt = async () => {
|
|||||||
saving.value = true
|
saving.value = true
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// Clean up payment_methods and tva_breakdown - convert null amounts to 0
|
||||||
|
const cleanedPaymentMethods = form.value.payment_methods?.map(pm => ({
|
||||||
|
...pm,
|
||||||
|
amount: pm.amount ?? 0
|
||||||
|
})) || null
|
||||||
|
|
||||||
|
const cleanedTvaBreakdown = form.value.tva_breakdown?.map(entry => ({
|
||||||
|
...entry,
|
||||||
|
amount: entry.amount ?? 0
|
||||||
|
})) || null
|
||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
...form.value,
|
...form.value,
|
||||||
receipt_date: form.value.receipt_date.toISOString().split('T')[0],
|
receipt_date: form.value.receipt_date.toISOString().split('T')[0],
|
||||||
|
payment_methods: cleanedPaymentMethods,
|
||||||
|
tva_breakdown: cleanedTvaBreakdown,
|
||||||
}
|
}
|
||||||
|
|
||||||
let savedReceipt
|
let savedReceipt
|
||||||
|
|||||||
Reference in New Issue
Block a user