Skip to content

Commit

Permalink
Add Items to PoS (#31)
Browse files Browse the repository at this point in the history
* add items table and models
* add and update items
* merchant UI done
* show QR code #18
* pos with items
* add description, tax and fix UI
* import export JSON
  • Loading branch information
talvasconcelos authored Nov 22, 2023
1 parent f60496e commit 2079378
Show file tree
Hide file tree
Showing 6 changed files with 1,062 additions and 197 deletions.
12 changes: 12 additions & 0 deletions migrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,15 @@ async def m005_initial(db):
);
"""
)


async def m006_items(db):
"""
Add items to tpos table for storing various items (JSON format)
See `Item` class in models.
"""
await db.execute(
"""
ALTER TABLE tpos.pos ADD items TEXT DEFAULT '[]';
"""
)
17 changes: 16 additions & 1 deletion models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from sqlite3 import Row
from typing import Optional, Any
from typing import Optional, Any, List

from fastapi import Request
from lnurl import Lnurl, LnurlWithdrawResponse
Expand Down Expand Up @@ -33,6 +33,7 @@ class TPoS(BaseModel):
withdrawamt: int
withdrawtime: int
withdrawbtwn: int
items: Optional[str]

@classmethod
def from_row(cls, row: Row) -> "TPoS":
Expand All @@ -52,6 +53,7 @@ class TPoSClean(BaseModel):
withdrawamt: int
withdrawtime: int
withdrawbtwn: int
items: Optional[str]

@classmethod
def from_row(cls, row: Row) -> "TPoSClean":
Expand Down Expand Up @@ -102,3 +104,16 @@ class HashCheck(BaseModel):

class PayLnurlWData(BaseModel):
lnurl: str


class Item(BaseModel):
image: Optional[str]
price: float
title: str
description: Optional[str]
tax: Optional[float] = 0.0
disabled: bool = False


class CreateUpdateItemData(BaseModel):
items: List[Item]
Loading

0 comments on commit 2079378

Please sign in to comment.