Skip to content

Commit

Permalink
Mobile v15 metadata component (#196)
Browse files Browse the repository at this point in the history
Co-authored-by: Tyler Matteson <[email protected]>
  • Loading branch information
lauty95 and agritheory authored Nov 21, 2024
1 parent 8718aec commit 5c9e99f
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 35 deletions.
8 changes: 7 additions & 1 deletion beam/beam/demand/demand.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ def get_sales_demand(name: str | None = None, item_code: str | None = None) -> l
SalesOrder.delivery_date,
(total_required_qty).as_("total_required_qty"),
Item.stock_uom,
fn.Coalesce(SalesOrder.customer, "").as_("customer"),
SalesOrder.creation,
)
.where(
Expand Down Expand Up @@ -677,7 +678,10 @@ def get_descendant_warehouses(company: str | None, warehouse: str) -> list[str]:
@frappe.whitelist()
def get_demand(*args, **kwargs) -> list[Demand]:
records_per_page = 20
page = int(kwargs.get("page", 1))
try:
page = int(kwargs.get("page", 1))
except ValueError:
page = 1
order_by = kwargs.get("order_by", "workstation, assigned")

demand = Table("demand")
Expand Down Expand Up @@ -733,6 +737,7 @@ def get_demand(*args, **kwargs) -> list[Demand]:
ValueWrapper("").as_("status"),
demand.assigned,
demand.creation,
fn.Coalesce(demand.customer, "").as_("customer"),
)
.where(
fn.Coalesce(
Expand Down Expand Up @@ -785,6 +790,7 @@ def get_demand(*args, **kwargs) -> list[Demand]:
allocation.status,
allocation.assigned,
allocation.creation,
ValueWrapper("").as_("customer"),
)
.where(allocation.allocated_qty > 0)
.orderby(
Expand Down
5 changes: 4 additions & 1 deletion beam/beam/demand/receiving.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def _get_receiving_demand(
PurchaseOrder.schedule_date,
PurchaseOrderItem.stock_qty.as_("stock_qty"),
PurchaseOrderItem.received_qty,
PurchaseOrder.supplier,
Item.stock_uom,
PurchaseOrder.creation,
)
Expand Down Expand Up @@ -103,6 +104,7 @@ def _get_receiving_demand(
PurchaseInvoice.due_date.as_("schedule_date"),
PurchaseInvoiceItem.stock_qty.as_("stock_qty"),
PurchaseInvoiceItem.received_qty,
PurchaseInvoice.supplier,
Item.stock_uom,
PurchaseInvoice.creation,
)
Expand Down Expand Up @@ -190,7 +192,6 @@ def build_receiving_map(
name: str | None = None, item_code: str | None = None, cursor: Optional["Cursor"] = None
) -> None:
output: list[Receiving] = []

for row in get_receiving_list(name, item_code):
row.key = row.get("key") or frappe.generate_hash()
row.schedule_date = str(row.schedule_date or get_epoch_from_datetime(row.schedule_date))
Expand Down Expand Up @@ -250,6 +251,7 @@ def get_receiving_demand(*args, **kwargs) -> list[Receiving]:
receiving.stock_uom,
receiving.stock_qty,
receiving.received_qty,
receiving.supplier,
ValueWrapper("").as_("status"),
receiving.assigned,
receiving.creation,
Expand All @@ -270,6 +272,7 @@ def get_receiving_demand(*args, **kwargs) -> list[Receiving]:
{
"stock_qty": max(0.0, row.stock_qty),
"received_qty": max(0.0, row.received_qty or 0.0),
"rejected_qty": max(0.0, row.rejected_qty or 0.0),
"schedule_date": get_datetime_from_epoch(row.schedule_date),
"modified": get_datetime_from_epoch(row.modified),
"creation": get_datetime_from_epoch(row.creation),
Expand Down
6 changes: 4 additions & 2 deletions beam/beam/demand/sqlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ def create_demand_db(cursor: sqlite3.Cursor) -> sqlite3.Connection:
total_required_qty real,
stock_uom text,
assigned text,
creation int
creation int,
customer text
{inventory_dimensions}
)
"""
Expand Down Expand Up @@ -104,7 +105,8 @@ def create_demand_db(cursor: sqlite3.Cursor) -> sqlite3.Connection:
received_qty real,
stock_uom text,
assigned text,
creation int
creation int,
supplier text
{inventory_dimensions}
)
"""
Expand Down
7 changes: 1 addition & 6 deletions beam/www/beam/components/ControlButtons.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
<template>
<div :class="`button-${buttons.length} control-buttons`">
<BeamBtn
v-for="(button, index) in buttons"
:key="index"
@click="button.action"
:disabled="button.disabled"
>
<BeamBtn v-for="(button, index) in buttons" :key="index" @click="button.action" :disabled="button.disabled">
{{ button.label }}
</BeamBtn>
</div>
Expand Down
2 changes: 1 addition & 1 deletion beam/www/beam/pages/Demand.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ useInfiniteScroll(
window,
async () => {
const { data } = await store.getDemand({ order_by: 'creation asc', page: page.value })
if (data.length === 0) {
if (!data || data.length === 0) {
canLoadMore.value = false
return
}
Expand Down
16 changes: 11 additions & 5 deletions beam/www/beam/pages/Receive.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,25 @@ useInfiniteScroll(
row.count = { count: row.received_qty, of: `${row.stock_qty}` }
row.label = `${row.item_code} from ${row.warehouse}`
row.linkComponent = 'ListAnchor'
row.description = row.parent
row.route = `#/purchase-receipt/${row.parent || 'new-purchase-receipt'}` //
row.description = `
[${row.parent}]
Warehouse: ${row.warehouse}
Supplier: ${row.supplier}
`.trim()
row.route = `#/purchase_order/${row.parent || 'new-purchase-order'}`
transfer.value.push(row)
})
page.value++
},
{ canLoadMore: () => canLoadMore.value }
)
// const handlePrimaryAction = () => {}
</script>

<style scoped>
<style>
@import url('@stonecrop/beam/styles');
.beam_list-text label,
.beam_list-text p {
white-space: pre-line !important;
}
</style>
48 changes: 32 additions & 16 deletions beam/www/beam/pages/Ship.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,43 @@
</template>

<script setup lang="ts">
import { onMounted, ref } from 'vue'
import { ref } from 'vue'
import { useInfiniteScroll } from '@vueuse/core'
import { useDataStore } from '@/store'
import type { ListViewItem } from '@/types'
const store = useDataStore()
const items = ref<Partial<ListViewItem>[]>([])
onMounted(async () => {
const { data } = await store.getDemand({ workstation: 'Shipping' })
// TODO: move this to the server
data.forEach(row => {
row.count = { count: row.allocated_qty, of: row.total_required_qty }
row.label = `${row.doctype} - ${row.parent}`
row.linkComponent = 'ListAnchor'
row.description = `${row.item_code} - ${row.warehouse}`
row.route = `#/Delivery Note/new-delivery-note` // or draft delivery note if it exists
items.value.push(row)
})
})
const canLoadMore = ref(true)
const page = ref(1)
useInfiniteScroll(
window,
async () => {
const { data } = await store.getDemand({ workstation: 'Shipping', page: page.value })
if (data.length === 0) {
canLoadMore.value = false
return
}
// TODO: move this to the server
data.forEach(row => {
row.count = { count: row.allocated_qty, of: `${row.total_required_qty}` }
row.label = `${row.doctype} - ${row.parent}`
row.linkComponent = 'ListAnchor'
row.description = `
Item: ${row.item_code}
Warehouse: ${row.warehouse}
${row.customer ?? `Customer: ${row.customer}`}
`.trim()
row.route = `#/Delivery Note/new-delivery-note` // or draft delivery note if it exists
items.value.push(row)
})
page.value++
},
{ canLoadMore: () => canLoadMore.value }
)
function newDeliveryNote(so) {
// match save and name API
Expand Down
13 changes: 10 additions & 3 deletions beam/www/beam/pages/WorkOrder.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
<div>
<p>Planned Start: {{ (store.form as WorkOrder).planned_start_date }}</p>
</div>
<div class="box" v-show="operations.length">
<ListView :items="operations" />
</div>
<div class="box" v-show="items.length">
<ListView :items="items" />
</div>
<div class="box" v-show="operations.length">
<ListView :items="operations" />
</div>
<ControlButtons
:onCreate="create"
:onSubmit="() => store.submit<WorkOrder>('Work Order', workOrderId)"
Expand Down Expand Up @@ -50,6 +50,13 @@ onMounted(async () => {
route: `#/work_order/${workOrderId}/operation/${operation.name}`,
}))
workOrder.value = {
...workOrder.value,
product: order.item_name,
quantity: order.produced_qty,
total: order.qty,
complete: order.status === 'Complete',
}
// get job cards
// for (const operation of order.operations) {
// const jobList = await store.getAll<JobCard[]>('Job Card', {
Expand Down

0 comments on commit 5c9e99f

Please sign in to comment.