<commit_before>'use strict';

import models, { sequelize, Op } from '../server/models';
import Promise from 'bluebird';

const fetchTransactions = async () => {
  const query = { where: { taxAmount: { [Op.gt]: 0 } } };
  return await models.Transaction.findAll(query);
};

const toNegative = n => (n > 0 ? -n : n);

const fixTransaction = transaction => {
  const updatedTransaction = { ...transaction.dataValues };
  delete updatedTransaction.id;
  updatedTransaction.taxAmount = toNegative(transaction.taxAmount);
  if (transaction.type === 'CREDIT') {
    updatedTransaction.netAmountInCollectiveCurrency =
      transaction.netAmountInCollectiveCurrency + updatedTransaction.taxAmount;
  } else if (transaction.type === 'DEBIT') {<commit_msg>specify attributes in migration to avoid issues in the future<commit_after>'use strict';

import models, { sequelize, Op } from '../server/models';
import Promise from 'bluebird';

const fetchTransactions = async () => {
  const query = {
    attributes: [
      'id',
      'type',
      'description',
      'amount',
      'currency',
      'createdAt',
      'updatedAt',
      'CollectiveId',
      'CreatedByUserId',
      'PaymentMethodId',
      'deletedAt',
      'data',
      'OrderId',
      'platformFeeInHostCurrency',
      'hostFeeInHostCurrency',
      'paymentProcessorFeeInHostCurrency',
      'hostCurrency',
      'hostCurrencyFxRate',
      'amountInHostCurrency',
      'netAmountInCollectiveCurrency',
      'ExpenseId',
      'uuid',
      'FromCollectiveId',
      'HostCollectiveId',
      'TransactionGroup',
      'RefundTransactionId',
      'UsingVirtualCardFromCollectiveId',
      'taxAmount',
    ],
    where: { taxAmount: { [Op.gt]: 0 } },
  };
  return await models.Transaction.findAll(query);
};

const toNegative = n => (n > 0 ? -n : n);

const fixTransaction = transaction => {
  const updatedTransaction = { ...transaction.dataValues };
  delete updatedTransaction.id;
  updatedTransaction.taxAmount = toNegative(transaction.taxAmount);
  if (transaction.type === 'CREDIT') {
    updatedTransaction.netAmountInCollectiveCurrency =
      transaction.netAmountInCollectiveCurrency + updatedTransaction.taxAmount;
  } else if (transaction.type === 'DEBIT') {
{'fraction_non_alphanumeric': 0.13068688670829617, 'fraction_numerical': 0.001784121320249777, 'mean_word_length': 3.624742268041237, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3102323', 'n_tokens_mistral': 643, 'n_tokens_neox': 644, 'n_words': 140}