rechu.command.new.step package¶
Submodules¶
rechu.command.new.step.base module¶
Base classes and types for new subcommand steps.
- class rechu.command.new.step.base.ResultMeta[source]¶
Bases:
TypedDict
Result of a step being run, indicator additional metadata to update.
‘receipt_path’: Boolean indicating pdate the path of the receipt based on receipt metadata.
- exception rechu.command.new.step.base.ReturnToMenu(msg: str = '')[source]¶
Bases:
RuntimeError
Indication that the step is interrupted to return to a menu.
- class rechu.command.new.step.base.Step(receipt: Receipt, input_source: InputSource)[source]¶
Bases:
object
Abstract base class for a step during receipt creation.
- run() ResultMeta [source]¶
Perform the step. Returns whether there is additional metadata which needs to be updated outside of the step.
rechu.command.new.step.discounts module¶
Discounts step of new subcommand.
- class rechu.command.new.step.discounts.Discounts(receipt: Receipt, input_source: InputSource, matcher: ProductMatcher, more: bool = False)[source]¶
Bases:
Step
Step to add discounts.
- run() ResultMeta [source]¶
Perform the step. Returns whether there is additional metadata which needs to be updated outside of the step.
rechu.command.new.step.edit module¶
Edit step of new subcommand.
- class rechu.command.new.step.edit.Edit(receipt: Receipt, input_source: InputSource, matcher: ProductMatcher, editor: str | None = None)[source]¶
Bases:
Step
Step to edit the receipt in its YAML representation via a temporary file.
- run() ResultMeta [source]¶
Perform the step. Returns whether there is additional metadata which needs to be updated outside of the step.
rechu.command.new.step.help module¶
Help step of new subcommand.
- class rechu.command.new.step.help.Help(receipt: Receipt, input_source: InputSource)[source]¶
Bases:
Step
Step to display help for steps that are usable from the menu.
- run() ResultMeta [source]¶
Perform the step. Returns whether there is additional metadata which needs to be updated outside of the step.
rechu.command.new.step.meta module¶
Meta step of new subcommand.
- class rechu.command.new.step.meta.ProductMeta(receipt: Receipt, input_source: InputSource, matcher: ProductMatcher, more: bool = False)[source]¶
Bases:
Step
Step to add product metadata that matches one or more products.
- CONFIRM_ID = re.compile('^-?\\d+$', re.ASCII)¶
- MATCHERS: dict[str, _Matcher] = {'discount': {'key': 'label', 'model': <class 'rechu.models.product.DiscountMatch'>, 'options': 'discounts'}, 'label': {'key': 'name', 'model': <class 'rechu.models.product.LabelMatch'>, 'options': 'products'}, 'price': {'extra_key': 'indicator', 'input_type': <class 'rechu.types.quantized.Price'>, 'key': 'value', 'model': <class 'rechu.models.product.PriceMatch'>, 'normalize': 'quantity', 'options': 'prices'}}¶
- add_product(item: ProductItem | None = None, initial_key: str | None = None, matched_items: set[ProductItem] | None = None, product: Product | None = None) tuple[bool, str | None] [source]¶
Request fields for a product’s metadata and add it to the database as well as a products YAML file. item is an optional product item from the receipt to specifically match the metadata for. initial_key is a metadata key to use for the first prompt. matched_items is a set of product items on the receipt that already have metadata. product is an existing product to start with, if any. Returns whether to no longer attempt to create product metadata and the current prompt answer.
- run() ResultMeta [source]¶
Perform the step. Returns whether there is additional metadata which needs to be updated outside of the step.
rechu.command.new.step.products module¶
Products step of new subcommand.
- class rechu.command.new.step.products.Products(receipt: Receipt, input_source: InputSource, matcher: ProductMatcher)[source]¶
Bases:
Step
Step to add products.
- add_product(first: bool = False) bool [source]¶
Request fields for a product and add it to the receipt.
- run() ResultMeta [source]¶
Perform the step. Returns whether there is additional metadata which needs to be updated outside of the step.
rechu.command.new.step.quit module¶
Quit step of new subcommand.
- class rechu.command.new.step.quit.Quit(receipt: Receipt, input_source: InputSource)[source]¶
Bases:
Step
Step to exit the receipt creation menu.
- run() ResultMeta [source]¶
Perform the step. Returns whether there is additional metadata which needs to be updated outside of the step.
rechu.command.new.step.read module¶
Read step of new subcommand.
- class rechu.command.new.step.read.Read(receipt: Receipt, input_source: InputSource, matcher: ProductMatcher)[source]¶
Bases:
Step
Step to check if there are any new or updated product metadata entries in the file inventory that should be synchronized with the database inventory before creating and matching receipt products.
- run() ResultMeta [source]¶
Perform the step. Returns whether there is additional metadata which needs to be updated outside of the step.
rechu.command.new.step.view module¶
View step of new subcommand.
- class rechu.command.new.step.view.View(receipt: Receipt, input_source: InputSource, products: set[Product] | None = None)[source]¶
Bases:
Step
Step to display the receipt in its YAML representation.
- run() ResultMeta [source]¶
Perform the step. Returns whether there is additional metadata which needs to be updated outside of the step.
rechu.command.new.step.write module¶
Write step of new subcommand.
- class rechu.command.new.step.write.Write(receipt: Receipt, input_source: InputSource, matcher: ProductMatcher)[source]¶
Bases:
Step
Final step to write the receipt to a YAML file and store in the database.
- run() ResultMeta [source]¶
Perform the step. Returns whether there is additional metadata which needs to be updated outside of the step.
Module contents¶
Steps for creating a receipt in new subcommand.
- class rechu.command.new.step.Discounts(receipt: Receipt, input_source: InputSource, matcher: ProductMatcher, more: bool = False)[source]¶
Bases:
Step
Step to add discounts.
- run() ResultMeta [source]¶
Perform the step. Returns whether there is additional metadata which needs to be updated outside of the step.
- class rechu.command.new.step.Edit(receipt: Receipt, input_source: InputSource, matcher: ProductMatcher, editor: str | None = None)[source]¶
Bases:
Step
Step to edit the receipt in its YAML representation via a temporary file.
- run() ResultMeta [source]¶
Perform the step. Returns whether there is additional metadata which needs to be updated outside of the step.
- class rechu.command.new.step.Help(receipt: Receipt, input_source: InputSource)[source]¶
Bases:
Step
Step to display help for steps that are usable from the menu.
- run() ResultMeta [source]¶
Perform the step. Returns whether there is additional metadata which needs to be updated outside of the step.
- class rechu.command.new.step.ProductMeta(receipt: Receipt, input_source: InputSource, matcher: ProductMatcher, more: bool = False)[source]¶
Bases:
Step
Step to add product metadata that matches one or more products.
- CONFIRM_ID = re.compile('^-?\\d+$', re.ASCII)¶
- MATCHERS: dict[str, _Matcher] = {'discount': {'key': 'label', 'model': <class 'rechu.models.product.DiscountMatch'>, 'options': 'discounts'}, 'label': {'key': 'name', 'model': <class 'rechu.models.product.LabelMatch'>, 'options': 'products'}, 'price': {'extra_key': 'indicator', 'input_type': <class 'rechu.types.quantized.Price'>, 'key': 'value', 'model': <class 'rechu.models.product.PriceMatch'>, 'normalize': 'quantity', 'options': 'prices'}}¶
- add_product(item: ProductItem | None = None, initial_key: str | None = None, matched_items: set[ProductItem] | None = None, product: Product | None = None) tuple[bool, str | None] [source]¶
Request fields for a product’s metadata and add it to the database as well as a products YAML file. item is an optional product item from the receipt to specifically match the metadata for. initial_key is a metadata key to use for the first prompt. matched_items is a set of product items on the receipt that already have metadata. product is an existing product to start with, if any. Returns whether to no longer attempt to create product metadata and the current prompt answer.
- run() ResultMeta [source]¶
Perform the step. Returns whether there is additional metadata which needs to be updated outside of the step.
- class rechu.command.new.step.Products(receipt: Receipt, input_source: InputSource, matcher: ProductMatcher)[source]¶
Bases:
Step
Step to add products.
- add_product(first: bool = False) bool [source]¶
Request fields for a product and add it to the receipt.
- run() ResultMeta [source]¶
Perform the step. Returns whether there is additional metadata which needs to be updated outside of the step.
- class rechu.command.new.step.Quit(receipt: Receipt, input_source: InputSource)[source]¶
Bases:
Step
Step to exit the receipt creation menu.
- run() ResultMeta [source]¶
Perform the step. Returns whether there is additional metadata which needs to be updated outside of the step.
- class rechu.command.new.step.Read(receipt: Receipt, input_source: InputSource, matcher: ProductMatcher)[source]¶
Bases:
Step
Step to check if there are any new or updated product metadata entries in the file inventory that should be synchronized with the database inventory before creating and matching receipt products.
- run() ResultMeta [source]¶
Perform the step. Returns whether there is additional metadata which needs to be updated outside of the step.
- exception rechu.command.new.step.ReturnToMenu(msg: str = '')[source]¶
Bases:
RuntimeError
Indication that the step is interrupted to return to a menu.
- class rechu.command.new.step.Step(receipt: Receipt, input_source: InputSource)[source]¶
Bases:
object
Abstract base class for a step during receipt creation.
- run() ResultMeta [source]¶
Perform the step. Returns whether there is additional metadata which needs to be updated outside of the step.
- class rechu.command.new.step.View(receipt: Receipt, input_source: InputSource, products: set[Product] | None = None)[source]¶
Bases:
Step
Step to display the receipt in its YAML representation.
- run() ResultMeta [source]¶
Perform the step. Returns whether there is additional metadata which needs to be updated outside of the step.
- class rechu.command.new.step.Write(receipt: Receipt, input_source: InputSource, matcher: ProductMatcher)[source]¶
Bases:
Step
Final step to write the receipt to a YAML file and store in the database.
- run() ResultMeta [source]¶
Perform the step. Returns whether there is additional metadata which needs to be updated outside of the step.