// @generated by protobuf-ts 2.9.6
// @generated from protobuf file "stockAction.proto" (package "api", syntax proto3)
// tslint:disable
import type { BinaryWriteOptions } from "@protobuf-ts/runtime";
import type { IBinaryWriter } from "@protobuf-ts/runtime";
import { WireType } from "@protobuf-ts/runtime";
import type { BinaryReadOptions } from "@protobuf-ts/runtime";
import type { IBinaryReader } from "@protobuf-ts/runtime";
import { UnknownFieldHandler } from "@protobuf-ts/runtime";
import type { PartialMessage } from "@protobuf-ts/runtime";
import { reflectionMergePartial } from "@protobuf-ts/runtime";
import { MessageType } from "@protobuf-ts/runtime";
import { StockMovement } from "./warehousingShared";
import { EntityID } from "./shared";
import { CommandHeader } from "./shared";
import { QuantityInLV } from "./warehousingShared";
import { StockSnapshot } from "./warehousingShared";
import { EnrichedGoods } from "./warehousingShared";
// _common_

// Action Summary
// GenerateDelta : generate a movement with the delta value following the snapshotted message
// UpdateMovement : send to the movement the value of the stock just after the movement is applied

/**
 *
 * GenerateDelta : generate a movement with the delta value following the snapshotted message
 *
 * @generated from protobuf message api.StockGenerateDeltaPayload
 */
export interface StockGenerateDeltaPayload {
    /**
     * @generated from protobuf field: api.EnrichedGoods Goods = 1 [json_name = "Goods"];
     */
    goods?: EnrichedGoods;
    /**
     * @generated from protobuf field: string ActorID = 2 [json_name = "ActorID"];
     */
    actorID: string;
    /**
     * @generated from protobuf field: api.StockSnapshot Snapshot = 3 [json_name = "Snapshot"];
     */
    snapshot?: StockSnapshot;
    /**
     * @generated from protobuf field: api.QuantityInLV QuantityInBaseLV = 4 [json_name = "QuantityInBaseLV"];
     */
    quantityInBaseLV?: QuantityInLV;
}
/**
 * @generated from protobuf message api.StockGenerateDelta
 */
export interface StockGenerateDelta {
    /**
     * @generated from protobuf field: api.CommandHeader Header = 1 [json_name = "Header"];
     */
    header?: CommandHeader;
    /**
     * @generated from protobuf field: api.EntityID ID = 2 [json_name = "ID"];
     */
    iD?: EntityID;
    /**
     * @generated from protobuf field: api.StockGenerateDeltaPayload Payload = 3 [json_name = "Payload"];
     */
    payload?: StockGenerateDeltaPayload;
    /**
     * @generated from protobuf field: api.StockGenerateDeltaPayload EventPayload = 4 [json_name = "EventPayload"];
     */
    eventPayload?: StockGenerateDeltaPayload;
    /**
     * @generated from protobuf field: api.StockGenerateDeltaPayload PreviousPayload = 5 [json_name = "PreviousPayload"];
     */
    previousPayload?: StockGenerateDeltaPayload;
}
/**
 *
 * UpdateMovement : send to the movement the value of the stock just after the movement is applied
 *
 * @generated from protobuf message api.StockUpdateMovementPayload
 */
export interface StockUpdateMovementPayload {
    /**
     * @generated from protobuf field: api.StockMovement Movement = 1 [json_name = "Movement"];
     */
    movement?: StockMovement;
    /**
     * @generated from protobuf field: api.QuantityInLV QuantityInBaseLV = 2 [json_name = "QuantityInBaseLV"];
     */
    quantityInBaseLV?: QuantityInLV;
}
/**
 * @generated from protobuf message api.StockUpdateMovement
 */
