using PayRollDAL.DTO.SAP; using System.Collections.Generic; namespace PayRollBLL.SAP.Builders { /// /// One SAP POST target produced by a builder. /// Most infotypes produce a single sub-type per declaration; infotype 584 produces two /// (Housing Loan and Other Income Sources), each targeting a separate OData endpoint. /// /// SAP infotype number this sub-payload belongs to. /// Human-readable sub-type label, e.g. "Housing Loan". /// OData entity-set path to POST to. /// Response navigation property carrying SAP messages. /// Serialized JSON body to POST. public record SapSubtypePayload( int Infotype, string Description, string EndpointPath, string MsgNavProperty, string Json); /// /// Contract for a builder that transforms flat declaration rows into one or more /// SAP OData POST payloads. Each implementation handles exactly one SAP infotype (580–586). /// public interface ISapInfotypeBuilder { /// SAP infotype number (580–586). int Infotype { get; } /// Human-readable name used in messages and audit logs, e.g. "HRA / Rent Paid". string DisplayName { get; } /// /// Primary OData entity-set endpoint path. /// For infotypes with multiple sub-types (e.g. 584) this is the first sub-type's path. /// string EndpointPath { get; } /// /// Navigation property name carrying SAP messages in the primary sub-type response. /// string MsgNavProperty { get; } /// /// Builds the primary JSON payload for this infotype. /// Returns an empty string when contains no relevant data. /// Used by preview / download endpoints; push logic uses instead. /// string Build(IEnumerable rows, string date, string remarks); /// /// Returns all sub-type payloads to POST for this infotype. /// The default implementation wraps in a single-item result. /// Infotypes with multiple sub-types (e.g. 584) override this to yield additional items. /// IEnumerable BuildAll( IEnumerable rows, string date, string remarks) { string json = Build(rows, date, remarks); if (!string.IsNullOrEmpty(json)) yield return new SapSubtypePayload(Infotype, string.Empty, EndpointPath, MsgNavProperty, json); } } }