private void RecordLedgerRecordAsync(Journal journal, Transaction transaction) { var cashOutLedgerRecord = new LedgerRecord { LedgerId = journal.Ledgers.FirstOrDefault(l => l.Type == "cash-out").Id, Amount = transaction.Amount, TimeStamp = transaction.TimeStamp }; var principalLedgerRecord = new LedgerRecord { LedgerId = journal.Ledgers.FirstOrDefault(l => l.Type == "principal").Id, Amount = transaction.Amount, TimeStamp = transaction.TimeStamp }; switch (transaction.Type.ToLower()) { case "purchase": cashOutLedgerRecord.Type = "debit"; principalLedgerRecord.Type = "credit"; break; case "payment": cashOutLedgerRecord.Type = "credit"; principalLedgerRecord.Type = "debit"; break; default: throw new ArgumentException("Unknown transaction type"); } transaction.LedgerRecords.Add(cashOutLedgerRecord); transaction.LedgerRecords.Add(principalLedgerRecord); }
/// <summary> /// Withdraw /// </summary> /// <exception cref="Io.Gate.GateApi.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="ledgerRecord"></param> /// <returns>ApiResponse of LedgerRecord</returns> public ApiResponse <LedgerRecord> WithdrawWithHttpInfo(LedgerRecord ledgerRecord) { // verify the required parameter 'ledgerRecord' is set if (ledgerRecord == null) { throw new ApiException(400, "Missing required parameter 'ledgerRecord' when calling WithdrawalApi->Withdraw"); } RequestOptions localVarRequestOptions = new RequestOptions(); string[] _contentTypes = { "application/json" }; // to determine the Accept header string[] _accepts = { "application/json" }; var localVarContentType = ClientUtils.SelectHeaderContentType(_contentTypes); if (localVarContentType != null) { localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); } var localVarAccept = ClientUtils.SelectHeaderAccept(_accepts); if (localVarAccept != null) { localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); } localVarRequestOptions.Data = ledgerRecord; // authentication (apiv4) required localVarRequestOptions.RequireApiV4Auth = true; // make the HTTP request var localVarResponse = this.Client.Post <LedgerRecord>("/withdrawals", localVarRequestOptions, this.Configuration); if (this.ExceptionFactory != null) { Exception _exception = this.ExceptionFactory("Withdraw", localVarResponse); if (_exception != null) { throw _exception; } } return(localVarResponse); }
/// <summary> /// Withdraw /// </summary> /// <exception cref="Io.Gate.GateApi.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="ledgerRecord"></param> /// <returns>Task of ApiResponse (LedgerRecord)</returns> public async Task <ApiResponse <LedgerRecord> > WithdrawAsyncWithHttpInfo(LedgerRecord ledgerRecord) { // verify the required parameter 'ledgerRecord' is set if (ledgerRecord == null) { throw new ApiException(400, "Missing required parameter 'ledgerRecord' when calling WithdrawalApi->Withdraw"); } RequestOptions localVarRequestOptions = new RequestOptions(); String[] _contentTypes = new String[] { "application/json" }; // to determine the Accept header String[] _accepts = new String[] { "application/json" }; foreach (var _contentType in _contentTypes) { localVarRequestOptions.HeaderParameters.Add("Content-Type", _contentType); } foreach (var _accept in _accepts) { localVarRequestOptions.HeaderParameters.Add("Accept", _accept); } localVarRequestOptions.Data = ledgerRecord; // authentication (apiv4) required localVarRequestOptions.RequireApiV4Auth = true; // make the HTTP request var localVarResponse = await this.AsynchronousClient.PostAsync <LedgerRecord>("/withdrawals", localVarRequestOptions, this.Configuration); if (this.ExceptionFactory != null) { Exception _exception = this.ExceptionFactory("Withdraw", localVarResponse); if (_exception != null) { throw _exception; } } return(localVarResponse); }
public void WriteLedgerRecord(LedgerRecord ledgerRecord, StringBuilder stringBuilder) { Write(stringBuilder, "L"); Write(stringBuilder, ledgerRecord.TransactionDate); Write(stringBuilder, ledgerRecord.AccountID); Write(stringBuilder, ledgerRecord.AccountName); Write(stringBuilder, ledgerRecord.TransactionDescription); Write(stringBuilder, ledgerRecord.Name); Write(stringBuilder, ledgerRecord.TransactionID); Write(stringBuilder, ledgerRecord.SourceDocumentID); Write(stringBuilder, ledgerRecord.SourceType); Write(stringBuilder, RoundAmount(ledgerRecord.DebitAmount)); Write(stringBuilder, RoundAmount(ledgerRecord.CreditAmount)); WriteLast(stringBuilder, RoundAmount(ledgerRecord.BalanceAmount)); }
private LedgerRecord BuildLedgerRecordForTran(Account account, GLTran tran, LedgerRecord prevLedgerRecord) { var ledgerRecord = new LedgerRecord(); ledgerRecord.AccountID = account.AccountCD; ledgerRecord.AccountName = account.Description; ledgerRecord.TransactionDate = tran.TranDate.Value; ledgerRecord.TransactionDescription = tran.TranDesc; ledgerRecord.Name = GetContragentCompanyNameIfApplicable(tran); ledgerRecord.TransactionID = tran.BatchNbr; ledgerRecord.SourceDocumentID = tran.RefNbr; ledgerRecord.SourceType = tran.Module; ledgerRecord.DebitAmount = tran.DebitAmt.Value; ledgerRecord.CreditAmount = tran.CreditAmt.Value; ledgerRecord.BalanceAmount = prevLedgerRecord.BalanceAmount + ledgerRecord.DebitAmount - ledgerRecord.CreditAmount; return(ledgerRecord); }
public async Task <bool> WriteLedger(LedgerRecord record) { throw new NotImplementedException(); }
/// <summary> /// Withdraw /// </summary> /// <exception cref="Io.Gate.GateApi.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="ledgerRecord"></param> /// <returns>Task of LedgerRecord</returns> public async Task <LedgerRecord> WithdrawAsync(LedgerRecord ledgerRecord) { Io.Gate.GateApi.Client.ApiResponse <LedgerRecord> localVarResponse = await WithdrawAsyncWithHttpInfo(ledgerRecord); return(localVarResponse.Data); }
/// <summary> /// Withdraw /// </summary> /// <exception cref="Io.Gate.GateApi.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="ledgerRecord"></param> /// <returns>LedgerRecord</returns> public LedgerRecord Withdraw(LedgerRecord ledgerRecord) { ApiResponse <LedgerRecord> localVarResponse = WithdrawWithHttpInfo(ledgerRecord); return(localVarResponse.Data); }