export interface StockUpdateMovement {
    /**
     * @generated from protobuf field: api.CommandHeader Header = 1 [json_name = "Header"];
     */
    header?: CommandHeader;
    /**
     * @generated from protobuf field: api.EntityID ID = 2 [json_name = "ID"];
     */
    iD?: EntityID;
    /**
     * @generated from protobuf field: api.StockUpdateMovementPayload Payload = 3 [json_name = "Payload"];
     */
    payload?: StockUpdateMovementPayload;
    /**
     * @generated from protobuf field: api.StockUpdateMovementPayload EventPayload = 4 [json_name = "EventPayload"];
     */
    eventPayload?: StockUpdateMovementPayload;
    /**
     * @generated from protobuf field: api.StockUpdateMovementPayload PreviousPayload = 5 [json_name = "PreviousPayload"];
     */
    previousPayload?: StockUpdateMovementPayload;
}
// @generated message type with reflection information, may provide speed optimized methods
class StockGenerateDeltaPayload$Type extends MessageType<StockGenerateDeltaPayload> {
    constructor() {
        super("api.StockGenerateDeltaPayload", [
            { no: 1, name: "Goods", kind: "message", jsonName: "Goods", T: () => EnrichedGoods },
            { no: 2, name: "ActorID", kind: "scalar", jsonName: "ActorID", T: 9 /*ScalarType.STRING*/ },
            { no: 3, name: "Snapshot", kind: "message", jsonName: "Snapshot", T: () => StockSnapshot },
            { no: 4, name: "QuantityInBaseLV", kind: "message", jsonName: "QuantityInBaseLV", T: () => QuantityInLV }
        ], { "api.messageType": "Command", "api.payload": true, "api.action": "GenerateDelta" });
    }
    create(value?: PartialMessage<StockGenerateDeltaPayload>): StockGenerateDeltaPayload {
        const message = globalThis.Object.create((this.messagePrototype!));
        message.actorID = "";
        if (value !== undefined)
            reflectionMergePartial<StockGenerateDeltaPayload>(this, message, value);
        return message;
    }
    internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: StockGenerateDeltaPayload): StockGenerateDeltaPayload {
        let message = target ?? this.create(), end = reader.pos + length;
        while (reader.pos < end) {
            let [fieldNo, wireType] = reader.tag();
            switch (fieldNo) {
                case /* api.EnrichedGoods Goods = 1 [json_name = "Goods"];*/ 1:
                    message.goods = EnrichedGoods.internalBinaryRead(reader, reader.uint32(), options, message.goods);
                    break;
                case /* string ActorID = 2 [json_name = "ActorID"];*/ 2:
                    message.actorID = reader.string();
                    break;
                case /* api.StockSnapshot Snapshot = 3 [json_name = "Snapshot"];*/ 3:
                    message.snapshot = StockSnapshot.internalBinaryRead(reader, reader.uint32(), options, message.snapshot);
                    break;
                case /* api.QuantityInLV QuantityInBaseLV = 4 [json_name = "QuantityInBaseLV"];*/ 4:
                    message.quantityInBaseLV = QuantityInLV.internalBinaryRead(reader, reader.uint32(), options, message.quantityInBaseLV);
                    break;
                default:
                    let u = options.readUnknownField;
                    if (u === "throw")
                        throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
                    let d = reader.skip(wireType);
                    if (u !== false)
                        (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
            }
        }
        return message;
    }
    internalBinaryWrite(message: StockGenerateDeltaPayload, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
        /* api.EnrichedGoods Goods = 1 [json_name = "Goods"]; */
        if (message.goods)
            EnrichedGoods.internalBinaryWrite(message.goods, writer.tag(1, WireType.LengthDelimited).fork(), options).join();
        /* string ActorID = 2 [json_name = "ActorID"]; */
        if (message.actorID !== "")
            writer.tag(2, WireType.LengthDelimited).string(message.actorID);
        /* api.StockSnapshot Snapshot = 3 [json_name = "Snapshot"]; */
        if (message.snapshot)
            StockSnapshot.internalBinaryWrite(message.snapshot, writer.tag(3, WireType.LengthDelimited).fork(), options).join();
        /* api.QuantityInLV QuantityInBaseLV = 4 [json_name = "QuantityInBaseLV"]; */
        if (message.quantityInBaseLV)
            QuantityInLV.internalBinaryWrite(message.quantityInBaseLV, writer.tag(4, WireType.LengthDelimited).fork(), options).join();
        let u = options.writeUnknownFields;
        if (u !== false)
            (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
        return writer;
    }
}
/**
 * @generated MessageType for protobuf message api.StockGenerateDeltaPayload
 */
export const StockGenerateDeltaPayload = new StockGenerateDeltaPayload$Type();
// @generated message type with reflection information, may provide speed optimized methods
class StockGenerateDelta$Type extends MessageType<StockGenerateDelta> {
    constructor() {
        super("api.StockGenerateDelta", [
            { no: 1, name: "Header", kind: "message", jsonName: "Header", T: () => CommandHeader },
            { no: 2, name: "ID", kind: "message", jsonName: "ID", T: () => EntityID },
            { no: 3, name: "Payload", kind: "message", jsonName: "Payload", T: () => StockGenerateDeltaPayload },
            { no: 4, name: "EventPayload", kind: "message", jsonName: "EventPayload", T: () => StockGenerateDeltaPayload },
            { no: 5, name: "PreviousPayload", kind: "message", jsonName: "PreviousPayload", T: () => StockGenerateDeltaPayload }
        ], { "api.messageType": "Command", "api.action": "GenerateDelta", "api.resultingEvent": "movement.Generated", "api.triggerEventFilters": "Snapshotted" });
    }
    create(value?: PartialMessage<StockGenerateDelta>): StockGenerateDelta {
        const message = globalThis.Object.create((this.messagePrototype!));
        if (value !== undefined)
            reflectionMergePartial<StockGenerateDelta>(this, message, value);
        return message;
    }
    internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: StockGenerateDelta): StockGenerateDelta {
        let message = target ?? this.create(), end = reader.pos + length;
        while (reader.pos < end) {
            let [fieldNo, wireType] = reader.tag();
            switch (fieldNo) {
                case /* api.CommandHeader Header = 1 [json_name = "Header"];*/ 1:
                    message.header = CommandHeader.internalBinaryRead(reader, reader.uint32(), options, message.header);
                    break;
                case /* api.EntityID ID = 2 [json_name = "ID"];*/ 2:
                    message.iD = EntityID.internalBinaryRead(reader, reader.uint32(), options, message.iD);
                    break;
                case /* api.StockGenerateDeltaPayload Payload = 3 [json_name = "Payload"];*/ 3:
                    message.payload = StockGenerateDeltaPayload.internalBinaryRead(reader, reader.uint32(), options, message.payload);
                    break;
                case /* api.StockGenerateDeltaPayload EventPayload = 4 [json_name = "EventPayload"];*/ 4:
                    message.eventPayload = StockGenerateDeltaPayload.internalBinaryRead(reader, reader.uint32(), options, message.eventPayload);
                    break;
                case /* api.StockGenerateDeltaPayload PreviousPayload = 5 [json_name = "PreviousPayload"];*/ 5:
                    message.previousPayload = StockGenerateDeltaPayload.internalBinaryRead(reader, reader.uint32(), options, message.previousPayload);
                    break;
                default:
                    let u = options.readUnknownField;
                    if (u === "throw")
                        throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
                    let d = reader.skip(wireType);
                    if (u !== false)
                        (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
            }
        }
        return message;
    }
    internalBinaryWrite(message: StockGenerateDelta, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
        /* api.CommandHeader Header = 1 [json_name = "Header"]; */
        if (message.header)
            CommandHeader.internalBinaryWrite(message.header, writer.tag(1, WireType.LengthDelimited).fork(), options).join();
        /* api.EntityID ID = 2 [json_name = "ID"]; */
        if (message.iD)
            EntityID.internalBinaryWrite(message.iD, writer.tag(2, WireType.LengthDelimited).fork(), options).join();
        /* api.StockGenerateDeltaPayload Payload = 3 [json_name = "Payload"]; */
        if (message.payload)
            StockGenerateDeltaPayload.internalBinaryWrite(message.payload, writer.tag(3, WireType.LengthDelimited).fork(), options).join();
        /* api.StockGenerateDeltaPayload EventPayload = 4 [json_name = "EventPayload"]; */
        if (message.eventPayload)
            StockGenerateDeltaPayload.internalBinaryWrite(message.eventPayload, writer.tag(4, WireType.LengthDelimited).fork(), options).join();
        /* api.StockGenerateDeltaPayload PreviousPayload = 5 [json_name = "PreviousPayload"]; */
        if (message.previousPayload)
            StockGenerateDeltaPayload.internalBinaryWrite(message.previousPayload, writer.tag(5, WireType.LengthDelimited).fork(), options).join();
        let u = options.writeUnknownFields;
        if (u !== false)
            (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
        return writer;
    }
}
/**
 * @generated MessageType for protobuf message api.StockGenerateDelta
 */
export const StockGenerateDelta = new StockGenerateDelta$Type();
// @generated message type with reflection information, may provide speed optimized methods
class StockUpdateMovementPayload$Type extends MessageType<StockUpdateMovementPayload> {
    constructor() {
        super("api.StockUpdateMovementPayload", [
            { no: 1, name: "Movement", kind: "message", jsonName: "Movement", T: () => StockMovement },
            { no: 2, name: "QuantityInBaseLV", kind: "message", jsonName: "QuantityInBaseLV", T: () => QuantityInLV }
        ], { "api.messageType": "Command", "api.payload": true, "api.action": "UpdateMovement" });
    }
    create(value?: PartialMessage<StockUpdateMovementPayload>): StockUpdateMovementPayload {
        const message = globalThis.Object.create((this.messagePrototype!));
        if (value !== undefined)
            reflectionMergePartial<StockUpdateMovementPayload>(this, message, value);
        return message;
    }
    internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: StockUpdateMovementPayload): StockUpdateMovementPayload {
        let message = target ?? this.create(), end = reader.pos + length;
        while (reader.pos < end) {
            let [fieldNo, wireType] = reader.tag();
            switch (fieldNo) {
                case /* api.StockMovement Movement = 1 [json_name = "Movement"];*/ 1:
                    message.movement = StockMovement.internalBinaryRead(reader, reader.uint32(), options, message.movement);
                    break;
                case /* api.QuantityInLV QuantityInBaseLV = 2 [json_name = "QuantityInBaseLV"];*/ 2:
                    message.quantityInBaseLV = QuantityInLV.internalBinaryRead(reader, reader.uint32(), options, message.quantityInBaseLV);
                    break;
                default:
                    let u = options.readUnknownField;
                    if (u === "throw")
                        throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
                    let d = reader.skip(wireType);
                    if (u !== false)
                        (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
            }
        }
        return message;
    }
    internalBinaryWrite(message: StockUpdateMovementPayload, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
        /* api.StockMovement Movement = 1 [json_name = "Movement"]; */
        if (message.movement)
            StockMovement.internalBinaryWrite(message.movement, writer.tag(1, WireType.LengthDelimited).fork(), options).join();
        /* api.QuantityInLV QuantityInBaseLV = 2 [json_name = "QuantityInBaseLV"]; */
        if (message.quantityInBaseLV)
            QuantityInLV.internalBinaryWrite(message.quantityInBaseLV, writer.tag(2, WireType.LengthDelimited).fork(), options).join();
        let u = options.writeUnknownFields;
        if (u !== false)
            (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
        return writer;
    }
}
/**
 * @generated MessageType for protobuf message api.StockUpdateMovementPayload
 */
export const StockUpdateMovementPayload = new StockUpdateMovementPayload$Type();
// @generated message type with reflection information, may provide speed optimized methods
class StockUpdateMovement$Type extends MessageType<StockUpdateMovement> {
    constructor() {
        super("api.StockUpdateMovement", [
            { no: 1, name: "Header", kind: "message", jsonName: "Header", T: () => CommandHeader },
            { no: 2, name: "ID", kind: "message", jsonName: "ID", T: () => EntityID },
            { no: 3, name: "Payload", kind: "message", jsonName: "Payload", T: () => StockUpdateMovementPayload },
            { no: 4, name: "EventPayload", kind: "message", jsonName: "EventPayload", T: () => StockUpdateMovementPayload },
            { no: 5, name: "PreviousPayload", kind: "message", jsonName: "PreviousPayload", T: () => StockUpdateMovementPayload }
        ], { "api.messageType": "Command", "api.action": "UpdateMovement", "api.resultingEvent": "movement.StockValueUpdated", "api.triggerEventFilters": "Moved" });
    }
    create(value?: PartialMessage<StockUpdateMovement>): StockUpdateMovement {
        const message = globalThis.Object.create((this.messagePrototype!));
        if (value !== undefined)
            reflectionMergePartial<StockUpdateMovement>(this, message, value);
        return message;
    }
    internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: StockUpdateMovement): StockUpdateMovement {
        let message = target ?? this.create(), end = reader.pos + length;
        while (reader.pos < end) {
            let [fieldNo, wireType] = reader.tag();
            switch (fieldNo) {
                case /* api.CommandHeader Header = 1 [json_name = "Header"];*/ 1:
                    message.header = CommandHeader.internalBinaryRead(reader, reader.uint32(), options, message.header);
                    break;
                case /* api.EntityID ID = 2 [json_name = "ID"];*/ 2:
                    message.iD = EntityID.internalBinaryRead(reader, reader.uint32(), options, message.iD);
                    break;
                case /* api.StockUpdateMovementPayload Payload = 3 [json_name = "Payload"];*/ 3:
                    message.payload = StockUpdateMovementPayload.internalBinaryRead(reader, reader.uint32(), options, message.payload);
                    break;
                case /* api.StockUpdateMovementPayload EventPayload = 4 [json_name = "EventPayload"];*/ 4:
                    message.eventPayload = StockUpdateMovementPayload.internalBinaryRead(reader, reader.uint32(), options, message.eventPayload);
                    break;
                case /* api.StockUpdateMovementPayload PreviousPayload = 5 [json_name = "PreviousPayload"];*/ 5:
                    message.previousPayload = StockUpdateMovementPayload.internalBinaryRead(reader, reader.uint32(), options, message.previousPayload);
                    break;
                default:
                    let u = options.readUnknownField;
                    if (u === "throw")
                        throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
                    let d = reader.skip(wireType);
                    if (u !== false)
                        (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
            }
        }
        return message;
    }
    internalBinaryWrite(message: StockUpdateMovement, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
        /* api.CommandHeader Header = 1 [json_name = "Header"]; */
        if (message.header)
            CommandHeader.internalBinaryWrite(message.header, writer.tag(1, WireType.LengthDelimited).fork(), options).join();
        /* api.EntityID ID = 2 [json_name = "ID"]; */
        if (message.iD)
            EntityID.internalBinaryWrite(message.iD, writer.tag(2, WireType.LengthDelimited).fork(), options).join();
        /* api.StockUpdateMovementPayload Payload = 3 [json_name = "Payload"]; */
        if (message.payload)
            StockUpdateMovementPayload.internalBinaryWrite(message.payload, writer.tag(3, WireType.LengthDelimited).fork(), options).join();
        /* api.StockUpdateMovementPayload EventPayload = 4 [json_name = "EventPayload"]; */
        if (message.eventPayload)
            StockUpdateMovementPayload.internalBinaryWrite(message.eventPayload, writer.tag(4, WireType.LengthDelimited).fork(), options).join();
        /* api.StockUpdateMovementPayload PreviousPayload = 5 [json_name = "PreviousPayload"]; */
        if (message.previousPayload)
            StockUpdateMovementPayload.internalBinaryWrite(message.previousPayload, writer.tag(5, WireType.LengthDelimited).fork(), options).join();
        let u = options.writeUnknownFields;
        if (u !== false)
            (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
        return writer;
    }
}
/**
 * @generated MessageType for protobuf message api.StockUpdateMovement
 */
export const StockUpdateMovement = new StockUpdateMovement$Type();
