calendario delle consegne (griglia del mese + ordini del giorno) e fedelta' dei dati: gli ordini conservano nota del cliente e origine, la consegna scala le uova dal magazzino come nell'originale
This commit is contained in:
+21
-9
@@ -137,15 +137,26 @@ function accrueStock(stock, breedSettings, catalog, daysPassed) {
|
||||
// --------------------------------------------------------- prenotazioni
|
||||
|
||||
function cloneReservation(r) {
|
||||
return {
|
||||
id: r.id,
|
||||
customerName: r.customerName,
|
||||
breedId: r.breedId,
|
||||
eggsRequested: r.eggsRequested,
|
||||
createdAt: r.createdAt,
|
||||
deliveryDate: r.deliveryDate,
|
||||
isDelivered: r.isDelivered
|
||||
};
|
||||
// Copia TUTTI i campi: l'ordine dell'app Android ne ha anche di piu'
|
||||
// (source, clientNote) e il ricalcolo delle date non deve perderli.
|
||||
var out = {}, k;
|
||||
for (k in r) {
|
||||
if (r.hasOwnProperty(k)) out[k] = r[k];
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
// Consegna: l'app originale, quando un ordine viene segnato come consegnato,
|
||||
// SCALA le uova dal magazzino di quella razza; annullando la consegna le
|
||||
// rimette. Restituisce un magazzino nuovo (l'input non viene toccato).
|
||||
function applyDelivery(stock, reservation, delivered) {
|
||||
var out = {}, k;
|
||||
for (k in stock) {
|
||||
if (stock.hasOwnProperty(k)) out[k] = stock[k];
|
||||
}
|
||||
var eggs = reservation.eggsRequested || 0;
|
||||
out[reservation.breedId] = (out[reservation.breedId] || 0) + (delivered ? -eggs : eggs);
|
||||
return out;
|
||||
}
|
||||
|
||||
function pendingEggs(reservations, breedId) {
|
||||
@@ -268,6 +279,7 @@ if (typeof module !== "undefined" && module.exports) {
|
||||
isProductive: isProductive,
|
||||
accrueStock: accrueStock,
|
||||
pendingEggs: pendingEggs,
|
||||
applyDelivery: applyDelivery,
|
||||
estimateDeliveryDate: estimateDeliveryDate,
|
||||
refreshDeliveryDates: refreshDeliveryDates,
|
||||
statusKey: statusKey,
|
||||
|
||||
Reference in New Issue
Block a user