feat(iva): prepare P111-P120 listed services as one compatible QA set
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
import {useState} from 'react';
|
||||
import {newListedService,switchListedTreatment,listedServiceBook,listedServiceConditions,ownListedConditions,listedServiceCurrent,listedServiceReportRows,listedServiceSource,listedServiceTreatments,recordListedServices,saveListedServiceBook,type ListedServiceBook,type ListedServiceRow} from '@/lib/iva-listed-services';
|
||||
|
||||
export function SimulationListedServices({draft,onChange}:{draft:Record<string,unknown>;onChange:(field:string,value:string)=>void}){
|
||||
const[error,setError]=useState('');let book:ListedServiceBook;
|
||||
try{book=listedServiceBook(draft);}catch(cause){return<p role="alert">{String(cause)}</p>;}
|
||||
const save=(next:ListedServiceBook)=>{try{onChange('modelo_a_snapshot',saveListedServiceBook(draft,next));setError('');}catch(cause){setError(String(cause));}};
|
||||
const change=(id:string,patch:Partial<ListedServiceRow>)=>save({...book,rows:book.rows.map(row=>row.id===id?{...row,...patch}:row)});
|
||||
return<details className="space-y-3 rounded border p-3">
|
||||
<summary>Serviços enumerados — localização e responsável pelas obrigações</summary>
|
||||
<p>Oportunidade: {String(draft.context_opportunity||'entrada geral')}. Identifique a natureza do serviço,o estabelecimento a partir do qual o prestador o fornece e o estabelecimento estável ou domicílio do adquirente. Nacionalidade não substitui estes factos.</p>
|
||||
<p>Adquirente no estrangeiro:conferir6(8). Prestador estrangeiro e adquirente nacional:6(7)inclui sujeitos passivos2(1)a/b que realizem exclusivamente operações isentas sem direito à dedução. Não exigir direito à dedução como condição de localização. Digital,imóveis e outras regras próprias têm os seus percursos.</p>
|
||||
<p>A classificação não concede isenção nem calcula IVA. A identificação do responsável explica a regra aplicável;não apresenta declaração nem inicia pagamento.</p>
|
||||
<p>{listedServiceSource}</p>{error&&<p role="alert">{error}</p>}
|
||||
<button type="button" className="underline" onClick={()=>save({...book,rows:[...book.rows,newListedService(crypto.randomUUID())]})}>Acrescentar serviço enumerado</button>
|
||||
{book.rows.map(row=><details key={row.id} className="rounded border p-3"><summary>{row.description||'Serviço por identificar'} — {row.period||'mês por indicar'}</summary>
|
||||
<div className="grid gap-3 md:grid-cols-2">
|
||||
<label>Tratamento do serviço<select className="block rounded border p-2" value={row.treatment} onChange={e=>change(row.id,switchListedTreatment(row,e.target.value))}><option value="">Por indicar</option>{listedServiceTreatments.map(t=><option key={t.id} value={t.id}>{t.label}</option>)}</select></label>
|
||||
<label>Natureza dos dados<select className="block rounded border p-2" value={row.origin} onChange={e=>change(row.id,{origin:e.target.value as ListedServiceRow['origin']})}><option value="projected">Projectados / pressupostos</option><option value="effective">Efectivos declarados</option></select></label>
|
||||
{([['description','Serviço identificado'],['operationRef','Referência da operação / pressuposto'],['operationDate','Data do serviço / prevista'],['period','Mês do serviço'],['documentRef','Documento da operação / referência da previsão'],['documentDate','Data do documento / prevista'],['subjectRef','Objecto:direito,campanha,serviço,pessoal,bens ou contrato'],['useRef','Destinatário e utilização / pressuposto'],['scope','Âmbito:serviço,operação,período e condições'],['evidence','Fundamento factual / pressupostos'],['providerPlace','Sede,EP ou domicílio a partir do qual o prestador fornece'],['providerRef','Referência do estabelecimento prestador'],['buyerPlace','Estabelecimento estável ou domicílio do adquirente'],['buyerRef','Referência do estabelecimento ou domicílio adquirente']] as const).map(([field,label])=><label key={field}>{label}<input className="block rounded border p-2" type={['operationDate','documentDate'].includes(field)?'date':field==='period'?'month':'text'} value={row[field]} onChange={e=>change(row.id,{[field]:e.target.value})}/></label>)}
|
||||
{([['providerCountry','País do estabelecimento prestador'],['buyerCountry','País do estabelecimento ou domicílio adquirente']] as const).map(([field,label])=><label key={field}>{label}<select className="block rounded border p-2" value={row[field]} onChange={e=>change(row.id,{[field]:e.target.value})}><option value="">Por indicar</option><option value="MZ">Moçambique</option><option value="foreign">Estrangeiro</option></select></label>)}
|
||||
{row.providerCountry==='foreign'&&row.buyerCountry==='MZ'&&<>
|
||||
<label>Qualidade do adquirente2(1)<select className="block rounded border p-2" value={row.recipientType} onChange={e=>change(row.id,{recipientType:e.target.value})}><option value="">Por esclarecer</option><option value="a">Alínea a — actividade independente habitual,incluindo operações isentas sem dedução</option><option value="b">Alínea b — operação independente nos pressupostos legais</option><option value="other">Não corresponde às alíneas a/b</option></select></label>
|
||||
<label>Referência da qualidade fiscal do adquirente<input className="block rounded border p-2" value={row.recipientRef} onChange={e=>change(row.id,{recipientRef:e.target.value})}/></label>
|
||||
</>}
|
||||
{row.providerCountry==='MZ'&&row.buyerCountry==='MZ'&&<>
|
||||
<label>Prestador sujeito passivo no regime geral<select className="block rounded border p-2" value={row.providerTaxable} onChange={e=>change(row.id,{providerTaxable:e.target.value})}><option value="">Por esclarecer</option><option value="yes">Sim</option><option value="no">Não</option></select></label>
|
||||
<label>Referência da qualidade fiscal do prestador<input className="block rounded border p-2" value={row.providerTaxRef} onChange={e=>change(row.id,{providerTaxRef:e.target.value})}/></label>
|
||||
</>}
|
||||
{['intermediation_service','abstention_service'].includes(row.treatment)&&<>
|
||||
<label>Alínea6(7)do serviço,direito ou actividade subjacente<select className="block rounded border p-2" value={row.targetClause} onChange={e=>change(row.id,{targetClause:e.target.value})}><option value="">Por indicar</option>{listedServiceTreatments.filter(t=>t.id!==row.treatment).map(t=><option key={t.id} value={t.clause}>{t.clause} — {t.label}</option>)}</select></label>
|
||||
<label>Referência do subjacente e relação da intermediação/obrigação<input className="block rounded border p-2" value={row.targetRef} onChange={e=>change(row.id,{targetRef:e.target.value})}/></label>
|
||||
</>}
|
||||
</div>
|
||||
<p>Mudar tratamento conserva dados e referências ocultos,mas exige rever os factos próprios. Campos sem aplicação ficam ocultos e conservados.</p>
|
||||
<fieldset><legend>Factos próprios deste tratamento</legend>{[...listedServiceConditions,...ownListedConditions(row.treatment)].map(([key,label])=><label className="block" key={key}>{label}<select className="block rounded border p-2" value={row.conditions[key]??''} onChange={e=>change(row.id,{conditions:{...row.conditions,[key]:e.target.value as ''|'yes'|'no'}})}><option value="">Por indicar</option><option value="yes">Sim</option><option value="no">Não</option></select></label>)}</fieldset>
|
||||
</details>)}
|
||||
{!!book.rows.length&&<button type="button" className="rounded bg-emerald-800 p-2 text-white" onClick={()=>{try{save(recordListedServices(draft,book));}catch(cause){setError(String(cause));}}}>Classificar serviços e guardar versão</button>}
|
||||
{book.result&&<><p role="status">{listedServiceCurrent(draft,book)?'Resultados correspondentes às entradas guardadas.':'Entradas alteradas;resultados históricos conservados. Reveja e classifique novamente.'} {book.history?.length??0} versões anteriores. Localização e responsável não determinam isenção,IVA ou dedução/campo11.</p><dl>{listedServiceReportRows(draft).map(([,label,value,origin],index)=><div key={index}><dt className="font-semibold">{label}</dt><dd>{value}<small className="block">{origin}</small></dd></div>)}</dl></>}
|
||||
</details>;
|
||||
}
|
||||
@@ -17,6 +17,7 @@ import { SimulationValueReview } from './simulation-value-review';
|
||||
import { SimulationServiceNormal } from './simulation-service-normal';
|
||||
import { SimulationGoodsLocation } from './simulation-goods-location';
|
||||
import { SimulationServiceLocation } from './simulation-service-location';
|
||||
import { SimulationListedServices } from './simulation-listed-services';
|
||||
import { SimulationOfferPreparations } from './simulation-offer-preparations';
|
||||
import { SimulationOperations } from './simulation-operations';
|
||||
|
||||
@@ -112,6 +113,7 @@ export function SimulationMonthlyIva({draft, busy, onCalculate, onChange}: {
|
||||
<SimulationServiceNormal draft={draft} onChange={onChange} />
|
||||
<SimulationGoodsLocation draft={draft} onChange={onChange} />
|
||||
<SimulationServiceLocation draft={draft} onChange={onChange} />
|
||||
<SimulationListedServices draft={draft} onChange={onChange} />
|
||||
<SimulationOfferPreparations draft={draft} onChange={onChange} />
|
||||
<SimulationModeloA draft={draft} />
|
||||
</section>;
|
||||
|
||||
Reference in New Issue
Block a user