Initial roborto accounting implementation

This commit is contained in:
rob
2026-08-30 07:16:21 +01:00
commit 97a75d0243
145 changed files with 5525 additions and 0 deletions
+19
View File
@@ -0,0 +1,19 @@
from datetime import date
from decimal import Decimal
from roborto_accounting.persistence.base import Base
from roborto_accounting.persistence.db import make_engine,make_session_factory
from roborto_accounting.persistence.models import Account,AccountClass,Supplier
from roborto_accounting.services.payables import bill_outstanding,pay_supplier_bill,record_supplier_bill,record_supplier_refund
def test_supplier_bill_partial_full_payment_and_linked_refund():
e=make_engine("sqlite://");Base.metadata.create_all(e);s=make_session_factory(e)()
supplier=Supplier(name="Supplier");expense=Account(code="5000",name="Expense",account_class=AccountClass.EXPENSE)
ap=Account(code="2000",name="AP",account_class=AccountClass.LIABILITY);bank=Account(code="1000",name="Bank",account_class=AccountClass.ASSET)
s.add_all([supplier,expense,ap,bank]);s.flush()
bill=record_supplier_bill(s,supplier_id=supplier.id,bill_date=date(2026,1,1),description="Hosting",amount=Decimal("100"),expense_account_id=expense.id,payable_account_id=ap.id)
pay_supplier_bill(s,bill=bill,payment_date=date(2026,1,5),amount=Decimal("40"),payable_account_id=ap.id,financial_account_id=bank.id)
assert bill.status=="PARTIALLY_PAID" and bill_outstanding(bill)==Decimal("60")
pay_supplier_bill(s,bill=bill,payment_date=date(2026,1,6),amount=Decimal("60"),payable_account_id=ap.id,financial_account_id=bank.id)
refund=record_supplier_refund(s,bill=bill,refund_date=date(2026,1,10),amount=Decimal("25"),financial_account_id=bank.id,reason="Service credit")
assert bill.status=="PAID" and refund.bill_id==bill.id and bill.amount==Decimal("100")
s.close();e.dispose()