transfer into an existing resource hands the source resource's rights and custody to the receiver

Aperta Adatta ai principianti
#87 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
elixir
Ambito
backend, databases

Direzione di ricerca

Leggi il ramo to_resource_inventoried_as_id in src/zenflows/vf/economic_event/domain.ex intorno alle righe 980–990 e confrontalo con il ramo intorno alle righe 1023–1029. Aggiungi un test per un trasferimento parziale in test/vf/economic_event/domain.test.exs, basato sul test esistente di :to_resource_inventoried_as, e verifica l’accountable e il custodian della risorsa di origine. Il lavoro è completato quando la risorsa di origine conserva entrambi dopo un trasferimento parziale verso una risorsa esistente.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Problem

When a transfer names an existing destination (toResourceInventoriedAs), the update of the source resource also sets its primaryAccountable and custodian to the receiver:

domain.ex L980-L990

|> Multi.update_all("#{key}.set_and_dec",
	where(EconomicResource, id: ^evt.resource_inventoried_as_id),
	set: [
		previous_event_id: evt.id,
		primary_accountable_id: evt.receiver_id,
		custodian_id: evt.receiver_id,
	],
	inc: [ ...negate(resource_quantity)... ])

A partial transfer (for example 2 of 5 units into the buyer's existing resource) therefore gives the receiver the rights and custody of the 3 units the provider kept. The branch without a destination keeps the source's owner (set: [previous_event_id: evt.id] only, L1023-L1029). That is what we'd expect in both cases.

The existing test "pass with :to_resource_inventoried_as" transfers the whole accounting quantity and does not assert the source's accountable or custodian afterwards, so this goes unnoticed.

Proposal

In the to_resource_inventoried_as_id branch, set only previous_event_id on the source, as the other branch does. Add a test with a partial transfer into an existing resource that asserts the source keeps its accountable and custodian.

If moving ownership of the source is intended (for example, only for full transfers), it should be conditioned on the transfer emptying the resource, and documented.

The marketplace does not use toResourceInventoriedAs today: each sale creates a new resource for the buyer. Reusing the buyer's existing resource with N-unit sales (interfacerproject/interfacer-gui#962) would hit this. Read from the code at 91be858, not reproduced against a running instance.


Generated by Claude Code

Lingua principale
Elixir
Stelle
18
Fork
4
Merge medio
22g 17h
PR unite (30g)
1

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di interfacerproject/zenflows

Tutte le issue di interfacerproject/zenflows

Issue simili

Altre issue su Elixir

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.