def __init__(self): super().__init__() # tables self.category = Table('GroupKala', _('Category')) self.category_map = Table('CategoryMap', _('CategoryMap')) # woocommerce api self.woocommerce = wc.get(wc_api.get(), 'products/categories')
def save_all_confirm(self): error = False saves = 0 conn = connection.get() self.invoice.set_connection(conn) for order in self._current['completed']: order_number = order['number'] try: self.invoice.save(order) except Exception as e: conn.rollback() error = True message = _('Save progress interrupt by order #{}.').format(order_number) msg = Message(self.ui, Message.ERROR, message, str(e)) msg.show() break else: conn.commit() saves += 1 del self._orders[order_number] index = self.orders_table.findRecord(order_number) if index is not None: self.orders_table.removeRecord(index) # close connection conn.close() # check for error if not error: plural = _('s ') if saves > 1 else ' ' message = _('{} order{}saved successfully.').format(saves, plural) msg = Message(self.ui, Message.SUCCESS, message) msg.show()
def show_options(self, subject): conn = connection.get() self.model.set_connection(conn) try: if subject == self.form.ID: columns = [_('ID'), _('Name')] title = self.messages[1] # cache unmapped self._current['unmapped'] = self.model.unmapped() options = [[um['id'], um['name']] for um in self._current['unmapped']] else: columns = [_('WCID'), _('Name')] title = self.messages[0] # cache wc_unmapped self._current['wcunmapped'] = self.model.wc_unmapped() options = [[um['id'], um['name']] for um in self._current['wcunmapped']] except Exception as e: msg = Message(self.form, Message.ERROR, self.messages[3], str(e)) msg.show() else: self.options_list = OptionsList(self.form, columns, [1, 3]) self.options_list.setWindowTitle(title) self.options_list.setList(options) self.options_list.btnAddAll.clicked.connect( lambda: self.add_all(subject)) self.options_list.signals.select.connect( lambda item: self.select_option(subject, item)) self.options_list.show() finally: conn.close()
def setupControl(self): self.checkAll = QCheckBox('Select all') self.btnAddAll = AddSMButton(_('Add')) self.btnCancel = CancelSMButton(_('Cancel')) self.controlLayout.addWidget(self.checkAll) self.controlLayout.addWidget(self.btnAddAll) self.controlLayout.addWidget(self.btnCancel)
def get(self): if self._orders is None: conn = connection.get() self.invoice.set_connection(conn) try: raw_orders = self.invoice.orders() except Exception as e: msg = Message(self.ui, Message.ERROR, _('Cannot get orders from WooCommerce.'), str(e)) msg.show() else: orders = dict() summary = list() for order in raw_orders: orders[order['number']] = order # generate summary summary.append([ order['id'], '#{} {} {}'.format(order['id'], order['first_name'], order['last_name']), order['created_date'].strftime('%Y-%m-%d @ %H:%M:%S'), order['status'], order['total'] ]) self._orders = orders self.orders_table.setRecords(reversed(summary)) finally: conn.close()
def order_details(self): index = self.orders_table.getCurrentRecordIndex() if index is not None: record = self.orders_table.getRecord(index) order = self._orders[record[0]] # save current order id and table's index self._current['number'] = order['number'] self._current['index'] = index details = { 'items': [ [item['id'], item['name'], item['price'], item['quantity'], item['total']] for item in order['items'] ], 'totals': { 'order': order['total'], 'tax': order['total_tax'], 'items': order['items_subtotal'], 'shipping': order['shipping_total'], 'discount': order['discount_total'] }, 'general': { 'status': order['status'], 'customer': order['customer_id'] or _('Guest'), 'date': order['created_date'].strftime('%Y-%m-%d @ %H:%M:%S') }, 'billing': { 'firstname': order['billing']['first_name'], 'lastname': order['billing']['last_name'], 'company': order['billing']['company'], 'email': order['billing']['email'], 'phone': order['billing']['phone'], 'country': order['billing']['country'], 'state': order['billing']['state'], 'city': order['billing']['city'], 'postcode': order['billing']['postcode'], 'address1': order['billing']['address_1'], 'address2': order['billing']['address_2'], 'payment': order['payment_method_title'], 'transaction': order['transaction_id'] }, 'shipping': { 'firstname': order['shipping']['first_name'], 'lastname': order['shipping']['last_name'], 'company': order['shipping']['company'], 'country': order['shipping']['country'], 'state': order['shipping']['state'], 'city': order['shipping']['city'], 'postcode': order['shipping']['postcode'], 'address1': order['shipping']['address_1'], 'address2': order['shipping']['address_2'], 'note': order['customer_note'] } } self.details.setDetails(details) self.details.show()
def setupControl(self): # status combo box self.comboStatus = MDCombo() self.comboStatus.addItems(self.STATUSES) # update button self.btnUpdate = SyncMDButton(_('Update')) # save button self.btnSave = SaveMDButton(_('Save')) # - hide save button as default self.btnSave.hide() # cancel button self.btnCancel = CancelMDButton(_('Cancel')) # register combo and buttons self.controlLayout.addWidget(self.comboStatus) self.controlLayout.addWidget(self.btnUpdate) self.controlLayout.addWidget(self.btnSave) self.controlLayout.addWidget(self.btnCancel)
def update(self): status = self.details.getCurrentStatus() try: self.invoice.update_order(self._current['number'], {'status': status}) except Exception as e: msg = Message(self.details, Message.ERROR, _('Cannot update order.'), str(e)) msg.show() else: # update cached orders self._orders[self._current['number']]['status'] = status # update order details dialog self.details.changeStatus(status) # update order's summary table record = self.orders_table.getRecord(self._current['index']) record[3] = status self.orders_table.updateRecord(self._current['index'], record) msg = Message(self.details, Message.SUCCESS, _('Order updated successfully.')) msg.show()
def save_all(self): if self._orders is not None: completed = list() for order in self._orders.values(): if order['status'] == 'completed': completed.insert(0, order) if completed: # cache completed orders self._current['completed'] = completed # create confirm dialog plural = _('s ') if len(completed) > 1 else ' ' details = _('{} order{}will be save.').format(len(completed), plural) confirm = Confirm(self.ui, Confirm.WARNING, _('Are you sure?'), details) confirm.btnOk.clicked.connect(self.save_all_confirm) confirm.show() else: msg = Message(self.ui, Message.ERROR, _('Order with completed status not found.')) msg.show()
def setupDialog(self): self.form = QFormLayout() self.dialogLayout.addLayout(self.form) # id self.id = SMEdit() self.idOptions = SMButton('...') self.idOptions.setObjectName('Options') idLayout = QHBoxLayout() idLayout.addWidget(self.id) idLayout.addWidget(self.idOptions) self.form.addRow(QLabel(_('ID')), idLayout) # wcid self.wcid = SMEdit() self.wcidOptions = SMButton('...') self.wcidOptions.setObjectName('Options') wcidLayout = QHBoxLayout() wcidLayout.addWidget(self.wcid) wcidLayout.addWidget(self.wcidOptions) self.form.addRow(QLabel(_('WCID')), wcidLayout)
def remove(self): index = self.invoices_table.getCurrentRecordIndex() if index is not None: conn = connection.get() self.invoice.set_connection(conn) try: order_id = int(self.invoices_table.getRecord(index)[2]) self.invoice.remove(order_id) except Exception as e: conn.rollback() msg = Message(self.ui, Message.ERROR, _('Cannot remove invoice.'), str(e)) msg.show() else: conn.commit() self.invoices_table.removeRecord(index) msg = Message(self.ui, Message.SUCCESS, _('Invoice removed successfully.')) msg.show() finally: conn.close()
class WCBaseError(Exception): """WooCommerce Base Error""" message = _('WooCommerce base error') def __init__(self, *args, details=''): super().__init__(*args) self.details = details def __str__(self): return '{}: {}'.format(self.message, self.details)
def save(self): try: settings = self.tab.get() s.set('general', settings['general']) s.set('wc', settings['wc']) s.set('moein', settings['moein']) s.set('import_export', settings['import_export']) s.set('orders', settings['orders']) s.set('invoices', settings['invoices']) s.set('engine', settings['engine']) s.save() except Exception as e: lvl = Message.ERROR msg_txt = _('Cannot Save Settings.') details = str(e) else: lvl = Message.SUCCESS msg_txt = _('Settings Saved Successfully.') details = None msg = Message(self.ui, lvl, msg_txt, details) msg.show()
def __init__(self): super().__init__() # tables self.invoice = Table('Factor1', _('Invoice')) self.invoice_map = Table('InvoiceMap', _('InvoiceMap')) self.customer = Table('AshkhasList', _('Customer')) self.customer_map = Table('CustomerMap', _('CustomerMap')) self.product = Table('KalaList', _('Product')) self.product_map = Table('ProductMap', _('ProductMap')) self.line_item = Table('Faktor2', _('LineItem')) # woocommerce self.woocommerce = wc.get(wc_api.get(), 'orders')
def save(self): conn = connection.get() self.invoice.set_connection(conn) order = self._orders[self._current['number']] try: self.invoice.save(order) except Exception as e: # rollback all changes conn.rollback() msg = Message(self.details, Message.ERROR, _('Cannot save order.'), str(e)) msg.show() else: # commit all changes conn.commit() # update ui del self._orders[self._current['number']] self.orders_table.removeRecord(self._current['index']) # show success message msg = Message(self.details, Message.SUCCESS, _('Order saved successfully.')) msg.btnOk.clicked.connect(self.details.close) msg.show() finally: conn.close()
def engine_error_handle(self, error): if isinstance(error, ConnectionsError): # put tab state on connecting... self.tab.connecting() # create network checker nc = NetworkChecker(s.IP, s.PORT, s.TIMEOUT, s.INTERVAL, s.JITTER) # connect signals nc.signals.connected.connect(self.nc_connected_handler) nc.signals.tik.connect(self.tab.connecting_count) # move to thread pool and start QThreadPool.globalInstance().start(nc) else: self.engine.stop() msg = Message(self.ui, Message.ERROR, _('Engine stop working.'), str(error)) msg.show()
def __init__(self): super().__init__() # tables self.product = Table('KalaList', _('Product')) self.product_map = Table('ProductMap', _('ProductMap')) self.category_map = Table('CategoryMap', _('CategoryMap')) self.price_level = Table('PriceLevel', _('PriceLevel')) self.product_price = Table('KalaPrice', _('ProductPrice')) self.product_repository = Table('MojodiList', _('ProductRepository')) # woocommerce api self.woocommerce = wc.get(wc_api.get(), 'products')
def get_saved(self): conn = connection.get() self.invoice.set_connection(conn) try: saved = self.invoice.saved() except Exception as e: msg = Message(self.ui, Message.ERROR, _('Cannot load saved invoices.'), str(e)) msg.show() else: records = list() for invoice in saved: records.append([ invoice['No'], '{} {}'.format(invoice['customer_code'], invoice['customer_name']), invoice['order_id'], invoice['saved_date'].strftime('%Y-%m-%d @ %H:%M:%S') ]) self.invoices_table.setRecords(records) finally: conn.close()
def import2moein(self, wc_category): # check for category name if len(wc_category['_name']) > 50: raise Exception( _('Category {} name is too long.').format( wc_category['_name'])) # check for parent if wc_category['parent']: parent = self.category_map.get(wcid=wc_category['parent']) parent_id = parent.id else: parent_id = 0 # create category self.category.create({ 'GroupKala': wc_category['_name'], 'ParentID': parent_id }) # create map self.category_map.create({ 'id': self.category.max('ID'), 'wcid': wc_category['id'], 'last_update': datetime.now() })
def save(self, order): # get settings settings = s.get('invoices') # current date and time in jalali calendar date_frmt = '%Y/%m/%d' time_frmt = '%H:%M:%S' current_date = jdatetime.now().date().strftime(date_frmt) current_time = jdatetime.now().date().strftime(time_frmt) # order date and time in jalali calendar order_datetime = jdatetime.fromgregorian( datetime=order['created_date']) order_date = order_datetime.date().strftime(date_frmt) order_time = order_datetime.time().strftime(time_frmt) # detect customer if not order['customer_id']: customer_id = settings['guest'] else: try: customer_map = self.customer_map.get(wcid=order['customer_id']) customer_id = customer_map.id except DoesNotExists: self.customer.create({ 'Code': self.customer.max('Code') + 1, 'Fname': order['first_name'], 'LName': order['last_name'], 'Name': '{} {}'.format(order['first_name'], order['last_name']), 'BuyPriceLevel': settings['price_level'], 'SellPriceLevel': settings['price_level'], 'StartDate': current_date, 'Prefix': '', 'ShiftTo': '23:59:59', 'ShiftFrom': '00:00:00', 'Visitor': 0, 'CarryPrice': 0, 'VisitorBed': 0, 'EtebarNaghd': 0, 'VisitorPerc': 0, 'EtebarCheque': 0, 'MablaghAvalDore': 0, }) customer_id = self.customer.max('ID') self.customer_map.create({ 'id': customer_id, 'wcid': order['customer_id'], 'last_update': datetime.now() }) # get next invoice No invoice_no = self.invoice.custom_sql("SELECT dbo.NewFactorNo(?)", [settings['type']], method='fetchval') # prepare invoice fields fields = { 'FactorNo': invoice_no, 'FishNo': invoice_no, 'Type': settings['type'], 'IDShakhs': customer_id, 'UserID': 1, 'Date': order_date, 'Time': order_time, 'PaymentDate': order_date, 'DeliverDate': order_date, 'InsertDate': current_date, 'InsertTime': current_time, 'Info': '', 'JamKol': int(order['total']), 'GmeFactor': order['items_subtotal'], 'MandeFactor': int(order['total']), 'Maliat': int(order['total_tax']), 'Takhfif': order['discount'], 'TakhfifItem': order['items_discount'], 'CarryPrice': int(order['shipping_total']), 'CarryType': 0, 'Nagd': 0, 'Nagd2': 0, 'Naseh': 0, 'Naseh2': 0, 'Chek': 0, 'Chek2': 0, 'Anbar': 0, 'Confirmed': 0, 'VisitorPrice': 0, 'VisitorPerc': 0, 'PaymentValue': 0, 'PaymentType': 0, 'Tmp': 0, 'Converted': 0, 'MaliatPerc': 0, 'ServicePerc': 0, 'ServicePrice': 0 } # check for info if fields['CarryPrice']: fields['Info'] = _('carry price: {}').format(fields['CarryPrice']) # create invoice self.invoice.create(fields) invoice_id = self.invoice.max('ID') # insert items for i, item in enumerate(order['items'], 1): self.line_item.create({ 'FactorID': invoice_id, 'IDKala': item['id'], 'Tedad': item['quantity'], 'Tedad1': 0, 'Tedad2': item['quantity'], 'TedadStr': str(item['quantity']), 'Price': item['regular_price'], 'SumPrice': int(item['total']), 'Takhfif': item['discount'], 'TakhfifPerc': 0, 'TakhfifPerItem': 0, 'TakhfifIsGift': 0, 'Anbar': settings['repository'], 'Info': '', 'Row': i, 'VisitorPrice': 0, 'VisitorPerc': 0, 'PaymentValue': 0, 'PaymentType': 0, 'PaymentDate': order_date, 'JozDarKol': 0, 'Maliat': 0, 'Height': 0, 'Width': 0, 'Thick': 0, 'Density': 0, 'UnitType': 0, 'Amount': 0, 'Overhead': 0, 'Gift': 0, 'Value': 0, 'PriceLevelID': settings['price_level'], 'ValueEdited': 0 }) # create map self.invoice_map.create({ 'id': invoice_id, 'wcid': order['id'], 'last_update': datetime.now() })
class ConnectionsError(WCBaseError): """WooCommerce Connections Error""" message = _('Connections error')
def __str__(self): msg = '{} {} '.format(self.name, _('with')) for column, value in self.conditions.items(): msg += '{}:{}, '.format(column, value) return msg.rstrip(', ') + _(' does not exists.')
class UnauthorizedError(WCBaseError): """WooCommerce 401 Unauthorized Error""" message = _('Authentication error')
def setupDialog(self): # scrollable area self.scrollableArea = ScrollArea() self.dialogLayout.addWidget(self.scrollableArea) # order layout self.orderLayout = QVBoxLayout() self.orderLayout.setSpacing(20) self.scrollableArea.setLayout(self.orderLayout) ########################### # Section1: Order Details # ########################### # widget self.section1 = QWidget(objectName='Section') self.orderLayout.addWidget(self.section1) # layout self.layout1 = QVBoxLayout() self.section1.setLayout(self.layout1) # order details layout self.detailsLayout = QHBoxLayout() self.layout1.addLayout(self.detailsLayout) # general self.general = QVBoxLayout() self.detailsLayout.addLayout(self.general) # - title self.generalTitle = QLabel(_('General'), objectName='SectionTitle') self.general.addWidget(self.generalTitle) # - date self.dateCreated = QLabel(objectName='DetailValue') self.general.addWidget(QLabel('{}:'.format(_('Date created')))) self.general.addWidget(self.dateCreated) # - customer self.customer = QLabel(objectName='DetailValue') self.general.addWidget(QLabel('{}:'.format(_('Customer')))) self.general.addWidget(self.customer) # - status self.status = QLabel(objectName='OrderStatus') self.general.addWidget(QLabel('{}:'.format(_('Status')))) self.general.addWidget(self.status) # add stretch self.general.addStretch(1) # billing self.billing = QVBoxLayout() self.billing.setContentsMargins(20, 0, 20, 0) self.detailsLayout.addLayout(self.billing) # - title self.billingTitle = QLabel(_('Billing'), objectName='SectionTitle') self.billing.addWidget(self.billingTitle) # - first name and last name billingFullnameRow = QHBoxLayout() self.billing.addLayout(billingFullnameRow) billingFirstnameColumn = QVBoxLayout() billingLastnameColumn = QVBoxLayout() billingFullnameRow.addLayout(billingFirstnameColumn) billingFullnameRow.addLayout(billingLastnameColumn) # -- first name self.billingFirstname = QLabel(objectName='DetailValue') billingFirstnameColumn.addWidget(QLabel(_('First name'))) billingFirstnameColumn.addWidget(self.billingFirstname) # -- last name self.billingLastname = QLabel(objectName='DetailValue') billingLastnameColumn.addWidget(QLabel(_('Last name'))) billingLastnameColumn.addWidget(self.billingLastname) # - company self.billingCompany = QLabel(objectName='DetailValue') self.billing.addWidget(QLabel(_('Company'))) self.billing.addWidget(self.billingCompany) # - email and phone billingEmailPhoneRow = QHBoxLayout() self.billing.addLayout(billingEmailPhoneRow) billingEmailColumn = QVBoxLayout() billingPhoneColumn = QVBoxLayout() billingEmailPhoneRow.addLayout(billingEmailColumn) billingEmailPhoneRow.addLayout(billingPhoneColumn) # -- email self.billingEmail = QLabel(objectName='DetailValue') billingEmailColumn.addWidget(QLabel(_('Email'))) billingEmailColumn.addWidget(self.billingEmail) # -- phone self.billingPhone = QLabel(objectName='DetailValue') billingPhoneColumn.addWidget(QLabel(_('Phone'))) billingPhoneColumn.addWidget(self.billingPhone) # - country and state billingCountryStateRow = QHBoxLayout() self.billing.addLayout(billingCountryStateRow) billingCountryColumn = QVBoxLayout() billingStateColumn = QVBoxLayout() billingCountryStateRow.addLayout(billingCountryColumn) billingCountryStateRow.addLayout(billingStateColumn) # -- country self.billingCountry = QLabel(objectName='DetailValue') billingCountryColumn.addWidget(QLabel(_('Country'))) billingCountryColumn.addWidget(self.billingCountry) # -- state self.billingState = QLabel(objectName='DetailValue') billingStateColumn.addWidget(QLabel(_('State'))) billingStateColumn.addWidget(self.billingState) # - city and postcode billingCityPostcodeRow = QHBoxLayout() self.billing.addLayout(billingCityPostcodeRow) billingCityColumn = QVBoxLayout() billingPostcodeColumn = QVBoxLayout() billingCityPostcodeRow.addLayout(billingCityColumn) billingCityPostcodeRow.addLayout(billingPostcodeColumn) # -- city self.billingCity = QLabel(objectName='DetailValue') billingCityColumn.addWidget(QLabel(_('City'))) billingCityColumn.addWidget(self.billingCity) # -- postcode self.billingPostcode = QLabel(objectName='DetailValue') billingPostcodeColumn.addWidget(QLabel(_('PostCode'))) billingPostcodeColumn.addWidget(self.billingPostcode) # - address line 1 self.billingAddressLine1 = QLabel(objectName='DetailValue') self.billing.addWidget(QLabel(_('Address line 1'))) self.billing.addWidget(self.billingAddressLine1) # - address line 2 self.billingAddressLine2 = QLabel(objectName='DetailValue') self.billing.addWidget(QLabel(_('Address line 2'))) self.billing.addWidget(self.billingAddressLine2) # - payment and transaction billingPaymentTransactionRow = QHBoxLayout() self.billing.addLayout(billingPaymentTransactionRow) billingPaymentColumn = QVBoxLayout() billingTransactionColumn = QVBoxLayout() billingPaymentTransactionRow.addLayout(billingPaymentColumn) billingPaymentTransactionRow.addLayout(billingTransactionColumn) # -- payment self.billingPayment = QLabel(_('Cash on delivery'), objectName='DetailValue') billingPaymentColumn.addWidget(QLabel(_('Payment method'))) billingPaymentColumn.addWidget(self.billingPayment) # -- transaction self.billingTransaction = QLabel(objectName='DetailValue') billingTransactionColumn.addWidget(QLabel(_('Transaction ID'))) billingTransactionColumn.addWidget(self.billingTransaction) # add stretch self.billing.addStretch(1) # shipping self.shipping = QVBoxLayout() self.detailsLayout.addLayout(self.shipping) # - title self.shippingTitle = QLabel(_('Shipping'), objectName='SectionTitle') self.shipping.addWidget(self.shippingTitle) # - first name and last name shippingFullnameRow = QHBoxLayout() self.shipping.addLayout(shippingFullnameRow) shippingFirstnameColumn = QVBoxLayout() shippingLastnameColumn = QVBoxLayout() shippingFullnameRow.addLayout(shippingFirstnameColumn) shippingFullnameRow.addLayout(shippingLastnameColumn) # -- first name self.shippingFirstname = QLabel(objectName='DetailValue') shippingFirstnameColumn.addWidget(QLabel(_('First name'))) shippingFirstnameColumn.addWidget(self.shippingFirstname) # -- last name self.shippingLastname = QLabel(objectName='DetailValue') shippingLastnameColumn.addWidget(QLabel(_('Last name'))) shippingLastnameColumn.addWidget(self.shippingLastname) # - company self.shippingCompany = QLabel(objectName='DetailValue') self.shipping.addWidget(QLabel(_('Company'))) self.shipping.addWidget(self.shippingCompany) # - country and state shippingCountryStateRow = QHBoxLayout() self.shipping.addLayout(shippingCountryStateRow) shippingCountryColumn = QVBoxLayout() shippingStateColumn = QVBoxLayout() shippingCountryStateRow.addLayout(shippingCountryColumn) shippingCountryStateRow.addLayout(shippingStateColumn) # -- country self.shippingCountry = QLabel(objectName='DetailValue') shippingCountryColumn.addWidget(QLabel(_('Country'))) shippingCountryColumn.addWidget(self.shippingCountry) # -- state self.shippingState = QLabel(objectName='DetailValue') shippingStateColumn.addWidget(QLabel(_('State'))) shippingStateColumn.addWidget(self.shippingState) # - city and postcode shippingCityPostcodeRow = QHBoxLayout() self.shipping.addLayout(shippingCityPostcodeRow) shippingCityColumn = QVBoxLayout() shippingPostcodeColumn = QVBoxLayout() shippingCityPostcodeRow.addLayout(shippingCityColumn) shippingCityPostcodeRow.addLayout(shippingPostcodeColumn) # -- city self.shippingCity = QLabel(objectName='DetailValue') shippingCityColumn.addWidget(QLabel(_('City'))) shippingCityColumn.addWidget(self.shippingCity) # -- postcode self.shippingPostcode = QLabel(objectName='DetailValue') shippingPostcodeColumn.addWidget(QLabel(_('PostCode'))) shippingPostcodeColumn.addWidget(self.shippingPostcode) # - address line 1 self.shippingAddressLine1 = QLabel(objectName='DetailValue') self.shipping.addWidget(QLabel(_('Address line 1'))) self.shipping.addWidget(self.shippingAddressLine1) # - address line 2 self.shippingAddressLine2 = QLabel(objectName='DetailValue') self.shipping.addWidget(QLabel(_('Address line 2'))) self.shipping.addWidget(self.shippingAddressLine2) # - customer note self.shippingCustomerNote = QLabel(objectName='ShippingCustomerNote') self.shipping.addWidget(QLabel(_('Customer provided note'))) self.shipping.addWidget(self.shippingCustomerNote) # add stretch self.shipping.addStretch(1) ######################### # Section2: Order Items # ######################### # widget self.section2 = QWidget(objectName='Section') self.orderLayout.addWidget(self.section2) # layout self.layout2 = QVBoxLayout() self.section2.setLayout(self.layout2) # title self.itemsTitle = QLabel(_('Items'), objectName='SectionTitle') self.layout2.addWidget(self.itemsTitle) # table self.itemsTable = Table( [_('ID'), _('Name'), _('Cost'), _('Quantity'), _('Total')], [1, 3, 1, 1, 1]) self.itemsTable.setMinimumHeight(200) self.layout2.addWidget(self.itemsTable) ########################## # Section3: Order Totals # ########################## # widget self.section3 = QWidget(objectName='Section') self.orderLayout.addWidget(self.section3) # layout self.layout3 = QVBoxLayout() self.section3.setLayout(self.layout3) # title self.totalsTitle = QLabel(_('Totals'), objectName='SectionTitle') self.layout3.addWidget(self.totalsTitle) # form self.totalsForm = QFormLayout() self.totalsForm.setHorizontalSpacing(50) self.totalsForm.setVerticalSpacing(20) self.layout3.addLayout(self.totalsForm) # order items total self.itemsTotal = QLabel() self.totalsForm.addRow(QLabel(_('Items total')), self.itemsTotal) # order total tax self.totalTax = QLabel() self.totalsForm.addRow(QLabel(_('Total tax')), self.totalTax) # order shipping total self.shippingTotal = QLabel() self.totalsForm.addRow(QLabel(_('Shipping total')), self.shippingTotal) # order discount total self.discountTotal = QLabel() self.totalsForm.addRow(QLabel(_('Discount total')), self.discountTotal) # order total self.orderTotal = QLabel() self.totalsForm.addRow(QLabel('<b>{}</b>'.format(_('Order total'))), self.orderTotal)
def setupLayout(self): super().setupLayout() # set dialog title self.setWindowTitle(_('Order details')) # set dialog minimum size self.setMinimumSize(900, 562)
def setupControl(self): self.btnSave = SaveSMButton(_('Save')) self.btnCancel = CancelSMButton(_('Cancel')) self.controlLayout.addWidget(self.btnSave) self.controlLayout.addWidget(self.btnCancel)
class InternalServerError(WCBaseError): """WooCommerce Internal Server Error""" message = _('Server internal error')
class NotFoundError(WCBaseError): """WooCommerce 404 Not Found Error""" message = _('Requests to resources that dont exist or are missing')
def setupControl(self): super().setupControl() self.btnCancel = CancelSMButton(_('Cencel')) self.controlLayout.addWidget(self.btnCancel)
class BadRequestError(WCBaseError): """WooCommerce 400 Bad Request Error""" message = _('Invalid request')