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
|
||||
async def can_edit(receipt: Receipt, username: str) -> bool:
|
||||
"""Check if user can edit receipt."""
|
||||
# Only DRAFT receipts can be edited
|
||||
if receipt.status != ReceiptStatus.DRAFT:
|
||||
# DRAFT and REJECTED receipts can be edited (to fix and resubmit)
|
||||
if receipt.status not in [ReceiptStatus.DRAFT, ReceiptStatus.REJECTED]:
|
||||
return False
|
||||
|
||||
# Only creator can edit their own drafts
|
||||
# Only creator can edit their own receipts
|
||||
return receipt.created_by == username
|
||||
|
||||
@staticmethod
|
||||
|
||||
@@ -351,9 +351,6 @@
|
||||
<label>TOTAL *</label>
|
||||
<InputNumber
|
||||
v-model="form.amount"
|
||||
mode="currency"
|
||||
currency="RON"
|
||||
locale="ro-RO"
|
||||
:minFractionDigits="2"
|
||||
:maxFractionDigits="2"
|
||||
required
|
||||
@@ -374,10 +371,18 @@
|
||||
class="dropdown-payment"
|
||||
/>
|
||||
</div>
|
||||
<!-- Payment methods from OCR (CARD, NUMERAR) with uniform layout -->
|
||||
<div class="value-item payment-method-item" v-for="pm in form.payment_methods" :key="pm.method">
|
||||
<!-- Payment methods from OCR (CARD, NUMERAR) - editable -->
|
||||
<div class="value-item payment-method-item" v-for="(pm, idx) in form.payment_methods" :key="pm.method">
|
||||
<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>
|
||||
|
||||
@@ -387,10 +392,8 @@
|
||||
<label>TVA {{ entry.code }} {{ entry.percent }}%</label>
|
||||
<InputNumber
|
||||
v-model="form.tva_breakdown[idx].amount"
|
||||
mode="currency"
|
||||
currency="RON"
|
||||
locale="ro-RO"
|
||||
:minFractionDigits="2"
|
||||
:maxFractionDigits="2"
|
||||
:disabled="isReadOnly"
|
||||
:inputStyle="{ width: '110px' }"
|
||||
class="input-tva"
|
||||
@@ -532,7 +535,7 @@
|
||||
<!-- View mode buttons -->
|
||||
<template v-if="isViewMode">
|
||||
<Button
|
||||
v-if="receipt?.status === 'draft'"
|
||||
v-if="receipt?.status === 'draft' || receipt?.status === 'rejected'"
|
||||
icon="pi pi-pencil"
|
||||
label="Editeaza"
|
||||
@click="$router.push(`/receipt/${receipt.id}/edit`)"
|
||||
@@ -1719,9 +1722,22 @@ const saveReceipt = async () => {
|
||||
saving.value = true
|
||||
|
||||
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 = {
|
||||
...form.value,
|
||||
receipt_date: form.value.receipt_date.toISOString().split('T')[0],
|
||||
payment_methods: cleanedPaymentMethods,
|
||||
tva_breakdown: cleanedTvaBreakdown,
|
||||
}
|
||||
|
||||
let savedReceipt
|
||||
|
||||
Reference in New Issue
Block a user