Fix: suppression des ventes
La suppression des derniers éléments ne marchait plus deleteEmbeddedDocuments prend un tableau d'ids
This commit is contained in:
		| @@ -3601,18 +3601,17 @@ export class RdDActor extends Actor { | |||||||
|         return; |         return; | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
|     const itemVendu = vendeur?.getObjet(itemId); |     const itemVendu = Misc.data(vendeur?.getObjet(itemId)); | ||||||
|     if (itemVendu) { |     if (itemVendu) { | ||||||
|       let itemVenduData = Misc.data(itemVendu); |       if ("quantite" in itemVendu.data ? itemVendu.data.quantite < achat.quantiteTotal : achat.choix.nombreLots != 1) { | ||||||
|       if ("quantite" in itemVenduData.data ? itemVenduData.data.quantite < achat.quantiteTotal : achat.choix.nombreLots != 1) { |  | ||||||
|         await acheteur?.ajouterDeniers(coutDeniers); |         await acheteur?.ajouterDeniers(coutDeniers); | ||||||
|         ChatUtility.notifyUser(achat.userId, 'warn', `Le vendeur n'a plus assez de ${vente.item.name} !`); |         ChatUtility.notifyUser(achat.userId, 'warn', `Le vendeur n'a plus assez de ${vente.item.name} !`); | ||||||
|         return; |         return; | ||||||
|       } |       } | ||||||
|       vendeur.ajouterDeniers(coutDeniers); |       vendeur.ajouterDeniers(coutDeniers); | ||||||
|       let resteQuantite = (itemVenduData.data.quantite ?? 1) - achat.quantiteTotal; |       let resteQuantite = (itemVendu.data.quantite ?? 1) - achat.quantiteTotal; | ||||||
|       if (resteQuantite == 0) { |       if (resteQuantite == 0) { | ||||||
|         vendeur.deleteEmbeddedDocuments("Item", itemId); |         vendeur.deleteEmbeddedDocuments("Item", [itemId]); | ||||||
|       } |       } | ||||||
|       else { |       else { | ||||||
|         vendeur.updateEmbeddedDocuments("Item", [{ _id: itemId, 'data.quantite': resteQuantite }]); |         vendeur.updateEmbeddedDocuments("Item", [{ _id: itemId, 'data.quantite': resteQuantite }]); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user