mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Add customer balance to customer list
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
class Api::Admin::CustomerSerializer < ActiveModel::Serializer
|
||||
attributes :id, :email, :enterprise_id, :user_id, :code, :tags, :tag_list, :name,
|
||||
:allow_charges, :default_card_present?
|
||||
:allow_charges, :default_card_present?, :balance
|
||||
|
||||
has_one :ship_address, serializer: Api::AddressSerializer
|
||||
has_one :bill_address, serializer: Api::AddressSerializer
|
||||
@@ -13,6 +13,10 @@ class Api::Admin::CustomerSerializer < ActiveModel::Serializer
|
||||
object.name.presence || object.bill_address.andand.full_name
|
||||
end
|
||||
|
||||
def balance
|
||||
OpenFoodNetwork::UserBalanceCalculator.new(object.email, object.enterprise).balance
|
||||
end
|
||||
|
||||
def tags
|
||||
customer_tag_list.map do |tag|
|
||||
tag_rule_map = options[:tag_rule_mapping].andand[tag]
|
||||
|
||||
@@ -55,6 +55,7 @@
|
||||
%col.tags{ width: "20%", 'ng-show' => 'columns.tags.visible' }
|
||||
%col.bill_address{ width: "10%", 'ng-show' => 'columns.bill_address.visible' }
|
||||
%col.ship_address{ width: "10%", 'ng-show' => 'columns.ship_address.visible' }
|
||||
%col.balance{ width: "10%", 'ng-show' => 'columns.balance.visible' }
|
||||
%col.actions{ width: "10%"}
|
||||
%thead
|
||||
%tr{ ng: { controller: "ColumnsCtrl" } }
|
||||
@@ -69,6 +70,7 @@
|
||||
%th.tags{ 'ng-show' => 'columns.tags.visible' }=t('admin.tags')
|
||||
%th.bill_address{ 'ng-show' => 'columns.bill_address.visible' }=t('admin.customers.index.bill_address')
|
||||
%th.ship_address{ 'ng-show' => 'columns.ship_address.visible' }=t('admin.customers.index.ship_address')
|
||||
%th.balance{ 'ng-show' => 'columns.balance.visible' }=t('admin.customers.index.balance')
|
||||
%th.actions
|
||||
Ask?
|
||||
%input{ :type => 'checkbox', 'ng-model' => "confirmDelete" }
|
||||
@@ -92,6 +94,8 @@
|
||||
%a{ id: 'bill-address-link', href: 'javascript:void(0)', "ng-bind" => "customer.bill_address ? customer.bill_address.address1 : '#{t('admin.customers.index.edit')}' | limitTo: 15", 'edit-address-dialog' => true }
|
||||
%td.ship_address{ 'ng-show' => 'columns.ship_address.visible' }
|
||||
%a{ id: 'ship-address-link', href: 'javascript:void(0)', "ng-bind" => "customer.ship_address ? customer.ship_address.address1 : '#{t('admin.customers.index.edit')}' | limitTo: 15", 'edit-address-dialog' => true }
|
||||
%td.balance{ 'ng-show' => 'columns.balance.visible'}
|
||||
%span{ 'ng-bind' => '::customer.balance' }
|
||||
%td.actions
|
||||
%a{ 'ng-click' => "deleteCustomer(customer)", :class => "delete-customer icon-trash no-text" }
|
||||
|
||||
|
||||
@@ -444,6 +444,7 @@ en:
|
||||
duplicate_code: "This code is used already."
|
||||
bill_address: "Billing Address"
|
||||
ship_address: "Shipping Address"
|
||||
balance: "Balance"
|
||||
update_address_success: 'Address updated successfully.'
|
||||
update_address_error: 'Sorry! Please input all of the required fields!'
|
||||
edit_bill_address: 'Edit Billing Address'
|
||||
|
||||
@@ -32,7 +32,8 @@ module OpenFoodNetwork
|
||||
code: { name: I18n.t("#{node}.code"), visible: true },
|
||||
tags: { name: I18n.t("admin.tags"), visible: true },
|
||||
bill_address: { name: I18n.t("#{node}.bill_address"), visible: true },
|
||||
ship_address: { name: I18n.t("#{node}.ship_address"), visible: true }
|
||||
ship_address: { name: I18n.t("#{node}.ship_address"), visible: true },
|
||||
balance: { name: I18n.t("#{node}.balance"), visible: true }
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user