# Path: core/gui/util.py
# def splitted_splits(splits):
#     """Returns `splits` separated in two groups ("froms" and "tos").
# 
#     "froms" are splits with a negative amount and "tos", the positive ones. Null splits are
#     generally sent to the "froms" side, unless "tos" is empty.
# 
#     Returns ``(froms, tos)``.
#     """
#     null_amounts = [s for s in splits if s.amount == 0]
#     froms = [s for s in splits if s.amount < 0]
#     tos = [s for s in splits if s.amount > 0]
#     if not tos and null_amounts:
#         tos.append(null_amounts.pop())
#     froms += null_amounts
#     return froms, tos


import datetime
from operator import attrgetter
from core.trans import trget, tr
from .column import Column
from ..model._ccore import amount_convert, Transaction
from .table import Row, RowWithDateMixIn, rowattr
from .transaction_table_base import TransactionTableBase
from .util import splitted_splits
        self.load()

    def _autofill_row(self, ref_row, dest_attrs):
        self._amount_fmt = None
        if len(ref_row.transaction.splits) > 2:
            dest_attrs.discard('_from')
            dest_attrs.discard('_to')
        Row._autofill_row(self, ref_row, dest_attrs)

    def _get_autofill_attrs(self):
        return AUTOFILL_ATTRS

    def _get_autofill_rows(self):
        original = self.transaction
        transactions = sorted(self.document.transactions, key=attrgetter('mtime'), reverse=True)
        for transaction in transactions:
            if transaction is original:
                continue
            yield TransactionTableRow(self.table, transaction)

    # --- Public
    def can_edit(self):
        return True

    def load(self):
        transaction = self.transaction
        self._load_from_fields(transaction, self.FIELDS)
        self._date_fmt = None
        self._position = transaction.position
        splits = transaction.splits

# Path: core/gui/util.py
# def splitted_splits(splits):
#     """Returns `splits` separated in two groups ("froms" and "tos").
# 
#     "froms" are splits with a negative amount and "tos", the positive ones. Null splits are
#     generally sent to the "froms" side, unless "tos" is empty.
# 
#     Returns ``(froms, tos)``.
#     """
#     null_amounts = [s for s in splits if s.amount == 0]
#     froms = [s for s in splits if s.amount < 0]
#     tos = [s for s in splits if s.amount > 0]
#     if not tos and null_amounts:
#         tos.append(null_amounts.pop())
#     froms += null_amounts
#     return froms, tos


# Path: core/gui/transaction_table.py
import datetime
from operator import attrgetter
from core.trans import trget, tr
from .column import Column
from ..model._ccore import amount_convert, Transaction
from .table import Row, RowWithDateMixIn, rowattr
from .transaction_table_base import TransactionTableBase
from .util import splitted_splits

        self.load()

    def _autofill_row(self, ref_row, dest_attrs):
        self._amount_fmt = None
        if len(ref_row.transaction.splits) > 2:
            dest_attrs.discard('_from')
            dest_attrs.discard('_to')
        Row._autofill_row(self, ref_row, dest_attrs)

    def _get_autofill_attrs(self):
        return AUTOFILL_ATTRS

    def _get_autofill_rows(self):
        original = self.transaction
        transactions = sorted(self.document.transactions, key=attrgetter('mtime'), reverse=True)
        for transaction in transactions:
            if transaction is original:
                continue
            yield TransactionTableRow(self.table, transaction)

    # --- Public
    def can_edit(self):
        return True

    def load(self):
        transaction = self.transaction
        self._load_from_fields(transaction, self.FIELDS)
        self._date_fmt = None
        self._position = transaction.position
        splits = transaction.splits

        froms, tos = splitted_splits(splits)