def create_journalentry_lineitems(self, je: JournalEntry): je.prebatch( JournalEntryLineItem( account=Account.get(ACCT_REVENUE_MEMBERSHIP), action=JournalEntryLineItem.ACTION_BALANCE_INCREASE, amount=self.sale_price, ))
def create_membership_jelis(self, je: JournalEntry): # Interestingly, this case requires that we create a number of future revenue recognition # journal entries, in addition to the line items we create for the sale's journal entry. def recognize_revenue(date_to_recognize, amount): je2 = JournalEntry( # Calling it "je2" so it doesn't shadow outer "je". when=date_to_recognize, source_url=je.source_url) je2.prebatch( JournalEntryLineItem( account=Account.get(ACCT_REVENUE_MEMBERSHIP), action=JournalEntryLineItem.ACTION_BALANCE_INCREASE, amount=amount, description="From unearned membership revenue")) je2.prebatch( JournalEntryLineItem( account=Account.get(ACCT_LIABILITY_UNEARNED_MSHIP_REVENUE), action=JournalEntryLineItem.ACTION_BALANCE_DECREASE, amount=amount, description="To (earned) membership revenue")) Journaler.batch(je2) if hasattr(self, 'member') and hasattr(self, 'membership_type'): uname = quote_entity( self.member.username) if self.member is not None else "unknown" mtype = Membership.MEMBERSHIP_TYPE_STRINGS[self.membership_type] desc = "{} purchased a membership ({})".format(uname, mtype) else: desc = "Membership purchase" je.prebatch( JournalEntryLineItem( account=Account.get(ACCT_LIABILITY_UNEARNED_MSHIP_REVENUE), action=JournalEntryLineItem.ACTION_BALANCE_INCREASE, amount=self.sale_price, description=desc)) mship_duration = self.end_date - self.start_date # type: timedelta mship_days = mship_duration.days + 1 rev_per_day = self.sale_price / Decimal(mship_days) curr_date = self.start_date rev_acc = Decimal("0.00") while curr_date <= self.end_date: rev_acc += rev_per_day if is_very_last_day_of_month( curr_date) or curr_date == self.end_date: recognize_revenue(curr_date, rev_acc) rev_acc = Decimal("0.00") curr_date += timedelta(days=1)
def create_journalentry_lineitems(self, je: JournalEntry): # The Sale Journaler has already put the case into the general cash account, so we need to get that back: je.prebatch( JournalEntryLineItem( account=Account.get(ACCT_ASSET_CASH), action=JournalEntryLineItem.ACTION_BALANCE_DECREASE, amount=self.sale_price, description="{} paid us".format( quote_entity(self.sale.payer_str)))) # The next two line items are the balanced KMKR Cash/Revenue pair, where cash was clawed back by prev line item: je.prebatch( JournalEntryLineItem( account=Account.get(ACCT_KMKR_CASH), action=JournalEntryLineItem.ACTION_BALANCE_INCREASE, amount=self.sale_price, description="{} paid us".format( quote_entity(self.sale.payer_str)))) je.prebatch( JournalEntryLineItem( account=Account.get(ACCT_KMKR_DONATION), action=JournalEntryLineItem.ACTION_BALANCE_INCREASE, amount=self.sale_price, description="Underwriting by {}".format( quote_entity(str(self.quote.prepared_for)))))
def recognize_revenue(date_to_recognize, amount): je2 = JournalEntry( # Calling it "je2" so it doesn't shadow outer "je". when=date_to_recognize, source_url=je.source_url) je2.prebatch( JournalEntryLineItem( account=Account.get(ACCT_REVENUE_MEMBERSHIP), action=JournalEntryLineItem.ACTION_BALANCE_INCREASE, amount=amount, description="From unearned membership revenue")) je2.prebatch( JournalEntryLineItem( account=Account.get(ACCT_LIABILITY_UNEARNED_MSHIP_REVENUE), action=JournalEntryLineItem.ACTION_BALANCE_DECREASE, amount=amount, description="To (earned) membership revenue")) Journaler.batch(je2)