public DipsNabChq CreateNewDipsNabChq(
            string batchNumber,
            string documentReferenceNumber,
            DateTime processingDate,
            string extraAuxDom,
            bool extraAuxDomStatus,
            string auxDom,
            bool auxDomStatus,
            string bsbNumber,
            bool bsbNumberStatus,
            string accountNumber,
            bool accountNumberStatus,
            string transactionCode,
            bool transactionCodeStatus,
            string capturedAmount,
            string amountConfidenceLevel,
            string documentType,
            string jobId,
            string manualRepair,
            string amount,
            bool amountStatus,
            string captureBsb,
            string batchAccountNumber,
            string processingState,
            string collectingBank,
            string unitId,
            bool tpcRequired,
            
            string preAdjustmentAmount,
            bool adjustedFlag,
            bool thirdPartyCheckFailed,
            bool thirdPartyPoolFlag,
            bool highValueFlag,
            string voucherDelayedIndicator,
            string batchType,
            
            bool unprocessable,
            bool unencodedEcdReturnFlag,
            string transactionLinkNumber,
            bool thirdPartyMixedDepositReturnFlag,
            bool suspectFraud,
            bool surplusItemFlag,
            string rawMicr,
            string rawOcr,
            string presentationMode,
            bool isGeneratedVoucher,
            bool adjustmentsOnHold,

            string dipsTraceNumber,
            string dipsSequenceNumber,

            bool adjustmentLetterRequired,

            bool postTransmissionQaAmountFlag,
            bool postTransmissionQaCodelineFlag,

            string adjustmentReasonCode,
            string adjustmentDescription,

            string subBatchType
            )
        {
            if (string.IsNullOrEmpty(batchNumber))
            {
                batchNumber = randomBatchNumber.ToString();
            }

            if (string.IsNullOrEmpty(jobId))
            {
                jobId = DipsJobIdType.NabChqPod.Value;
            }

            if (WorkTypeEnum.NABCHQ_POD.ToString().Equals(jobId))
            {
                jobId = DipsJobIdType.NabChqPod.Value;
            }

            string originalDocumentReferenceNumber = documentReferenceNumber.Substring(documentReferenceNumber.Length - 9);
            //documentReferenceNumber = RequestHelper.ResolveDocumentReferenceNumber(documentReferenceNumber);
            
            if (string.IsNullOrEmpty(dipsTraceNumber))
            {
                documentReferenceNumber = RequestHelper.ResolveDocumentReferenceNumber(documentReferenceNumber);
            }
            else
            {
                documentReferenceNumber = RequestHelper.ResolveDocumentReferenceNumber(dipsTraceNumber);
            }

            if (string.IsNullOrEmpty(dipsSequenceNumber))
            {

                dipsSequenceNumber = "0000 ";
            }
            
            // calculate a value for the S_STATUS1 field, which represents a
            // bitmask of invalid fields in Dips
            int statusMask = DipsStatus1Bitmask.GetStatusMask(extraAuxDomStatus, auxDomStatus, accountNumberStatus,
                amountStatus, bsbNumberStatus, transactionCodeStatus);

            var output = new DipsNabChq
            {
                //Dynamic DipsNabChq Values
                S_BATCH = batchNumber.PadRight(8, '0'),
                S_TRACE = documentReferenceNumber.PadLeft(9, '0'),
                acc_num = accountNumber,
                adjustedFlag = RequestHelper.ConvertBoolToIntString(adjustedFlag),
                amount = string.IsNullOrEmpty(capturedAmount) ? amount : capturedAmount,
                amountConfidenceLevel = amountConfidenceLevel,
                batch = batchNumber.PadRight(8, '0'),
                batchAccountNumber = batchAccountNumber,
                batch_type = batchType,
                bsb_num = bsbNumber,
                captureBSB = captureBsb,
                collecting_bank = collectingBank,
                doc_ref_num = originalDocumentReferenceNumber,
                doc_type = documentType,
                ead = RequestHelper.ConvertNullValueToEmptyString(extraAuxDom),
                fxa_tpc_suspense_pool_flag = RequestHelper.ConvertBoolToIntString(thirdPartyPoolFlag),
                fxa_unencoded_ECD_return = RequestHelper.ConvertBoolToIntString(unencodedEcdReturnFlag),
                highValueFlag = RequestHelper.ConvertBoolToIntString(highValueFlag),
                isGeneratedVoucher = RequestHelper.ConvertBoolToIntString(isGeneratedVoucher),
                job_id = jobId.PadRight(15, ' '),
                man_rep_ind = manualRepair,
                micr_suspect_fraud_flag = RequestHelper.ConvertBoolToIntString(suspectFraud),
                orig_amount = preAdjustmentAmount,
                presentationMode = presentationMode,
                proc_date = processingDate.ToString("yyyyMMdd"),
                processing_state = processingState,
                raw_micr = rawMicr,
                raw_ocr = rawOcr,
                ser_num = RequestHelper.ConvertNullValueToEmptyString(auxDom),
                surplusItemFlag = RequestHelper.ConvertBoolToIntString(surplusItemFlag),
                tpcMixedDepRet = RequestHelper.ConvertBoolToIntString(thirdPartyMixedDepositReturnFlag),
                tpcRequired = RequestHelper.ConvertBoolToYNString(tpcRequired),
                trace = documentReferenceNumber.PadLeft(9, '0'),
                trancode = RequestHelper.ConvertNullValueToEmptyString(transactionCode),
                transactionLinkNumber = transactionLinkNumber,
                unit_id = unitId,
                unproc_flag = RequestHelper.ConvertBoolToIntString(unprocessable),
                voucherIndicatorField = voucherDelayedIndicator,

                S_SEQUENCE = dipsSequenceNumber,

                adjustmentLetterRequired = RequestHelper.ConvertBoolToIntString(adjustmentLetterRequired),

                fxaPtQAAmtFlag = RequestHelper.ConvertBoolToIntString(postTransmissionQaAmountFlag),
                fxaPtQACodelineFlag = RequestHelper.ConvertBoolToIntString(postTransmissionQaCodelineFlag),

                adjustmentReasonCode = adjustmentReasonCode,
                adjustmentDescription = adjustmentDescription,
                sub_batch_type = subBatchType,

                //Default DipsNabChq Values
                //mandatory fields
                S_DEL_IND = ZeroString(5),
                S_MODIFIED = ZeroString(5),
                S_COMPLETE = ZeroString(5),
                S_TYPE = ZeroString(5),
                S_STATUS1 = statusMask.ToString().PadLeft(9, ' '),
                S_STATUS2 = ZeroString(9),
                S_STATUS3 = ZeroString(9),
                S_STATUS4 = ZeroString(9),
                S_IMG1_OFF = ZeroString(9),
                S_IMG1_LEN = ZeroString(9),
                S_IMG1_TYP = ZeroString(5),
                S_IMG2_OFF = ZeroString(9),
                S_IMG2_LEN = ZeroString(9),
                S_IMG2_TYP = ZeroString(5),
                S_LENGTH = SLength,
                //S_SEQUENCE = "0000 ",
                S_BALANCE = ZeroString(6),
                S_REPROCESS = ZeroString(5),
                S_REPORTED = ZeroString(5),
                S_COMMITTED = ZeroString(5),
                //custom fields
                sys_date = dateTimeProvider.CurrentTimeInAustralianEasternTimeZone().ToString("yyyyMMdd"),
                //ignored fields
                pocket = ZeroString(2),
                payee_name = IgnoreString(240),
                manual_repair = IgnoreString(5),
                rec_type_id = IgnoreString(4),
                proof_seq = IgnoreString(12),
                trans_seq = IgnoreString(5),
                delay_ind = IgnoreString(1),
                fv_exchange = IgnoreString(1),
                adj_code = IgnoreString(2),
                adj_desc = IgnoreString(30),
                op_id = IgnoreString(15),
                proc_time = IgnoreString(4),
                @override = IgnoreString(5),
                fv_ind = IgnoreString(1),
                host_trans_no = IgnoreString(3),
                volume = IgnoreString(8),
                img_location = IgnoreString(80),
                img_front = IgnoreString(8),
                img_rear = IgnoreString(8),
                held_ind = IgnoreString(1),
                receiving_bank = IgnoreString(3),
                ie_transaction_id = IgnoreString(12),
                micr_flag = IgnoreString(1),
                micr_unproc_flag = IgnoreString(1),
            
                

                adjustedBy = IgnoreString(15),
                //adjustmentsOnHold = IgnoreString(1),
                //adjustedFlag = IgnoreString(1),
                
                adjustmentType = IgnoreString(9)
            };
            return output;
        }
        public DipsNabChq CreateNewDipsNabChq(
            string batchNumber,
            string documentReferenceNumber,
            DateTime processingDate,
            string extraAuxDom,
            bool extraAuxDomStatus,
            string auxDom,
            bool auxDomStatus,
            string bsbNumber,
            bool bsbNumberStatus,
            string accountNumber,
            bool accountNumberStatus,
            string transactionCode,
            bool transactionCodeStatus,
            string capturedAmount,
            string amountConfidenceLevel,
            string documentType,
            string jobId,
            string manualRepair,
            string amount,
            bool amountStatus,
            string captureBsb,
            string batchAccountNumber,
            string processingState,
            string collectingBank,
            string unitId,
            string batchType,
            string repostFromDRN,
            DateTime? repostFromProcessingDate,
            string batchCollectingBank,
            string subBatchType,
            bool creditNoteFlag)
        {
            if (string.IsNullOrEmpty(jobId))
            {
                jobId = DipsJobIdType.NabChqPod.Value;
            }

            if (WorkTypeEnum.NABCHQ_POD.ToString().Equals(jobId))
            {
                jobId = DipsJobIdType.NabChqPod.Value;
            }
            else if (WorkTypeEnum.NABCHQ_LBOX.ToString().Equals(jobId))
            {
                jobId = DipsJobIdType.NabChqLBox.Value;
            }

            // calculate a value for the S_STATUS1 field, which represents a bitmask of invalid fields in Dips
            int statusMask = DipsStatus1Bitmask.GetStatusMask(extraAuxDomStatus, auxDomStatus, accountNumberStatus,
                amountStatus, bsbNumberStatus, transactionCodeStatus);

            var output = new DipsNabChq
            {
                //Dynamic DipsNabChq Values
                S_BATCH = batchNumber.PadRight(8, '0'),
                S_TRACE = documentReferenceNumber.PadLeft(9, '0'),
                acc_num = accountNumber,
                amount = string.IsNullOrEmpty(capturedAmount) ? amount : capturedAmount,
                amountConfidenceLevel = RequestHelper.ResolveAmountConfidenceLevel(amountConfidenceLevel),
                batch = batchNumber.PadRight(8, '0'),
                batchAccountNumber = batchAccountNumber,
                batch_type = batchType,
                bsb_num = bsbNumber,
                captureBSB = captureBsb,
                //collecting_bank = collectingBank,
                collecting_bank = RequestHelper.ResolveCollectingBank(collectingBank, batchCollectingBank),

                doc_ref_num = documentReferenceNumber,
                doc_type = documentType,
                ead = RequestHelper.ConvertNullValueToEmptyString(extraAuxDom),
                job_id = jobId.PadRight(15, ' '),
                man_rep_ind = manualRepair,
                proc_date = processingDate.ToString("yyyyMMdd"),
                processing_state = processingState,
                ser_num = RequestHelper.ConvertNullValueToEmptyString(auxDom),
                trace = documentReferenceNumber.PadLeft(9, '0'),
                trancode = RequestHelper.ConvertNullValueToEmptyString(transactionCode),
                unit_id = unitId,

                repostFromDRN = repostFromDRN,
                repostFromProcessingDate = RequestHelper.ConvertNullableDateToString(repostFromProcessingDate),
                sub_batch_type = subBatchType,

                creditNoteFlag = RequestHelper.ConvertBoolToIntString(creditNoteFlag),

                //Default DipsNabChq Values
                //mandatory fields
                S_DEL_IND = ZeroString(5),
                S_MODIFIED = ZeroString(5),
                S_COMPLETE = ZeroString(5),
                S_TYPE = ZeroString(5),
                S_STATUS1 = statusMask.ToString().PadLeft(9, ' '),
                S_STATUS2 = ZeroString(9),
                S_STATUS3 = ZeroString(9),
                S_STATUS4 = ZeroString(9),
                S_IMG1_OFF = ZeroString(9),
                S_IMG1_LEN = ZeroString(9),
                S_IMG1_TYP = ZeroString(5),
                S_IMG2_OFF = ZeroString(9),
                S_IMG2_LEN = ZeroString(9),
                S_IMG2_TYP = ZeroString(5),
                S_LENGTH = SLength,
                S_SEQUENCE = "0000 ",
                S_BALANCE = ZeroString(6),
                S_REPROCESS = ZeroString(5),
                S_REPORTED = ZeroString(5),
                S_COMMITTED = ZeroString(5),
                //custom fields
                sys_date = dateTimeProvider.CurrentTimeInAustralianEasternTimeZone().ToString("yyyyMMdd"),
                //ignored fields
                pocket = ZeroString(2),
                payee_name = IgnoreString(240),
                manual_repair = IgnoreString(5),
                rec_type_id = IgnoreString(4),
                proof_seq = IgnoreString(12),
                trans_seq = IgnoreString(5),
                delay_ind = IgnoreString(1),
                fv_exchange = IgnoreString(1),
                adj_code = IgnoreString(2),
                adj_desc = IgnoreString(30),
                op_id = IgnoreString(15),
                proc_time = IgnoreString(4),
                @override = IgnoreString(5),
                fv_ind = IgnoreString(1),
                host_trans_no = IgnoreString(3),
                volume = IgnoreString(8),
                img_location = IgnoreString(80),
                img_front = IgnoreString(8),
                img_rear = IgnoreString(8),
                held_ind = IgnoreString(1),
                receiving_bank = IgnoreString(3),
                ie_transaction_id = IgnoreString(12),
                raw_micr = IgnoreString(64),
                raw_ocr = IgnoreString(64),
                micr_flag = IgnoreString(1),
                micr_unproc_flag = IgnoreString(1),
                micr_suspect_fraud_flag = IgnoreString(1),
                presentationMode = IgnoreString(1),
                adjustmentReasonCode = IgnoreString(2),
                adjustmentDescription = IgnoreString(60),
                adjustedBy = IgnoreString(15),
                adjustedFlag = IgnoreString(1),
                adjustmentLetterRequired = IgnoreString(1),
                adjustmentType = IgnoreString(9)
            };
            return output;
        }
        public DipsNabChq CreateNewDipsNabChqForValidateTransactionRequest(
            string batchNumber,
            string traceId,
            DateTime processingDate,
            string reasonCode,
            string transactionLinkNumber,
            bool unprocessable,
            string extraAuxDom,
            bool extraAuxDomStatus,
            string auxDom,
            bool auxDomStatus,
            string bsbNumber,
            bool bsbNumberStatus,
            string accountNumber,
            bool accountNumberStatus,
            string transactionCode,
            bool transactionCodeStatus,
            string capturedAmount,
            bool amountStatus,
            string documentType,
            string jobId,
            string rawMicr,
            string rawOcr,
            string captureBsb,
            string batchAccountNumber,
            string processingState,
            string collectingBank,
            string unitId,
            string forValueIndicator,
            string dipsOverride,
            string batchType,
            bool postTransmissionQaAmountFlag,
            bool postTransmissionQaCodelineFlag,
            string subBatchType)
        {
            // calculate a value for the S_STATUS1 field, which represents a
            // bitmask of invalid fields in Dips
            int statusMask = DipsStatus1Bitmask.GetStatusMask(extraAuxDomStatus, auxDomStatus, accountNumberStatus,
                amountStatus, bsbNumberStatus, transactionCodeStatus);

            //traceId = traceId.Substring(traceId.Length - 9);
            //traceId = ResolveTraceNumber(traceId);
            traceId = RequestHelper.ResolveDocumentReferenceNumber(traceId);

            if (string.IsNullOrEmpty(jobId))
            {
                jobId = DipsJobIdType.NabChqPod.Value;
            }

            if (WorkTypeEnum.NABCHQ_POD.ToString().Equals(jobId))
            {
                jobId = DipsJobIdType.NabChqPod.Value;
            }

            var output = new DipsNabChq
            {
                //Dynamic DipsNabChq Values
                @override = dipsOverride,
                S_BATCH = batchNumber.PadRight(8, '0'),
                S_TRACE = traceId.PadLeft(9, '0'),
                acc_num = accountNumber,
                amount = capturedAmount ?? string.Empty,
                balanceReason = reasonCode,
                batch = batchNumber.PadRight(8, '0'),
                batchAccountNumber = batchAccountNumber,
                batch_type = batchType,
                bsb_num = bsbNumber,
                captureBSB = captureBsb,
                collecting_bank = collectingBank,
                doc_type = documentType,
                ead = RequestHelper.ConvertNullValueToEmptyString(extraAuxDom),
                fv_ind = RequestHelper.ConvertNullValueToEmptyString(forValueIndicator),
                fxaPtQAAmtFlag = RequestHelper.ConvertBoolToIntString(postTransmissionQaAmountFlag),
                fxaPtQACodelineFlag = RequestHelper.ConvertBoolToIntString(postTransmissionQaCodelineFlag),
                job_id = jobId.PadRight(15, ' '),
                micr_unproc_flag = Convert.ToInt32(unprocessable).ToString(CultureInfo.InvariantCulture),
                proc_date = processingDate.ToString("yyyyMMdd"),
                processing_state = processingState,
                raw_micr = rawMicr,
                raw_ocr = rawOcr,
                ser_num = RequestHelper.ConvertNullValueToEmptyString(auxDom),
                trace = traceId.PadLeft(9, '0'),
                trancode = RequestHelper.ConvertNullValueToEmptyString(transactionCode),
                transactionLinkNumber = transactionLinkNumber,
                unit_id = unitId,
                unproc_flag = Convert.ToInt32(unprocessable).ToString(CultureInfo.InvariantCulture),
                sub_batch_type = subBatchType,

                //Default DipsNabChq Values
                //mandatory fields
                S_DEL_IND = ZeroString(5),
                S_MODIFIED = ZeroString(5),
                S_COMPLETE = ZeroString(5),
                S_TYPE = ZeroString(5),
                S_STATUS1 = statusMask.ToString().PadLeft(9, ' '),
                S_STATUS2 = ZeroString(9),
                S_STATUS3 = ZeroString(9),
                S_STATUS4 = ZeroString(9),
                S_IMG1_OFF = ZeroString(9),
                S_IMG1_LEN = ZeroString(9),
                S_IMG1_TYP = ZeroString(5),
                S_IMG2_OFF = ZeroString(9),
                S_IMG2_LEN = ZeroString(9),
                S_IMG2_TYP = ZeroString(5),
                S_LENGTH = SLength,
                S_SEQUENCE = "0000 ",
                S_BALANCE = ZeroString(6),
                S_REPROCESS = ZeroString(5),
                S_REPORTED = ZeroString(5),
                S_COMMITTED = ZeroString(5),
                //custom fields
                sys_date = dateTimeProvider.CurrentTimeInAustralianEasternTimeZone().ToString("yyyyMMdd"),
                //ignored fields
                pocket = ZeroString(2),
                man_rep_ind = "0",
                payee_name = IgnoreString(240),
                manual_repair = IgnoreString(5),
                rec_type_id = IgnoreString(4),
                proof_seq = IgnoreString(12),
                trans_seq = IgnoreString(5),
                delay_ind = IgnoreString(1),
                fv_exchange = IgnoreString(1),
                adj_code = IgnoreString(2),
                adj_desc = IgnoreString(30),
                op_id = IgnoreString(15),
                proc_time = IgnoreString(4),
                host_trans_no = IgnoreString(3),
                volume = IgnoreString(8),
                img_location = IgnoreString(80),
                img_front = IgnoreString(8),
                img_rear = IgnoreString(8),
                held_ind = IgnoreString(1),
                receiving_bank = IgnoreString(3),
                ie_transaction_id = IgnoreString(12),
                doc_ref_num = IgnoreString(9),
                micr_flag = IgnoreString(1),
                micr_suspect_fraud_flag = IgnoreString(1),
                presentationMode = IgnoreString(1),
                adjustmentReasonCode = IgnoreString(2),
                adjustmentDescription = IgnoreString(60),
                adjustedBy = IgnoreString(15),
                adjustedFlag = IgnoreString(1),
                adjustmentLetterRequired = IgnoreString(1),
                adjustmentType = IgnoreString(9)
            };
            return output;
        }