def _display_price()

in iact3/termial_print.py [0:0]


    def _display_price(stacker):
        def _format_association_price(price_dict: dict, result: list, association_product: str):
            if price_dict:
                for k, v in price_dict.items():
                    association_prefix = association_product
                    if isinstance(v, dict) and "Result" in v:
                        association_prefix = v["Type"][v["Type"].index("::")+2:] if "Type" in v else association_product
                        try:
                            association_price = {
                                "Type": f'{association_product}-{k}' if not "Type" in v else v["Type"],
                                "ChargeType": v["Result"]["OrderSupplement"]["ChargeType"],
                                "PeriodUnit": v["Result"]["OrderSupplement"]["PriceUnit"],
                                "Quantity": v["Result"]["OrderSupplement"]["Quantity"],
                                "Currency": v["Result"]["Order"]["Currency"],
                                "OriginalAmount": v["Result"]["Order"]["OriginalAmount"] if "OriginalAmount" in v["Result"]["Order"] else None,
                                "DiscountAmount": v["Result"]["Order"]["DiscountAmount"] if "DiscountAmount" in v["Result"]["Order"] else None,
                                "TradeAmount": v["Result"]["Order"]["TradeAmount"],
                            }
                            result.append(association_price)
                        except Exception:
                            pass
                    if isinstance(v, dict):
                        _format_association_price(v, result, association_prefix)

        for stack in stacker.stacks:
            test_name = f' test_name: {stack.test_name} '
            line_width_default = 140
                  
            if stack.template_price:
                price_detail = []
                for k,v in stack.template_price.items():
                    try:
                        resource_price = {
                            "Resource": k,
                            "Region": stack.region,
                            "Type": v["Type"],
                            "ChargeType": v["Result"]["OrderSupplement"]['ChargeType'],
                            "PeriodUnit": v["Result"]["OrderSupplement"]['PriceUnit'],
                            "Quantity": v["Result"]["OrderSupplement"]['Quantity'],
                            "Currency": v["Result"]["Order"]["Currency"],
                            "OriginalAmount": v["Result"]["Order"]["OriginalAmount"] if "OriginalAmount" in v["Result"]["Order"] else None,
                            "DiscountAmount": v["Result"]["Order"]["DiscountAmount"] if "DiscountAmount" in v["Result"]["Order"] else None,
                            "TradeAmount": v["Result"]["Order"]["TradeAmount"]
                        }
                        price_detail.append(resource_price)
                    except Exception:
                        resource_price = {
                            "Resource": k,
                            "Region": stack.region,
                            "Type": v["Type"],
                            "ChargeType": None,
                            "PeriodUnit": None,
                            "Quantity": None,
                            "Currency": None,
                            "OriginalAmount": None,
                            "DiscountAmount": None,
                            "TradeAmount": None
                        }
                        price_detail.append(resource_price)
                        pass

                    _format_association_price(v["Result"],price_detail,v["Type"][v["Type"].index("::")+2:])
                    
                tab = tabulate.tabulate(price_detail, headers="keys")
                tab_lines = tab.splitlines() 
                tab_width = len(tab_lines[1])

                test_name = test_name.ljust(int(tab_width/2) + int(len(test_name)/2) + 1, "\u2501")
                test_name = test_name.rjust(tab_width + 2, "\u2501")
                LOG.info("{}{}{}{}{} ".format("\u250f", PrintMsg.blod, 
                                                test_name, "\u2513", PrintMsg.rst_color)) 

                for i, line in enumerate(tab_lines):
                    LOG.info("{} {} {}".format("\u2523" if i != len(tab_lines)-1 else "\u2517", 
                                                 line.ljust(tab_width," "), 
                                                 "\u252B" if i != len(tab_lines)-1 else "\u251B"))
                LOG.info("\n")
            if not stack.template_price:
                test_name = test_name.ljust(int(line_width_default/2)+int(len(test_name)/2)-1, "\u2501")
                test_name = test_name.rjust(line_width_default-1 , "\u2501")
                LOG.info("{}{}{}{}{} ".format("\u250f", PrintMsg.blod, 
                                                test_name, "\u2513", PrintMsg.rst_color)) 
                LOG.info(
                    "{} status: {}{}{} ".format(
                    "\u2523", PrintMsg.text_red_background_write, 
                    (stack.status + PrintMsg.rst_color).ljust(line_width_default-len(" status: ")+len(PrintMsg.rst_color)-1,' '), 
                    "\u252B"
                ))
                subsequent_indent = ' ' * 28
                status_reason = textwrap.fill(stack.status_reason, width=line_width_default-16, break_long_words=False, replace_whitespace=True, subsequent_indent=subsequent_indent)
                status_reason = PrintMsg.text_red_background_write + status_reason.replace('\n', f'{PrintMsg.rst_color}\n{PrintMsg.text_red_background_write}').replace(subsequent_indent,f'{PrintMsg.rst_color}{subsequent_indent}{PrintMsg.text_red_background_write}') + PrintMsg.rst_color
                LOG.info("{} status reason: {} {}\n".format("\u2517", status_reason, PrintMsg.rst_color))