# Path: exactonline/elements/base.py
# class ExactElement(object):
#     def __init__(self, api=None, **kwargs):
#         super(ExactElement, self).__init__(**kwargs)
# 
#         self._api = api
# 
#     def get_guid(self):
#         # Raises ObjectDoesNotExist if it cannot be found remotely.
#         raise NotImplementedError()
# 
#     def commit(self):
#         # This needs API specific work.
#         raise NotImplementedError()
# 
# Path: exactonline/exceptions.py
# class ExactOnlineError(Exception):
#     pass
# 
# class ObjectDoesNotExist(ExactOnlineError):
#     """
#     Exception named Django style.
#     """
#     pass
# 
# Path: exactonline/resource.py
# class DELETE(_Resource):
#     pass
# 
# class POST(_Resource):
#     pass


from datetime import timedelta
from .base import ExactElement
from ..exceptions import ExactOnlineError, ObjectDoesNotExist
from ..resource import DELETE, POST
            line['To'] = end_of_month.strftime('%Y-%m-%dT%H:%M:%SZ')

        return line

    def commit(self):
        try:
            exact_guid = self.get_guid()
        except ObjectDoesNotExist:
            exact_guid = None

        data = self.assemble()

        if exact_guid:
            # We cannot supply the SalesEntryLines in the dict like
            # usual when we update (PUT). Instead, we add the new ones
            # and remove the old ones by hand.
            #
            # You don't want to do that the other way around, because
            # deleting the last item removes the entire invoice.
            old_salesentrylines = self.__get_remote()['SalesEntryLines']

            # Add new (and pop the SalesEntryLines from the invoice
            # dict).
            new_salesentrylines = data.pop('SalesEntryLines')
            for line in new_salesentrylines:
                line['EntryID'] = exact_guid
                self._api.restv1(POST('salesentry/SalesEntryLines', line))

            # Remove old.
            for line in old_salesentrylines:

# Path: exactonline/elements/base.py
# class ExactElement(object):
#     def __init__(self, api=None, **kwargs):
#         super(ExactElement, self).__init__(**kwargs)
# 
#         self._api = api
# 
#     def get_guid(self):
#         # Raises ObjectDoesNotExist if it cannot be found remotely.
#         raise NotImplementedError()
# 
#     def commit(self):
#         # This needs API specific work.
#         raise NotImplementedError()
# 
# Path: exactonline/exceptions.py
# class ExactOnlineError(Exception):
#     pass
# 
# class ObjectDoesNotExist(ExactOnlineError):
#     """
#     Exception named Django style.
#     """
#     pass
# 
# Path: exactonline/resource.py
# class DELETE(_Resource):
#     pass
# 
# class POST(_Resource):
#     pass


# Path: exactonline/elements/invoice.py
from datetime import timedelta
from .base import ExactElement
from ..exceptions import ExactOnlineError, ObjectDoesNotExist
from ..resource import DELETE, POST

            line['To'] = end_of_month.strftime('%Y-%m-%dT%H:%M:%SZ')

        return line

    def commit(self):
        try:
            exact_guid = self.get_guid()
        except ObjectDoesNotExist:
            exact_guid = None

        data = self.assemble()

        if exact_guid:
            # We cannot supply the SalesEntryLines in the dict like
            # usual when we update (PUT). Instead, we add the new ones
            # and remove the old ones by hand.
            #
            # You don't want to do that the other way around, because
            # deleting the last item removes the entire invoice.
            old_salesentrylines = self.__get_remote()['SalesEntryLines']

            # Add new (and pop the SalesEntryLines from the invoice
            # dict).
            new_salesentrylines = data.pop('SalesEntryLines')
            for line in new_salesentrylines:
                line['EntryID'] = exact_guid
                self._api.restv1(POST('salesentry/SalesEntryLines', line))

            # Remove old.
            for line in old_salesentrylines:

                self._api.restv1(DELETE(