def _add_payment_deadline(cls, business, payment_line, estimation): """ Add a payment deadline for the given payment line to the business deadlines """ from autonomie.models.project.business import BusinessPaymentDeadline if payment_line not in business.payment_lines: business.payment_deadlines.append( BusinessPaymentDeadline(payment_line=payment_line, estimation=estimation))
def find_deadline_from_invoice(cls, business, invoice): """ Find the deadline having this invoice attached to it :param obj business: The parent Business :param obj invoice: The associated Invoice """ from autonomie.models.project.business import BusinessPaymentDeadline result = BusinessPaymentDeadline.query().filter_by( invoice_id=invoice.id).filter_by(business_id=business.id).first() return result
def find_deadline(cls, business, deadline_id): """ Find the deadline matching this id :param obj business: The parent Business :param int deadline_id: The associated deadline_id """ from autonomie.models.project.business import BusinessPaymentDeadline result = BusinessPaymentDeadline.get(deadline_id) if result.business_id != business.id: result = None return result
def _add_deposit_deadline(cls, business, estimation): """ Add a deposit deadline to a business """ deposit = estimation.deposit if not deposit: return business from autonomie.models.project.business import BusinessPaymentDeadline query = BusinessPaymentDeadline.query() query = query.filter_by(business_id=business.id) query = query.filter_by(estimation_id=estimation.id) query = query.filter_by(deposit=True) if query.count() == 0: business.payment_deadlines.append( BusinessPaymentDeadline( business_id=business.id, estimation_id=estimation.id, deposit=True, )) DBSESSION().merge(business) return business
def find_deadline_from_invoice(cls, business, invoice): """ Find the deadline having this invoice attached to it :param obj business: The parent Business :param obj invoice: The associated Invoice """ from autonomie.models.project.business import BusinessPaymentDeadline result = BusinessPaymentDeadline.query().filter_by( invoice_id=invoice.id ).filter_by( business_id=business.id ).first() return result
def _add_deposit_deadline(cls, business, estimation): """ Add a deposit deadline to a business """ deposit = estimation.deposit if not deposit: return business from autonomie.models.project.business import BusinessPaymentDeadline query = BusinessPaymentDeadline.query() query = query.filter_by(business_id=business.id) query = query.filter_by(estimation_id=estimation.id) query = query.filter_by(deposit=True) if query.count() == 0: business.payment_deadlines.append( BusinessPaymentDeadline( business_id=business.id, estimation_id=estimation.id, deposit=True, ) ) DBSESSION().merge(business) return business