Removing opening info for read and update, puting in another resource
This commit is contained in:
@@ -100,15 +100,7 @@ class AccountResource:
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def select(cls):
|
def select(cls):
|
||||||
split_filter = aliased(Split)
|
return select(Account)
|
||||||
account_filter = aliased(Account)
|
|
||||||
columns = [Account.id, Account.name, Account.parent_account_id, Account.family, Account.type, Account.path,
|
|
||||||
Split.amount.label("opening_balance"), literal_column('"1970-01-01"').label("opening_date")]
|
|
||||||
return (select(*columns)
|
|
||||||
.join(Split)
|
|
||||||
.join(Transaction)
|
|
||||||
.join(split_filter)
|
|
||||||
.join(account_filter, account_filter.id == split_filter.account_id and Account.path == "/Equity/"))
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def list(cls, filters):
|
def list(cls, filters):
|
||||||
|
|||||||
@@ -21,8 +21,7 @@ class AccountBaseId(AccountBase):
|
|||||||
path: str = Field(index=True)
|
path: str = Field(index=True)
|
||||||
|
|
||||||
class AccountRead(AccountBaseId):
|
class AccountRead(AccountBaseId):
|
||||||
opening_date: date = Field()
|
pass
|
||||||
opening_balance: Decimal = Field(decimal_places=2, default=0)
|
|
||||||
|
|
||||||
class BaseAccountWrite(AccountBase):
|
class BaseAccountWrite(AccountBase):
|
||||||
path: SkipJsonSchema[str] = Field(default="")
|
path: SkipJsonSchema[str] = Field(default="")
|
||||||
@@ -39,11 +38,10 @@ class AccountWrite(BaseAccountWrite):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
opening_date: date = Field()
|
|
||||||
opening_balance: MonetaryAmount = Field()
|
|
||||||
|
|
||||||
class AccountCreate(AccountWrite):
|
class AccountCreate(AccountWrite):
|
||||||
pass
|
opening_date: date = Field()
|
||||||
|
opening_balance: MonetaryAmount = Field()
|
||||||
|
|
||||||
class AccountUpdate(AccountWrite):
|
class AccountUpdate(AccountWrite):
|
||||||
pass
|
pass
|
||||||
@@ -63,11 +61,9 @@ class CategoryWrite(BaseAccountWrite):
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
class CategoryCreate(CategoryWrite):
|
||||||
opening_date: SkipJsonSchema[date] = Field(default=date(1970, 1, 1))
|
opening_date: SkipJsonSchema[date] = Field(default=date(1970, 1, 1))
|
||||||
opening_balance: SkipJsonSchema[Decimal] = Field(default=0)
|
opening_balance: SkipJsonSchema[Decimal] = Field(default=0)
|
||||||
|
|
||||||
class CategoryCreate(CategoryWrite):
|
|
||||||
pass
|
|
||||||
|
|
||||||
class CategoryUpdate(CategoryWrite):
|
class CategoryUpdate(CategoryWrite):
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -6,10 +6,17 @@ export const AccountEdit: React.FC = () => {
|
|||||||
const { id } = useParams()
|
const { id } = useParams()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<div>
|
||||||
<CrudForm
|
<CrudForm
|
||||||
schemaName={"AccountUpdate"}
|
schemaName={"AccountUpdate"}
|
||||||
resource={"accounts"}
|
resource={"accounts"}
|
||||||
id={id}
|
id={id}
|
||||||
/>
|
/>
|
||||||
|
<CrudForm
|
||||||
|
schemaName={"AccountUpdate"}
|
||||||
|
resource={`accounts/${id}/opening`}
|
||||||
|
id={id}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user